]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/UefiLib.h
PeiSmbusLib & DxeSmbusLib
[mirror_edk2.git] / MdePkg / Include / Library / UefiLib.h
CommitLineData
878ddf1f 1/** @file\r
2 MDE UEFI library functions and macros\r
3\r
4 Copyright (c) 2006, Intel Corporation \r
5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15#ifndef __UEFI_LIB_H__\r
16#define __UEFI_LIB_H__\r
17\r
18//\r
19// Unicode String Table\r
20//\r
21typedef struct {\r
22 CHAR8 *Language;\r
23 CHAR16 *UnicodeString;\r
24} EFI_UNICODE_STRING_TABLE;\r
25\r
26//\r
27// EFI Lock Status\r
28//\r
29typedef enum {\r
30 EfiLockUninitialized = 0,\r
31 EfiLockReleased = 1,\r
32 EfiLockAcquired = 2\r
33} EFI_LOCK_STATE;\r
34\r
35//\r
36// EFI Lock \r
37//\r
38typedef struct {\r
39 EFI_TPL Tpl;\r
40 EFI_TPL OwnerTpl;\r
41 EFI_LOCK_STATE Lock;\r
42} EFI_LOCK;\r
43\r
44\r
45/**\r
46 This function searches the list of configuration tables stored in the EFI System \r
47 Table for a table with a GUID that matches TableGuid. If a match is found, \r
48 then a pointer to the configuration table is returned in Table, and EFI_SUCCESS \r
49 is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned.\r
50\r
51 @param TableGuid Pointer to table's GUID type..\r
52 @param Table Pointer to the table associated with TableGuid in the EFI System Table.\r
53\r
54 @retval EFI_SUCCESS A configuration table matching TableGuid was found.\r
55 @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.\r
56\r
57**/\r
58EFI_STATUS\r
59EFIAPI\r
60EfiGetSystemConfigurationTable ( \r
61 IN EFI_GUID *TableGuid,\r
62 OUT VOID **Table\r
63 );\r
64\r
65/**\r
66 This function causes the notification function to be executed for every protocol \r
67 of type ProtocolGuid instance that exists in the system when this function is \r
68 invoked. In addition, every time a protocol of type ProtocolGuid instance is \r
69 installed or reinstalled, the notification function is also executed.\r
70\r
71 @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.\r
72 @param NotifyTpl Supplies the task priority level of the event notifications.\r
73 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
74 @param NotifyContext The context parameter to pass to NotifyFunction.\r
75 @param Registration A pointer to a memory location to receive the registration value.\r
76\r
77 @return The notification event that was created. \r
78\r
79**/\r
80EFI_EVENT\r
81EFIAPI\r
82EfiCreateProtocolNotifyEvent(\r
83 IN EFI_GUID *ProtocolGuid,\r
84 IN EFI_TPL NotifyTpl,\r
85 IN EFI_EVENT_NOTIFY NotifyFunction,\r
86 IN VOID *NotifyContext, OPTIONAL\r
87 OUT VOID *Registration\r
88 );\r
89\r
90/**\r
91 This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.\r
92 This event is signaled with EfiNamedEventSignal(). This provide the ability for \r
93 one or more listeners on the same event named by the GUID specified by Name.\r
94\r
95 @param Name Supplies GUID name of the event.\r
96 @param NotifyTpl Supplies the task priority level of the event notifications.\r
97 @param NotifyFunction Supplies the function to notify when the event is signaled.\r
98 @param NotifyContext The context parameter to pass to NotifyFunction. \r
99 @param Registration A pointer to a memory location to receive the registration value.\r
100\r
101 @retval EFI_SUCCESS A named event was created.\r
102 @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.\r
103\r
104**/\r
105EFI_STATUS\r
106EFIAPI\r
107EfiNamedEventListen (\r
108 IN CONST EFI_GUID *Name,\r
109 IN EFI_TPL NotifyTpl,\r
110 IN EFI_EVENT_NOTIFY NotifyFunction,\r
111 IN CONST VOID *NotifyContext, OPTIONAL\r
112 OUT VOID *Registration OPTIONAL\r
113 );\r
114\r
115/**\r
116 This function signals the named event specified by Name. The named event must \r
117 have been created with EfiNamedEventListen().\r
118\r
119 @param Name Supplies GUID name of the event.\r
120\r
121 @retval EFI_SUCCESS A named event was signaled.\r
122 @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.\r
123\r
124**/\r
125EFI_STATUS\r
126EFIAPI\r
127EfiNamedEventSignal (\r
128 IN CONST EFI_GUID *Name\r
129 );\r
130\r
131/**\r
132 This function initializes a basic mutual exclusion lock to the released state \r
133 and returns the lock. Each lock provides mutual exclusion access at its task \r
134 priority level. Since there is no preemption or multiprocessor support in EFI,\r
135 acquiring the lock only consists of raising to the locks TPL.\r
136\r
137 @param Lock A pointer to the lock data structure to initialize.\r
138 @param Priority EFI TPL associated with the lock.\r
139\r
140 @return The lock.\r
141\r
142**/\r
143EFI_LOCK *\r
144EFIAPI\r
145EfiInitializeLock (\r
146 IN OUT EFI_LOCK *Lock,\r
147 IN EFI_TPL Priority\r
148 );\r
149\r
150/**\r
151 This macro initializes the contents of a basic mutual exclusion lock to the \r
152 released state. Each lock provides mutual exclusion access at its task \r
153 priority level. Since there is no preemption or multiprocessor support in EFI,\r
154 acquiring the lock only consists of raising to the locks TPL.\r
155\r
156 @param Lock A pointer to the lock data structure to initialize.\r
157 @param Priority The task priority level of the lock.\r
158\r
159 @return The lock.\r
160\r
161**/\r
162#define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \\r
163 {Priority, EFI_TPL_APPLICATION, EfiLockReleased }\r
164\r
165\r
166/**\r
167 \r
168 Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.\r
169\r
170 If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, \r
171 then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock \r
172 is not in the locked state, then DebugAssert() is called passing in the source \r
173 filename, source line number, and Lock.\r
174\r
175 If Lock is NULL, then ASSERT().\r
176\r
177 @param LockParameter A pointer to the lock to acquire.\r
178\r
179**/\r
180#define ASSERT_LOCKED(LockParameter) \\r
181 do { \\r
182 if (DebugAssertEnabled ()) { \\r
183 ASSERT (LockParameter != NULL); \\r
184 if ((LockParameter)->Lock != EfiLockAcquired) { \\r
185 _ASSERT (LockParameter not locked); \\r
186 } \\r
187 } \\r
188 } while (FALSE)\r
189\r
190\r
191/**\r
192