]> git.proxmox.com Git - mirror_edk2.git/blame - InOsEmuPkg/Include/Protocol/EmuBlockIo.h
Add BlockIO support to the emulator, still needs testing. Also update Emulator start...
[mirror_edk2.git] / InOsEmuPkg / Include / Protocol / EmuBlockIo.h
CommitLineData
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
9 This program and the accompanying materials \r
10 are licensed and made available under the terms and conditions of the BSD License \r
11 which accompanies this distribution. The full text of the license may be found at \r
12 http://opensource.org/licenses/bsd-license.php \r
13\r
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
16\r
17**/\r
18\r
19#ifndef __EMU_BLOCK_IO_H__\r
20#define __EMU_BLOCK_IO_H__\r
21\r
22#include <Protocol/BlockIo.h>\r
23#include <Protocol/BlockIo2.h>\r
24\r
25#define EMU_BLOCK_IO_PROTOCOL_GUID \\r
26 { 0x3EC5F7E0, 0x1124, 0xDF45, { 0x9F, 0x96, 0x7D, 0xD6, 0x63, 0xC0, 0xAF, 0xE7 } }\r
27\r
28typedef struct _EMU_BLOCK_IO_PROTOCOL EMU_BLOCK_IO_PROTOCOL;\r
29\r
30\r
31\r
32/**\r
33 Reset the block device hardware.\r
34\r
35 @param[in] This Indicates a pointer to the calling context.\r
36 @param[in] ExtendedVerification Indicates that the driver may perform a more\r
37 exhausive verfication operation of the device\r
38 during reset.\r
39\r
40 @retval EFI_SUCCESS The device was reset.\r
41 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
42 not be reset.\r
43\r
44**/\r
45typedef\r
46EFI_STATUS\r
47(EFIAPI *EMU_BLOCK_RESET) (\r
48 IN EMU_BLOCK_IO_PROTOCOL *This,\r
49 IN BOOLEAN ExtendedVerification\r
50 );\r
51\r
52/**\r
53 Read BufferSize bytes from Lba into Buffer.\r
54 \r
55 This function reads the requested number of blocks from the device. All the\r
56 blocks are read, or an error is returned.\r
57 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and\r
58 non-blocking I/O is being used, the Event associated with this request will\r
59 not be signaled.\r
60\r
61 @param[in] This Indicates a pointer to the calling context.\r
62 @param[in] MediaId Id of the media, changes every time the media is \r
63 replaced.\r
64 @param[in] Lba The starting Logical Block Address to read from.\r
65 @param[in, out] Token A pointer to the token associated with the transaction.\r
66 @param[in] BufferSize Size of Buffer, must be a multiple of device block size. \r
67 @param[out] Buffer A pointer to the destination buffer for the data. The \r
68 caller is responsible for either having implicit or \r
69 explicit ownership of the buffer.\r
70\r
71 @retval EFI_SUCCESS The read request was queued if Token->Event is\r
72 not NULL.The data was read correctly from the\r
73 device if the Token->Event is NULL.\r
74 @retval EFI_DEVICE_ERROR The device reported an error while performing\r
75 the read.\r
76 @retval EFI_NO_MEDIA There is no media in the device.\r
77 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
78 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
79 intrinsic block size of the device.\r
80 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid, \r
81 or the buffer is not on proper alignment.\r
82 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
83 of resources.\r
84**/\r
85typedef\r
86EFI_STATUS\r
87(EFIAPI *EMU_BLOCK_READ) (\r
88 IN EMU_BLOCK_IO_PROTOCOL *This,\r
89 IN UINT32 MediaId,\r
90 IN EFI_LBA LBA,\r
91 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
92 IN UINTN BufferSize,\r
93 OUT VOID *Buffer\r
94 );\r
95\r
96/**\r
97 Write BufferSize bytes from Lba into Buffer.\r
98\r
99 This function writes the requested number of blocks to the device. All blocks\r
100 are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,\r
101 EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is\r
102 being used, the Event associated with this request will not be signaled.\r
103\r
104 @param[in] This Indicates a pointer to the calling context.\r
105 @param[in] MediaId The media ID that the write request is for.\r
106 @param[in] Lba The starting logical block address to be written. The\r
107 caller is responsible for writing to only legitimate\r
108 locations.\r
109 @param[in, out] Token A pointer to the token associated with the transaction.\r
110 @param[in] BufferSize Size of Buffer, must be a multiple of device block size.\r
111 @param[in] Buffer A pointer to the source buffer for the data.\r
112\r
113 @retval EFI_SUCCESS The write request was queued if Event is not NULL.\r
114 The data was written correctly to the device if\r
115 the Event is NULL.\r
116 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
117 @retval EFI_NO_MEDIA There is no media in the device.\r
118 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
119 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
120 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
121 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
122 or the buffer is not on proper alignment.\r
123 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
124 of resources.\r
125\r
126**/\r
127typedef\r
128EFI_STATUS\r
129(EFIAPI *EMU_BLOCK_WRITE) (\r
130 IN EMU_BLOCK_IO_PROTOCOL *This,\r
131 IN UINT32 MediaId,\r
132 IN EFI_LBA LBA,\r
133 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
134 IN UINTN BufferSize,\r
135 IN VOID *Buffer\r
136 );\r
137\r
138/**\r
139 Flush the Block Device.\r
140 \r
141 If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED\r
142 is returned and non-blocking I/O is being used, the Event associated with\r
143 this request will not be signaled. \r
144\r
145 @param[in] This Indicates a pointer to the calling context.\r
146 @param[in,out] Token A pointer to the token associated with the transaction\r
147\r
148 @retval EFI_SUCCESS The flush request was queued if Event is not NULL.\r
149 All outstanding data was written correctly to the\r
150 device if the Event is NULL.\r
151 @retval EFI_DEVICE_ERROR The device reported an error while writting back\r
152 the data.\r
153 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
154 @retval EFI_NO_MEDIA There is no media in the device.\r
155 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
156 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack\r
157 of resources.\r
158\r
159**/\r
160typedef\r
161EFI_STATUS\r
162(EFIAPI *EMU_BLOCK_FLUSH) (\r
163 IN EMU_BLOCK_IO_PROTOCOL *This,\r
164 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
165 );\r
166\r
167\r
168typedef\r
169EFI_STATUS\r
170(EFIAPI *EMU_BLOCK_CREATE_MAPPING) (\r
171 IN EMU_BLOCK_IO_PROTOCOL *This,\r
172 IN EFI_BLOCK_IO_MEDIA *Media\r
173 );\r
174\r
175\r
176///\r
177/// The Block I/O2 protocol defines an extension to the Block I/O protocol which\r
178/// enables the ability to read and write data at a block level in a non-blocking\r
179// manner.\r
180///\r
181struct _EMU_BLOCK_IO_PROTOCOL {\r
182 EMU_BLOCK_RESET Reset;\r
183 EMU_BLOCK_READ ReadBlocks;\r
184 EMU_BLOCK_WRITE WriteBlocks;\r
185 EMU_BLOCK_FLUSH FlushBlocks;\r
186 EMU_BLOCK_CREATE_MAPPING CreateMapping;\r
187};\r
188\r
189extern EFI_GUID gEmuBlockIoProtocolGuid;\r
190\r
191#endif\r
192\r