]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
4ea9375a HT |
3 | Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | RuntimeLib.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Light weight lib to support Tiano Sal drivers.\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "Tiano.h"\r | |
23 | #include "EfiRuntimeLib.h"\r | |
24 | #include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)\r | |
25 | #include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)\r | |
26 | #include "IpfDefines.h"\r | |
27 | #include "SalApi.h"\r | |
28 | \r | |
29 | //\r | |
30 | // Worker functions in EsalLib.s\r | |
31 | //\r | |
32 | SAL_RETURN_REGS\r | |
33 | GetEsalEntryPoint (\r | |
34 | VOID\r | |
35 | );\r | |
36 | \r | |
37 | SAL_RETURN_REGS\r | |
38 | SetEsalPhysicalEntryPoint (\r | |
39 | IN UINT64 EntryPoint,\r | |
40 | IN UINT64 Gp\r | |
41 | );\r | |
42 | \r | |
43 | SAL_RETURN_REGS\r | |
44 | SetEsalVirtualEntryPoint (\r | |
45 | IN UINT64 EntryPoint,\r | |
46 | IN UINT64 Gp\r | |
47 | );\r | |
48 | \r | |
49 | VOID\r | |
50 | SalFlushCache (\r | |
51 | IN EFI_PHYSICAL_ADDRESS Start,\r | |
52 | IN UINT64 Length\r | |
53 | );\r | |
54 | \r | |
55 | //\r | |
56 | // Module Globals. It's not valid to use these after the\r | |
57 | // EfiRuntimeLibVirtualNotifyEvent has fired.\r | |
58 | //\r | |
59 | static EFI_EVENT mEfiVirtualNotifyEvent;\r | |
60 | static EFI_RUNTIME_SERVICES *mRT;\r | |
61 | static EFI_PLABEL mPlabel;\r | |
62 | static EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;\r | |
63 | static BOOLEAN mRuntimeLibInitialized = FALSE;\r | |
64 | \r | |
65 | VOID\r | |
66 | EFIAPI\r | |
67 | EfiRuntimeLibVirtualNotifyEvent (\r | |
68 | IN EFI_EVENT Event,\r | |
69 | IN VOID *Context\r | |
70 | )\r | |
71 | /*++\r | |
72 | \r | |
73 | Routine Description:\r | |
74 | \r | |
75 | Fixup internal data so that EFI and SAL can be call in virtual mode.\r | |
76 | Call the passed in Child Notify event and convert any pointers in \r | |
77 | lib to virtual mode.\r | |
78 | \r | |
79 | Arguments:\r | |
80 | \r | |
81 | Event - The Event that is being processed\r | |
82 | \r | |
83 | Context - Event Context\r | |
84 | \r | |
85 | Returns: \r | |
86 | \r | |
87 | None\r | |
88 | \r | |
89 | --*/\r | |
90 | {\r | |
91 | EFI_EVENT_NOTIFY ChildNotify;\r | |
92 | \r | |
93 | if (Context != NULL) {\r | |
94 | //\r | |
95 | // Call child event\r | |
96 | //\r | |
97 | ChildNotify = (EFI_EVENT_NOTIFY) (UINTN) Context;\r | |
98 | ChildNotify (Event, NULL);\r | |
99 | }\r | |
100 | \r | |
101 | mRT->ConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &mPlabel.EntryPoint);\r | |
102 | mRT->ConvertPointer (EFI_INTERNAL_POINTER | EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP);\r | |
103 | \r | |
104 | SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r | |
105 | \r | |
106 | //\r | |
107 | // Clear out BootService globals\r | |
108 | //\r | |
109 | gBS = NULL;\r | |
110 | gST = NULL;\r | |
111 | mRT = NULL;\r | |
112 | \r | |
113 | //\r | |
114 | // Pointers don't work you must use a direct lib call\r | |
115 | //\r | |
116 | }\r | |
117 | \r | |
118 | EFI_STATUS\r | |
119 | EfiInitializeRuntimeDriverLib (\r | |
120 | IN EFI_HANDLE ImageHandle,\r | |
121 | IN EFI_SYSTEM_TABLE *SystemTable,\r | |
122 | IN EFI_EVENT_NOTIFY GoVirtualChildEvent\r | |
123 | )\r | |
124 | /*++\r | |
125 | \r | |
126 | Routine Description:\r | |
127 | \r | |
128 | Intialize runtime Driver Lib if it has not yet been initialized. \r | |
129 | \r | |
130 | Arguments:\r | |
131 | \r | |
132 | ImageHandle - The firmware allocated handle for the EFI image.\r | |
133 | \r | |
134 | SystemTable - A pointer to the EFI System Table.\r | |
135 | \r | |
136 | GoVirtualChildEvent - Caller can register a virtual notification event.\r | |
137 | \r | |
138 | Returns: \r | |
139 | \r | |
140 | EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
141 | \r | |
142 | --*/\r | |
143 | {\r | |
144 | EFI_STATUS Status;\r | |
145 | EFI_PLABEL *Plabel;\r | |
146 | \r | |
147 | if (mRuntimeLibInitialized) {\r | |
148 | return EFI_ALREADY_STARTED;\r | |
149 | }\r | |
150 | \r | |
151 | mRuntimeLibInitialized = TRUE;\r | |
152 | \r | |
153 | gST = SystemTable;\r | |
154 | gBS = SystemTable->BootServices;\r | |
155 | mRT = SystemTable->RuntimeServices;\r | |
156 | Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r | |
157 | ASSERT_EFI_ERROR (Status);\r | |
158 | \r | |
159 | //\r | |
160 | // The protocol contains a function pointer, which is an indirect procedure call.\r | |
161 | // An indirect procedure call goes through a plabel, and pointer to a function is\r | |
162 | // a pointer to a plabel. To implement indirect procedure calls that can work in\r | |
163 | // both physical and virtual mode, two plabels are required (one physical and one\r | |
164 | // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it\r | |
165 | // away. We cache it in a module global, so we can register the vitrual version.\r | |
166 | //\r | |
717656c7 | 167 | Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, (VOID **) &mEsalBootService);\r |
3eb9473e | 168 | ASSERT_EFI_ERROR (Status);\r |
169 | \r | |
170 | Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;\r | |
171 | \r | |
172 | mPlabel.EntryPoint = Plabel->EntryPoint;\r | |
173 | mPlabel.GP = Plabel->GP;\r | |
174 | \r | |
175 | SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);\r | |
176 | \r | |
177 | //\r | |
178 | // Create a Virtual address change notification event. Pass in the callers\r | |
179 | // GoVirtualChildEvent so it's get passed to the event as contex.\r | |
180 | //\r | |
181 | Status = gBS->CreateEvent (\r | |
182 | EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r | |
183 | EFI_TPL_NOTIFY,\r | |
184 | EfiRuntimeLibVirtualNotifyEvent,\r | |
185 | (VOID *) GoVirtualChildEvent,\r | |
186 | &mEfiVirtualNotifyEvent\r | |
187 | );\r | |
188 | ASSERT_EFI_ERROR (Status);\r | |
189 | \r | |
190 | return EFI_SUCCESS;\r | |
191 | }\r | |
192 | \r | |
193 | EFI_STATUS\r | |
194 | EfiShutdownRuntimeDriverLib (\r | |
195 | VOID\r | |
196 | )\r | |
197 | /*++\r | |
198 | \r | |
199 | Routine Description:\r | |
200 | \r | |
201 | This routine will free some resources which have been allocated in\r | |
202 | EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r | |
203 | it must call this routine to free the allocated resource before the exiting.\r | |
204 | \r | |
205 | Arguments:\r | |
206 | \r | |
207 | None\r | |
208 | \r | |
209 | Returns: \r | |
210 | \r | |
211 | EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r | |
212 | EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r | |
213 | \r | |
214 | --*/\r | |
215 | {\r | |
216 | EFI_STATUS Status;\r | |
217 | \r | |
218 | if (!mRuntimeLibInitialized) {\r | |
219 | //\r | |
220 | // You must call EfiInitializeRuntimeDriverLib() first\r | |
221 | //\r | |
222 | return EFI_UNSUPPORTED;\r | |
223 | }\r | |
224 | \r | |
225 | mRuntimeLibInitialized = FALSE;\r | |
226 | \r | |
227 | //\r | |
228 | // Close SetVirtualAddressMap () notify function\r | |
229 | //\r | |
230 | Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r | |
231 | ASSERT_EFI_ERROR (Status);\r | |
232 | \r | |
233 | return EFI_SUCCESS;\r | |
234 | }\r | |
235 | \r | |
236 | EFI_STATUS\r | |
237 | RegisterEsalFunction (\r | |
238 | IN UINT64 FunctionId,\r | |
239 | IN EFI_GUID *ClassGuid,\r | |
240 | IN SAL_INTERNAL_EXTENDED_SAL_PROC Function,\r | |
241 | IN VOID *ModuleGlobal\r | |
242 | )\r | |
243 | /*++\r | |
244 | \r | |
245 | Routine Description:\r | |
246 | \r | |
247 | Register ESAL Class Function and it's asociated global.\r | |
248 | This function is boot service only!\r | |
249 | \r | |
250 | Arguments:\r | |
251 | FunctionId - ID of function to register\r | |
252 | ClassGuid - GUID of function class \r | |
253 | Function - Function to register under ClassGuid/FunctionId pair\r | |
254 | ModuleGlobal - Module global for Function.\r | |
255 | \r | |
256 | Returns: \r | |
257 | EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.\r | |
258 | \r | |
259 | --*/\r | |
260 | {\r | |
261 | return mEsalBootService->AddExtendedSalProc (\r | |
262 | mEsalBootService,\r | |
263 | ClassGuid,\r | |
264 | FunctionId,\r | |
265 | Function,\r | |
266 | ModuleGlobal\r | |
267 | );\r | |
268 | }\r | |
269 | \r | |
270 | EFI_STATUS\r | |
271 | RegisterEsalClass (\r | |
272 | IN EFI_GUID *ClassGuid,\r | |
273 | IN VOID *ModuleGlobal,\r | |
274 | ...\r | |
275 | )\r | |
276 | /*++\r | |
277 | \r | |
278 | Routine Description:\r | |
279 | \r | |
280 | Register ESAL Class and it's asociated global.\r | |
281 | This function is boot service only!\r | |
282 | \r | |
283 | Arguments:\r | |
284 | ClassGuid - GUID of function class \r | |
285 | ModuleGlobal - Module global for Function.\r | |
286 | ... - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL \r | |
287 | indicates the end of the list.\r | |
288 | \r | |
289 | Returns: \r | |
290 | EFI_SUCCESS - All members of ClassGuid registered\r | |
291 | \r | |
292 | --*/\r | |
293 | {\r | |
294 | VA_LIST Args;\r | |
295 | EFI_STATUS Status;\r | |
296 | SAL_INTERNAL_EXTENDED_SAL_PROC Function;\r | |
297 | UINT64 FunctionId;\r | |
298 | EFI_HANDLE NewHandle;\r | |
299 | \r | |
300 | VA_START (Args, ModuleGlobal);\r | |
301 | \r | |
302 | Status = EFI_SUCCESS;\r | |
303 | while (!EFI_ERROR (Status)) {\r | |
304 | Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC);\r | |
305 | if (Function == NULL) {\r | |
306 | break;\r | |
307 | }\r | |
308 | \r | |
309 | FunctionId = VA_ARG (Args, UINT64);\r | |
310 | \r | |
311 | Status = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal);\r | |
312 | }\r | |
313 | \r | |
314 | if (EFI_ERROR (Status)) {\r | |
315 | return Status;\r | |
316 | }\r | |
317 | \r | |
318 | NewHandle = NULL;\r | |
319 | return gBS->InstallProtocolInterface (\r | |
320 | &NewHandle,\r | |
321 | ClassGuid,\r | |
322 | EFI_NATIVE_INTERFACE,\r | |
323 | NULL\r | |
324 | );\r | |
325 | }\r | |
326 | \r | |
327 | SAL_RETURN_REGS\r | |
328 | EfiCallEsalService (\r | |
329 | IN EFI_GUID *ClassGuid,\r | |
330 | IN UINT64 FunctionId,\r | |
331 | IN UINT64 Arg2,\r | |
332 | IN UINT64 Arg3,\r | |
333 | IN UINT64 Arg4,\r | |
334 | IN UINT64 Arg5,\r | |
335 | IN UINT64 Arg6,\r | |
336 | IN UINT64 Arg7,\r | |
337 | IN UINT64 Arg8\r | |
338 | )\r | |
339 | /*++\r | |
340 | \r | |
341 | Routine Description:\r | |
342 | \r | |
343 | Call module that is not linked direclty to this module. This code is IP \r | |
344 | relative and hides the binding issues of virtual or physical calling. The\r | |
345 | function that gets dispatched has extra arguments that include the registered\r | |
346 | module global and a boolean flag to indicate if the system is in virutal mode.\r | |
347 | \r | |
348 | Arguments:\r | |
349 | ClassGuid - GUID of function\r | |
350 | FunctionId - Function in ClassGuid to call\r | |
351 | Arg2 - Argument 2 ClassGuid/FunctionId defined\r | |
352 | Arg3 - Argument 3 ClassGuid/FunctionId defined\r | |
353 | Arg4 - Argument 4 ClassGuid/FunctionId defined\r | |
354 | Arg5 - Argument 5 ClassGuid/FunctionId defined\r | |
355 | Arg6 - Argument 6 ClassGuid/FunctionId defined\r | |
356 | Arg7 - Argument 7 ClassGuid/FunctionId defined\r | |
357 | Arg8 - Argument 8 ClassGuid/FunctionId defined\r | |
358 | \r | |
359 | Returns: \r | |
360 | Status of ClassGuid/FuncitonId\r | |
361 | \r | |
362 | --*/\r | |
363 | {\r | |
364 | SAL_RETURN_REGS ReturnReg;\r | |
365 | SAL_EXTENDED_SAL_PROC EsalProc;\r | |
366 | \r | |
367 | ReturnReg = GetEsalEntryPoint ();\r | |
368 | if (ReturnReg.Status != EFI_SAL_SUCCESS) {\r | |
369 | return ReturnReg;\r | |
370 | }\r | |
371 | \r | |
372 | if (ReturnReg.r11 & PSR_IT_MASK) {\r | |
373 | //\r | |
374 | // Virtual mode plabel to entry point\r | |
375 | //\r | |
376 | EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r10;\r | |
377 | } else {\r | |
378 | //\r | |
379 | // Physical mode plabel to entry point\r | |
380 | //\r | |
381 | EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r9;\r | |
382 | }\r | |
383 | \r | |
384 | return EsalProc (\r | |
385 | ClassGuid,\r | |
386 | FunctionId,\r | |
387 | Arg2,\r | |
388 | Arg3,\r | |
389 | Arg4,\r | |
390 | Arg5,\r | |
391 | Arg6,\r | |
392 | Arg7,\r | |
393 | Arg8\r | |
394 | );\r | |
395 | }\r | |
396 | \r | |
397 | EFI_STATUS\r | |
398 | EfiConvertPointer (\r | |
399 | IN UINTN DebugDisposition,\r | |
400 | IN OUT VOID *Address\r | |
401 | )\r | |
402 | /*++\r | |
403 | \r | |
404 | Routine Description:\r | |
405 | \r | |
406 | Determines the new virtual address that is to be used on subsequent memory accesses.\r | |
407 | \r | |
408 | Arguments:\r | |
409 | \r | |
410 | DebugDisposition - Supplies type information for the pointer being converted.\r | |
411 | Address - A pointer to a pointer that is to be fixed to be the value needed\r | |
412 | for the new virtual address mappings being applied.\r | |
413 | \r | |
414 | Returns:\r | |
415 | \r | |
416 | Status code\r | |
417 | \r | |
418 | --*/\r | |
419 | {\r | |
420 | return mRT->ConvertPointer (DebugDisposition, Address);\r | |
421 | }\r | |
422 | \r | |
423 | BOOLEAN\r | |
424 | EfiGoneVirtual (\r | |
425 | VOID\r | |
426 | )\r | |
427 | /*++\r | |
428 | \r | |
429 | Routine Description:\r | |
430 | Return TRUE if SetVirtualAddressMap () has been called\r | |
431 | \r | |
432 | Arguments:\r | |
433 | NONE\r | |
434 | \r | |
435 | Returns: \r | |
436 | TRUE - If SetVirtualAddressMap () has been called\r | |
437 | \r | |
438 | --*/\r | |
439 | {\r | |
440 | EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r | |
441 | SAL_RETURN_REGS ReturnReg;\r | |
442 | \r | |
443 | ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);\r | |
444 | \r | |
445 | return (BOOLEAN) (ReturnReg.r9 == 1);\r | |
446 | }\r | |
447 | \r | |
448 | BOOLEAN\r | |
449 | EfiAtRuntime (\r | |
450 | VOID\r | |
451 | )\r | |
452 | /*++\r | |
453 | \r | |
454 | Routine Description:\r | |
455 | Return TRUE if ExitBootService () has been called\r | |
456 | \r | |
457 | Arguments:\r | |
458 | NONE\r | |
459 | \r | |
460 | Returns: \r | |
461 | TRUE - If ExitBootService () has been called\r | |
462 | \r | |
463 | --*/\r | |
464 | {\r | |
465 | EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r | |
466 | SAL_RETURN_REGS ReturnReg;\r | |
467 | \r | |
468 | ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);\r | |
469 | \r | |
470 | return (BOOLEAN) (ReturnReg.r9 == 1);\r | |
471 | }\r | |
472 | \r | |
473 | EFI_STATUS\r | |
474 | EfiReportStatusCode (\r | |
475 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
476 | IN EFI_STATUS_CODE_VALUE Value,\r | |
477 | IN UINT32 Instance,\r | |
478 | IN EFI_GUID * CallerId,\r | |
479 | IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r | |
480 | )\r | |
481 | /*++\r | |
482 | \r | |
483 | Routine Description:\r | |
484 | \r | |
485 | Status Code reporter\r | |
486 | \r | |
487 | Arguments:\r | |
488 | \r | |
489 | CodeType - Type of Status Code.\r | |
490 | \r | |
491 | Value - Value to output for Status Code.\r | |
492 | \r | |
493 | Instance - Instance Number of this status code.\r | |
494 | \r | |
495 | CallerId - ID of the caller of this status code.\r | |
496 | \r | |
497 | Data - Optional data associated with this status code.\r | |
498 | \r | |
499 | Returns:\r | |
500 | \r | |
501 | Status code\r | |
502 | \r | |
503 | --*/\r | |
504 | {\r | |
505 | EFI_GUID Guid = EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID;\r | |
506 | SAL_RETURN_REGS ReturnReg;\r | |
507 | \r | |
508 | \r | |
509 | ReturnReg = EfiCallEsalService (\r | |
510 | &Guid,\r | |
511 | StatusCode,\r | |
512 | (UINT64) CodeType,\r | |
513 | (UINT64) Value,\r | |
514 | (UINT64) Instance,\r | |
515 | (UINT64) CallerId,\r | |
516 | (UINT64) Data,\r | |
517 | 0,\r | |
518 | 0\r | |
519 | );\r | |
520 | \r | |
521 | return (EFI_STATUS) ReturnReg.Status;\r | |
522 | }\r | |
523 | //\r | |
524 | // Sal Reset Driver Class\r | |
525 | //\r | |
526 | VOID\r | |
527 | EfiResetSystem (\r | |
528 | IN EFI_RESET_TYPE ResetType,\r | |
529 | IN EFI_STATUS ResetStatus,\r | |
530 | IN UINTN DataSize,\r | |
531 | IN CHAR16 *ResetData\r | |
532 | )\r | |
533 | /*++\r | |
534 | \r | |
535 | Routine Description:\r | |
536 | \r | |
537 | Resets the entire platform.\r | |
538 | \r | |
539 | Arguments:\r | |
540 | \r | |
541 | ResetType - The type of reset to perform.\r | |
542 | ResetStatus - The status code for the reset.\r | |
543 | DataSize - The size, in bytes, of ResetData.\r | |
544 | ResetData - A data buffer that includes a Null-terminated Unicode string, optionally\r | |
545 | followed by additional binary data.\r | |
546 | \r | |
547 | Returns:\r | |
548 | \r | |
549 | None\r | |
550 | \r | |
551 | --*/\r | |
552 | {\r | |
553 | EFI_GUID Guid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID;\r | |
554 | \r | |
555 | EfiCallEsalService (\r | |
556 | &Guid,\r | |
557 | ResetSystem,\r | |
558 | (UINT64) ResetType,\r | |
559 | (UINT64) ResetStatus,\r | |
560 | (UINT64) DataSize,\r | |
561 | (UINT64) ResetData,\r | |
562 | 0,\r | |
563 | 0,\r | |
564 | 0\r | |
565 | );\r | |
566 | }\r | |
567 | //\r | |
568 | // Sal MTC Driver Class\r | |
569 | //\r | |
570 | EFI_STATUS\r | |
571 | EfiGetNextHighMonotonicCount (\r | |
572 | OUT UINT32 *HighCount\r | |
573 | )\r | |
574 | /*++\r | |
575 | \r | |
576 | Routine Description:\r | |
577 | \r | |
fd0d281b | 578 | Returns the next high 32 bits of the platform's monotonic counter.\r |
3eb9473e | 579 | \r |
580 | Arguments:\r | |
581 | \r | |
582 | HighCount - Pointer to returned value.\r | |
583 | \r | |
584 | Returns:\r | |
585 | \r | |
586 | Status code\r | |
587 | \r | |
588 | --*/\r | |
589 | {\r | |
590 | SAL_RETURN_REGS ReturnReg;\r | |
591 | \r | |
592 | EFI_GUID Guid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID;\r | |
593 | \r | |
594 | ReturnReg = EfiCallEsalService (&Guid, GetNextHighMonotonicCount, (UINT64) HighCount, 0, 0, 0, 0, 0, 0);\r | |
595 | return (EFI_STATUS) ReturnReg.Status;\r | |
596 | }\r | |
597 | //\r | |
598 | // Sal Variable Driver Class\r | |
599 | //\r | |
600 | EFI_STATUS\r | |
601 | EfiGetVariable (\r | |
602 | IN CHAR16 *VariableName,\r | |
603 | IN EFI_GUID * VendorGuid,\r | |
604 | OUT UINT32 *Attributes OPTIONAL,\r | |
605 | IN OUT UINTN *DataSize,\r | |
606 | OUT VOID *Data\r | |
607 | )\r | |
608 | /*++\r | |
609 | \r | |
610 | Routine Description:\r | |
611 | \r | |
612 | Returns the value of a variable.\r | |
613 | \r | |
614 | Arguments:\r | |
615 | \r | |
616 | VariableName - A Null-terminated Unicode string that is the name of the\r | |
fd0d281b | 617 | vendor's variable.\r |
3eb9473e | 618 | VendorGuid - A unique identifier for the vendor.\r |
619 | Attributes - If not NULL, a pointer to the memory location to return the\r | |
620 | attributes bitmask for the variable.\r | |
621 | DataSize - On input, the size in bytes of the return Data buffer.\r | |
622 | On output the size of data returned in Data.\r | |
623 | Data - The buffer to return the contents of the variable.\r | |
624 | \r | |
625 | Returns:\r | |
626 | \r | |
627 | Status code\r | |
628 | \r | |
629 | --*/\r | |
630 | {\r | |
631 | SAL_RETURN_REGS ReturnReg;\r | |
632 | EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r | |
633 | \r | |
634 | ReturnReg = EfiCallEsalService (\r | |
635 | &Guid,\r | |
636 | EsalGetVariable,\r | |
637 | (UINT64) VariableName,\r | |
638 | (UINT64) VendorGuid,\r | |
639 | (UINT64) Attributes,\r | |
640 | (UINT64) DataSize,\r | |
641 | (UINT64) Data,\r | |
642 | 0,\r | |
643 | 0\r | |
644 | );\r | |
645 | return (EFI_STATUS) ReturnReg.Status;\r | |
646 | }\r | |
647 | \r | |
648 | EFI_STATUS\r | |
649 | EfiGetNextVariableName (\r | |
650 | IN OUT UINTN *VariableNameSize,\r | |
651 | IN OUT CHAR16 *VariableName,\r | |
652 | IN OUT EFI_GUID *VendorGuid\r | |
653 | )\r | |
654 | /*++\r | |
655 | \r | |
656 | Routine Description:\r | |
657 | \r | |
658 | Enumerates the current variable names.\r | |
659 | \r | |
660 | Arguments:\r | |
661 | \r | |
662 | VariableNameSize - The size of the VariableName buffer.\r | |
663 | VariableName - On input, supplies the last VariableName that was returned\r | |
664 | by GetNextVariableName(). \r | |
665 | On output, returns the Nullterminated Unicode string of the\r | |
666 | current variable.\r | |
667 | VendorGuid - On input, supplies the last VendorGuid that was returned by\r | |
668 | GetNextVariableName(). \r | |
669 | On output, returns the VendorGuid of the current variable.\r | |
670 | \r | |
671 | Returns:\r | |
672 | \r | |
673 | Status code\r | |
674 | \r | |
675 | --*/\r | |
676 | {\r | |
677 | SAL_RETURN_REGS ReturnReg;\r | |
678 | EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r | |
679 | \r | |
680 | ReturnReg = EfiCallEsalService (\r | |
681 | &Guid,\r | |
682 | EsalGetNextVariableName,\r | |
683 | (UINT64) VariableNameSize,\r | |
684 | (UINT64) VariableName,\r | |
685 | (UINT64) VendorGuid,\r | |
686 | 0,\r | |
687 | 0,\r | |
688 | 0,\r | |
689 | 0\r | |
690 | );\r | |
691 | return (EFI_STATUS) ReturnReg.Status;\r | |
692 | }\r | |
693 | \r | |
694 | EFI_STATUS\r | |
695 | EfiSetVariable (\r | |
696 | IN CHAR16 *VariableName,\r | |
697 | IN EFI_GUID *VendorGuid,\r | |
698 | IN UINT32 Attributes,\r | |
699 | IN UINTN DataSize,\r | |
700 | IN VOID *Data\r | |
701 | )\r | |
702 | /*++\r | |
703 | \r | |
704 | Routine Description:\r | |
705 | \r | |
706 | Sets the value of a variable.\r | |
707 | \r | |
708 | Arguments:\r | |
709 | \r | |
710 | VariableName - A Null-terminated Unicode string that is the name of the\r | |
fd0d281b | 711 | vendor's variable.\r |
3eb9473e | 712 | VendorGuid - A unique identifier for the vendor.\r |
713 | Attributes - Attributes bitmask to set for the variable.\r | |
714 | DataSize - The size in bytes of the Data buffer.\r | |
715 | Data - The contents for the variable.\r | |
716 | \r | |
717 | Returns:\r | |
718 | \r | |
719 | Status code\r | |
720 | \r | |
721 | --*/\r | |
722 | {\r | |
723 | SAL_RETURN_REGS ReturnReg;\r | |
724 | EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r | |
725 | \r | |
726 | ReturnReg = EfiCallEsalService (\r | |
727 | &Guid,\r | |
728 | EsalSetVariable,\r | |
729 | (UINT64) VariableName,\r | |
730 | (UINT64) VendorGuid,\r | |
731 | (UINT64) Attributes,\r | |
732 | (UINT64) DataSize,\r | |
733 | (UINT64) Data,\r | |
734 | 0,\r | |
735 | 0\r | |
736 | );\r | |
737 | return (EFI_STATUS) ReturnReg.Status;\r | |
738 | }\r | |
739 | \r | |
740 | #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r | |
741 | \r | |
742 | EFI_STATUS\r | |
743 | EfiQueryVariableInfo (\r | |
744 | IN UINT32 Attributes,\r | |
745 | OUT UINT64 *MaximumVariableStorageSize,\r | |
746 | OUT UINT64 *RemainingVariableStorageSize,\r | |
747 | OUT UINT64 *MaximumVariableSize\r | |
748 | )\r | |
749 | /*++\r | |
750 | \r | |
751 | Routine Description:\r | |
752 | \r | |
753 | This code returns information about the EFI variables.\r | |
754 | \r | |
755 | Arguments:\r | |
756 | \r | |
757 | Attributes Attributes bitmask to specify the type of variables \r | |
758 | on which to return information.\r | |
759 | MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r | |
760 | for the EFI variables associated with the attributes specified.\r | |
761 | RemainingVariableStorageSize Pointer to the remaining size of the storage space available \r | |
762 | for the EFI variables associated with the attributes specified.\r | |
763 | MaximumVariableSize Pointer to the maximum size of the individual EFI variables\r | |
764 | associated with the attributes specified.\r | |
765 | \r | |
766 | Returns:\r | |
767 | \r | |
768 | Status code\r | |
769 | \r | |
770 | --*/\r | |
771 | {\r | |
772 | SAL_RETURN_REGS ReturnReg;\r | |
773 | EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;\r | |
774 | \r | |
775 | ReturnReg = EfiCallEsalService (\r | |
776 | &Guid,\r | |
777 | EsalQueryVariableInfo,\r | |
778 | (UINT64) Attributes,\r | |
779 | (UINT64) MaximumVariableStorageSize,\r | |
780 | (UINT64) RemainingVariableStorageSize,\r | |
781 | (UINT64) MaximumVariableSize,\r | |
782 | 0, \r | |
783 | 0,\r | |
784 | 0\r | |
785 | );\r | |
786 | return (EFI_STATUS) ReturnReg.Status;\r | |
787 | }\r | |
788 | \r | |
789 | #endif\r | |
790 | \r | |
791 | //\r | |
792 | // Sal RTC Driver Class.\r | |
793 | //\r | |
794 | EFI_STATUS\r | |
795 | EfiGetTime (\r | |
796 | OUT EFI_TIME *Time,\r | |
797 | OUT EFI_TIME_CAPABILITIES *Capabilities\r | |
798 | )\r | |
799 | /*++\r | |
800 | \r | |
801 | Routine Description:\r | |
802 | \r | |
803 | Returns the current time and date information, and the time-keeping \r | |
804 | capabilities of the hardware platform.\r | |
805 | \r | |
806 | Arguments:\r | |
807 | \r | |
808 | Time - A pointer to storage to receive a snapshot of the current time.\r | |
fd0d281b | 809 | Capabilities - An optional pointer to a buffer to receive the real time clock device's\r |
3eb9473e | 810 | capabilities.\r |
811 | \r | |
812 | Returns:\r | |
813 | \r | |
814 | Status code\r | |
815 | \r | |
816 | --*/\r | |
817 | {\r | |
818 | SAL_RETURN_REGS ReturnReg;\r | |
819 | EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r | |
820 | \r | |
821 | ReturnReg = EfiCallEsalService (&Guid, GetTime, (UINT64) Time, (UINT64) Capabilities, 0, 0, 0, 0, 0);\r | |
822 | return ReturnReg.Status;\r | |
823 | }\r | |
824 | \r | |
825 | EFI_STATUS\r | |
826 | EfiSetTime (\r | |
827 | OUT EFI_TIME *Time\r | |
828 | )\r | |
829 | /*++\r | |
830 | \r | |
831 | Routine Description:\r | |
832 | \r | |
833 | Sets the current local time and date information.\r | |
834 | \r | |
835 | Arguments:\r | |
836 | \r | |
837 | Time - A pointer to the current time.\r | |
838 | \r | |
839 | Returns:\r | |
840 | \r | |
841 | Status code\r | |
842 | \r | |
843 | --*/\r | |
844 | {\r | |
845 | SAL_RETURN_REGS ReturnReg;\r | |
846 | \r | |
847 | EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r | |
848 | \r | |
849 | ReturnReg = EfiCallEsalService (&Guid, SetTime, (UINT64) Time, 0, 0, 0, 0, 0, 0);\r | |
850 | return ReturnReg.Status;\r | |
851 | }\r | |
852 | \r | |
853 | EFI_STATUS\r | |
854 | EfiGetWakeupTime (\r | |
855 | OUT BOOLEAN *Enabled,\r | |
856 | OUT BOOLEAN *Pending,\r | |
857 | OUT EFI_TIME *Time\r | |
858 | )\r | |
859 | /*++\r | |
860 | \r | |
861 | Routine Description:\r | |
862 | \r | |
863 | Returns the current wakeup alarm clock setting.\r | |
864 | \r | |
865 | Arguments:\r | |
866 | \r | |
867 | Enabled - Indicates if the alarm is currently enabled or disabled.\r | |
868 | Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r | |
869 | Time - The current alarm setting.\r | |
870 | \r | |
871 | Returns:\r | |
872 | \r | |
873 | Status code\r | |
874 | \r | |
875 | --*/\r | |
876 | {\r | |
877 | SAL_RETURN_REGS ReturnReg;\r | |
878 | \r | |
879 | EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r | |
880 | \r | |
881 | ReturnReg = EfiCallEsalService (&Guid, GetWakeupTime, (UINT64) Enabled, (UINT64) Pending, (UINT64) Time, 0, 0, 0, 0);\r | |
882 | return ReturnReg.Status;\r | |
883 | }\r | |
884 | \r | |
885 | EFI_STATUS\r | |
886 | EfiSetWakeupTime (\r | |
887 | IN BOOLEAN Enable,\r | |
888 | IN EFI_TIME *Time\r | |
889 | )\r | |
890 | /*++\r | |
891 | \r | |
892 | Routine Description:\r | |
893 | \r | |
894 | Sets the system wakeup alarm clock time.\r | |
895 | \r | |
896 | Arguments:\r | |
897 | \r | |
898 | Enable - Enable or disable the wakeup alarm.\r | |
899 | Time - If Enable is TRUE, the time to set the wakeup alarm for.\r | |
900 | If Enable is FALSE, then this parameter is optional, and may be NULL.\r | |
901 | \r | |
902 | Returns:\r | |
903 | \r | |
904 | Status code\r | |
905 | \r | |
906 | --*/\r | |
907 | {\r | |
908 | SAL_RETURN_REGS ReturnReg;\r | |
909 | \r | |
910 | EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;\r | |
911 | \r | |
912 | ReturnReg = EfiCallEsalService (&Guid, SetWakeupTime, (UINT64) Enable, (UINT64) Time, 0, 0, 0, 0, 0);\r | |
913 | return ReturnReg.Status;\r | |
914 | }\r | |
915 | \r | |
916 | \r | |
917 | \r | |
918 | //\r | |
919 | // Base IO Services\r | |
920 | //\r | |
921 | EFI_STATUS\r | |
922 | EfiIoRead (\r | |
923 | IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r | |
924 | IN UINT64 Address,\r | |
925 | IN UINTN Count,\r | |
926 | IN OUT VOID *Buffer\r | |
927 | )\r | |
928 | /*++\r | |
929 | \r | |
930 | Routine Description:\r | |
931 | Perform an IO read into Buffer.\r | |
932 | \r | |
933 | Arguments:\r | |
934 | Width - Width of read transaction, and repeat operation to use\r | |
935 | Address - IO address to read\r | |
936 | Count - Number of times to read the IO address.\r | |
937 | Buffer - Buffer to read data into. size is Width * Count\r | |
938 | \r | |
939 | Returns:\r | |
940 | Status code\r | |
941 | \r | |
942 | --*/\r | |
943 | {\r | |
944 | \r | |
945 | SAL_RETURN_REGS ReturnReg;\r | |
946 | \r | |
947 | EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r | |
948 | \r | |
949 | ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r | |
950 | \r | |
951 | return ReturnReg.Status;\r | |
952 | \r | |
953 | }\r | |
954 | \r | |
955 | EFI_STATUS\r | |
956 | EfiIoWrite (\r | |
957 | IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r | |
958 | IN UINT64 Address,\r | |
959 | IN UINTN Count,\r | |
960 | IN OUT VOID *Buffer\r | |
961 | )\r | |
962 | /*++\r | |
963 | \r | |
964 | Routine Description:\r | |
965 | Perform an IO write into Buffer.\r | |
966 | \r | |
967 | Arguments:\r | |
968 | Width - Width of write transaction, and repeat operation to use\r | |
969 | Address - IO address to write\r | |
970 | Count - Number of times to write the IO address.\r | |
971 | Buffer - Buffer to write data from. size is Width * Count\r | |
972 | \r | |
973 | Returns:\r | |
974 | Status code\r | |
975 | \r | |
976 | --*/\r | |
977 | {\r | |
978 | \r | |
979 | SAL_RETURN_REGS ReturnReg;\r | |
980 | \r | |
981 | EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r | |
982 | \r | |
983 | ReturnReg = EfiCallEsalService (&Guid, IoWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r | |
984 | \r | |
985 | return ReturnReg.Status;\r | |
986 | \r | |
987 | }\r | |
988 | \r | |
989 | EFI_STATUS\r | |
990 | EfiMemRead (\r | |
991 | IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r | |
992 | IN UINT64 Address,\r | |
993 | IN UINTN Count,\r | |
994 | IN OUT VOID *Buffer\r | |
995 | )\r | |
996 | /*++\r | |
997 | \r | |
998 | Routine Description:\r | |
999 | Perform a Memory mapped IO read into Buffer.\r | |
1000 | \r | |
1001 | Arguments:\r | |
1002 | Width - Width of each read transaction.\r | |
1003 | Address - Memory mapped IO address to read\r | |
1004 | Count - Number of Width quanta to read\r | |
1005 | Buffer - Buffer to read data into. size is Width * Count\r | |
1006 | \r | |
1007 | Returns:\r | |
1008 | Status code\r | |
1009 | \r | |
1010 | --*/\r | |
1011 | {\r | |
1012 | \r | |
1013 | SAL_RETURN_REGS ReturnReg;\r | |
1014 | \r | |
1015 | EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r | |
1016 | \r | |
1017 | ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r | |
1018 | \r | |
1019 | return ReturnReg.Status;\r | |
1020 | \r | |
1021 | }\r | |
1022 | \r | |
1023 | EFI_STATUS\r | |
1024 | EfiMemWrite (\r | |
1025 | IN EFI_CPU_IO_PROTOCOL_WIDTH Width,\r | |
1026 | IN UINT64 Address,\r | |
1027 | IN UINTN Count,\r | |
1028 | IN OUT VOID *Buffer\r | |
1029 | )\r | |
1030 | /*++\r | |
1031 | \r | |
1032 | Routine Description:\r | |
1033 | Perform a memory mapped IO write into Buffer.\r | |
1034 | \r | |
1035 | Arguments:\r | |
1036 | Width - Width of write transaction, and repeat operation to use\r | |
1037 | Address - IO address to write\r | |
1038 | Count - Number of times to write the IO address.\r | |
1039 | Buffer - Buffer to write data from. size is Width * Count\r | |
1040 | \r | |
1041 | Returns:\r | |
1042 | Status code\r | |
1043 | \r | |
1044 | --*/\r | |
1045 | {\r | |
1046 | \r | |
1047 | SAL_RETURN_REGS ReturnReg;\r | |
1048 | \r | |
1049 | EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r | |
1050 | \r | |
1051 | ReturnReg = EfiCallEsalService (&Guid, MemWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r | |
1052 | \r | |
1053 | return ReturnReg.Status;\r | |
1054 | \r | |
1055 | }\r | |
1056 | \r | |
1057 | \r | |
1058 | #define EFI_PCI_ADDRESS_IPF(_seg, _bus, _devfunc, _reg) \\r | |
1059 | (((_seg) << 24) | ((_bus) << 16) | ((_devfunc) << 8) | (_reg)) & 0xFFFFFFFF\r | |
1060 | \r | |
1061 | //\r | |
1062 | // PCI Class Functions\r | |
1063 | //\r | |
1064 | UINT8\r | |
1065 | PciRead8 (\r | |
1066 | UINT8 Segment,\r | |
1067 | UINT8 Bus,\r | |
1068 | UINT8 DevFunc,\r | |
1069 | UINT8 Register\r | |
1070 | )\r | |
1071 | /*++\r | |
1072 | \r | |
1073 | Routine Description:\r | |
1074 | Perform an one byte PCI config cycle read\r | |
1075 | \r | |
1076 | Arguments:\r | |
1077 | Segment - PCI Segment ACPI _SEG\r | |
1078 | Bus - PCI Bus\r | |
1079 | DevFunc - PCI Device(7:3) and Func(2:0)\r | |
1080 | Register - PCI config space register\r | |
1081 | \r | |
1082 | Returns:\r | |
1083 | Data read from PCI config space\r | |
1084 | \r | |
1085 | --*/\r | |
1086 | {\r | |
1087 | EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r | |
1088 | UINT64 Address;\r | |
1089 | SAL_RETURN_REGS Return;\r | |
1090 | \r | |
1091 | Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r | |
1092 | Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 1, 0, 0, 0, 0, 0);\r | |
1093 | \r | |
1094 | return (UINT8) Return.r9;\r | |
1095 | }\r | |
1096 | \r | |
1097 | \r | |
1098 | UINT16\r | |
1099 | PciRead16 (\r | |
1100 | UINT8 Segment,\r | |
1101 | UINT8 Bus,\r | |
1102 | UINT8 DevFunc,\r | |
1103 | UINT8 Register\r | |
1104 | )\r | |
1105 | /*++\r | |
1106 | \r | |
1107 | Routine Description:\r | |
1108 | Perform an two byte PCI config cycle read\r | |
1109 | \r | |
1110 | Arguments:\r | |
1111 | Segment - PCI Segment ACPI _SEG\r | |
1112 | Bus - PCI Bus\r | |
1113 | DevFunc - PCI Device(7:3) and Func(2:0)\r | |
1114 | Register - PCI config space register\r | |
1115 | \r | |
1116 | Returns:\r | |
1117 | Data read from PCI config space\r | |
1118 | \r | |
1119 | --*/\r | |
1120 | {\r | |
1121 | EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r | |
1122 | UINT64 Address;\r | |
1123 | SAL_RETURN_REGS Return;\r | |
1124 | \r | |
1125 | Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r | |
1126 | Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 2, 0, 0, 0, 0, 0);\r | |
1127 | \r | |
1128 | return (UINT16) Return.r9;\r | |
1129 | }\r | |
1130 | \r | |
1131 | UINT32\r | |
1132 | PciRead32 (\r | |
1133 | UINT8 Segment,\r | |
1134 | UINT8 Bus,\r | |
1135 | UINT8 DevFunc,\r | |
1136 | UINT8 Register\r | |
1137 | )\r | |
1138 | /*++\r | |
1139 | \r | |
1140 | Routine Description:\r | |
1141 | Perform an four byte PCI config cycle read\r | |
1142 | \r | |
1143 | Arguments:\r | |
1144 | Segment - PCI Segment ACPI _SEG\r | |
1145 | Bus - PCI Bus\r | |
1146 | DevFunc - PCI Device(7:3) and Func(2:0)\r | |
1147 | Register - PCI config space register\r | |
1148 | \r | |
1149 | Returns:\r | |
1150 | Data read from PCI config space\r | |
1151 | \r | |
1152 | --*/\r | |
1153 | {\r | |
1154 | EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r | |
1155 | UINT64 Address;\r | |
1156 | SAL_RETURN_REGS Return;\r | |
1157 | \r | |
1158 | Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r | |
1159 | Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 4, 0, 0, 0, 0, 0);\r | |
1160 | \r | |
1161 | return (UINT32) Return.r9;\r | |
1162 | }\r | |
1163 | \r | |
1164 | VOID\r | |
1165 | PciWrite8 (\r | |
1166 | UINT8 Segment,\r | |
1167 | UINT8 Bus,\r | |
1168 | UINT8 DevFunc,\r | |
1169 | UINT8 Register,\r | |
1170 | UINT8 Data\r | |
1171 | )\r | |
1172 | /*++\r | |
1173 | \r | |
1174 | Routine Description:\r | |
1175 | Perform an one byte PCI config cycle write\r | |
1176 | \r | |
1177 | Arguments:\r | |
1178 | Segment - PCI Segment ACPI _SEG\r | |
1179 | Bus - PCI Bus\r | |
1180 | DevFunc - PCI Device(7:3) and Func(2:0)\r | |
1181 | Register - PCI config space register\r | |
1182 | Data - Data to write\r | |
1183 | \r | |
1184 | Returns:\r | |
1185 | NONE\r | |
1186 | \r | |
1187 | --*/\r | |
1188 | {\r | |
1189 | EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r | |
1190 | UINT64 Address;\r | |
1191 | \r | |
1192 | Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r | |
1193 | EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 1, Data, 0, 0, 0, 0);\r | |
1194 | }\r | |
1195 | \r | |
1196 | VOID\r | |
1197 | PciWrite16 (\r | |
1198 | UINT8 Segment,\r | |
1199 | UINT8 Bus,\r | |
1200 | UINT8 DevFunc,\r | |
1201 | UINT8 Register,\r | |
1202 | UINT16 Data\r | |
1203 | )\r | |
1204 | /*++\r | |
1205 | \r | |
1206 | Routine Description:\r | |
1207 | Perform an two byte PCI config cycle write\r | |
1208 | \r | |
1209 | Arguments:\r | |
1210 | Segment - PCI Segment ACPI _SEG\r | |
1211 | Bus - PCI Bus\r | |
1212 | DevFunc - PCI Device(7:3) and Func(2:0)\r | |
1213 | Register - PCI config space register\r | |
1214 | Data - Data to write\r | |
1215 | \r | |
1216 | Returns:\r | |
1217 | None.\r | |
1218 | \r | |
1219 | --*/\r | |
1220 | {\r | |
1221 | EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r | |
1222 | UINT64 Address;\r | |
1223 | \r | |
1224 | Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r | |
1225 | EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 2, Data, 0, 0, 0, 0);\r | |
1226 | }\r | |
1227 | \r | |
1228 | VOID\r | |
1229 | PciWrite32 (\r | |
1230 | UINT8 Segment,\r | |
1231 | UINT8 Bus,\r | |
1232 | UINT8 DevFunc,\r | |
1233 | UINT8 Register,\r | |
1234 | UINT32 Data\r | |
1235 | )\r | |
1236 | /*++\r | |
1237 | \r | |
1238 | Routine Description:\r | |
1239 | Perform an four byte PCI config cycle write\r | |
1240 | \r | |
1241 | Arguments:\r | |
1242 | Segment - PCI Segment ACPI _SEG\r | |
1243 | Bus - PCI Bus\r | |
1244 | DevFunc - PCI Device(7:3) and Func(2:0)\r | |
1245 | Register - PCI config space register\r | |
1246 | Data - Data to write\r | |
1247 | \r | |
1248 | Returns:\r | |
1249 | NONE\r | |
1250 | \r | |
1251 | --*/\r | |
1252 | {\r | |
1253 | EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;\r | |
1254 | UINT64 Address;\r | |
1255 | \r | |
1256 | Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);\r | |
1257 | EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 4, Data, 0, 0, 0, 0);\r | |
1258 | }\r | |
1259 | \r | |
1260 | //\r | |
1261 | // Stall class functions\r | |
1262 | //\r | |
1263 | VOID\r | |
1264 | EfiStall (\r | |
1265 | IN UINTN Microseconds\r | |
1266 | )\r | |
1267 | /*++\r | |
1268 | \r | |
1269 | Routine Description:\r | |
1270 | Delay for at least the request number of microseconds\r | |
1271 | \r | |
1272 | Arguments:\r | |
1273 | Microseconds - Number of microseconds to delay.\r | |
1274 | \r | |
1275 | Returns:\r | |
1276 | NONE\r | |
1277 | \r | |
1278 | --*/\r | |
1279 | {\r | |
1280 | EFI_GUID Guid = EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID;\r | |
1281 | \r | |
1282 | if (EfiAtRuntime ()) {\r | |
1283 | EfiCallEsalService (&Guid, Stall, Microseconds, 4, 0, 0, 0, 0, 0);\r | |
1284 | } else {\r | |
1285 | gBS->Stall (Microseconds);\r | |
1286 | }\r | |
1287 | }\r | |
1288 | //\r | |
1289 | // Cache Flush Routine.\r | |
1290 | //\r | |
1291 | EFI_STATUS\r | |
1292 | EfiCpuFlushCache (\r | |
1293 | IN EFI_PHYSICAL_ADDRESS Start,\r | |
1294 | IN UINT64 Length\r | |
1295 | )\r | |
1296 | /*++\r | |
1297 | \r | |
1298 | Routine Description:\r | |
1299 | \r | |
1300 | Flush cache with specified range.\r | |
1301 | \r | |
1302 | Arguments:\r | |
1303 | \r | |
1304 | Start - Start address\r | |
1305 | Length - Length in bytes\r | |
1306 | \r | |
1307 | Returns:\r | |
1308 | \r | |
1309 | Status code\r | |
1310 | \r | |
1311 | EFI_SUCCESS - success\r | |
1312 | \r | |
1313 | --*/\r | |
1314 | {\r | |
1315 | SalFlushCache (Start, Length);\r | |
1316 | return EFI_SUCCESS;\r | |
1317 | }\r |