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