]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / Include / EfiDriverLib.h
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 EfiDriverLib.h\r
15\r
16Abstract:\r
17\r
18 Light weight lib to support EFI drivers.\r
19\r
20--*/\r
21\r
22#ifndef _EFI_DRIVER_LIB_H_\r
23#define _EFI_DRIVER_LIB_H_\r
24\r
25#include "EfiStatusCode.h"\r
26#include "EfiCommonLib.h"\r
27#include "EfiPerf.h"\r
28#include "LinkedList.h"\r
29#include "GetImage.h"\r
30#include "EfiImageFormat.h"\r
d850121e 31#include "EfiCompNameSupport.h"\r
3eb9473e 32\r
33#include EFI_GUID_DEFINITION (DxeServices)\r
34#include EFI_GUID_DEFINITION (EventGroup)\r
35#include EFI_GUID_DEFINITION (EventLegacyBios)\r
36#include EFI_GUID_DEFINITION (FrameworkDevicePath)\r
37#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)\r
38#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)\r
39#include EFI_PROTOCOL_DEFINITION (DataHub)\r
40#include EFI_PROTOCOL_DEFINITION (DriverBinding)\r
41#include EFI_PROTOCOL_DEFINITION (ComponentName)\r
42#include EFI_PROTOCOL_DEFINITION (ComponentName2)\r
43#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)\r
d850121e 44#include EFI_PROTOCOL_DEFINITION (DriverConfiguration2)\r
3eb9473e 45#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)\r
d850121e 46#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics2)\r
3eb9473e 47\r
48#include EFI_PROTOCOL_DEFINITION (DebugMask)\r
49\r
f90eb36c 50#if defined(__GNUC__) && defined(ECP_CPU_IPF)\r
51\r
52VOID\r
53EFIAPI\r
54EcpEfiBreakPoint (\r
55 VOID\r
56 )\r
57/*++\r
58\r
59Routine Description:\r
60\r
61 Generates a breakpoint on the CPU.\r
62\r
63 Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
64 that code can resume normal execution after the breakpoint.\r
65\r
66Arguments:\r
67\r
68 VOID\r
69\r
70Returns: \r
71\r
72 VOID\r
73\r
74--*/\r
75;\r
76\r
77VOID\r
78EFIAPI\r
79EcpMemoryFence (\r
80 VOID\r
81 )\r
82/*++\r
83\r
84Routine Description:\r
85\r
86 Used to serialize load and store operations.\r
87\r
88 All loads and stores that proceed calls to this function are guaranteed to be\r
89 globally visible when this function returns.\r
90\r
91Arguments:\r
92\r
93 VOID\r
94\r
95Returns: \r
96\r
97 VOID\r
98\r
99--*/\r
100;\r
101\r
102#endif\r
103\r
3eb9473e 104typedef struct {\r
105 CHAR8 *Language;\r
106 CHAR16 *UnicodeString;\r
107} EFI_UNICODE_STRING_TABLE;\r
108#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
109#define LANGUAGE_RFC_3066\r
110#define LANGUAGE_CODE_ENGLISH "en-US"\r
111#else\r
112#define LANGUAGE_ISO_639_2\r
113#define LANGUAGE_CODE_ENGLISH "eng"\r
114#endif\r
115\r
116//\r
117// Macros for EFI Driver Library Functions that are really EFI Boot Services\r
118//\r
119#define EfiCopyMem(_Destination, _Source, _Length) gBS->CopyMem ((_Destination), (_Source), (_Length))\r
120#define EfiSetMem(_Destination, _Length, _Value) gBS->SetMem ((_Destination), (_Length), (_Value))\r
121#define EfiZeroMem(_Destination, _Length) gBS->SetMem ((_Destination), (_Length), 0)\r
122\r
123//\r
124// Driver Lib Globals.\r
125//\r
126extern EFI_BOOT_SERVICES *gBS;\r
127extern EFI_DXE_SERVICES *gDS;\r
128extern EFI_RUNTIME_SERVICES *gRT;\r
129extern EFI_SYSTEM_TABLE *gST;\r
130extern UINTN gErrorLevel;\r
131extern EFI_GUID gEfiCallerIdGuid;\r
132extern EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface;\r
133\r
134EFI_STATUS\r
135EfiInitializeDriverLib (\r
136 IN EFI_HANDLE ImageHandle,\r
137 IN EFI_SYSTEM_TABLE *SystemTable\r
138 )\r
139/*++\r
140\r
141Routine Description:\r
142\r
143 Intialize Driver Lib if it has not yet been initialized. \r
144\r
145Arguments:\r
146\r
147 ImageHandle - The firmware allocated handle for the EFI image.\r
148 \r
149 SystemTable - A pointer to the EFI System Table.\r
150\r
151\r
152Returns: \r
153\r
154 EFI_STATUS always returns EFI_SUCCESS\r
155\r
156--*/\r
157;\r
158\r
159EFI_STATUS\r
160DxeInitializeDriverLib (\r
161 IN EFI_HANDLE ImageHandle,\r
162 IN EFI_SYSTEM_TABLE *SystemTable\r
163 )\r
164/*++\r
165\r
166Routine Description:\r
167\r
168 Intialize Driver Lib if it has not yet been initialized. \r
169\r
170Arguments:\r
171\r
172 ImageHandle - The firmware allocated handle for the EFI image.\r
173 \r
174 SystemTable - A pointer to the EFI System Table.\r
175\r
176Returns: \r
177\r
178 EFI_STATUS always returns EFI_SUCCESS\r
179\r
180--*/\r
181;\r
182\r
183EFI_STATUS\r
184EfiLibInstallDriverBinding (\r
185 IN EFI_HANDLE ImageHandle,\r
186 IN EFI_SYSTEM_TABLE *SystemTable,\r
187 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
188 IN EFI_HANDLE DriverBindingHandle\r
189 )\r
190/*++\r
191\r
192Routine Description:\r
193\r
194 Intialize a driver by installing the Driver Binding Protocol onto the \r
195 driver's DriverBindingHandle. This is typically the same as the driver's\r
196 ImageHandle, but it can be different if the driver produces multiple\r
197 DriverBinding Protocols. This function also initializes the EFI Driver\r
198 Library that initializes the global variables gST, gBS, gRT.\r
199\r
200Arguments:\r
201\r
202 ImageHandle - The image handle of the driver\r
203\r
204 SystemTable - The EFI System Table that was passed to the driver's entry point\r
205\r
206 DriverBinding - A Driver Binding Protocol instance that this driver is producing\r
207\r
208 DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this\r
209 parameter is NULL, then a new handle is created.\r
210\r
211Returns: \r
212\r
213 EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle\r
214\r
215 Otherwise, then return status from gBS->InstallProtocolInterface()\r
216\r
217--*/\r
218;\r
219\r
220EFI_STATUS\r
221EfiLibInstallAllDriverProtocols (\r
222 IN EFI_HANDLE ImageHandle,\r
223 IN EFI_SYSTEM_TABLE *SystemTable,\r
224 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
225 IN EFI_HANDLE DriverBindingHandle,\r
d850121e 226 IN EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
227 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
228 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL\r
3eb9473e 229 )\r
230/*++\r
231\r
232Routine Description:\r
233\r
234 Intialize a driver by installing the Driver Binding Protocol onto the \r
235 driver's DriverBindingHandle. This is typically the same as the driver's\r
236 ImageHandle, but it can be different if the driver produces multiple\r
237 DriverBinding Protocols. This function also initializes the EFI Driver\r
238 Library that initializes the global variables gST, gBS, gRT.\r
239\r
240Arguments:\r
241\r
242 ImageHandle - The image handle of the driver\r
243\r
244 SystemTable - The EFI System Table that was passed to the driver's entry point\r
245\r
246 DriverBinding - A Driver Binding Protocol instance that this driver is producing\r
247\r
248 DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this\r
249 parameter is NULL, then a new handle is created.\r
250\r
251 ComponentName - A Component Name Protocol instance that this driver is producing\r
252\r
253 DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing\r
254 \r
255 DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing\r
256\r
257Returns: \r
258\r
259 EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
260\r
261 Otherwise, then return status from gBS->InstallProtocolInterface()\r
262\r
263--*/\r
264;\r
265\r
d850121e 266EFI_STATUS\r
267EfiLibInstallAllDriverProtocols2 (\r
268 IN EFI_HANDLE ImageHandle,\r
269 IN EFI_SYSTEM_TABLE *SystemTable,\r
270 IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
271 IN EFI_HANDLE DriverBindingHandle,\r
272 IN EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL\r
273 IN EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2, OPTIONAL\r
274 IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL\r
275 )\r
276/*++\r
277\r
278Routine Description:\r
279\r
280 Intialize a driver by installing the Driver Binding Protocol onto the \r
281 driver's DriverBindingHandle. This is typically the same as the driver's\r
282 ImageHandle, but it can be different if the driver produces multiple\r
283 DriverBinding Protocols. This function also initializes the EFI Driver\r
284 Library that initializes the global variables gST, gBS, gRT.\r
285\r
286Arguments:\r
287\r
288 ImageHandle - The image handle of the driver\r
289\r
290 SystemTable - The EFI System Table that was passed to the driver's entry point\r
291\r
292 DriverBinding - A Driver Binding Protocol instance that this driver is producing\r
293\r
294 DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this\r
295 parameter is NULL, then a new handle is created.\r
296\r
297 ComponentName2 - A Component Name2 Protocol instance that this driver is producing\r
298\r
299 DriverConfiguration2- A Driver Configuration2 Protocol instance that this driver is producing\r
300 \r
301 DriverDiagnostics2 - A Driver Diagnostics2 Protocol instance that this driver is producing\r
302\r
303Returns: \r
304\r
305 EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle\r
306\r
307 Otherwise, then return status from gBS->InstallProtocolInterface()\r
308\r
309--*/\r
310;\r
311\r
3eb9473e 312EFI_STATUS\r
313EfiLibGetSystemConfigurationTable (\r
314 IN EFI_GUID *TableGuid,\r
315 OUT VOID **Table\r
316 )\r
317/*++\r
318\r
319Routine Description:\r
320 \r
321 Return the EFI 1.0 System Tabl entry with TableGuid\r
322\r
323Arguments:\r
324\r
325 TableGuid - Name of entry to return in the system table\r
326 Table - Pointer in EFI system table associated with TableGuid\r
327\r
328Returns: \r
329\r
330 EFI_SUCCESS - Table returned;\r
331 EFI_NOT_FOUND - TableGuid not in EFI system table\r
332\r
333--*/\r
334;\r
335\r
336BOOLEAN\r
337EfiLibCompareLanguage (\r
338 CHAR8 *Language1,\r
339 CHAR8 *Language2\r
340 )\r
341/*++\r
342\r
343Routine Description:\r
344\r
345 Compare two languages to say whether they are identical.\r
346\r
347Arguments:\r
348\r
349 Language1 - first language\r
350 Language2 - second language\r
351\r
352Returns:\r
353\r
354 TRUE - identical\r
355 FALSE - not identical\r
356\r
357--*/\r
358;\r
359\r
360//\r
361// DevicePath.c\r
362//\r
363BOOLEAN\r
364EfiIsDevicePathMultiInstance (\r
365 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
366 )\r
367/*++\r
368\r
369Routine Description:\r
370 Return TRUE is this is a multi instance device path.\r
371\r
372Arguments:\r
373 DevicePath - A pointer to a device path data structure.\r
374\r
375\r
376Returns:\r
377 TRUE - If DevicePath is multi instance. \r
378 FALSE - If DevicePath is not multi instance.\r
379\r
380--*/\r
381;\r
382\r
383EFI_DEVICE_PATH_PROTOCOL *\r
384EfiDevicePathInstance (\r
385 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
386 OUT UINTN *Size\r
387 )\r
388/*++\r
389\r
390Routine Description:\r
391 Function retrieves the next device path instance from a device path data structure.\r
392\r
393Arguments:\r
394 DevicePath - A pointer to a device path data structure.\r
395\r
396 Size - A pointer to the size of a device path instance in bytes.\r
397\r
398Returns:\r
399\r
400 This function returns a pointer to the current device path instance.\r
401 In addition, it returns the size in bytes of the current device path instance in Size,\r
402 and a pointer to the next device path instance in DevicePath.\r
403 If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.\r
404\r
405--*/\r
406;\r
407\r
408UINTN\r
409EfiDevicePathSize (\r
410 IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
411 )\r
412/*++\r
413\r
414Routine Description:\r
415\r
416 Calculate the size of a whole device path. \r
417 \r
418Arguments:\r
419\r
420 DevPath - The pointer to the device path data.\r
421 \r
422Returns:\r
423\r
424 Size of device path data structure..\r
425\r
426--*/\r
427;\r
428\r
429EFI_DEVICE_PATH_PROTOCOL *\r
430EfiAppendDevicePath (\r
431 IN EFI_DEVICE_PATH_PROTOCOL *Src1,\r
432 IN EFI_DEVICE_PATH_PROTOCOL *Src2\r
433 )\r
434/*++\r
435\r
436Routine Description:\r
437 Function is used to append a Src1 and Src2 together.\r
438\r
439Arguments:\r
440 Src1 - A pointer to a device path data structure.\r
441\r
442 Src2 - A pointer to a device path data structure.\r
443\r
444Returns:\r
445\r
446 A pointer to the new device path is returned.\r
447 NULL is returned if space for the new device path could not be allocated from pool.\r
448 It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.\r
449\r
450--*/\r
451;\r
452\r
453EFI_DEVICE_PATH_PROTOCOL *\r
454EfiDevicePathFromHandle (\r
455 IN EFI_HANDLE Handle\r
456 )\r
457/*++\r
458\r
459Routine Description:\r
460\r
461 Locate device path protocol interface on a device handle.\r
462\r
463Arguments:\r
464\r
465 Handle - The device handle\r
466\r
467Returns:\r
468\r
469 Device path protocol interface located.\r
470\r
471--*/\r
472;\r
473\r
474EFI_DEVICE_PATH_PROTOCOL *\r
475EfiDuplicateDevicePath (\r
476 IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
477 )\r
478/*++\r
479\r
480Routine Description:\r
481 Duplicate a new device path data structure from the old one.\r
482\r
483Arguments:\r
484 DevPath - A pointer to a device path data structure.\r
485\r
486Returns:\r
487 A pointer to the new allocated device path data.\r
488 Caller must free the memory used by DevicePath if it is no longer needed.\r
489\r
490--*/\r
491;\r
492\r
493EFI_DEVICE_PATH_PROTOCOL *\r
494EfiAppendDevicePathNode (\r
495 IN EFI_DEVICE_PATH_PROTOCOL *Src1,\r
496 IN EFI_DEVICE_PATH_PROTOCOL *Src2\r
497 )\r
498/*++\r
499\r
500Routine Description:\r
501 Function is used to append a device path node to the end of another device path.\r
502\r
503Arguments:\r
504 Src1 - A pointer to a device path data structure.\r
505\r
506 Src2 - A pointer to a device path data structure.\r
507\r
508Returns:\r
509 This function returns a pointer to the new device path.\r
510 If there is not enough temporary pool memory available to complete this function,\r
511 then NULL is returned.\r
512\r
513\r
514--*/\r
515;\r
516\r
517EFI_DEVICE_PATH_PROTOCOL *\r
518EfiFileDevicePath (\r
519 IN EFI_HANDLE Device OPTIONAL,\r
520 IN CHAR16 *FileName\r
521 )\r
522/*++\r
523\r
524Routine Description:\r
525 Create a device path that appends a MEDIA_DEVICE_PATH with\r
526 FileNameGuid to the device path of DeviceHandle.\r
527\r
528Arguments:\r
529 Device - Optional Device Handle to use as Root of the Device Path\r
530\r
531 FileName - FileName\r
532\r
533Returns:\r
534 EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory\r
535 or NULL pointer.\r
536\r
537--*/\r
538;\r
539\r
540EFI_DEVICE_PATH_PROTOCOL *\r
541EfiAppendDevicePathInstance (\r
542 IN EFI_DEVICE_PATH_PROTOCOL *Src,\r
543 IN EFI_DEVICE_PATH_PROTOCOL *Instance\r
544 )\r
545/*++\r
546\r
547Routine Description:\r
548\r
549 Append a device path instance to another.\r
550\r
551Arguments:\r
552\r
553 Src - The device path instance to be appended with.\r
554 Instance - The device path instance appending the other.\r
555\r
556Returns:\r
557\r
558 The contaction of these two.\r
559\r
560--*/\r
561;\r
562\r
563//\r
564// Lock.c\r
565//\r
566typedef struct {\r
567 EFI_TPL Tpl;\r
568 EFI_TPL OwnerTpl;\r
569 UINTN Lock;\r
570} EFI_LOCK;\r
571\r
572VOID\r
573EfiInitializeLock (\r
574 IN OUT EFI_LOCK *Lock,\r
575 IN EFI_TPL Priority\r
576 )\r
577/*++\r
578\r
579Routine Description:\r
580\r
581 Initialize a basic mutual exclusion lock. Each lock\r
582 provides mutual exclusion access at it's task priority\r
583 level. Since there is no-premption (at any TPL) or\r
584 multiprocessor support, acquiring the lock only consists\r
585 of raising to the locks TPL.\r
586\r
587 Note on a check build ASSERT()s are used to ensure proper\r
588 lock usage.\r
589 \r
590Arguments:\r
591\r
592 Lock - The EFI_LOCK structure to initialize\r
593\r
594 Priority - The task priority level of the lock\r
595\r
596 \r
597Returns:\r
598\r
599 An initialized Efi Lock structure.\r
600\r
601--*/\r
602;\r
603\r
604//\r
605// Macro to initialize the state of a lock when a lock variable is declared\r
606//\r
607#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}\r
608\r
609VOID\r
610EfiAcquireLock (\r
611 IN EFI_LOCK *Lock\r
612 )\r
613/*++\r
614\r
615Routine Description:\r
616\r
617 Raising to the task priority level of the mutual exclusion\r
618 lock, and then acquires ownership of the lock.\r
619 \r
620Arguments:\r
621\r
622 Lock - The lock to acquire\r
623 \r
624Returns:\r
625\r
626 None\r
627\r
628--*/\r
629;\r
630\r
631EFI_STATUS\r
632EfiAcquireLockOrFail (\r
633 IN EFI_LOCK *Lock\r
634 )\r
635/*++\r
636\r
637Routine Description:\r
638\r
639 Initialize a basic mutual exclusion lock. Each lock\r
640 provides mutual exclusion access at it's task priority\r
641 level. Since there is no-premption (at any TPL) or\r
642 multiprocessor support, acquiring the lock only consists\r
643 of raising to the locks TPL.\r
644 \r
645Arguments:\r
646\r
647 Lock - The EFI_LOCK structure to initialize\r
648 \r
649Returns:\r
650\r
651 EFI_SUCCESS - Lock Owned.\r
652 EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.\r
653\r
654--*/\r
655;\r
656\r
657VOID\r
658EfiReleaseLock (\r
659 IN EFI_LOCK *Lock\r
660 )\r
661/*++\r
662\r
663Routine Description:\r
664\r
665 Releases ownership of the mutual exclusion lock, and\r
666 restores the previous task priority level.\r
667 \r
668Arguments:\r
669\r
670 Lock - The lock to release\r
671 \r
672Returns:\r
673\r
674 None\r
675\r
676--*/\r
677;\r
678\r
679VOID *\r
680EfiLibAllocatePool (\r
681 IN UINTN AllocationSize\r
682 )\r
683/*++\r
684\r
685Routine Description:\r
686\r
687 Allocate EfiBootServicesData pool of size AllocationSize\r
688\r
689Arguments:\r
690\r
691 AllocationSize - Pool size\r
692\r
693Returns:\r
694\r
695 Pointer to the pool allocated\r
696\r
697--*/\r
698;\r
699\r
700VOID *\r
701EfiLibAllocateRuntimePool (\r
702 IN UINTN AllocationSize\r
703 )\r
704/*++\r
705\r
706Routine Description:\r
707\r
708 Allocate EfiRuntimeServicesData pool of size AllocationSize\r
709\r
710Arguments:\r
711\r
712 AllocationSize - Pool size\r
713\r
714Returns:\r
715\r
716 Pointer to the pool allocated\r
717\r
718--*/\r
719;\r
720\r
721VOID *\r
722EfiLibAllocateZeroPool (\r
723 IN UINTN AllocationSize\r
724 )\r
725/*++\r
726\r
727Routine Description:\r
728\r
729 Allocate EfiBootServicesData pool of size AllocationSize and set memory to zero.\r
730\r
731Arguments:\r
732\r
733 AllocationSize - Pool size\r
734\r
735Returns:\r
736\r
737 Pointer to the pool allocated\r
738\r
739--*/\r
740;\r
741\r
742VOID *\r
743EfiLibAllocateRuntimeZeroPool (\r
744 IN UINTN AllocationSize\r
745 )\r
746/*++\r
747\r
748Routine Description:\r
749\r
750 Allocate EfiRuntimeServicesData pool of size AllocationSize and set memory to zero.\r
751\r
752Arguments:\r
753\r
754 AllocationSize - Pool size\r
755\r
756Returns:\r
757\r
758 Pointer to the pool allocated\r
759\r
760--*/\r
761;\r
762\r
763VOID *\r
764EfiLibAllocateCopyPool (\r
765 IN UINTN AllocationSize,\r
766 IN VOID *Buffer\r
767 )\r
768/*++\r
769\r
770Routine Description:\r
771\r
772 Allocate BootServicesData pool and use a buffer provided by \r
773 caller to fill it.\r
774\r
775Arguments:\r
776\r
777 AllocationSize - The size to allocate\r
778 \r
779 Buffer - Buffer that will be filled into the buffer allocated\r
780\r
781Returns:\r
782\r
783 Pointer of the buffer allocated.\r
784\r
785--*/\r
786;\r
787\r
788VOID *\r
789EfiLibAllocateRuntimeCopyPool (\r
790 IN UINTN AllocationSize,\r
791 IN VOID *Buffer\r
792 )\r
793/*++\r
794\r
795Routine Description:\r
796\r
797 Allocate RuntimeServicesData pool and use a buffer provided by \r
798 caller to fill it.\r
799\r
800Arguments:\r
801\r
802 AllocationSize - The size to allocate\r
803 \r
804 Buffer - Buffer that will be filled into the buffer allocated\r
805\r
806Returns:\r
807\r
808 Pointer of the buffer allocated.\r
809\r
810--*/\r
811;\r
812\r
813//\r
814// Event.c\r
815//\r
816EFI_EVENT\r
817EfiLibCreateProtocolNotifyEvent (\r
818 IN EFI_GUID *ProtocolGuid,\r
819 IN EFI_TPL NotifyTpl,\r
820 IN EFI_EVENT_NOTIFY NotifyFunction,\r
821 IN VOID *NotifyContext,\r
822 OUT VOID **Registration\r
823 )\r
824/*++\r
825\r
826Routine Description:\r
827\r
828 Create a protocol notification event and return it.\r
829\r
830Arguments:\r
831\r
832 ProtocolGuid - Protocol to register notification event on.\r
833\r
834 NotifyTpl - Maximum TPL to single the NotifyFunction.\r
835\r
836 NotifyFunction - EFI notification routine.\r
837\r
838 NotifyContext - Context passed into Event when it is created.\r
839\r
840 Registration - Registration key returned from RegisterProtocolNotify().\r
841\r
842Returns:\r
843\r
844 The EFI_EVENT that has been registered to be signaled when a ProtocolGuid\r
845 is added to the system.\r
846\r
847--*/\r
848;\r
849\r
850EFI_STATUS\r
851EfiLibNamedEventSignal (\r
852 IN EFI_GUID *Name\r
853 )\r
854/*++\r
855\r
856Routine Description:\r
857 Signals a named event. All registered listeners will run.\r
858 The listeners should register using EfiLibNamedEventListen() function.\r
859\r
860 NOTE: For now, the named listening/signalling is implemented\r
861 on a protocol interface being installed and uninstalled.\r
862 In the future, this maybe implemented based on a dedicated mechanism.\r
863\r
864Arguments:\r
865 Name - Name to perform the signaling on. The name is a GUID.\r
866\r
867Returns:\r
868 EFI_SUCCESS if successfull.\r
869\r
870--*/\r
871;\r
872\r
873EFI_STATUS\r
874EfiLibNamedEventListen (\r
875 IN EFI_GUID * Name,\r
876 IN EFI_TPL NotifyTpl,\r
877 IN EFI_EVENT_NOTIFY NotifyFunction,\r
878 IN VOID *NotifyContext\r
879 )\r
880/*++\r
881\r
882Routine Description:\r
883 Listenes to signals on the name.\r
884 EfiLibNamedEventSignal() signals the event.\r
885\r
886 NOTE: For now, the named listening/signalling is implemented\r
887 on a protocol interface being installed and uninstalled.\r
888 In the future, this maybe implemented based on a dedicated mechanism.\r
889\r
890Arguments:\r
891 Name - Name to register the listener on.\r
892 NotifyTpl - Maximum TPL to singnal the NotifyFunction.\r
893 NotifyFunction - The listener routine.\r
894 NotifyContext - Context passed into the listener routine.\r
895\r
896Returns:\r
897 EFI_SUCCESS if successful.\r
898\r
899--*/\r
900;\r
901\r
902//\r
903// Handle.c\r
904//\r
905EFI_STATUS\r
906EfiLibLocateHandleProtocolByProtocols (\r
907 IN OUT EFI_HANDLE * Handle, OPTIONAL\r
908 OUT VOID **Interface, OPTIONAL\r
909 ...\r
910 )\r
911/*++\r
912Routine Description:\r
913\r
914 Function locates Protocol and/or Handle on which all Protocols specified\r
915 as a variable list are installed.\r
916 It supports continued search. The caller must assure that no handles are added\r
917 or removed while performing continued search, by e.g., rising the TPL and not\r
918 calling any handle routines. Otherwise the behavior is undefined.\r
919\r
920Arguments:\r
921\r
922 Handle - The address of handle to receive the handle on which protocols\r
923 indicated by the variable list are installed.\r
924 If points to NULL, all handles are searched. If pointing to a\r
925 handle returned from previous call, searches starting from next handle.\r
926 If NULL, the parameter is ignored.\r
927\r
928 Interface - The address of a pointer to a protocol interface that will receive\r
929 the interface indicated by first variable argument.\r
930 If NULL, the parameter is ignored.\r
931\r
932 ... - A variable argument list containing protocol GUIDs. Must end with NULL.\r
933\r
934Returns:\r
935\r
936 EFI_SUCCESS - All the protocols where found on same handle.\r
937 EFI_NOT_FOUND - A Handle with all the protocols installed was not found.\r
938 Other values as may be returned from LocateHandleBuffer() or HandleProtocol().\r
939\r
940--*/\r
941;\r
942\r
943//\r
944// Debug.c init\r
945//\r
946EFI_STATUS\r
947EfiDebugAssertInit (\r
948 VOID\r
949 )\r
950/*++\r
951\r
952Routine Description:\r
953 \r
954 Locate Debug Assert Protocol and set as mDebugAssert\r
955\r
956Arguments:\r
957\r
958 None\r
959\r
960Returns:\r
961\r
962 Status code\r
963\r
964--*/\r
965;\r
966\r
967//\r
968// Unicode String Support\r
969//\r
970EFI_STATUS\r
971EfiLibLookupUnicodeString (\r
972 CHAR8 *Language,\r
973 CHAR8 *SupportedLanguages,\r
974 EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
975 CHAR16 **UnicodeString\r
976 )\r
977/*++\r
978\r
979Routine Description:\r
980\r
981 Translate a unicode string to a specified language if supported.\r
982 \r
983Arguments:\r
984\r
985 Language - The name of language to translate to\r
986 SupportedLanguages - Supported languages set\r
987 UnicodeStringTable - Pointer of one item in translation dictionary\r
988 UnicodeString - The translated string\r
989\r
990Returns: \r
991\r
992 EFI_INVALID_PARAMETER - Invalid parameter\r
993 EFI_UNSUPPORTED - System not supported this language or this string translation\r
994 EFI_SUCCESS - String successfully translated\r
995\r
996--*/\r
997;\r
998\r
999EFI_STATUS\r
1000EfiLibAddUnicodeString (\r
1001 CHAR8 *Language,\r
1002 CHAR8 *SupportedLanguages,\r
1003 EFI_UNICODE_STRING_TABLE **UnicodeStringTable,\r
1004 CHAR16 *UnicodeString\r
1005 )\r
1006/*++\r
1007\r
1008Routine Description:\r
1009\r
1010 Add an translation to the dictionary if this language if supported.\r
1011 \r
1012Arguments:\r
1013\r
1014 Language - The name of language to translate to\r
1015 SupportedLanguages - Supported languages set\r
1016 UnicodeStringTable - Translation dictionary\r
1017 UnicodeString - The corresponding string for the language to be translated to\r
1018\r
1019Returns: \r
1020\r
1021 EFI_INVALID_PARAMETER - Invalid parameter\r
1022 EFI_UNSUPPORTED - System not supported this language\r
1023 EFI_ALREADY_STARTED - Already has a translation item of this language\r
1024 EFI_OUT_OF_RESOURCES - No enough buffer to be allocated\r
1025 EFI_SUCCESS - String successfully translated\r
1026\r
1027--*/\r
1028;\r
1029\r
1030EFI_STATUS\r
1031EfiLibFreeUnicodeStringTable (\r
1032 EFI_UNICODE_STRING_TABLE *UnicodeStringTable\r
1033 )\r
1034/*++\r
1035\r
1036Routine Description:\r
1037\r
1038 Free a string table.\r
1039\r
1040Arguments:\r
1041\r
1042 UnicodeStringTable - The string table to be freed.\r
1043\r
1044Returns: \r
1045\r
1046 EFI_SUCCESS - The table successfully freed.\r
1047\r
1048--*/\r
1049;\r
1050\r
1051EFI_STATUS\r
1052EfiLibReportStatusCode (\r
1053 IN EFI_STATUS_CODE_TYPE Type,\r
1054 IN EFI_STATUS_CODE_VALUE Value,\r
1055 IN UINT32 Instance,\r
1056 IN EFI_GUID *CallerId OPTIONAL,\r
1057 IN EFI_STATUS_CODE_DATA *Data OPTIONAL \r
1058 )\r
1059/*++\r
1060\r
1061Routine Description:\r
1062\r
1063 Report status code.\r
1064\r
1065Arguments:\r
1066\r
1067 Type - Code type\r
1068 Value - Code value\r
1069 Instance - Instance number\r
1070 CallerId - Caller name\r
1071 DevicePath - Device path that to be reported\r
1072\r
1073Returns:\r
1074\r
1075 Status code.\r
1076\r
1077 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
1078\r
1079--*/\r
1080;\r
1081\r
1082EFI_STATUS\r
1083ReportStatusCodeWithDevicePath (\r
1084 IN EFI_STATUS_CODE_TYPE Type,\r
1085 IN EFI_STATUS_CODE_VALUE Value,\r
1086 IN UINT32 Instance,\r
1087 IN EFI_GUID * CallerId OPTIONAL,\r
1088 IN EFI_DEVICE_PATH_PROTOCOL * DevicePath\r
1089 )\r
1090/*++\r
1091\r
1092Routine Description:\r
1093\r
1094 Report device path through status code.\r
1095\r
1096Arguments:\r
1097\r
1098 Type - Code type\r
1099 Value - Code value\r
1100 Instance - Instance number\r
1101 CallerId - Caller name\r
1102 DevicePath - Device path that to be reported\r
1103\r
1104Returns:\r
1105\r
1106 Status code.\r
1107\r
1108 EFI_OUT_OF_RESOURCES - No enough buffer could be allocated\r
1109\r
1110--*/\r
1111;\r
1112\r
1113EFI_STATUS\r
1114EFIAPI\r
1115EfiCreateEventLegacyBoot (\r
1116 IN EFI_TPL NotifyTpl,\r
1117 IN EFI_EVENT_NOTIFY NotifyFunction,\r
1118 IN VOID *NotifyContext,\r
1119 OUT EFI_EVENT *LegacyBootEvent\r
1120 )\r
1121/*++\r
1122\r
1123Routine Description:\r
1124 Create a Legacy Boot Event. \r
1125 Tiano extended the CreateEvent Type enum to add a legacy boot event type. \r
1126 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
1127 added and now it's possible to not voilate the UEFI specification by \r
1128 declaring a GUID for the legacy boot event class. This library supports\r
1129 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
1130 work both ways.\r
1131\r
1132Arguments:\r
1133 LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)\r
1134\r
1135Returns:\r
1136 EFI_SUCCESS Event was created.\r
1137 Other Event was not created.\r
1138\r
1139--*/\r
1140;\r
1141\r
1142EFI_STATUS\r
1143EFIAPI\r
1144EfiCreateEventReadyToBoot (\r
1145 IN EFI_TPL NotifyTpl,\r
1146 IN EFI_EVENT_NOTIFY NotifyFunction,\r
1147 IN VOID *NotifyContext,\r
1148 OUT EFI_EVENT *ReadyToBootEvent\r
1149 )\r
1150/*++\r
1151\r
1152Routine Description:\r
1153 Create a Read to Boot Event. \r
1154 \r
1155 Tiano extended the CreateEvent Type enum to add a ready to boot event type. \r
1156 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was\r
1157 added and now it's possible to not voilate the UEFI specification and use \r
1158 the ready to boot event class defined in UEFI 2.0. This library supports\r
1159 the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to \r
1160 work both ways.\r
1161\r
1162Arguments:\r
1163 @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)\r
1164\r
1165Return:\r
1166 EFI_SUCCESS - Event was created.\r
1167 Other - Event was not created.\r
1168\r
1169--*/\r
1170;\r
1171\r
1172VOID\r
1173EFIAPI\r
1174EfiInitializeFwVolDevicepathNode (\r
1175 IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,\r
1176 IN EFI_GUID *NameGuid\r
1177 )\r
1178/*++\r
1179Routine Description:\r
1180 Initialize a Firmware Volume (FV) Media Device Path node.\r
1181 \r
1182 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
1183 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
1184 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
1185 device path is defined for PIWG extensions of device path. If the code \r
1186 is compiled to conform with the UEFI 2.0 specification use the new device path\r
1187 else use the old form for backwards compatability.\r
1188\r
1189Arguments:\r
1190 FvDevicePathNode - Pointer to a FV device path node to initialize\r
1191 NameGuid - FV file name to use in FvDevicePathNode\r
1192\r
1193--*/\r
1194;\r
1195\r
1196EFI_GUID *\r
1197EFIAPI\r
1198EfiGetNameGuidFromFwVolDevicePathNode (\r
1199 IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode\r
1200 )\r
1201/*++\r
1202Routine Description:\r
1203 Check to see if the Firmware Volume (FV) Media Device Path is valid.\r
1204 \r
1205 Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
1206 so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
1207 the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
1208 device path is defined for PIWG extensions of device path. If the code \r
1209 is compiled to conform with the UEFI 2.0 specification use the new device path\r
1210 else use the old form for backwards compatability. The return value to this\r
1211 function points to a location in FvDevicePathNode and it does not allocate\r
1212 new memory for the GUID pointer that is returned.\r
1213\r
1214Arguments:\r
1215 FvDevicePathNode - Pointer to FV device path to check\r
1216\r
1217Return:\r
1218 NULL - FvDevicePathNode is not valid.\r
1219 Other - FvDevicePathNode is valid and pointer to NameGuid was returned.\r
1220\r
1221--*/\r
1222;\r
1223\r
1224VOID\r
1225EfiLibSafeFreePool (\r
1226 IN VOID *Buffer\r
1227 )\r
1228/*++\r
1229\r
1230Routine Description:\r
1231\r
1232 Free pool safely.\r
1233\r
1234Arguments:\r
1235 \r
1236 Buffer - The allocated pool entry to free\r
1237\r
1238Returns:\r
1239\r
1240 Pointer of the buffer allocated.\r
1241\r
1242--*/\r
1243;\r
1244\r
1245EFI_STATUS\r
1246EfiLibTestManagedDevice (\r
1247 IN EFI_HANDLE ControllerHandle,\r
1248 IN EFI_HANDLE DriverBindingHandle,\r
1249 IN EFI_GUID *ManagedProtocolGuid\r
1250 )\r
1251/*++\r
1252\r
1253Routine Description:\r
1254\r
1255 Test to see if the controller is managed by a specific driver.\r
1256\r
1257Arguments:\r
1258\r
1259 ControllerHandle - Handle for controller to test\r
1260\r
1261 DriverBindingHandle - Driver binding handle for controller\r
1262\r
1263 ManagedProtocolGuid - The protocol guid the driver opens on controller\r
1264\r
1265Returns: \r
1266\r
1267 EFI_SUCCESS - The controller is managed by the driver\r
1268\r
1269 EFI_UNSUPPORTED - The controller is not managed by the driver\r
1270\r
1271--*/\r
1272;\r
1273\r
1274EFI_STATUS\r
1275EfiLibTestChildHandle (\r
1276 IN EFI_HANDLE ControllerHandle,\r
1277 IN EFI_HANDLE ChildHandle,\r
1278 IN EFI_GUID *ConsumedGuid\r
1279 )\r
1280/*++\r
1281\r
1282Routine Description:\r
1283\r
1284 Test to see if the child handle is the child of the controller\r
1285\r
1286Arguments:\r
1287\r
1288 ControllerHandle - Handle for controller (parent)\r
1289\r
1290 ChildHandle - Child handle to test\r
1291\r
1292 ConsumsedGuid - Protocol guid consumed by child from controller\r
1293\r
1294Returns: \r
1295\r
1296 EFI_SUCCESS - The child handle is the child of the controller\r
1297\r
1298 EFI_UNSUPPORTED - The child handle is not the child of the controller\r
1299\r
1300--*/\r
1301;\r
1302#endif\r