]>
Commit | Line | Data |
---|---|---|
87f8ccbe | 1 | /** @file\r |
2 | Cirrus Logic 5430 Controller Driver\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation \r | |
5 | All rights reserved. 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 | //\r | |
16 | // Cirrus Logic 5430 Controller Driver\r | |
17 | //\r | |
18 | \r | |
19 | #ifndef _CIRRUS_LOGIC_5430_H_\r | |
20 | #define _CIRRUS_LOGIC_5430_H_\r | |
21 | \r | |
22 | \r | |
23 | #include <Uefi.h>\r | |
24 | #include <Protocol/UgaDraw.h>\r | |
25 | #include <Protocol/GraphicsOutput.h>\r | |
26 | #include <Protocol/PciIo.h>\r | |
27 | #include <Protocol/DriverSupportedEfiVersion.h>\r | |
28 | \r | |
29 | #include <Library/DebugLib.h>\r | |
30 | #include <Library/UefiDriverEntryPoint.h>\r | |
31 | #include <Library/UefiLib.h>\r | |
32 | #include <Library/PcdLib.h>\r | |
33 | #include <Library/MemoryAllocationLib.h>\r | |
34 | #include <Library/UefiBootServicesTableLib.h>\r | |
35 | \r | |
36 | #include <IndustryStandard/pci22.h>\r | |
37 | //\r | |
38 | // Cirrus Logic 5430 PCI Configuration Header values\r | |
39 | //\r | |
40 | #define CIRRUS_LOGIC_VENDOR_ID 0x1013\r | |
41 | #define CIRRUS_LOGIC_5430_DEVICE_ID 0x00a8\r | |
42 | #define CIRRUS_LOGIC_5430_ALTERNATE_DEVICE_ID 0x00a0\r | |
43 | #define CIRRUS_LOGIC_5446_DEVICE_ID 0x00b8\r | |
44 | \r | |
45 | //\r | |
46 | // Cirrus Logic Graphical Mode Data\r | |
47 | //\r | |
48 | #define CIRRUS_LOGIC_5430_MODE_COUNT 3\r | |
49 | \r | |
50 | typedef struct {\r | |
51 | UINT32 HorizontalResolution;\r | |
52 | UINT32 VerticalResolution;\r | |
53 | UINT32 ColorDepth;\r | |
54 | UINT32 RefreshRate;\r | |
55 | } CIRRUS_LOGIC_5430_MODE_DATA;\r | |
56 | \r | |
57 | #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r | |
58 | \r | |
59 | //\r | |
60 | // Cirrus Logic 5440 Private Data Structure\r | |
61 | //\r | |
62 | #define CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('C', 'L', '5', '4')\r | |
63 | \r | |
64 | typedef struct {\r | |
65 | UINT64 Signature;\r | |
66 | EFI_HANDLE Handle;\r | |
67 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
68 | EFI_UGA_DRAW_PROTOCOL UgaDraw;\r | |
69 | EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r | |
70 | UINTN CurrentMode;\r | |
71 | UINTN MaxMode;\r | |
72 | CIRRUS_LOGIC_5430_MODE_DATA ModeData[CIRRUS_LOGIC_5430_MODE_COUNT];\r | |
73 | UINT8 *LineBuffer;\r | |
74 | BOOLEAN HardwareNeedsStarting;\r | |
75 | } CIRRUS_LOGIC_5430_PRIVATE_DATA;\r | |
76 | \r | |
77 | ///\r | |
78 | /// Video Mode structure\r | |
79 | ///\r | |
80 | typedef struct {\r | |
81 | UINT32 Width;\r | |
82 | UINT32 Height;\r | |
83 | UINT32 ColorDepth;\r | |
84 | UINT32 RefreshRate;\r | |
85 | UINT8 *CrtcSettings;\r | |
86 | UINT16 *SeqSettings;\r | |
87 | UINT8 MiscSetting;\r | |
88 | } CIRRUS_LOGIC_5430_VIDEO_MODES;\r | |
89 | \r | |
90 | #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS(a) \\r | |
91 | CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, UgaDraw, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)\r | |
92 | \r | |
93 | #define CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS(a) \\r | |
94 | CR(a, CIRRUS_LOGIC_5430_PRIVATE_DATA, GraphicsOutput, CIRRUS_LOGIC_5430_PRIVATE_DATA_SIGNATURE)\r | |
95 | \r | |
96 | \r | |
97 | //\r | |
98 | // Global Variables\r | |
99 | //\r | |
100 | extern UINT8 AttributeController[];\r | |
101 | extern UINT8 GraphicsController[];\r | |
102 | extern UINT8 Crtc_640_480_256_60[];\r | |
103 | extern UINT16 Seq_640_480_256_60[];\r | |
104 | extern UINT8 Crtc_800_600_256_60[];\r | |
105 | extern UINT16 Seq_800_600_256_60[];\r | |
106 | extern UINT8 Crtc_1024_768_256_60[];\r | |
107 | extern UINT16 Seq_1024_768_256_60[];\r | |
108 | extern CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes[];\r | |
109 | extern EFI_DRIVER_BINDING_PROTOCOL gCirrusLogic5430DriverBinding;\r | |
110 | extern EFI_COMPONENT_NAME_PROTOCOL gCirrusLogic5430ComponentName;\r | |
111 | extern EFI_COMPONENT_NAME2_PROTOCOL gCirrusLogic5430ComponentName2;\r | |
112 | extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gCirrusLogic5430DriverSupportedEfiVersion;\r | |
113 | \r | |
114 | //\r | |
115 | // Io Registers defined by VGA\r | |
116 | //\r | |
117 | #define CRTC_ADDRESS_REGISTER 0x3d4\r | |
118 | #define CRTC_DATA_REGISTER 0x3d5\r | |
119 | #define SEQ_ADDRESS_REGISTER 0x3c4\r | |
120 | #define SEQ_DATA_REGISTER 0x3c5\r | |
121 | #define GRAPH_ADDRESS_REGISTER 0x3ce\r | |
122 | #define GRAPH_DATA_REGISTER 0x3cf\r | |
123 | #define ATT_ADDRESS_REGISTER 0x3c0\r | |
124 | #define MISC_OUTPUT_REGISTER 0x3c2\r | |
125 | #define INPUT_STATUS_1_REGISTER 0x3da\r | |
126 | #define DAC_PIXEL_MASK_REGISTER 0x3c6\r | |
127 | #define PALETTE_INDEX_REGISTER 0x3c8\r | |
128 | #define PALETTE_DATA_REGISTER 0x3c9\r | |
129 | \r | |
130 | //\r | |
131 | // UGA Draw Hardware abstraction internal worker functions\r | |
132 | //\r | |
133 | EFI_STATUS\r | |
134 | CirrusLogic5430UgaDrawConstructor (\r | |
135 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
136 | )\r | |
137 | ;\r | |
138 | \r | |
139 | EFI_STATUS\r | |
140 | CirrusLogic5430UgaDrawDestructor (\r | |
141 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
142 | )\r | |
143 | ;\r | |
144 | \r | |
145 | //\r | |
146 | // Graphics Output Hardware abstraction internal worker functions\r | |
147 | //\r | |
148 | EFI_STATUS\r | |
149 | CirrusLogic5430GraphicsOutputConstructor (\r | |
150 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
151 | )\r | |
152 | ;\r | |
153 | \r | |
154 | EFI_STATUS\r | |
155 | CirrusLogic5430GraphicsOutputDestructor (\r | |
156 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
157 | )\r | |
158 | ;\r | |
159 | \r | |
160 | \r | |
161 | //\r | |
162 | // EFI_DRIVER_BINDING_PROTOCOL Protocol Interface\r | |
163 | //\r | |
164 | /**\r | |
165 | TODO: Add function description\r | |
166 | \r | |
167 | @param This TODO: add argument description\r | |
168 | @param Controller TODO: add argument description\r | |
169 | @param RemainingDevicePath TODO: add argument description\r | |
170 | \r | |
171 | TODO: add return values\r | |
172 | \r | |
173 | **/\r | |
174 | EFI_STATUS\r | |
175 | EFIAPI\r | |
176 | CirrusLogic5430ControllerDriverSupported (\r | |
177 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
178 | IN EFI_HANDLE Controller,\r | |
179 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
180 | )\r | |
181 | ;\r | |
182 | \r | |
183 | /**\r | |
184 | TODO: Add function description\r | |
185 | \r | |
186 | @param This TODO: add argument description\r | |
187 | @param Controller TODO: add argument description\r | |
188 | @param RemainingDevicePath TODO: add argument description\r | |
189 | \r | |
190 | TODO: add return values\r | |
191 | \r | |
192 | **/\r | |
193 | EFI_STATUS\r | |
194 | EFIAPI\r | |
195 | CirrusLogic5430ControllerDriverStart (\r | |
196 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
197 | IN EFI_HANDLE Controller,\r | |
198 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
199 | )\r | |
200 | ;\r | |
201 | \r | |
202 | /**\r | |
203 | TODO: Add function description\r | |
204 | \r | |
205 | @param This TODO: add argument description\r | |
206 | @param Controller TODO: add argument description\r | |
207 | @param NumberOfChildren TODO: add argument description\r | |
208 | @param ChildHandleBuffer TODO: add argument description\r | |
209 | \r | |
210 | TODO: add return values\r | |
211 | \r | |
212 | **/\r | |
213 | EFI_STATUS\r | |
214 | EFIAPI\r | |
215 | CirrusLogic5430ControllerDriverStop (\r | |
216 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
217 | IN EFI_HANDLE Controller,\r | |
218 | IN UINTN NumberOfChildren,\r | |
219 | IN EFI_HANDLE *ChildHandleBuffer\r | |
220 | )\r | |
221 | ;\r | |
222 | \r | |
223 | //\r | |
224 | // EFI Component Name Functions\r | |
225 | //\r | |
226 | /**\r | |
227 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
228 | \r | |
229 | This function retrieves the user readable name of a driver in the form of a\r | |
230 | Unicode string. If the driver specified by This has a user readable name in\r | |
231 | the language specified by Language, then a pointer to the driver name is\r | |
232 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
233 | by This does not support the language specified by Language,\r | |
234 | then EFI_UNSUPPORTED is returned.\r | |
235 | \r | |
236 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
237 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
238 | \r | |
239 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
240 | array indicating the language. This is the\r | |
241 | language of the driver name that the caller is\r | |
242 | requesting, and it must match one of the\r | |
243 | languages specified in SupportedLanguages. The\r | |
244 | number of languages supported by a driver is up\r | |
245 | to the driver writer. Language is specified\r | |
246 | in RFC 3066 or ISO 639-2 language code format.\r | |
247 | \r | |
248 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
249 | This Unicode string is the name of the\r | |
250 | driver specified by This in the language\r | |
251 | specified by Language.\r | |
252 | \r | |
253 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
254 | This and the language specified by Language was\r | |
255 | returned in DriverName.\r | |
256 | \r | |
257 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
258 | \r | |
259 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
260 | \r | |
261 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
262 | the language specified by Language.\r | |
263 | \r | |
264 | **/\r | |
265 | EFI_STATUS\r | |
266 | EFIAPI\r | |
267 | CirrusLogic5430ComponentNameGetDriverName (\r | |
268 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
269 | IN CHAR8 *Language,\r | |
270 | OUT CHAR16 **DriverName\r | |
271 | );\r | |
272 | \r | |
273 | \r | |
274 | /**\r | |
275 | Retrieves a Unicode string that is the user readable name of the controller\r | |
276 | that is being managed by a driver.\r | |
277 | \r | |
278 | This function retrieves the user readable name of the controller specified by\r | |
279 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
280 | driver specified by This has a user readable name in the language specified by\r | |
281 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
282 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
283 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
284 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
285 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
286 | \r | |
287 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
288 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
289 | \r | |
290 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
291 | specified by This is managing. This handle\r | |
292 | specifies the controller whose name is to be\r | |
293 | returned.\r | |
294 | \r | |
295 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
296 | the name of. This is an optional parameter that\r | |
297 | may be NULL. It will be NULL for device\r | |
298 | drivers. It will also be NULL for a bus drivers\r | |
299 | that wish to retrieve the name of the bus\r | |
300 | controller. It will not be NULL for a bus\r | |
301 | driver that wishes to retrieve the name of a\r | |
302 | child controller.\r | |
303 | \r | |
304 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
305 | array indicating the language. This is the\r | |
306 | language of the driver name that the caller is\r | |
307 | requesting, and it must match one of the\r | |
308 | languages specified in SupportedLanguages. The\r | |
309 | number of languages supported by a driver is up\r | |
310 | to the driver writer. Language is specified in\r | |
311 | RFC 3066 or ISO 639-2 language code format.\r | |
312 | \r | |
313 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
314 | This Unicode string is the name of the\r | |
315 | controller specified by ControllerHandle and\r | |
316 | ChildHandle in the language specified by\r | |
317 | Language from the point of view of the driver\r | |
318 | specified by This.\r | |
319 | \r | |
320 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
321 | the language specified by Language for the\r | |
322 | driver specified by This was returned in\r | |
323 | DriverName.\r | |
324 | \r | |
325 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
326 | \r | |
327 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
328 | EFI_HANDLE.\r | |
329 | \r | |
330 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
331 | \r | |
332 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
333 | \r | |
334 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
335 | managing the controller specified by\r | |
336 | ControllerHandle and ChildHandle.\r | |
337 | \r | |
338 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
339 | the language specified by Language.\r | |
340 | \r | |
341 | **/\r | |
342 | EFI_STATUS\r | |
343 | EFIAPI\r | |
344 | CirrusLogic5430ComponentNameGetControllerName (\r | |
345 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
346 | IN EFI_HANDLE ControllerHandle,\r | |
347 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
348 | IN CHAR8 *Language,\r | |
349 | OUT CHAR16 **ControllerName\r | |
350 | );\r | |
351 | \r | |
352 | \r | |
353 | //\r | |
354 | // Local Function Prototypes\r | |
355 | //\r | |
356 | VOID\r | |
357 | InitializeGraphicsMode (\r | |
358 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
359 | CIRRUS_LOGIC_5430_VIDEO_MODES *ModeData\r | |
360 | );\r | |
361 | \r | |
362 | VOID\r | |
363 | SetPaletteColor (\r | |
364 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
365 | UINTN Index,\r | |
366 | UINT8 Red,\r | |
367 | UINT8 Green,\r | |
368 | UINT8 Blue\r | |
369 | );\r | |
370 | \r | |
371 | VOID\r | |
372 | SetDefaultPalette (\r | |
373 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private\r | |
374 | );\r | |
375 | \r | |
376 | VOID\r | |
377 | DrawLogo (\r | |
378 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
379 | UINTN ScreenWidth,\r | |
380 | UINTN ScreenHeight\r | |
381 | );\r | |
382 | \r | |
383 | VOID\r | |
384 | outb (\r | |
385 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
386 | UINTN Address,\r | |
387 | UINT8 Data\r | |
388 | );\r | |
389 | \r | |
390 | VOID\r | |
391 | outw (\r | |
392 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
393 | UINTN Address,\r | |
394 | UINT16 Data\r | |
395 | );\r | |
396 | \r | |
397 | UINT8\r | |
398 | inb (\r | |
399 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
400 | UINTN Address\r | |
401 | );\r | |
402 | \r | |
403 | UINT16\r | |
404 | inw (\r | |
405 | CIRRUS_LOGIC_5430_PRIVATE_DATA *Private,\r | |
406 | UINTN Address\r | |
407 | );\r | |
408 | \r | |
409 | #endif\r |