]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/DiskIo2.h
Correct file header comments for DiskIo2.h.
[mirror_edk2.git] / MdePkg / Include / Protocol / DiskIo2.h
1 /** @file
2 Disk I/O 2 protocol as defined in the UEFI 2.4 specification.
3
4 The Disk I/O 2 protocol defines an extension to the Disk I/O protocol to enable
5 non-blocking / asynchronous byte-oriented disk operation.
6
7 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __DISK_IO2_H__
19 #define __DISK_IO2_H__
20
21 #define EFI_DISK_IO2_PROTOCOL_GUID \
22 { \
23 0x151c8eae, 0x7f2c, 0x472c, 0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88 \
24 }
25
26 typedef struct _EFI_DISK_IO2_PROTOCOL EFI_DISK_IO2_PROTOCOL;
27
28 /**
29 The struct of Disk IO2 Token.
30 **/
31 typedef struct {
32 //
33 // If Event is NULL, then blocking I/O is performed.
34 // If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed,
35 // and Event will be signaled when the I/O request is completed.
36 // The caller must be prepared to handle the case where the callback associated with Event occurs
37 // before the original asynchronous I/O request call returns.
38 //
39 EFI_EVENT Event;
40
41 //
42 // Defines whether or not the signaled event encountered an error.
43 //
44 EFI_STATUS TransactionStatus;
45 } EFI_DISK_IO2_TOKEN;
46
47 /**
48 Terminate outstanding asynchronous requests to a device.
49
50 @param This Indicates a pointer to the calling context.
51
52 @retval EFI_SUCCESS All outstanding requests were successfully terminated.
53 @retval EFI_DEVICE_ERROR The device reported an error while performing the cancel
54 operation.
55 **/
56 typedef
57 EFI_STATUS
58 (EFIAPI *EFI_DISK_CANCEL_EX) (
59 IN EFI_DISK_IO2_PROTOCOL *This
60 );
61
62 /**
63 Reads a specified number of bytes from a device.
64
65 @param This Indicates a pointer to the calling context.
66 @param MediaId ID of the medium to be read.
67 @param Offset The starting byte offset on the logical block I/O device to read from.
68 @param Token A pointer to the token associated with the transaction.
69 If this field is NULL, synchronous/blocking IO is performed.
70 @param BufferSize The size in bytes of Buffer. The number of bytes to read from the device.
71 @param Buffer A pointer to the destination buffer for the data.
72 The caller is responsible either having implicit or explicit ownership of the buffer.
73
74 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read correctly from the device.
75 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
76 Event will be signaled upon completion.
77 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
78 @retval EFI_NO_MEDIA There is no medium in the device.
79 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
80 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device.
81 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
82
83 **/
84 typedef
85 EFI_STATUS
86 (EFIAPI *EFI_DISK_READ_EX) (
87 IN EFI_DISK_IO2_PROTOCOL *This,
88 IN UINT32 MediaId,
89 IN UINT64 Offset,
90 IN OUT EFI_DISK_IO2_TOKEN *Token,
91 IN UINTN BufferSize,
92 OUT VOID *Buffer
93 );
94
95 /**
96 Writes a specified number of bytes to a device.
97
98 @param This Indicates a pointer to the calling context.
99 @param MediaId ID of the medium to be written.
100 @param Offset The starting byte offset on the logical block I/O device to write to.
101 @param Token A pointer to the token associated with the transaction.
102 If this field is NULL, synchronous/blocking IO is performed.
103 @param BufferSize The size in bytes of Buffer. The number of bytes to write to the device.
104 @param Buffer A pointer to the buffer containing the data to be written.
105
106 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was written correctly to the device.
107 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
108 Event will be signaled upon completion.
109 @retval EFI_WRITE_PROTECTED The device cannot be written to.
110 @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
111 @retval EFI_NO_MEDIA There is no medium in the device.
112 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
113 @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device.
114 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
115
116 **/
117 typedef
118 EFI_STATUS
119 (EFIAPI *EFI_DISK_WRITE_EX) (
120 IN EFI_DISK_IO2_PROTOCOL *This,
121 IN UINT32 MediaId,
122 IN UINT64 Offset,
123 IN OUT EFI_DISK_IO2_TOKEN *Token,
124 IN UINTN BufferSize,
125 IN VOID *Buffer
126 );
127
128 /**
129 Flushes all modified data to the physical device.
130
131 @param This Indicates a pointer to the calling context.
132 @param MediaId ID of the medium to be written.
133 @param Token A pointer to the token associated with the transaction.
134 If this field is NULL, synchronous/blocking IO is performed.
135
136 @retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was flushed successfully to the device.
137 If Event is not NULL (asynchronous I/O): The request was successfully queued for processing.
138 Event will be signaled upon completion.
139 @retval EFI_WRITE_PROTECTED The device cannot be written to.
140 @retval EFI_DEVICE_ERROR The device reported an error while performing the write operation.
141 @retval EFI_NO_MEDIA There is no medium in the device.
142 @retval EFI_MEDIA_CHNAGED The MediaId is not for the current medium.
143 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
144 **/
145 typedef
146 EFI_STATUS
147 (EFIAPI *EFI_DISK_FLUSH_EX) (
148 IN EFI_DISK_IO2_PROTOCOL *This,
149 IN OUT EFI_DISK_IO2_TOKEN *Token
150 );
151
152 #define EFI_DISK_IO2_PROTOCOL_REVISION 0x00020000
153
154 ///
155 /// This protocol is used to abstract Block I/O interfaces.
156 ///
157 struct _EFI_DISK_IO2_PROTOCOL {
158 ///
159 /// The revision to which the disk I/O interface adheres. All future
160 /// revisions must be backwards compatible. If a future version is not
161 /// backwards compatible, it is not the same GUID.
162 ///
163 UINT64 Revision;
164 EFI_DISK_CANCEL_EX Cancel;
165 EFI_DISK_READ_EX ReadDiskEx;
166 EFI_DISK_WRITE_EX WriteDiskEx;
167 EFI_DISK_FLUSH_EX FlushDiskEx;
168 };
169
170 extern EFI_GUID gEfiDiskIo2ProtocolGuid;
171
172 #endif