2 Private include file for IsaFloppyPei PEIM.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _RECOVERY_FLOPPY_H_
18 #define _RECOVERY_FLOPPY_H_
20 #include <Ppi/BlockIo.h>
22 #include <Library/DebugLib.h>
23 #include <Library/PeimEntryPoint.h>
24 #include <Library/PeiServicesLib.h>
25 #include <Library/BaseMemoryLib.h>
26 #include <Library/ReportStatusCodeLib.h>
27 #include <Library/TimerLib.h>
28 #include <Library/IoLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/PcdLib.h>
36 // Some PC AT Compatible Device definitions
41 #define R_8237_DMA_BASE_CA_CH0 0x00
42 #define R_8237_DMA_BASE_CA_CH1 0x02
43 #define R_8237_DMA_BASE_CA_CH2 0x04
44 #define R_8237_DMA_BASE_CA_CH3 0xd6
45 #define R_8237_DMA_BASE_CA_CH5 0xc4
46 #define R_8237_DMA_BASE_CA_CH6 0xc8
47 #define R_8237_DMA_BASE_CA_CH7 0xcc
49 #define R_8237_DMA_BASE_CC_CH0 0x01
50 #define R_8237_DMA_BASE_CC_CH1 0x03
51 #define R_8237_DMA_BASE_CC_CH2 0x05
52 #define R_8237_DMA_BASE_CC_CH3 0xd7
53 #define R_8237_DMA_BASE_CC_CH5 0xc6
54 #define R_8237_DMA_BASE_CC_CH6 0xca
55 #define R_8237_DMA_BASE_CC_CH7 0xce
57 #define R_8237_DMA_MEM_LP_CH0 0x87
58 #define R_8237_DMA_MEM_LP_CH1 0x83
59 #define R_8237_DMA_MEM_LP_CH2 0x81
60 #define R_8237_DMA_MEM_LP_CH3 0x82
61 #define R_8237_DMA_MEM_LP_CH5 0x8B
62 #define R_8237_DMA_MEM_LP_CH6 0x89
63 #define R_8237_DMA_MEM_LP_CH7 0x8A
66 #define R_8237_DMA_COMMAND_CH0_3 0x08
67 #define R_8237_DMA_COMMAND_CH4_7 0xd0
68 #define B_8237_DMA_COMMAND_GAP 0x10
69 #define B_8237_DMA_COMMAND_CGE 0x04
72 #define R_8237_DMA_STA_CH0_3 0x09
73 #define R_8237_DMA_STA_CH4_7 0xd2
75 #define R_8237_DMA_WRSMSK_CH0_3 0x0a
76 #define R_8237_DMA_WRSMSK_CH4_7 0xd4
77 #define B_8237_DMA_WRSMSK_CMS 0x04
80 #define R_8237_DMA_CHMODE_CH0_3 0x0b
81 #define R_8237_DMA_CHMODE_CH4_7 0xd6
82 #define V_8237_DMA_CHMODE_DEMAND 0x00
83 #define V_8237_DMA_CHMODE_SINGLE 0x40
84 #define V_8237_DMA_CHMODE_CASCADE 0xc0
85 #define B_8237_DMA_CHMODE_DECREMENT 0x20
86 #define B_8237_DMA_CHMODE_INCREMENT 0x00
87 #define B_8237_DMA_CHMODE_AE 0x10
88 #define V_8237_DMA_CHMODE_VERIFY 0
89 #define V_8237_DMA_CHMODE_IO2MEM 0x04
90 #define V_8237_DMA_CHMODE_MEM2IO 0x08
92 #define R_8237_DMA_CBPR_CH0_3 0x0c
93 #define R_8237_DMA_CBPR_CH4_7 0xd8
95 #define R_8237_DMA_MCR_CH0_3 0x0d
96 #define R_8237_DMA_MCR_CH4_7 0xda
98 #define R_8237_DMA_CLMSK_CH0_3 0x0e
99 #define R_8237_DMA_CLMSK_CH4_7 0xdc
101 #define R_8237_DMA_WRMSK_CH0_3 0x0f
102 #define R_8237_DMA_WRMSK_CH4_7 0xde
107 #define ISA_MAX_MEMORY_ADDRESS 0x1000000
110 // Macro for time delay & interval
112 #define STALL_1_SECOND 1000000
113 #define STALL_1_MSECOND 1000
114 #define FDC_CHECK_INTERVAL 50
116 #define FDC_SHORT_DELAY 50
117 #define FDC_MEDIUM_DELAY 100
118 #define FDC_LONG_DELAY 4000
119 #define FDC_RESET_DELAY 2000
120 #define FDC_RECALIBRATE_DELAY 250000
143 BOOLEAN NeedRecalibrate
;
144 FDC_DISKET_TYPE Type
;
145 EFI_PEI_BLOCK_IO_MEDIA MediaInfo
;
146 } PEI_FLOPPY_DEVICE_INFO
;
148 #define FDC_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('F', 'b', 'i', 'o')
152 EFI_PEI_RECOVERY_BLOCK_IO_PPI FdcBlkIo
;
153 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor
;
155 PEI_FLOPPY_DEVICE_INFO DeviceInfo
[2];
158 #define PEI_RECOVERY_FDC_FROM_BLKIO_THIS(a) CR (a, FDC_BLK_IO_DEV, FdcBlkIo, FDC_BLK_IO_DEV_SIGNATURE)
161 // PEI Recovery Block I/O PPI
165 Get the number of FDC devices.
167 This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetNumberOfBlockDevices.
168 It get the number of FDC devices in the system.
170 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
171 @param This Pointer to this PPI instance.
172 @param NumberBlockDevices Pointer to the the number of FDC devices for output.
174 @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.
175 @retval EFI_INVALID_PARAMETER Parameter This is NULL.
180 FdcGetNumberOfBlockDevices (
181 IN EFI_PEI_SERVICES
**PeiServices
,
182 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
183 OUT UINTN
*NumberBlockDevices
187 Get the specified media information.
189 This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetBlockDeviceMediaInfo.
190 It gets the specified media information.
192 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
193 @param This Pointer to this PPI instance.
194 @param DeviceIndex Index of FDC device to get information.
195 @param MediaInfo Pointer to the media info buffer for output.
197 @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.
198 @retval EFI_INVALID_PARAMETER Parameter This is NULL.
199 @retval EFI_INVALID_PARAMETER Parameter MediaInfo is NULL.
200 @retval EFI_INVALID_PARAMETER DeviceIndex is not valid.
201 @retval EFI_DEVICE_ERROR FDC device does not exist or has errors.
206 FdcGetBlockDeviceMediaInfo (
207 IN EFI_PEI_SERVICES
**PeiServices
,
208 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
209 IN UINTN DeviceIndex
,
210 OUT EFI_PEI_BLOCK_IO_MEDIA
*MediaInfo
214 Get the requested number of blocks from the specified FDC device.
216 This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.ReadBlocks.
217 It reads the requested number of blocks from the specified FDC device.
219 @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
220 @param This Pointer to this PPI instance.
221 @param DeviceIndex Index of FDC device to get information.
222 @param StartLba The start LBA to read from.
223 @param BufferSize The size of range to read.
224 @param Buffer Buffer to hold the data read from FDC.
226 @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.
227 @retval EFI_INVALID_PARAMETER Parameter This is NULL.
228 @retval EFI_INVALID_PARAMETER Parameter Buffer is NULL.
229 @retval EFI_INVALID_PARAMETER Parameter BufferSize cannot be divided by block size of FDC device.
230 @retval EFI_NO_MEDIA No media present.
231 @retval EFI_DEVICE_ERROR FDC device has error.
232 @retval Others Fail to read blocks.
238 IN EFI_PEI_SERVICES
**PeiServices
,
239 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI
*This
,
240 IN UINTN DeviceIndex
,
241 IN EFI_PEI_LBA StartLba
,