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