]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/BlockIo.h
add a error macro to prevent this file from included for now #error "UEFI 2.1 HII...
[mirror_edk2.git] / MdePkg / Include / Protocol / BlockIo.h
1 /** @file
2 Block IO protocol as defined in the EFI 1.0 specification.
3
4 The Block IO protocol is used to abstract block devices like hard drives,
5 DVD-ROMs and floppy drives.
6
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __BLOCK_IO_H__
19 #define __BLOCK_IO_H__
20
21 #define EFI_BLOCK_IO_PROTOCOL_GUID \
22 { \
23 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
24 }
25
26 typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;
27
28 //
29 // Protocol GUID name defined in EFI1.1.
30 //
31 #define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID
32
33 //
34 // Protocol defined in EFI1.1.
35 //
36 typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;
37
38 /**
39 Reset the Block Device.
40
41 @param This Protocol instance pointer.
42 @param ExtendedVerification Driver may perform diagnostics on reset.
43
44 @retval EFI_SUCCESS The device was reset.
45 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
46 not be reset.
47
48 **/
49 typedef
50 EFI_STATUS
51 (EFIAPI *EFI_BLOCK_RESET) (
52 IN EFI_BLOCK_IO_PROTOCOL *This,
53 IN BOOLEAN ExtendedVerification
54 )
55 ;
56
57 /**
58 Read BufferSize bytes from Lba into Buffer.
59
60 @param This Protocol instance pointer.
61 @param MediaId Id of the media, changes every time the media is replaced.
62 @param Lba The starting Logical Block Address to read from
63 @param BufferSize Size of Buffer, must be a multiple of device block size.
64 @param Buffer Buffer containing read data
65
66 @retval EFI_SUCCESS The data was read correctly from the device.
67 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
68 @retval EFI_NO_MEDIA There is no media in the device.
69 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
70 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
71 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
72 valid for the device.
73
74 **/
75 typedef
76 EFI_STATUS
77 (EFIAPI *EFI_BLOCK_READ) (
78 IN EFI_BLOCK_IO_PROTOCOL *This,
79 IN UINT32 MediaId,
80 IN EFI_LBA Lba,
81 IN UINTN BufferSize,
82 OUT VOID *Buffer
83 )
84 ;
85
86 /**
87 Write BufferSize bytes from Lba into Buffer.
88
89 @param This Protocol instance pointer.
90 @param MediaId Id of the media, changes every time the media is replaced.
91 @param Lba The starting Logical Block Address to read from
92 @param BufferSize Size of Buffer, must be a multiple of device block size.
93 @param Buffer Buffer containing read data
94
95 @retval EFI_SUCCESS The data was written correctly to the device.
96 @retval EFI_WRITE_PROTECTED The device can not be written to.
97 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
98 @retval EFI_NO_MEDIA There is no media in the device.
99 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
100 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
101 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not
102 valid for the device.
103
104 **/
105 typedef
106 EFI_STATUS
107 (EFIAPI *EFI_BLOCK_WRITE) (
108 IN EFI_BLOCK_IO_PROTOCOL *This,
109 IN UINT32 MediaId,
110 IN EFI_LBA Lba,
111 IN UINTN BufferSize,
112 IN VOID *Buffer
113 )
114 ;
115
116 /**
117 Flush the Block Device.
118
119 @param This Protocol instance pointer.
120
121 @retval EFI_SUCCESS All outstanding data was written to the device
122 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
123 @retval EFI_NO_MEDIA There is no media in the device.
124
125 **/
126 typedef
127 EFI_STATUS
128 (EFIAPI *EFI_BLOCK_FLUSH) (
129 IN EFI_BLOCK_IO_PROTOCOL *This
130 )
131 ;
132
133 /**
134 Block IO read only mode data and updated only via members of BlockIO
135
136 **/
137 typedef struct {
138 UINT32 MediaId; ///< The curent media Id. If the media changes, this value is changed.
139 BOOLEAN RemovableMedia; ///< TRUE if the media is removable; otherwise, FALSE.
140 BOOLEAN MediaPresent; /**< TRUE if there is a media currently present in the device;
141 othersise, FALSE. THis field shows the media present status
142 as of the most recent ReadBlocks() or WriteBlocks() call.
143 **/
144 BOOLEAN LogicalPartition; /**< TRUE if LBA 0 is the first block of a partition; otherwise
145 FALSE. For media with only one partition this would be TRUE.
146 **/
147 BOOLEAN ReadOnly; /**< TRUE if the media is marked read-only otherwise, FALSE.
148 This field shows the read-only status as of the most recent WriteBlocks () call.
149 **/
150 BOOLEAN WriteCaching; ///< TRUE if the WriteBlock () function caches write data.
151
152 UINT32 BlockSize; /**< The intrinsic block size of the device. If the media changes, then
153 this field is updated.
154 **/
155 UINT32 IoAlign; ///< Supplies the alignment requirement for any buffer to read or write block(s).
156
157 EFI_LBA LastBlock; /**< The last logical block address on the device.
158 If the media changes, then this field is updated.
159 **/
160 } EFI_BLOCK_IO_MEDIA;
161
162 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
163 //
164 // Revision defined in EFI1.1.
165 //
166 #define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
167
168 struct _EFI_BLOCK_IO_PROTOCOL {
169 UINT64 Revision;
170
171 EFI_BLOCK_IO_MEDIA *Media;
172
173 EFI_BLOCK_RESET Reset;
174 EFI_BLOCK_READ ReadBlocks;
175 EFI_BLOCK_WRITE WriteBlocks;
176 EFI_BLOCK_FLUSH FlushBlocks;
177
178 };
179
180 extern EFI_GUID gEfiBlockIoProtocolGuid;
181
182 #endif