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