]> git.proxmox.com Git - mirror_edk2.git/blob - OldMdePkg/Include/Protocol/BlockIo.h
Adding top-level Conf directory for next generation of EDK II build infrastructure...
[mirror_edk2.git] / OldMdePkg / 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 Module Name: BlockIo.h
17
18 **/
19
20 #ifndef __BLOCK_IO_H__
21 #define __BLOCK_IO_H__
22
23 #define EFI_BLOCK_IO_PROTOCOL_GUID \
24 { \
25 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
26 }
27
28 //
29 // Forward reference for pure ANSI compatability
30 //
31 typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;
32
33 /**
34 Reset the Block Device.
35
36 @param This Protocol instance pointer.
37 @param ExtendedVerification Driver may perform diagnostics on reset.
38
39 @retval EFI_SUCCESS The device was reset.
40 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
41 not be reset.
42
43 **/
44 typedef
45 EFI_STATUS
46 (EFIAPI *EFI_BLOCK_RESET) (
47 IN EFI_BLOCK_IO_PROTOCOL *This,
48 IN BOOLEAN ExtendedVerification
49 )
50 ;
51
52 /**
53 Read BufferSize bytes from Lba into Buffer.
54
55 @param This Protocol instance pointer.
56 @param MediaId Id of the media, changes every time the media is replaced.
57 @param Lba The starting Logical Block Address to read from
58 @param BufferSize Size of Buffer, must be a multiple of device block size.
59 @param Buffer Buffer containing read data
60
61 @retval EFI_SUCCESS The data was read correctly from the device.
62 @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
63 @retval EFI_NO_MEDIA There is no media in the device.
64 @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
65 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
66 @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
67 valid for the device.
68
69 **/
70 typedef
71 EFI_STATUS
72 (EFIAPI *EFI_BLOCK_READ) (
73 IN EFI_BLOCK_IO_PROTOCOL *This,
74 IN UINT32 MediaId,
75 IN EFI_LBA Lba,
76 IN UINTN BufferSize,
77 OUT VOID *Buffer
78 )
79 ;
80
81 /**
82 Write BufferSize bytes from Lba into Buffer.
83
84 @param This Protocol instance pointer.
85 @param MediaId Id of the media, changes every time the media is replaced.
86 @param Lba The starting Logical Block Address to read from
87 @param BufferSize Size of Buffer, must be a multiple of device block size.
88 @param Buffer Buffer containing read data
89
90 @retval EFI_SUCCESS The data was written correctly to the device.
91 @retval EFI_WRITE_PROTECTED The device can not be written to.
92 @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
93 @retval EFI_NO_MEDIA There is no media in the device.
94 @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
95 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
96 @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not
97 valid for the device.
98
99 **/
100 typedef
101 EFI_STATUS
102 (EFIAPI *EFI_BLOCK_WRITE) (
103 IN EFI_BLOCK_IO_PROTOCOL *This,
104 IN UINT32 MediaId,
105 IN EFI_LBA Lba,
106 IN UINTN BufferSize,
107 IN VOID *Buffer
108 )
109 ;
110
111 /**
112 Flush the Block Device.
113
114 @param This Protocol instance pointer.
115
116 @retval EFI_SUCCESS All outstanding data was written to the device
117 @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
118 @retval EFI_NO_MEDIA There is no media in the device.
119
120 **/
121 typedef
122 EFI_STATUS
123 (EFIAPI *EFI_BLOCK_FLUSH) (
124 IN EFI_BLOCK_IO_PROTOCOL *This
125 )
126 ;
127
128 /**
129 Block IO read only mode data and updated only via members of BlockIO
130
131 **/
132 typedef struct {
133 UINT32 MediaId; ///< The curent media Id. If the media changes, this value is changed.
134 BOOLEAN RemovableMedia; ///< TRUE if the media is removable; otherwise, FALSE.
135 BOOLEAN MediaPresent; /**< TRUE if there is a media currently present in the device;
136 othersise, FALSE. THis field shows the media present status
137 as of the most recent ReadBlocks() or WriteBlocks() call.
138 **/
139 BOOLEAN LogicalPartition; /**< TRUE if LBA 0 is the first block of a partition; otherwise
140 FALSE. For media with only one partition this would be TRUE.
141 **/
142 BOOLEAN ReadOnly; /**< TRUE if the media is marked read-only otherwise, FALSE.
143 This field shows the read-only status as of the most recent WriteBlocks () call.
144 **/
145 BOOLEAN WriteCaching; ///< TRUE if the WriteBlock () function caches write data.
146
147 UINT32 BlockSize; /**< The intrinsic block size of the device. If the media changes, then
148 this field is updated.
149 **/
150 UINT32 IoAlign; ///< Supplies the alignment requirement for any buffer to read or write block(s).
151
152 EFI_LBA LastBlock; /**< The last logical block address on the device.
153 If the media changes, then this field is updated.
154 **/
155 } EFI_BLOCK_IO_MEDIA;
156
157 #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
158
159 struct _EFI_BLOCK_IO_PROTOCOL {
160 UINT64 Revision;
161
162 EFI_BLOCK_IO_MEDIA *Media;
163
164 EFI_BLOCK_RESET Reset;
165 EFI_BLOCK_READ ReadBlocks;
166 EFI_BLOCK_WRITE WriteBlocks;
167 EFI_BLOCK_FLUSH FlushBlocks;
168
169 };
170
171 extern EFI_GUID gEfiBlockIoProtocolGuid;
172
173 #endif