Add the following PI 1.2 PPIs to the MdePkg
[mirror_edk2.git] / IntelFrameworkPkg / Include / Ppi / BlockIo.h
1 /** @file
2 This file declares BlockIo PPI used to access block-oriented storage devices
3
4 Copyright (c) 2007 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 @par Revision Reference:
14 This PPI is defined in Framework of EFI Recovery Spec
15 Version 0.9
16
17 **/
18
19 #ifndef _PEI_BLOCK_IO_H_
20 #define _PEI_BLOCK_IO_H_
21
22 #define EFI_PEI_IDE_BLOCK_IO_PPI \
23 { \
24 0x0964e5b22, 0x6459, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
25 }
26
27 #define EFI_PEI_144_FLOPPY_BLOCK_IO_PPI \
28 { \
29 0xda6855bd, 0x07b7, 0x4c05, { 0x9e, 0xd8, 0xe2, 0x59, 0xfd, 0x36, 0x0e, 0x22 } \
30 }
31
32 #define EFI_PEI_VIRTUAL_BLOCK_IO_PPI \
33 { \
34 0x695d8aa1, 0x42ee, 0x4c46, { 0x80, 0x5c, 0x6e, 0xa6, 0xbc, 0xe7, 0x99, 0xe3 } \
35 }
36
37 typedef struct _EFI_PEI_RECOVERY_BLOCK_IO_PPI EFI_PEI_RECOVERY_BLOCK_IO_PPI;
38
39 typedef UINT64 EFI_PEI_LBA;
40
41 typedef enum {
42 LegacyFloppy = 0,
43 IdeCDROM = 1,
44 IdeLS120 = 2,
45 UsbMassStorage= 3,
46 MaxDeviceType
47 } EFI_PEI_BLOCK_DEVICE_TYPE;
48
49 ///
50 /// Inconsistent with specification here:
51 /// PEI_BLOCK_IO_MEDIA has been changed to EFI_PEI_BLOCK_IO_MEDIA.
52 /// Inconsistency exists in Framework Recovery Specification, where all referrences to this
53 /// structure name are with the "EFI_" prefix, except for the definition which is without "EFI_".
54 /// So the name of PEI_BLOCK_IO_MEDIA is taken as the exception caused by mistake, and
55 /// EFI_PEI_BLOCK_IO_MEDIA is used to comply with most part of the specification.
56 ///
57 typedef struct {
58 EFI_PEI_BLOCK_DEVICE_TYPE DeviceType;
59 BOOLEAN MediaPresent;
60 UINTN LastBlock;
61 UINTN BlockSize;
62 } EFI_PEI_BLOCK_IO_MEDIA;
63
64 /**
65 Gets the count of block I/O devices that one specific block driver detects.
66
67 @param PeiServices General-purpose services that are available to every PEIM.
68 @param This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
69 @param NumberBlockDevices The number of block I/O devices discovered.
70
71 @return Status code
72
73 **/
74 typedef
75 EFI_STATUS
76 (EFIAPI *EFI_PEI_GET_NUMBER_BLOCK_DEVICES)(
77 IN EFI_PEI_SERVICES **PeiServices,
78 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
79 OUT UINTN *NumberBlockDevices
80 );
81
82 /**
83 Gets a block device's media information.
84
85 @param PeiServices General-purpose services that are available to every PEIM
86 @param This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
87 @param DeviceIndex Specifies the block device to which the function
88 wants to talk. Because the driver that implements Block I/O PPIs
89 will manage multiple block devices, the PPIs that want to talk to a single
90 device must specify the device index that was assigned during the enumeration
91 process. This index is a number from one to NumberBlockDevices.
92 @param MediaInfo The media information of the specified block media.
93
94 @retval EFI_SUCCESS Media information about the specified block device was obtained successfully.
95 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware error.
96
97 **/
98 typedef
99 EFI_STATUS
100 (EFIAPI *EFI_PEI_GET_DEVICE_MEDIA_INFORMATION)(
101 IN EFI_PEI_SERVICES **PeiServices,
102 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
103 IN UINTN DeviceIndex,
104 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
105 );
106
107 /**
108 Reads the requested number of blocks from the specified block device.
109
110 @param PeiServices General-purpose services that are available to every PEIM.
111 @param This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
112 @param DeviceIndex Specifies the block device to which the function wants to talk.
113 @param StartLBA The starting logical block address (LBA) to read from on the device
114 @param BufferSize The size of the Buffer in bytes. This number must
115 be a multiple of the intrinsic block size of the device.
116 @param Buffer A pointer to the destination buffer for the data.
117 The caller is responsible for the ownership of the buffer.
118
119 @retval EFI_SUCCESS The data was read correctly from the device.
120 @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the read operation.
121 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
122 or the buffer is not properly aligned.
123 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
124 the intrinsic block size of the device.
125 @retval EFI_NO_MEDIA There is no media in the device.
126
127 **/
128 typedef
129 EFI_STATUS
130 (EFIAPI *EFI_PEI_READ_BLOCKS)(
131 IN EFI_PEI_SERVICES **PeiServices,
132 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
133 IN UINTN DeviceIndex,
134 IN EFI_PEI_LBA StartLBA,
135 IN UINTN BufferSize,
136 OUT VOID *Buffer
137 );
138
139 ///
140 /// EFI_PEI_RECOVERY_BLOCK_IO_PPI provides the services that are required
141 /// to access a block I/O device during PEI recovery boot mode.
142 ///
143 struct _EFI_PEI_RECOVERY_BLOCK_IO_PPI {
144 ///
145 /// Gets the number of block I/O devices that the specific block driver manages.
146 ///
147 EFI_PEI_GET_NUMBER_BLOCK_DEVICES GetNumberOfBlockDevices;
148
149 ///
150 /// Gets the specified media information.
151 ///
152 EFI_PEI_GET_DEVICE_MEDIA_INFORMATION GetBlockDeviceMediaInfo;
153
154 ///
155 /// Reads the requested number of blocks from the specified block device.
156 ///
157 EFI_PEI_READ_BLOCKS ReadBlocks;
158 };
159
160 extern EFI_GUID gEfiPeiIdeBlockIoPpiGuid;
161 extern EFI_GUID gEfiPei144FloppyBlockIoPpiGuid;
162 extern EFI_GUID gEfiPeiVirtualBlockIoPpiGuid;
163
164 #endif