]>
Commit | Line | Data |
---|---|---|
d59326d3 | 1 | /** @file\r |
2 | Emu Block IO2 protocol as defined in the UEFI 2.3.1 specification.\r | |
3 | \r | |
4 | The Block IO2 protocol defines an extension to the Block IO protocol which\r | |
5 | enables the ability to read and write data at a block level in a non-blocking\r | |
6 | manner.\r | |
7 | \r | |
8 | Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r | |
e3ba31da | 9 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
d59326d3 | 10 | \r |
11 | **/\r | |
12 | \r | |
13 | #ifndef __EMU_BLOCK_IO_H__\r | |
14 | #define __EMU_BLOCK_IO_H__\r | |
15 | \r | |
16 | #include <Protocol/BlockIo.h>\r | |
17 | #include <Protocol/BlockIo2.h>\r | |
18 | \r | |
19 | #define EMU_BLOCK_IO_PROTOCOL_GUID \\r | |
033d0e5f | 20 | { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r |
d59326d3 | 21 | \r |
22 | typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;\r | |
23 | \r | |
24 | \r | |
25 | \r | |
26 | /**\r | |
27 | Reset the block device hardware.\r | |
28 | \r | |
29 | @param[in] This Indicates a pointer to the calling context.\r | |
30 | @param[in] ExtendedVerification Indicates that the driver may perform a more\r | |
31 | exhausive verfication operation of the device\r | |
32 | during reset.\r | |
33 | \r | |
34 | @retval EFI_SUCCESS The device was reset.\r | |
35 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
36 | not be reset.\r | |
37 | \r | |
38 | **/\r | |
39 | typedef\r | |
40 | EFI_STATUS\r | |
41 | (EFIAPI *EMU_BLOCK_RESET) (\r | |
42 | IN EMU_BLOCK_IO_PROTOCOL *This,\r | |
43 | IN BOOLEAN ExtendedVerification\r | |
44 | );\r | |
45 | \r | |
46 | /**\r | |
47 | Read BufferSize bytes from Lba into Buffer.\r | |
d18d8a1d | 48 | \r |
d59326d3 | 49 | This function reads the requested number of blocks from the device. All the\r |
50 | blocks are read, or an error is returned.\r | |
51 | If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r | |
52 | non-blocking I/O is being used, the Event associated with this request will\r | |
53 | not be signaled.\r | |
54 | \r | |
55 | @param[in] This Indicates a pointer to the calling context.\r | |
d18d8a1d | 56 | @param[in] MediaId Id of the media, changes every time the media is\r |
d59326d3 | 57 | replaced.\r |
58 | @param[in] Lba The starting Logical Block Address to read from.\r | |
79e4f2a5 | 59 | @param[in, out] Token A pointer to the token associated with the transaction.\r |
d18d8a1d | 60 | @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r |
61 | @param[out] Buffer A pointer to the destination buffer for the data. The\r | |
62 | caller is responsible for either having implicit or\r | |
d59326d3 | 63 | explicit ownership of the buffer.\r |
64 | \r | |
65 | @retval EFI_SUCCESS The read request was queued if Token->Event is\r | |
66 | not NULL.The data was read correctly from the\r | |
67 | device if the Token->Event is NULL.\r | |
68 | @retval EFI_DEVICE_ERROR The device reported an error while performing\r | |
69 | the read.\r | |
70 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
71 | @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r | |
72 | @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r | |
73 | intrinsic block size of the device.\r | |
d18d8a1d | 74 | @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r |
d59326d3 | 75 | or the buffer is not on proper alignment.\r |
76 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r | |
77 | of resources.\r | |
78 | **/\r | |
79 | typedef\r | |
80 | EFI_STATUS\r | |
81 | (EFIAPI *EMU_BLOCK_READ) (\r | |
82 | IN EMU_BLOCK_IO_PROTOCOL *This,\r | |
83 | IN UINT32 MediaId,\r | |
84 | IN EFI_LBA LBA,\r | |
85 | IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r | |
86 | IN UINTN BufferSize,\r | |
033d0e5f | 87 | OUT VOID *Buffer\r |
d59326d3 | 88 | );\r |
89 | \r | |
90 | /**\r | |
91 | Write BufferSize bytes from Lba into Buffer.\r | |
92 | \r | |
93 | This function writes the requested number of blocks to the device. All blocks\r | |
94 | are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r | |
95 | EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r | |
96 | being used, the Event associated with this request will not be signaled.\r | |
97 | \r | |
98 | @param[in] This Indicates a pointer to the calling context.\r | |
99 | @param[in] MediaId The media ID that the write request is for.\r | |
100 | @param[in] Lba The starting logical block address to be written. The\r | |
101 | caller is responsible for writing to only legitimate\r | |
102 | locations.\r | |
103 | @param[in, out] Token A pointer to the token associated with the transaction.\r | |
104 | @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r | |
105 | @param[in] Buffer A pointer to the source buffer for the data.\r | |
106 | \r | |
107 | @retval EFI_SUCCESS The write request was queued if Event is not NULL.\r | |
108 | The data was written correctly to the device if\r | |
109 | the Event is NULL.\r | |
110 | @retval EFI_WRITE_PROTECTED The device can not be written to.\r | |
111 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
112 | @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r | |
113 | @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r | |
114 | @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r | |
d18d8a1d | 115 | @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r |
d59326d3 | 116 | or the buffer is not on proper alignment.\r |
117 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r | |
118 | of resources.\r | |
119 | \r | |
120 | **/\r | |
121 | typedef\r | |
122 | EFI_STATUS\r | |
123 | (EFIAPI *EMU_BLOCK_WRITE) (\r | |
033d0e5f | 124 | IN EMU_BLOCK_IO_PROTOCOL *This,\r |
d59326d3 | 125 | IN UINT32 MediaId,\r |
126 | IN EFI_LBA LBA,\r | |
127 | IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r | |
128 | IN UINTN BufferSize,\r | |
129 | IN VOID *Buffer\r | |
130 | );\r | |
131 | \r | |
132 | /**\r | |
133 | Flush the Block Device.\r | |
d18d8a1d | 134 | \r |
d59326d3 | 135 | If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r |
136 | is returned and non-blocking I/O is being used, the Event associated with\r | |
d18d8a1d | 137 | this request will not be signaled.\r |
d59326d3 | 138 | \r |
139 | @param[in] This Indicates a pointer to the calling context.\r | |
140 | @param[in,out] Token A pointer to the token associated with the transaction\r | |
141 | \r | |
142 | @retval EFI_SUCCESS The flush request was queued if Event is not NULL.\r | |
143 | All outstanding data was written correctly to the\r | |
144 | device if the Event is NULL.\r | |
145 | @retval EFI_DEVICE_ERROR The device reported an error while writting back\r | |
146 | the data.\r | |
147 | @retval EFI_WRITE_PROTECTED The device cannot be written to.\r | |
148 | @retval EFI_NO_MEDIA There is no media in the device.\r | |
149 | @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r | |
150 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r | |
151 | of resources.\r | |
152 | \r | |
153 | **/\r | |
154 | typedef\r | |
155 | EFI_STATUS\r | |
156 | (EFIAPI *EMU_BLOCK_FLUSH) (\r | |
157 | IN EMU_BLOCK_IO_PROTOCOL *This,\r | |
158 | IN OUT EFI_BLOCK_IO2_TOKEN *Token\r | |
159 | );\r | |
160 | \r | |
161 | \r | |
162 | typedef\r | |
163 | EFI_STATUS\r | |
164 | (EFIAPI *EMU_BLOCK_CREATE_MAPPING) (\r | |
165 | IN EMU_BLOCK_IO_PROTOCOL *This,\r | |
166 | IN EFI_BLOCK_IO_MEDIA *Media\r | |
167 | );\r | |
168 | \r | |
169 | \r | |
170 | ///\r | |
171 | /// The Block I/O2 protocol defines an extension to the Block I/O protocol which\r | |
172 | /// enables the ability to read and write data at a block level in a non-blocking\r | |
173 | // manner.\r | |
174 | ///\r | |
175 | struct _EMU_BLOCK_IO_PROTOCOL {\r | |
176 | EMU_BLOCK_RESET Reset;\r | |
177 | EMU_BLOCK_READ ReadBlocks;\r | |
178 | EMU_BLOCK_WRITE WriteBlocks;\r | |
179 | EMU_BLOCK_FLUSH FlushBlocks;\r | |
180 | EMU_BLOCK_CREATE_MAPPING CreateMapping;\r | |
181 | };\r | |
182 | \r | |
183 | extern EFI_GUID gEmuBlockIoProtocolGuid;\r | |
184 | \r | |
185 | #endif\r | |
186 | \r |