Skip to content

Commit 0be77e9

Browse files
committed
[efi] Add EFI_BLOCK_IO2_PROTOCOL header and GUID definition
Signed-off-by: Michael Brown <mcb30@ipxe.org>
1 parent f796d5b commit 0be77e9

4 files changed

Lines changed: 216 additions & 0 deletions

File tree

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
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, Intel Corporation. All rights reserved.<BR>
9+
This program and the accompanying materials
10+
are licensed and made available under the terms and conditions of the BSD License
11+
which accompanies this distribution. The full text of the license may be found at
12+
http://opensource.org/licenses/bsd-license.php
13+
14+
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16+
17+
**/
18+
19+
#ifndef __BLOCK_IO2_H__
20+
#define __BLOCK_IO2_H__
21+
22+
FILE_LICENCE ( BSD3 );
23+
24+
#include <ipxe/efi/Protocol/BlockIo.h>
25+
26+
#define EFI_BLOCK_IO2_PROTOCOL_GUID \
27+
{ \
28+
0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1} \
29+
}
30+
31+
typedef struct _EFI_BLOCK_IO2_PROTOCOL EFI_BLOCK_IO2_PROTOCOL;
32+
33+
/**
34+
The struct of Block IO2 Token.
35+
**/
36+
typedef struct {
37+
38+
///
39+
/// If Event is NULL, then blocking I/O is performed.If Event is not NULL and
40+
/// non-blocking I/O is supported, then non-blocking I/O is performed, and
41+
/// Event will be signaled when the read request is completed.
42+
///
43+
EFI_EVENT Event;
44+
45+
///
46+
/// Defines whether or not the signaled event encountered an error.
47+
///
48+
EFI_STATUS TransactionStatus;
49+
} EFI_BLOCK_IO2_TOKEN;
50+
51+
52+
/**
53+
Reset the block device hardware.
54+
55+
@param[in] This Indicates a pointer to the calling context.
56+
@param[in] ExtendedVerification Indicates that the driver may perform a more
57+
exhausive verification operation of the device
58+
during reset.
59+
60+
@retval EFI_SUCCESS The device was reset.
61+
@retval EFI_DEVICE_ERROR The device is not functioning properly and could
62+
not be reset.
63+
64+
**/
65+
typedef
66+
EFI_STATUS
67+
(EFIAPI *EFI_BLOCK_RESET_EX) (
68+
IN EFI_BLOCK_IO2_PROTOCOL *This,
69+
IN BOOLEAN ExtendedVerification
70+
);
71+
72+
/**
73+
Read BufferSize bytes from Lba into Buffer.
74+
75+
This function reads the requested number of blocks from the device. All the
76+
blocks are read, or an error is returned.
77+
If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_or EFI_MEDIA_CHANGED is returned and
78+
non-blocking I/O is being used, the Event associated with this request will
79+
not be signaled.
80+
81+
@param[in] This Indicates a pointer to the calling context.
82+
@param[in] MediaId Id of the media, changes every time the media is
83+
replaced.
84+
@param[in] Lba The starting Logical Block Address to read from.
85+
@param[in, out] Token A pointer to the token associated with the transaction.
86+
@param[in] BufferSize Size of Buffer, must be a multiple of device block size.
87+
@param[out] Buffer A pointer to the destination buffer for the data. The
88+
caller is responsible for either having implicit or
89+
explicit ownership of the buffer.
90+
91+
@retval EFI_SUCCESS The read request was queued if Token->Event is
92+
not NULL.The data was read correctly from the
93+
device if the Token->Event is NULL.
94+
@retval EFI_DEVICE_ERROR The device reported an error while performing
95+
the read.
96+
@retval EFI_NO_MEDIA There is no media in the device.
97+
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
98+
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
99+
intrinsic block size of the device.
100+
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
101+
or the buffer is not on proper alignment.
102+
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
103+
of resources.
104+
**/
105+
typedef
106+
EFI_STATUS
107+
(EFIAPI *EFI_BLOCK_READ_EX) (
108+
IN EFI_BLOCK_IO2_PROTOCOL *This,
109+
IN UINT32 MediaId,
110+
IN EFI_LBA LBA,
111+
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
112+
IN UINTN BufferSize,
113+
OUT VOID *Buffer
114+
);
115+
116+
/**
117+
Write BufferSize bytes from Lba into Buffer.
118+
119+
This function writes the requested number of blocks to the device. All blocks
120+
are written, or an error is returned.If EFI_DEVICE_ERROR, EFI_NO_MEDIA,
121+
EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED is returned and non-blocking I/O is
122+
being used, the Event associated with this request will not be signaled.
123+
124+
@param[in] This Indicates a pointer to the calling context.
125+
@param[in] MediaId The media ID that the write request is for.
126+
@param[in] Lba The starting logical block address to be written. The
127+
caller is responsible for writing to only legitimate
128+
locations.
129+
@param[in, out] Token A pointer to the token associated with the transaction.
130+
@param[in] BufferSize Size of Buffer, must be a multiple of device block size.
131+
@param[in] Buffer A pointer to the source buffer for the data.
132+
133+
@retval EFI_SUCCESS The write request was queued if Event is not NULL.
134+
The data was written correctly to the device if
135+
the Event is NULL.
136+
@retval EFI_WRITE_PROTECTED The device can not be written to.
137+
@retval EFI_NO_MEDIA There is no media in the device.
138+
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
139+
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.
140+
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
141+
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
142+
or the buffer is not on proper alignment.
143+
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
144+
of resources.
145+
146+
**/
147+
typedef
148+
EFI_STATUS
149+
(EFIAPI *EFI_BLOCK_WRITE_EX) (
150+
IN EFI_BLOCK_IO2_PROTOCOL *This,
151+
IN UINT32 MediaId,
152+
IN EFI_LBA LBA,
153+
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
154+
IN UINTN BufferSize,
155+
IN VOID *Buffer
156+
);
157+
158+
/**
159+
Flush the Block Device.
160+
161+
If EFI_DEVICE_ERROR, EFI_NO_MEDIA,_EFI_WRITE_PROTECTED or EFI_MEDIA_CHANGED
162+
is returned and non-blocking I/O is being used, the Event associated with
163+
this request will not be signaled.
164+
165+
@param[in] This Indicates a pointer to the calling context.
166+
@param[in,out] Token A pointer to the token associated with the transaction
167+
168+
@retval EFI_SUCCESS The flush request was queued if Event is not NULL.
169+
All outstanding data was written correctly to the
170+
device if the Event is NULL.
171+
@retval EFI_DEVICE_ERROR The device reported an error while writting back
172+
the data.
173+
@retval EFI_WRITE_PROTECTED The device cannot be written to.
174+
@retval EFI_NO_MEDIA There is no media in the device.
175+
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
176+
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
177+
of resources.
178+
179+
**/
180+
typedef
181+
EFI_STATUS
182+
(EFIAPI *EFI_BLOCK_FLUSH_EX) (
183+
IN EFI_BLOCK_IO2_PROTOCOL *This,
184+
IN OUT EFI_BLOCK_IO2_TOKEN *Token
185+
);
186+
187+
///
188+
/// The Block I/O2 protocol defines an extension to the Block I/O protocol which
189+
/// enables the ability to read and write data at a block level in a non-blocking
190+
// manner.
191+
///
192+
struct _EFI_BLOCK_IO2_PROTOCOL {
193+
///
194+
/// A pointer to the EFI_BLOCK_IO_MEDIA data for this device.
195+
/// Type EFI_BLOCK_IO_MEDIA is defined in BlockIo.h.
196+
///
197+
EFI_BLOCK_IO_MEDIA *Media;
198+
199+
EFI_BLOCK_RESET_EX Reset;
200+
EFI_BLOCK_READ_EX ReadBlocksEx;
201+
EFI_BLOCK_WRITE_EX WriteBlocksEx;
202+
EFI_BLOCK_FLUSH_EX FlushBlocksEx;
203+
};
204+
205+
extern EFI_GUID gEfiBlockIo2ProtocolGuid;
206+
207+
#endif
208+

src/include/ipxe/efi/efi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ extern EFI_GUID efi_apple_net_boot_protocol_guid;
158158
extern EFI_GUID efi_arp_protocol_guid;
159159
extern EFI_GUID efi_arp_service_binding_protocol_guid;
160160
extern EFI_GUID efi_block_io_protocol_guid;
161+
extern EFI_GUID efi_block_io2_protocol_guid;
161162
extern EFI_GUID efi_bus_specific_driver_override_protocol_guid;
162163
extern EFI_GUID efi_component_name_protocol_guid;
163164
extern EFI_GUID efi_component_name2_protocol_guid;

src/interface/efi/efi_debug.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ static struct efi_well_known_guid efi_well_known_guids[] = {
7979
"ArpSb" },
8080
{ &efi_block_io_protocol_guid,
8181
"BlockIo" },
82+
{ &efi_block_io2_protocol_guid,
83+
"BlockIo2" },
8284
{ &efi_bus_specific_driver_override_protocol_guid,
8385
"BusSpecificDriverOverride" },
8486
{ &efi_component_name_protocol_guid,

src/interface/efi/efi_guid.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
2828
#include <ipxe/efi/Protocol/AppleNetBoot.h>
2929
#include <ipxe/efi/Protocol/Arp.h>
3030
#include <ipxe/efi/Protocol/BlockIo.h>
31+
#include <ipxe/efi/Protocol/BlockIo2.h>
3132
#include <ipxe/efi/Protocol/BusSpecificDriverOverride.h>
3233
#include <ipxe/efi/Protocol/ComponentName.h>
3334
#include <ipxe/efi/Protocol/ComponentName2.h>
@@ -101,6 +102,10 @@ EFI_GUID efi_arp_service_binding_protocol_guid
101102
EFI_GUID efi_block_io_protocol_guid
102103
= EFI_BLOCK_IO_PROTOCOL_GUID;
103104

105+
/** Block I/O version 2 protocol GUID */
106+
EFI_GUID efi_block_io2_protocol_guid
107+
= EFI_BLOCK_IO2_PROTOCOL_GUID;
108+
104109
/** Bus specific driver override protocol GUID */
105110
EFI_GUID efi_bus_specific_driver_override_protocol_guid
106111
= EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID;

0 commit comments

Comments
 (0)