]>
Commit | Line | Data |
---|---|---|
558be455 RN |
1 | /** @file\r |
2 | The header file for ISA driver\r | |
0a6f4824 LG |
3 | \r |
4 | Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
558be455 RN |
5 | This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _ISA_DRIVER_H_\r | |
16 | #define _ISA_DRIVER_H_\r | |
17 | \r | |
18 | \r | |
19 | #include <Uefi.h>\r | |
20 | \r | |
21 | #include <Protocol/PciIo.h>\r | |
22 | #include <Protocol/SuperIo.h>\r | |
23 | #include <Protocol/ComponentName.h>\r | |
24 | #include <Protocol/IsaIo.h>\r | |
25 | #include <Protocol/DevicePath.h>\r | |
26 | #include <Protocol/DriverBinding.h>\r | |
27 | #include <Protocol/GenericMemoryTest.h>\r | |
28 | #include <Guid/StatusCodeDataTypeId.h>\r | |
29 | \r | |
30 | #include <Library/DebugLib.h>\r | |
31 | #include <Library/UefiDriverEntryPoint.h>\r | |
32 | #include <Library/UefiLib.h>\r | |
33 | #include <Library/DevicePathLib.h>\r | |
34 | #include <Library/BaseMemoryLib.h>\r | |
35 | #include <Library/MemoryAllocationLib.h>\r | |
36 | #include <Library/UefiBootServicesTableLib.h>\r | |
37 | #include <Library/ReportStatusCodeLib.h>\r | |
38 | #include <Library/PcdLib.h>\r | |
39 | #include <IndustryStandard/Acpi.h>\r | |
40 | \r | |
41 | #include "ComponentName.h"\r | |
42 | \r | |
43 | //\r | |
44 | // 8237 DMA registers\r | |
45 | //\r | |
46 | #define R_8237_DMA_BASE_CA_CH0 0x00\r | |
47 | #define R_8237_DMA_BASE_CA_CH1 0x02\r | |
48 | #define R_8237_DMA_BASE_CA_CH2 0x04\r | |
49 | #define R_8237_DMA_BASE_CA_CH3 0xd6\r | |
50 | #define R_8237_DMA_BASE_CA_CH5 0xc4\r | |
51 | #define R_8237_DMA_BASE_CA_CH6 0xc8\r | |
52 | #define R_8237_DMA_BASE_CA_CH7 0xcc\r | |
53 | \r | |
54 | #define R_8237_DMA_BASE_CC_CH0 0x01\r | |
55 | #define R_8237_DMA_BASE_CC_CH1 0x03\r | |
56 | #define R_8237_DMA_BASE_CC_CH2 0x05\r | |
57 | #define R_8237_DMA_BASE_CC_CH3 0xd7\r | |
58 | #define R_8237_DMA_BASE_CC_CH5 0xc6\r | |
59 | #define R_8237_DMA_BASE_CC_CH6 0xca\r | |
60 | #define R_8237_DMA_BASE_CC_CH7 0xce\r | |
61 | \r | |
62 | #define R_8237_DMA_MEM_LP_CH0 0x87\r | |
63 | #define R_8237_DMA_MEM_LP_CH1 0x83\r | |
64 | #define R_8237_DMA_MEM_LP_CH2 0x81\r | |
65 | #define R_8237_DMA_MEM_LP_CH3 0x82\r | |
66 | #define R_8237_DMA_MEM_LP_CH5 0x8B\r | |
67 | #define R_8237_DMA_MEM_LP_CH6 0x89\r | |
68 | #define R_8237_DMA_MEM_LP_CH7 0x8A\r | |
69 | \r | |
70 | \r | |
71 | #define R_8237_DMA_COMMAND_CH0_3 0x08\r | |
72 | #define R_8237_DMA_COMMAND_CH4_7 0xd0\r | |
73 | #define B_8237_DMA_COMMAND_GAP 0x10\r | |
74 | #define B_8237_DMA_COMMAND_CGE 0x04\r | |
75 | \r | |
76 | \r | |
77 | #define R_8237_DMA_STA_CH0_3 0xd8\r | |
78 | #define R_8237_DMA_STA_CH4_7 0xd0\r | |
79 | \r | |
80 | #define R_8237_DMA_WRSMSK_CH0_3 0x0a\r | |
81 | #define R_8237_DMA_WRSMSK_CH4_7 0xd4\r | |
82 | #define B_8237_DMA_WRSMSK_CMS 0x04\r | |
83 | \r | |
84 | \r | |
85 | #define R_8237_DMA_CHMODE_CH0_3 0x0b\r | |
86 | #define R_8237_DMA_CHMODE_CH4_7 0xd6\r | |
87 | #define V_8237_DMA_CHMODE_DEMAND 0x00\r | |
88 | #define V_8237_DMA_CHMODE_SINGLE 0x40\r | |
89 | #define V_8237_DMA_CHMODE_CASCADE 0xc0\r | |
90 | #define B_8237_DMA_CHMODE_DECREMENT 0x20\r | |
91 | #define B_8237_DMA_CHMODE_INCREMENT 0x00\r | |
92 | #define B_8237_DMA_CHMODE_AE 0x10\r | |
93 | #define V_8237_DMA_CHMODE_VERIFY 0\r | |
94 | #define V_8237_DMA_CHMODE_IO2MEM 0x04\r | |
95 | #define V_8237_DMA_CHMODE_MEM2IO 0x08\r | |
96 | \r | |
97 | #define R_8237_DMA_CBPR_CH0_3 0x0c\r | |
98 | #define R_8237_DMA_CBPR_CH4_7 0xd8\r | |
99 | \r | |
100 | #define R_8237_DMA_MCR_CH0_3 0x0d\r | |
101 | #define R_8237_DMA_MCR_CH4_7 0xda\r | |
102 | \r | |
103 | #define R_8237_DMA_CLMSK_CH0_3 0x0e\r | |
104 | #define R_8237_DMA_CLMSK_CH4_7 0xdc\r | |
105 | \r | |
106 | #define R_8237_DMA_WRMSK_CH0_3 0x0f\r | |
107 | #define R_8237_DMA_WRMSK_CH4_7 0xde\r | |
108 | \r | |
109 | typedef enum {\r | |
110 | IsaAccessTypeUnknown,\r | |
111 | IsaAccessTypeIo,\r | |
112 | IsaAccessTypeMem,\r | |
113 | IsaAccessTypeMaxType\r | |
114 | } ISA_ACCESS_TYPE;\r | |
115 | \r | |
116 | typedef struct {\r | |
117 | UINT8 Address;\r | |
118 | UINT8 Page;\r | |
119 | UINT8 Count;\r | |
120 | } EFI_ISA_DMA_REGISTERS;\r | |
121 | \r | |
122 | //\r | |
123 | // ISA I/O Device Structure\r | |
124 | //\r | |
125 | #define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')\r | |
126 | \r | |
127 | typedef struct {\r | |
128 | UINT32 Signature;\r | |
129 | EFI_HANDLE Handle;\r | |
130 | EFI_ISA_IO_PROTOCOL IsaIo;\r | |
131 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
132 | } ISA_IO_DEVICE;\r | |
133 | \r | |
134 | #define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)\r | |
135 | \r | |
136 | //\r | |
137 | // Mapping structure for performing ISA DMA to a buffer above 16 MB\r | |
138 | //\r | |
139 | typedef struct {\r | |
140 | EFI_ISA_IO_PROTOCOL_OPERATION Operation;\r | |
141 | UINTN NumberOfBytes;\r | |
142 | UINTN NumberOfPages;\r | |
143 | EFI_PHYSICAL_ADDRESS HostAddress;\r | |
144 | EFI_PHYSICAL_ADDRESS MappedHostAddress;\r | |
145 | } ISA_MAP_INFO;\r | |
146 | \r | |
147 | //\r | |
148 | // EFI Driver Binding Protocol Interface Functions\r | |
149 | //\r | |
150 | \r | |
0a6f4824 | 151 | /**\r |
558be455 RN |
152 | Tests to see if a controller can be managed by the ISA Driver.\r |
153 | \r | |
154 | How the Start() function of a driver is implemented can affect how the Supported() function is implemented.\r | |
155 | \r | |
0a6f4824 | 156 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
558be455 RN |
157 | @param[in] Controller The handle of the controller to test.\r |
158 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.\r | |
0a6f4824 | 159 | \r |
558be455 RN |
160 | @retval EFI_SUCCESS The device is supported by this driver.\r |
161 | @retval EFI_ALREADY_STARTED The device is already being managed by this driver.\r | |
0a6f4824 | 162 | @retval EFI_ACCESS_DENIED The device is already being managed by a different driver\r |
558be455 RN |
163 | or an application that requires exclusive access.\r |
164 | @retval EFI_UNSUPPORTED The device is is not supported by this driver.\r | |
165 | \r | |
166 | **/\r | |
167 | EFI_STATUS\r | |
168 | EFIAPI\r | |
169 | IsaIoDriverSupported (\r | |
170 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
171 | IN EFI_HANDLE Controller,\r | |
172 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
173 | );\r | |
174 | \r | |
175 | /**\r | |
0a6f4824 LG |
176 | Start this driver on ControllerHandle.\r |
177 | \r | |
178 | The Start() function is designed to be invoked from the EFI boot service ConnectController().\r | |
179 | As a result, much of the error checking on the parameters to Start() has been moved into this\r | |
180 | common boot service. It is legal to call Start() from other locations, but the following calling\r | |
558be455 RN |
181 | restrictions must be followed or the system behavior will not be deterministic.\r |
182 | 1. ControllerHandle must be a valid EFI_HANDLE.\r | |
183 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r | |
184 | EFI_DEVICE_PATH_PROTOCOL.\r | |
185 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r | |
0a6f4824 | 186 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.\r |
558be455 RN |
187 | \r |
188 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r | |
0a6f4824 LG |
189 | @param[in] ControllerHandle The handle of the controller to start. This handle\r |
190 | must support a protocol interface that supplies\r | |
558be455 | 191 | an I/O abstraction to the driver.\r |
0a6f4824 | 192 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.\r |
558be455 RN |
193 | This parameter is ignored by device drivers, and is optional for bus drivers.\r |
194 | \r | |
195 | @retval EFI_SUCCESS The device was started.\r | |
196 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error.\r | |
197 | Currently not implemented.\r | |
198 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
199 | @retval Others The driver failded to start the device.\r | |
200 | **/\r | |
201 | EFI_STATUS\r | |
202 | EFIAPI\r | |
203 | IsaIoDriverStart (\r | |
204 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
205 | IN EFI_HANDLE Controller,\r | |
206 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r | |
207 | );\r | |
208 | \r | |
209 | /**\r | |
0a6f4824 LG |
210 | Stop this driver on ControllerHandle.\r |
211 | \r | |
212 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().\r | |
213 | As a result, much of the error checking on the parameters to Stop() has been moved\r | |
214 | into this common boot service. It is legal to call Stop() from other locations,\r | |
558be455 RN |
215 | but the following calling restrictions must be followed or the system behavior will not be deterministic.\r |
216 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r | |
217 | same driver's Start() function.\r | |
218 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r | |
219 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r | |
220 | Start() function, and the Start() function must have called OpenProtocol() on\r | |
221 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r | |
0a6f4824 | 222 | \r |
558be455 | 223 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r |
0a6f4824 LG |
224 | @param[in] ControllerHandle A handle to the device being stopped. The handle must\r |
225 | support a bus specific I/O protocol for the driver\r | |
558be455 RN |
226 | to use to stop the device.\r |
227 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r | |
0a6f4824 | 228 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL\r |
558be455 RN |
229 | if NumberOfChildren is 0.\r |
230 | \r | |
231 | @retval EFI_SUCCESS The device was stopped.\r | |
232 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r | |
233 | **/\r | |
234 | EFI_STATUS\r | |
235 | EFIAPI\r | |
236 | IsaIoDriverStop (\r | |
237 | IN EFI_DRIVER_BINDING_PROTOCOL * This,\r | |
238 | IN EFI_HANDLE Controller,\r | |
239 | IN UINTN NumberOfChildren,\r | |
240 | IN EFI_HANDLE * ChildHandleBuffer OPTIONAL\r | |
241 | );\r | |
242 | \r | |
243 | //\r | |
244 | // Function Prototypes\r | |
245 | //\r | |
246 | \r | |
247 | /**\r | |
248 | Initializes an ISA I/O Instance\r | |
249 | \r | |
250 | @param[in] IsaIoDevice The isa device to be initialized.\r | |
251 | @param[in] DevicePath The device path of the isa device.\r | |
252 | @param[in] Resources The ACPI resource list.\r | |
0a6f4824 | 253 | \r |
558be455 RN |
254 | **/\r |
255 | VOID\r | |
256 | InitializeIsaIoInstance (\r | |
257 | IN ISA_IO_DEVICE *IsaIoDevice,\r | |
258 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
259 | IN ACPI_RESOURCE_HEADER_PTR Resources\r | |
260 | );\r | |
261 | \r | |
262 | #endif\r | |
263 | \r |