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