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