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