]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Dxe/Include/LinkedList.h
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / Include / LinkedList.h
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2004, 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 LinkedList.h\r
15\r
16Abstract:\r
17\r
18 This implementation of a linked list provides data structures for the\r
19 list itself and for list nodes. It provides operations for initializing\r
20 the list, modifying the list, and walking the list. \r
21 \r
22--*/\r
23\r
24//\r
25// Prevent multiple includes in the same source file\r
26//\r
27#ifndef _LINKED_LIST_H_\r
28#define _LINKED_LIST_H_\r
29\r
30\r
31typedef struct _EFI_LIST_ENTRY {\r
32 struct _EFI_LIST_ENTRY *ForwardLink;\r
33 struct _EFI_LIST_ENTRY *BackLink;\r
34} EFI_LIST_ENTRY;\r
35\r
36typedef EFI_LIST_ENTRY EFI_LIST; \r
37typedef EFI_LIST_ENTRY EFI_LIST_NODE;\r
38\r
39#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}\r
40\r
41//\r
42// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure\r
43//\r
44 \r
45#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))\r
46\r
47//\r
48// A lock structure\r
49//\r
50\r
51typedef struct {\r
52 EFI_TPL Tpl;\r
53 EFI_TPL OwnerTpl;\r
54 UINTN Lock;\r
55} FLOCK;\r
56\r
57VOID\r
58InitializeListHead (\r
59 EFI_LIST_ENTRY *List\r
60 )\r
61/*++\r
62\r
63Routine Description:\r
64\r
65 Initialize the head of the List. The caller must allocate the memory \r
66 for the EFI_LIST. This function must be called before the other linked\r
67 list macros can be used.\r
68 \r
69Arguments:\r
70\r
71 List - Pointer to list head to initialize\r
72 \r
73Returns:\r
74\r
75 None.\r
76\r
77--*/\r
78;\r
79\r
80BOOLEAN\r
81IsListEmpty (\r
82 EFI_LIST_ENTRY *List\r
83 )\r
84/*++\r
85\r
86Routine Description:\r
87\r
88 Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
89 The list must have been initialized with InitializeListHead () before using \r
90 this function.\r
91 \r
92Arguments:\r
93\r
94 List - Pointer to list head to test\r
95\r
96 \r
97Returns:\r
98\r
99 Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
100\r
101--*/\r
102;\r
103\r
104VOID\r
105RemoveEntryList (\r
106 EFI_LIST_ENTRY *Entry\r
107 )\r
108/*++\r
109\r
110Routine Description:\r
111\r
112 Remove Node from the doubly linked list. It is the caller's responsibility\r
113 to free any memory used by the entry if needed. The list must have been \r
114 initialized with InitializeListHead () before using this function.\r
115 \r
116Arguments:\r
117\r
118 Entry - Element to remove from the list.\r
119 \r
120Returns:\r
121 \r
122 None\r
123\r
124--*/\r
125;\r
126\r
127VOID\r
128InsertTailList (\r
129 EFI_LIST_ENTRY *ListHead,\r
130 EFI_LIST_ENTRY *Entry\r
131 )\r
132/*++\r
133\r
134Routine Description:\r
135\r
136 Insert a Node into the end of a doubly linked list. The list must have \r
137 been initialized with InitializeListHead () before using this function.\r
138 \r
139Arguments:\r
140\r
141 ListHead - Head of doubly linked list\r
142\r
143 Entry - Element to insert at the end of the list.\r
144 \r
145Returns:\r
146 \r
147 None\r
148\r
149--*/\r
150;\r
151\r
152VOID\r
153InsertHeadList (\r
154 EFI_LIST_ENTRY *ListHead,\r
155 EFI_LIST_ENTRY *Entry\r
156 )\r
157/*++\r
158\r
159Routine Description:\r
160\r
161 Insert a Node into the start of a doubly linked list. The list must have \r
162 been initialized with InitializeListHead () before using this function.\r
163 \r
164Arguments:\r
165\r
166 ListHead - Head of doubly linked list\r
167\r
168 Entry - Element to insert to beginning of list\r
169 \r
170Returns:\r
171 \r
172 None\r
173\r
174--*/\r
175;\r
176\r
177VOID\r
178SwapListEntries (\r
179 EFI_LIST_ENTRY *Entry1,\r
180 EFI_LIST_ENTRY *Entry2\r
181 )\r
182/*++\r
183\r
184Routine Description:\r
185\r
186 Swap the location of the two elements of a doubly linked list. Node2 \r
187 is placed in front of Node1. The list must have been initialized with \r
188 InitializeListHead () before using this function.\r
189 \r
190Arguments:\r
191\r
192 Entry1 - Element in the doubly linked list in front of Node2. \r
193\r
194 Entry2 - Element in the doubly linked list behind Node1.\r
195 \r
196Returns:\r
197 \r
198 None\r
199\r
200--*/\r
201;\r
202\r
203EFI_LIST_ENTRY *\r
204GetFirstNode (\r
205 EFI_LIST_ENTRY *List \r
206 )\r
207/*++\r
208\r
209Routine Description:\r
210\r
211 Return the first node pointed to by the list head. The list must \r
212 have been initialized with InitializeListHead () before using this \r
213 function and must contain data.\r
214 \r
215Arguments:\r
216\r
217 List - The head of the doubly linked list.\r
218 \r
219Returns:\r
220 \r
221 Pointer to the first node, if the list contains nodes. The list will\r
222 return a null value--that is, the value of List--when the list is empty.\r
223 See the description of IsNull for more information.\r
224\r
225\r
226--*/\r
227;\r
228\r
229EFI_LIST_ENTRY *\r
230GetNextNode (\r
231 EFI_LIST_ENTRY *List,\r
232 EFI_LIST_ENTRY *Node\r
233 )\r
234/*++\r
235\r
236Routine Description:\r
237\r
238 Returns the node following Node in the list. The list must \r
239 have been initialized with InitializeListHead () before using this \r
240 function and must contain data.\r
241 \r
242Arguments:\r
243\r
244 List - The head of the list. MUST NOT be the literal value NULL.\r
245 Node - The node in the list. This value MUST NOT be the literal value NULL.\r
246 See the description of IsNull for more information.\r
247 \r
248Returns:\r
249 \r
250 Pointer to the next node, if one exists. Otherwise, returns a null value,\r
251 which is actually a pointer to List.\r
252 See the description of IsNull for more information.\r
253\r
254--*/\r
255;\r
256\r
257BOOLEAN \r
258IsNull ( \r
259 EFI_LIST_ENTRY *List,\r
260 EFI_LIST_ENTRY *Node \r
261 )\r
262/*++\r
263\r
264Routine Description:\r
265\r
266 Determines whether the given node is null. Note that Node is null\r
267 when its value is equal to the value of List. It is an error for\r
268 Node to be the literal value NULL [(VOID*)0x0].\r
269\r
270Arguments:\r
271\r
272 List - The head of the list. MUST NOT be the literal value NULL.\r
273 Node - The node to test. MUST NOT be the literal value NULL. See\r
274 the description above.\r
275 \r
276Returns:\r
277 \r
278 Returns true if the node is null.\r
279\r
280--*/\r
281;\r
282\r
283BOOLEAN \r
284IsNodeAtEnd ( \r
285 EFI_LIST_ENTRY *List, \r
286 EFI_LIST_ENTRY *Node \r
287 )\r
288/*++\r
289\r
290Routine Description:\r
291\r
292 Determines whether the given node is at the end of the list. Used\r
293 to walk the list. The list must have been initialized with \r
294 InitializeListHead () before using this function and must contain \r
295 data.\r
296\r
297Arguments:\r
298\r
299 List - The head of the list. MUST NOT be the literal value NULL.\r
300 Node - The node to test. MUST NOT be the literal value NULL.\r
301 See the description of IsNull for more information.\r
302 \r
303Returns:\r
304 \r
305 Returns true if the list is the tail.\r
306\r
307--*/\r
308;\r
309\r
310#endif\r