Import IsaFloppy Dxe and Pei in IntelFrameworkModulePkg.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaFloppy / Pei / FloppyPeim.h
1 /*++
2
3 Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
10 Intel Corporation.
11
12
13 Module Name:
14
15 FloppyPeim.h
16
17 Abstract:
18
19
20 Revision History
21 --*/
22
23 #ifndef _RECOVERY_FLOPPY_H
24 #define _RECOVERY_FLOPPY_H
25
26 //
27 // The package level header files this module uses
28 //
29 #include <PiPei.h>
30 #include <FrameworkPei.h>
31
32 #include <Ppi/BlockIo.h>
33 //
34 // The Library classes this module consumes
35 //
36 #include <Library/DebugLib.h>
37 #include <Library/PeimEntryPoint.h>
38 #include <Library/PeiServicesLib.h>
39 #include <Library/BaseMemoryLib.h>
40 #include <Library/ReportStatusCodeLib.h>
41 #include <Library/TimerLib.h>
42 #include <Library/IoLib.h>
43
44 #include "Fdc.h"
45 //
46 // define some macro
47 //
48 #define STALL_1_SECOND 1000000
49 #define STALL_1_MSECOND 1000
50
51 #define DATA_IN 1
52 #define DATA_OUT 0
53 #define READ 0
54 #define WRITE 1
55
56 typedef enum {
57 _360K_360K = 0,
58 _360K_1200K,
59 _1200K_1200K,
60 _720K_720K,
61 _720K_1440K,
62 _1440K_1440K,
63 _720K_2880K,
64 _1440K_2880K,
65 _2880K_2880K
66 } FDC_DISKET_TYPE;
67
68 typedef struct {
69 UINT8 DevPos;
70 UINT8 Pcn;
71 BOOLEAN MotorOn;
72 BOOLEAN NeedRecalibrate;
73 FDC_DISKET_TYPE Type;
74 EFI_PEI_BLOCK_IO_MEDIA MediaInfo;
75 } PEI_FLOPPY_DEVICE_INFO;
76
77 #define FDC_BLK_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('F', 'b', 'i', 'o')
78
79 typedef struct {
80 UINTN Signature;
81 EFI_PEI_RECOVERY_BLOCK_IO_PPI FdcBlkIo;
82 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
83 UINTN DeviceCount;
84 PEI_FLOPPY_DEVICE_INFO DeviceInfo[2];
85 } FDC_BLK_IO_DEV;
86
87 #define PEI_RECOVERY_FDC_FROM_BLKIO_THIS(a) CR (a, FDC_BLK_IO_DEV, FdcBlkIo, FDC_BLK_IO_DEV_SIGNATURE)
88
89 //
90 // PEI Recovery Block I/O PPI
91 //
92 EFI_STATUS
93 EFIAPI
94 FdcGetNumberOfBlockDevices (
95 IN EFI_PEI_SERVICES **PeiServices,
96 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
97 OUT UINTN *NumberBlockDevices
98 );
99
100 EFI_STATUS
101 EFIAPI
102 FdcGetBlockDeviceMediaInfo (
103 IN EFI_PEI_SERVICES **PeiServices,
104 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
105 IN UINTN DeviceIndex,
106 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
107 );
108
109 EFI_STATUS
110 EFIAPI
111 FdcReadBlocks (
112 IN EFI_PEI_SERVICES **PeiServices,
113 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
114 IN UINTN DeviceIndex,
115 IN EFI_PEI_LBA StartLba,
116 IN UINTN BufferSize,
117 OUT VOID *Buffer
118 );
119
120 //
121 // Internal function declare
122 //
123 UINT8
124 FdcEnumeration (
125 IN FDC_BLK_IO_DEV *FdcBlkIoDev
126 );
127
128 EFI_STATUS
129 FdcReset (
130 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
131 IN UINT8 DevPos
132 );
133
134 BOOLEAN
135 DiscoverFdcDevice (
136 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
137 IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
138 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
139 );
140
141 EFI_STATUS
142 Recalibrate (
143 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
144 IN OUT PEI_FLOPPY_DEVICE_INFO *Info
145 );
146
147 EFI_STATUS
148 Seek (
149 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
150 IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
151 IN EFI_PEI_LBA Lba
152 );
153
154 EFI_STATUS
155 MotorOn (
156 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
157 IN OUT PEI_FLOPPY_DEVICE_INFO *Info
158 );
159
160 EFI_STATUS
161 MotorOff (
162 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
163 IN OUT PEI_FLOPPY_DEVICE_INFO *Info
164 );
165
166 EFI_STATUS
167 FdcWaitForBSYClear (
168 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
169 IN UINT8 DevPos,
170 IN UINTN TimeoutInSeconds
171 );
172
173 EFI_STATUS
174 SenseIntStatus (
175 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
176 IN OUT UINT8 *sts0,
177 IN OUT UINT8 *pcn
178 );
179
180 EFI_STATUS
181 Specify (
182 IN FDC_BLK_IO_DEV *FdcBlkIoDev
183 );
184
185 EFI_STATUS
186 DisketChanged (
187 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
188 IN OUT PEI_FLOPPY_DEVICE_INFO *Info
189 );
190
191 EFI_STATUS
192 DataInByte (
193 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
194 IN OUT UINT8 *pt
195 );
196
197 EFI_STATUS
198 DataOutByte (
199 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
200 IN UINT8 *pt
201 );
202
203 EFI_STATUS
204 FdcDRQReady (
205 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
206 IN BOOLEAN Dio,
207 IN UINTN TimeoutInSeconds
208 );
209
210 UINTN
211 GetTransferBlockCount (
212 IN PEI_FLOPPY_DEVICE_INFO *Info,
213 IN EFI_PEI_LBA LBA,
214 IN UINTN NumberOfBlocks
215 );
216
217 EFI_STATUS
218 ReadWriteDataSector (
219 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
220 IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
221 IN VOID *Buffer,
222 IN EFI_PEI_LBA Lba,
223 IN UINTN NumberOfBlocks,
224 IN BOOLEAN Read
225 );
226
227 EFI_STATUS
228 SetDMA (
229 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
230 IN VOID *Buffer,
231 IN UINTN NumberOfBlocks,
232 IN BOOLEAN Read
233 );
234
235 VOID
236 FillPara (
237 IN PEI_FLOPPY_DEVICE_INFO *Info,
238 IN EFI_PEI_LBA Lba,
239 IN FDC_COMMAND_PACKET1 *Command
240 );
241
242 EFI_STATUS
243 Setup (
244 IN FDC_BLK_IO_DEV *FdcBlkIoDev,
245 IN UINT8 DevPos
246 );
247
248 EFI_STATUS
249 CheckResult (
250 IN FDC_RESULT_PACKET *Result,
251 IN OUT PEI_FLOPPY_DEVICE_INFO *Info
252 );
253
254 #endif