iPXE
BlockIo2.h
Go to the documentation of this file.
1 /** @file
2  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 - 2018, Intel Corporation. All rights reserved.<BR>
9  SPDX-License-Identifier: BSD-2-Clause-Patent
10 
11 **/
12 
13 #ifndef __BLOCK_IO2_H__
14 #define __BLOCK_IO2_H__
15 
16 FILE_LICENCE ( BSD2_PATENT );
17 FILE_SECBOOT ( PERMITTED );
18 
20 
21 #define EFI_BLOCK_IO2_PROTOCOL_GUID \
22  { \
23  0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1} \
24  }
25 
27 
28 /**
29  The struct of Block IO2 Token.
30 **/
31 typedef struct {
32  ///
33  /// If Event is NULL, then blocking I/O is performed.If Event is not NULL and
34  /// non-blocking I/O is supported, then non-blocking I/O is performed, and
35  /// Event will be signaled when the read request is completed.
36  ///
38 
39  ///
40  /// Defines whether or not the signaled event encountered an error.
41  ///
44 
45 /**
46  Reset the block device hardware.
47 
48  @param[in] This Indicates a pointer to the calling context.
49  @param[in] ExtendedVerification Indicates that the driver may perform a more
50  exhausive verification operation of the device
51  during reset.
52 
53  @retval EFI_SUCCESS The device was reset.
54  @retval EFI_DEVICE_ERROR The device is not functioning properly and could
55  not be reset.
56 
57 **/
58 typedef
62  IN BOOLEAN ExtendedVerification
63  );
64 
65 /**
66  Read BufferSize bytes from Lba into Buffer.
67 
68  This function reads the requested number of blocks from the device. All the
69  blocks are read, or an error is returned.
70  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and
71  non-blocking I/O is being used, the Event associated with this request will
72  not be signaled.
73 
74  @param[in] This Indicates a pointer to the calling context.
75  @param[in] MediaId Id of the media, changes every time the media is
76  replaced.
77  @param[in] Lba The starting Logical Block Address to read from.
78  @param[in, out] Token A pointer to the token associated with the transaction.
79  @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
80  @param[out] Buffer A pointer to the destination buffer for the data. The
81  caller is responsible for either having implicit or
82  explicit ownership of the buffer.
83 
84  @retval EFI_SUCCESS The read request was queued if Token->Event is
85  not NULL.The data was read correctly from the
86  device if the Token->Event is NULL.
87  @retval EFI_DEVICE_ERROR The device reported an error while performing
88  the read.
89  @retval EFI_NO_MEDIA There is no media in the device.
90  @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
91  @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
92  intrinsic block size of the device.
93  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
94  or the buffer is not on proper alignment.
95  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
96  of resources.
97 **/
98 typedef
102  IN UINT32 MediaId,
103  IN EFI_LBA LBA,
104  IN OUT EFI_BLOCK_IO2_TOKEN *Token,
106  OUT VOID *Buffer
107  );
108 
109 /**
110  Write BufferSize bytes from Lba into Buffer.
111 
112  This function writes the requested number of blocks to the device. All blocks
113  are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,
114  EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is
115  being used, the Event associated with this request will not be signaled.
116 
117  @param[in] This Indicates a pointer to the calling context.
118  @param[in] MediaId The media ID that the write request is for.
119  @param[in] Lba The starting logical block address to be written. The
120  caller is responsible for writing to only legitimate
121  locations.
122  @param[in, out] Token A pointer to the token associated with the transaction.
123  @param[in] BufferSize Size of Buffer, must be a multiple of device block size.
124  @param[in] Buffer A pointer to the source buffer for the data.
125 
126  @retval EFI_SUCCESS The write request was queued if Event is not NULL.
127  The data was written correctly to the device if
128  the Event is NULL.
129  @retval EFI_WRITE_PROTECTED The device can not be written to.
130  @retval EFI_NO_MEDIA There is no media in the device.
131  @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
132  @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
133  @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
134  @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
135  or the buffer is not on proper alignment.
136  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
137  of resources.
138 
139 **/
140 typedef
144  IN UINT32 MediaId,
145  IN EFI_LBA LBA,
146  IN OUT EFI_BLOCK_IO2_TOKEN *Token,
148  IN VOID *Buffer
149  );
150 
151 /**
152  Flush the Block Device.
153 
154  If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED
155  is returned and non-blocking I/O is being used, the Event associated with
156  this request will not be signaled.
157 
158  @param[in] This Indicates a pointer to the calling context.
159  @param[in,out] Token A pointer to the token associated with the transaction
160 
161  @retval EFI_SUCCESS The flush request was queued if Event is not NULL.
162  All outstanding data was written correctly to the
163  device if the Event is NULL.
164  @retval EFI_DEVICE_ERROR The device reported an error while writting back
165  the data.
166  @retval EFI_WRITE_PROTECTED The device cannot be written to.
167  @retval EFI_NO_MEDIA There is no media in the device.
168  @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
169  @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
170  of resources.
171 
172 **/
173 typedef
177  IN OUT EFI_BLOCK_IO2_TOKEN *Token
178  );
179 
180 ///
181 /// The Block I/O2 protocol defines an extension to the Block I/O protocol which
182 /// enables the ability to read and write data at a block level in a non-blocking
183 // manner.
184 ///
186  ///
187  /// A pointer to the EFI_BLOCK_IO_MEDIA data for this device.
188  /// Type EFI_BLOCK_IO_MEDIA is defined in BlockIo.h.
189  ///
191 
196 };
197 
199 
200 #endif
EFI_BLOCK_IO_MEDIA * Media
A pointer to the EFI_BLOCK_IO_MEDIA data for this device.
Definition: BlockIo2.h:190
EFI_STATUS(EFIAPI * EFI_BLOCK_RESET_EX)(IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Reset the block device hardware.
Definition: BlockIo2.h:60
The Block I/O2 protocol defines an extension to the Block I/O protocol which enables the ability to r...
Definition: BlockIo2.h:185
EFI_STATUS(EFIAPI * EFI_BLOCK_READ_EX)(IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA LBA, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, OUT VOID *Buffer)
Read BufferSize bytes from Lba into Buffer.
Definition: BlockIo2.h:100
FILE_LICENCE(BSD2_PATENT)
128 bit buffer containing a unique identifier value.
Definition: Base.h:216
Definition: efi.h:63
unsigned char BOOLEAN
FILE_SECBOOT(PERMITTED)
unsigned int UINT32
Definition: ProcessorBind.h:99
UINT16_t BufferSize
Buffer size.
Definition: pxe_api.h:64
EFI_EVENT Event
If Event is NULL, then blocking I/O is performed.If Event is not NULL and non-blocking I/O is support...
Definition: BlockIo2.h:37
EFI_STATUS TransactionStatus
Defines whether or not the signaled event encountered an error.
Definition: BlockIo2.h:42
#define OUT
Definition: mlx_utils.h:29
UINT64 EFI_LBA
Logical block address.
Definition: UefiBaseType.h:48
EFI_GUID gEfiBlockIo2ProtocolGuid
EFI_BLOCK_RESET_EX Reset
Definition: BlockIo2.h:192
#define EFIAPI
SEGOFF16_t Buffer
Buffer address.
Definition: pxe_api.h:65
UINT64 UINTN
Unsigned value of native width.
EFI_BLOCK_WRITE_EX WriteBlocksEx
Definition: BlockIo2.h:194
EFI_STATUS(EFIAPI * EFI_BLOCK_WRITE_EX)(IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA LBA, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, IN VOID *Buffer)
Write BufferSize bytes from Lba into Buffer.
Definition: BlockIo2.h:142
#define VOID
Undeclared type.
Definition: Base.h:272
EFI_BLOCK_READ_EX ReadBlocksEx
Definition: BlockIo2.h:193
#define IN
Definition: mlx_utils.h:28
Block IO read only mode data and updated only via members of BlockIO.
Definition: BlockIo.h:131
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
Block IO protocol as defined in the UEFI 2.0 specification.
EFI_BLOCK_FLUSH_EX FlushBlocksEx
Definition: BlockIo2.h:195
The struct of Block IO2 Token.
Definition: BlockIo2.h:31
EFI_STATUS(EFIAPI * EFI_BLOCK_FLUSH_EX)(IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
Flush the Block Device.
Definition: BlockIo2.h:175