]>
Commit | Line | Data |
---|---|---|
d8387fa4 | 1 | /** @file\r |
2 | Private include file for IsaFloppyPei PEIM.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _RECOVERY_FLOPPY_H_\r | |
18 | #define _RECOVERY_FLOPPY_H_\r | |
19 | \r | |
20 | #include <Ppi/BlockIo.h>\r | |
21 | \r | |
22 | #include <Library/DebugLib.h>\r | |
23 | #include <Library/PeimEntryPoint.h>\r | |
24 | #include <Library/PeiServicesLib.h>\r | |
25 | #include <Library/BaseMemoryLib.h>\r | |
26 | #include <Library/ReportStatusCodeLib.h>\r | |
27 | #include <Library/TimerLib.h>\r | |
28 | #include <Library/IoLib.h>\r | |
29 | #include <Library/MemoryAllocationLib.h>\r | |
30 | #include <Library/PcdLib.h>\r | |
31 | \r | |
32 | #include "Fdc.h"\r | |
33 | \r | |
34 | \r | |
35 | //\r | |
36 | // Some PC AT Compatible Device definitions\r | |
37 | //\r | |
38 | //\r | |
39 | // 8237 DMA registers\r | |
40 | //\r | |
41 | #define R_8237_DMA_BASE_CA_CH0 0x00\r | |
42 | #define R_8237_DMA_BASE_CA_CH1 0x02\r | |
43 | #define R_8237_DMA_BASE_CA_CH2 0x04\r | |
44 | #define R_8237_DMA_BASE_CA_CH3 0xd6\r | |
45 | #define R_8237_DMA_BASE_CA_CH5 0xc4\r | |
46 | #define R_8237_DMA_BASE_CA_CH6 0xc8\r | |
47 | #define R_8237_DMA_BASE_CA_CH7 0xcc\r | |
48 | \r | |
49 | #define R_8237_DMA_BASE_CC_CH0 0x01\r | |
50 | #define R_8237_DMA_BASE_CC_CH1 0x03\r | |
51 | #define R_8237_DMA_BASE_CC_CH2 0x05\r | |
52 | #define R_8237_DMA_BASE_CC_CH3 0xd7\r | |
53 | #define R_8237_DMA_BASE_CC_CH5 0xc6\r | |
54 | #define R_8237_DMA_BASE_CC_CH6 0xca\r | |
55 | #define R_8237_DMA_BASE_CC_CH7 0xce\r | |
56 | \r | |
57 | #define R_8237_DMA_MEM_LP_CH0 0x87\r | |
58 | #define R_8237_DMA_MEM_LP_CH1 0x83\r | |
59 | #define R_8237_DMA_MEM_LP_CH2 0x81\r | |
60 | #define R_8237_DMA_MEM_LP_CH3 0x82\r | |
61 | #define R_8237_DMA_MEM_LP_CH5 0x8B\r | |
62 | #define R_8237_DMA_MEM_LP_CH6 0x89\r | |
63 | #define R_8237_DMA_MEM_LP_CH7 0x8A\r | |
64 | \r | |
65 | \r | |
66 | #define R_8237_DMA_COMMAND_CH0_3 0x08\r | |
67 | #define R_8237_DMA_COMMAND_CH4_7 0xd0\r | |
68 | #define B_8237_DMA_COMMAND_GAP 0x10\r | |
69 | #define B_8237_DMA_COMMAND_CGE 0x04\r | |
70 | \r | |
71 | \r | |
72 | #define R_8237_DMA_STA_CH0_3 0x09\r | |
73 | #define R_8237_DMA_STA_CH4_7 0xd2\r | |
74 | \r | |
75 | #define R_8237_DMA_WRSMSK_CH0_3 0x0a\r | |
76 | #define R_8237_DMA_WRSMSK_CH4_7 0xd4\r | |
77 | #define B_8237_DMA_WRSMSK_CMS 0x04\r | |
78 | \r | |
79 | \r | |
80 | #define R_8237_DMA_CHMODE_CH0_3 0x0b\r | |
81 | #define R_8237_DMA_CHMODE_CH4_7 0xd6\r | |
82 | #define V_8237_DMA_CHMODE_DEMAND 0x00\r | |
83 | #define V_8237_DMA_CHMODE_SINGLE 0x40\r | |
84 | #define V_8237_DMA_CHMODE_CASCADE 0xc0\r | |
85 | #define B_8237_DMA_CHMODE_DECREMENT 0x20\r | |
86 | #define B_8237_DMA_CHMODE_INCREMENT 0x00\r | |
87 | #define B_8237_DMA_CHMODE_AE 0x10\r | |
88 | #define V_8237_DMA_CHMODE_VERIFY 0\r | |
89 | #define V_8237_DMA_CHMODE_IO2MEM 0x04\r | |
90 | #define V_8237_DMA_CHMODE_MEM2IO 0x08\r | |
91 | \r | |
92 | #define R_8237_DMA_CBPR_CH0_3 0x0c\r | |
93 | #define R_8237_DMA_CBPR_CH4_7 0xd8\r | |
94 | \r | |
95 | #define R_8237_DMA_MCR_CH0_3 0x0d\r | |
96 | #define R_8237_DMA_MCR_CH4_7 0xda\r | |
97 | \r | |
98 | #define R_8237_DMA_CLMSK_CH0_3 0x0e\r | |
99 | #define R_8237_DMA_CLMSK_CH4_7 0xdc\r | |
100 | \r | |
101 | #define R_8237_DMA_WRMSK_CH0_3 0x0f\r | |
102 | #define R_8237_DMA_WRMSK_CH4_7 0xde\r | |
103 | \r | |
104 | ///\r | |
105 | /// ISA memory range\r | |
106 | ///\r | |
107 | #define ISA_MAX_MEMORY_ADDRESS 0x1000000 \r | |
108 | \r | |
109 | //\r | |
110 | // Macro for time delay & interval\r | |
111 | //\r | |
112 | #define STALL_1_SECOND 1000000\r | |
113 | #define STALL_1_MSECOND 1000\r | |
114 | #define FDC_CHECK_INTERVAL 50\r | |
115 | \r | |
116 | #define FDC_SHORT_DELAY 50\r | |
117 | #define FDC_MEDIUM_DELAY 100\r | |
118 | #define FDC_LONG_DELAY 4000\r | |
119 | #define FDC_RESET_DELAY 2000\r | |
120 | #define FDC_RECALIBRATE_DELAY 250000\r | |
121 | \r | |
122 | typedef enum {\r | |
123 | FdcType360K360K = 0,\r | |
124 | FdcType360K1200K,\r | |
125 | FdcType1200K1200K,\r | |
126 | FdcType720K720K,\r | |
127 | FdcType720K1440K,\r | |
128 | FdcType1440K1440K,\r | |
129 | FdcType720K2880K,\r | |
130 | FdcType1440K2880K,\r | |
131 | FdcType2880K2880K\r | |
132 | } FDC_DISKET_TYPE;\r | |
133 | \r | |
134 | typedef struct {\r | |
135 | UINT8 Register;\r | |
136 | UINT8 Value;\r | |
137 | } PEI_DMA_TABLE;\r | |
138 | \r | |
139 | typedef struct {\r | |
140 | UINT8 DevPos;\r | |
141 | UINT8 Pcn;\r | |
142 | BOOLEAN MotorOn;\r | |
143 | BOOLEAN NeedRecalibrate;\r | |
144 | FDC_DISKET_TYPE Type;\r | |
145 | EFI_PEI_BLOCK_IO_MEDIA MediaInfo;\r | |
146 | } PEI_FLOPPY_DEVICE_INFO;\r | |
147 | \r | |
148 | #define FDC_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('F', 'b', 'i', 'o')\r | |
149 | \r | |
150 | typedef struct {\r | |
151 | UINTN Signature;\r | |
152 | EFI_PEI_RECOVERY_BLOCK_IO_PPI FdcBlkIo;\r | |
153 | EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;\r | |
154 | UINTN DeviceCount;\r | |
155 | PEI_FLOPPY_DEVICE_INFO DeviceInfo[2];\r | |
156 | } FDC_BLK_IO_DEV;\r | |
157 | \r | |
158 | #define PEI_RECOVERY_FDC_FROM_BLKIO_THIS(a) CR (a, FDC_BLK_IO_DEV, FdcBlkIo, FDC_BLK_IO_DEV_SIGNATURE)\r | |
159 | \r | |
160 | //\r | |
161 | // PEI Recovery Block I/O PPI\r | |
162 | //\r | |
163 | \r | |
164 | /**\r | |
165 | Get the number of FDC devices.\r | |
166 | \r | |
167 | This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetNumberOfBlockDevices.\r | |
168 | It get the number of FDC devices in the system.\r | |
169 | \r | |
170 | @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r | |
171 | @param This Pointer to this PPI instance.\r | |
172 | @param NumberBlockDevices Pointer to the the number of FDC devices for output.\r | |
173 | \r | |
174 | @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.\r | |
175 | @retval EFI_INVALID_PARAMETER Parameter This is NULL.\r | |
176 | \r | |
177 | **/\r | |
178 | EFI_STATUS\r | |
179 | EFIAPI\r | |
180 | FdcGetNumberOfBlockDevices (\r | |
181 | IN EFI_PEI_SERVICES **PeiServices,\r | |
182 | IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r | |
183 | OUT UINTN *NumberBlockDevices\r | |
184 | );\r | |
185 | \r | |
186 | /**\r | |
187 | Get the specified media information.\r | |
188 | \r | |
189 | This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetBlockDeviceMediaInfo.\r | |
190 | It gets the specified media information.\r | |
191 | \r | |
192 | @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r | |
193 | @param This Pointer to this PPI instance.\r | |
194 | @param DeviceIndex Index of FDC device to get information.\r | |
195 | @param MediaInfo Pointer to the media info buffer for output.\r | |
196 | \r | |
197 | @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.\r | |
198 | @retval EFI_INVALID_PARAMETER Parameter This is NULL.\r | |
199 | @retval EFI_INVALID_PARAMETER Parameter MediaInfo is NULL.\r | |
200 | @retval EFI_INVALID_PARAMETER DeviceIndex is not valid.\r | |
201 | @retval EFI_DEVICE_ERROR FDC device does not exist or has errors.\r | |
202 | \r | |
203 | **/\r | |
204 | EFI_STATUS\r | |
205 | EFIAPI\r | |
206 | FdcGetBlockDeviceMediaInfo (\r | |
207 | IN EFI_PEI_SERVICES **PeiServices,\r | |
208 | IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r | |
209 | IN UINTN DeviceIndex,\r | |
210 | OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r | |
211 | );\r | |
212 | \r | |
213 | /**\r | |
214 | Get the requested number of blocks from the specified FDC device.\r | |
215 | \r | |
216 | This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.ReadBlocks.\r | |
217 | It reads the requested number of blocks from the specified FDC device.\r | |
218 | \r | |
219 | @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.\r | |
220 | @param This Pointer to this PPI instance.\r | |
221 | @param DeviceIndex Index of FDC device to get information.\r | |
222 | @param StartLba The start LBA to read from.\r | |
223 | @param BufferSize The size of range to read.\r | |
224 | @param Buffer Buffer to hold the data read from FDC.\r | |
225 | \r | |
226 | @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.\r | |
227 | @retval EFI_INVALID_PARAMETER Parameter This is NULL.\r | |
228 | @retval EFI_INVALID_PARAMETER Parameter Buffer is NULL.\r | |
229 | @retval EFI_INVALID_PARAMETER Parameter BufferSize cannot be divided by block size of FDC device.\r | |
230 | @retval EFI_NO_MEDIA No media present.\r | |
231 | @retval EFI_DEVICE_ERROR FDC device has error.\r | |
232 | @retval Others Fail to read blocks.\r | |
233 | \r | |
234 | **/\r | |
235 | EFI_STATUS\r | |
236 | EFIAPI\r | |
237 | FdcReadBlocks (\r | |
238 | IN EFI_PEI_SERVICES **PeiServices,\r | |
239 | IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r | |
240 | IN UINTN DeviceIndex,\r | |
241 | IN EFI_PEI_LBA StartLba,\r | |
242 | IN UINTN BufferSize,\r | |
243 | OUT VOID *Buffer\r | |
244 | );\r | |
245 | \r | |
246 | #endif\r |