• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Include file to suport EDD 3.0.
3   This file is coded to T13 D1386 Revision 3
4   Availible on http://www.t13.org/#Project drafts
5   Currently at ftp://fission.dt.wdc.com/pub/standards/x3t13/project/d1386r3.pdf
6 
7 Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>
8 
9 This program and the accompanying materials
10 are licensed and made available under the terms and conditions
11 of the BSD License which accompanies this distribution.  The
12 full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14 
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 
18 **/
19 
20 #ifndef _EDD_H_
21 #define _EDD_H_
22 
23 //
24 // packing with no compiler padding, so that the fields
25 // of the following architected structures can be
26 // properly accessed from C code.
27 //
28 #pragma pack(1)
29 
30 typedef struct {
31   UINT8   Bus;
32   UINT8   Device;
33   UINT8   Function;
34   UINT8   Controller;
35   UINT32  Reserved;
36 } EDD_PCI;
37 
38 typedef struct {
39   UINT16  Base;
40   UINT16  Reserved;
41   UINT32  Reserved2;
42 } EDD_LEGACY;
43 
44 typedef union {
45   EDD_PCI     Pci;
46   EDD_LEGACY  Legacy;
47 } EDD_INTERFACE_PATH;
48 
49 typedef struct {
50   UINT8 Master;
51   UINT8 Reserved[15];
52 } EDD_ATA;
53 
54 typedef struct {
55   UINT8 Master;
56   UINT8 Lun;
57   UINT8 Reserved[14];
58 } EDD_ATAPI;
59 
60 typedef struct {
61   UINT16  Pun;
62   UINT64  Lun;
63   UINT8   Reserved[6];
64 } EDD_SCSI;
65 
66 typedef struct {
67   UINT64  SerialNumber;
68   UINT64  Reserved;
69 } EDD_USB;
70 
71 typedef struct {
72   UINT64  Guid;
73   UINT64  Reserved;
74 } EDD_1394;
75 
76 typedef struct {
77   UINT64  Wwn;
78   UINT64  Lun;
79 } EDD_FIBRE;
80 
81 typedef union {
82   EDD_ATA   Ata;
83   EDD_ATAPI Atapi;
84   EDD_SCSI  Scsi;
85   EDD_USB   Usb;
86   EDD_1394  FireWire;
87   EDD_FIBRE FibreChannel;
88 } EDD_DEVICE_PATH;
89 
90 typedef struct {
91   UINT16              StructureSize;
92   UINT16              Flags;
93   UINT32              MaxCylinders;
94   UINT32              MaxHeads;
95   UINT32              SectorsPerTrack;
96   UINT64              PhysicalSectors;
97   UINT16              BytesPerSector;
98   UINT32              Fdpt;
99   UINT16              Key;
100   UINT8               DevicePathLength;
101   UINT8               Reserved1;
102   UINT16              Reserved2;
103   CHAR8               HostBusType[4];
104   CHAR8               InterfaceType[8];
105   EDD_INTERFACE_PATH  InterfacePath;
106   EDD_DEVICE_PATH     DevicePath;
107   UINT8               Reserved3;
108   UINT8               Checksum;
109 } EDD_DRIVE_PARAMETERS;
110 
111 //
112 // EDD_DRIVE_PARAMETERS.Flags defines
113 //
114 #define EDD_GEOMETRY_VALID          0x02
115 #define EDD_DEVICE_REMOVABLE        0x04
116 #define EDD_WRITE_VERIFY_SUPPORTED  0x08
117 #define EDD_DEVICE_CHANGE           0x10
118 #define EDD_DEVICE_LOCKABLE         0x20
119 
120 //
121 // BUGBUG: This bit does not follow the spec. It tends to be always set
122 //  to work properly with Win98.
123 //
124 #define EDD_DEVICE_GEOMETRY_MAX 0x40
125 
126 typedef struct {
127   UINT8   PacketSizeInBytes;  // 0x18
128   UINT8   Zero;
129   UINT8   NumberOfBlocks;     // Max 0x7f
130   UINT8   Zero2;
131   UINT32  SegOffset;
132   UINT64  Lba;
133   UINT64  TransferBuffer;
134   UINT32  ExtendedBlockCount; // Max 0xffffffff
135   UINT32  Zero3;
136 } EDD_DEVICE_ADDRESS_PACKET;
137 
138 #define EDD_VERSION_30  0x30
139 
140 //
141 // Int 13 BIOS Errors
142 //
143 #define BIOS_PASS                   0x00
144 #define BIOS_WRITE_PROTECTED        0x03
145 #define BIOS_SECTOR_NOT_FOUND       0x04
146 #define BIOS_RESET_FAILED           0x05
147 #define BIOS_DISK_CHANGED           0x06
148 #define BIOS_DRIVE_DOES_NOT_EXIST   0x07
149 #define BIOS_DMA_ERROR              0x08
150 #define BIOS_DATA_BOUNDRY_ERROR     0x09
151 #define BIOS_BAD_SECTOR             0x0a
152 #define BIOS_BAD_TRACK              0x0b
153 #define BIOS_MEADIA_TYPE_NOT_FOUND  0x0c
154 #define BIOS_INVALED_FORMAT         0x0d
155 #define BIOS_ECC_ERROR              0x10
156 #define BIOS_ECC_CORRECTED_ERROR    0x11
157 #define BIOS_HARD_DRIVE_FAILURE     0x20
158 #define BIOS_SEEK_FAILED            0x40
159 #define BIOS_DRIVE_TIMEOUT          0x80
160 #define BIOS_DRIVE_NOT_READY        0xaa
161 #define BIOS_UNDEFINED_ERROR        0xbb
162 #define BIOS_WRITE_FAULT            0xcc
163 #define BIOS_SENSE_FAILED           0xff
164 
165 #define MAX_EDD11_XFER              0xfe00
166 
167 #pragma pack()
168 //
169 // Internal Data Structures
170 //
171 typedef struct {
172   CHAR8                 Letter;
173   UINT8                 Number;
174   UINT8                 EddVersion;
175   BOOLEAN               ExtendedInt13;
176   BOOLEAN               DriveLockingAndEjecting;
177   BOOLEAN               Edd;
178   BOOLEAN               Extensions64Bit;
179   BOOLEAN               ParametersValid;
180   UINT8                 ErrorCode;
181   VOID                  *FdptPointer;
182   BOOLEAN               Floppy;
183   BOOLEAN               AtapiFloppy;
184   UINT8                 MaxHead;
185   UINT8                 MaxSector;
186   UINT16                MaxCylinder;
187   UINT16                Pad;
188   EDD_DRIVE_PARAMETERS  Parameters;
189 } BIOS_LEGACY_DRIVE;
190 
191 #define BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE SIGNATURE_32 ('b', 'b', 'i', 'o')
192 typedef struct {
193   UINTN                     Signature;
194 
195   EFI_HANDLE                Handle;
196   EFI_HANDLE                ControllerHandle;
197   EFI_BLOCK_IO_PROTOCOL     BlockIo;
198   EFI_BLOCK_IO_MEDIA        BlockMedia;
199   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
200   EFI_PCI_IO_PROTOCOL       *PciIo;
201   EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;
202 
203   BIOS_LEGACY_DRIVE         Bios;
204 
205 } BIOS_BLOCK_IO_DEV;
206 
207 #define BIOS_BLOCK_IO_FROM_THIS(a)  CR (a, BIOS_BLOCK_IO_DEV, BlockIo, BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE)
208 
209 #endif
210