summaryrefslogtreecommitdiff
path: root/IntelFrameworkPkg/Include/Ppi/BlockIo.h
blob: 014cca5c1f9680c5249bf38deb9e9ce5aedb709d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/** @file
  This file declares BlockIo PPI used to access block-oriented storage devices

  Copyright (c) 2007, Intel Corporation
  All rights reserved. This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

  Module Name:  BlockIo.h

  @par Revision Reference:
  This PPI is defined in Framework of EFI Recovery Spec
  Version 0.9

**/

#ifndef _PEI_BLOCK_IO_H_
#define _PEI_BLOCK_IO_H_

#include <PiPei.h>

#define EFI_PEI_IDE_BLOCK_IO_PPI \
  { \
    0x0964e5b22, 0x6459, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b }  \
  }

#define EFI_PEI_144_FLOPPY_BLOCK_IO_PPI \
  { \
    0xda6855bd, 0x07b7, 0x4c05, { 0x9e, 0xd8, 0xe2, 0x59, 0xfd, 0x36, 0x0e, 0x22 }  \
  }

#define EFI_PEI_VIRTUAL_BLOCK_IO_PPI \
  { \
    0x695d8aa1, 0x42ee, 0x4c46, { 0x80, 0x5c, 0x6e, 0xa6, 0xbc, 0xe7, 0x99, 0xe3 } \
  }

typedef struct _EFI_PEI_RECOVERY_BLOCK_IO_PPI EFI_PEI_RECOVERY_BLOCK_IO_PPI;

typedef UINT64  EFI_PEI_LBA;

typedef enum {
  LegacyFloppy  = 0,
  IdeCDROM      = 1,
  IdeLS120      = 2,
  UsbMassStorage= 3,
  MaxDeviceType
} EFI_PEI_BLOCK_DEVICE_TYPE;

typedef struct {
  EFI_PEI_BLOCK_DEVICE_TYPE  DeviceType;
  BOOLEAN                    MediaPresent;
  UINTN                      LastBlock;
  UINTN                      BlockSize;
} EFI_PEI_BLOCK_IO_MEDIA;

/**
  Gets the count of block I/O devices that one specific block driver detects.

  @param  PeiServices        General-purpose services that are available to every PEIM.
  @param  This               Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
  @param  NumberBlockDevices The number of block I/O devices discovered.

  @return Status code

**/
typedef
EFI_STATUS
(EFIAPI *EFI_PEI_GET_NUMBER_BLOCK_DEVICES)(
  IN  EFI_PEI_SERVICES                         **PeiServices,
  IN  EFI_PEI_RECOVERY_BLOCK_IO_PPI            *This,
  OUT UINTN                                    *NumberBlockDevices
  );

/**
  Gets a block device's media information.

  @param  PeiServices    General-purpose services that are available to every PEIM
  @param  This           Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
  @param  DeviceIndex    Specifies the block device to which the function
                         wants to talk. Because the driver that implements Block I/O PPIs
                         will manage multiple block devices, the PPIs that want to talk to a single
                         device must specify the device index that was assigned during the enumeration
                         process. This index is a number from one to NumberBlockDevices.
  @param  MediaInfo      The media information of the specified block media.

  @retval EFI_SUCCESS           Media information about the specified block device was obtained successfully.
  @retval EFI_DEVICE_ERROR      Cannot get the media information due to a hardware error.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_PEI_GET_DEVICE_MEDIA_INFORMATION)(
  IN  EFI_PEI_SERVICES                         **PeiServices,
  IN  EFI_PEI_RECOVERY_BLOCK_IO_PPI            *This,
  IN  UINTN                                    DeviceIndex,
  OUT EFI_PEI_BLOCK_IO_MEDIA                   *MediaInfo
  );

/**
  Reads the requested number of blocks from the specified block device.

  @param  PeiServices    General-purpose services that are available to every PEIM.
  @param  This           Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
  @param  DeviceIndex    Specifies the block device to which the function wants to talk.
  @param  StartLBA       The starting logical block address (LBA) to read from on the device
  @param  BufferSize     The size of the Buffer in bytes. This number must
                         be a multiple of the intrinsic block size of the device.
  @param  Buffer         A pointer to the destination buffer for the data.
                         The caller is responsible for the ownership of the buffer.

  @retval EFI_SUCCESS           The data was read correctly from the device.
  @retval EFI_DEVICE_ERROR      The device reported an error while attempting to perform the read operation.
  @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
                                or the buffer is not properly aligned.
  @retval EFI_BAD_BUFFER_SIZE   The BufferSize parameter is not a multiple of
                                the intrinsic block size of the device.
  @retval EFI_NO_MEDIA          There is no media in the device.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_PEI_READ_BLOCKS)(
  IN  EFI_PEI_SERVICES                         **PeiServices,
  IN  EFI_PEI_RECOVERY_BLOCK_IO_PPI            *This,
  IN  UINTN                                    DeviceIndex,
  IN  EFI_PEI_LBA                              StartLBA,
  IN  UINTN                                    BufferSize,
  OUT VOID                                     *Buffer
  );

/**
  @par Ppi Description:
  EFI_PEI_RECOVERY_BLOCK_IO_PPI provides the services that are required
  to access a block I/O device during PEI recovery boot mode.

  @param GetNumberOfBlockDevices
  Gets the number of block I/O devices that the specific block driver manages.

  @param GetBlockDeviceMediaInfo
  Gets the specified media information.

  @param ReadBlocks
  Reads the requested number of blocks from the specified block device.

**/
struct _EFI_PEI_RECOVERY_BLOCK_IO_PPI {
  EFI_PEI_GET_NUMBER_BLOCK_DEVICES      GetNumberOfBlockDevices;
  EFI_PEI_GET_DEVICE_MEDIA_INFORMATION  GetBlockDeviceMediaInfo;
  EFI_PEI_READ_BLOCKS                   ReadBlocks;
};

extern EFI_GUID gEfiPeiIdeBlockIoPpiGuid;
extern EFI_GUID gEfiPei144FloppyBlockIoPpiGuid;
extern EFI_GUID gEfiPeiVirtualBlockIoPpiGuid;

#endif