3 Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This implementation of a linked list provides data structures for the
19 list itself and for list nodes. It provides operations for initializing
20 the list, modifying the list, and walking the list.
25 // Prevent multiple includes in the same source file
27 #ifndef _LINKED_LIST_H_
28 #define _LINKED_LIST_H_
30 #ifndef _SHELL_LINKED_LIST_H_
32 typedef struct _EFI_LIST_ENTRY
{
33 struct _EFI_LIST_ENTRY
*ForwardLink
;
34 struct _EFI_LIST_ENTRY
*BackLink
;
37 typedef EFI_LIST_ENTRY EFI_LIST
;
38 typedef EFI_LIST_ENTRY EFI_LIST_NODE
;
40 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
43 // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure
46 #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))
66 Initialize the head of the List. The caller must allocate the memory
67 for the EFI_LIST. This function must be called before the other linked
68 list macros can be used.
72 List - Pointer to list head to initialize
89 Return TRUE is the list contains zero nodes. Otherzise return FALSE.
90 The list must have been initialized with InitializeListHead () before using
95 List - Pointer to list head to test
100 Return TRUE is the list contains zero nodes. Otherzise return FALSE.
107 EFI_LIST_ENTRY
*Entry
113 Remove Node from the doubly linked list. It is the caller's responsibility
114 to free any memory used by the entry if needed. The list must have been
115 initialized with InitializeListHead () before using this function.
119 Entry - Element to remove from the list.
130 EFI_LIST_ENTRY
*ListHead
,
131 EFI_LIST_ENTRY
*Entry
137 Insert a Node into the end of a doubly linked list. The list must have
138 been initialized with InitializeListHead () before using this function.
142 ListHead - Head of doubly linked list
144 Entry - Element to insert at the end of the list.
155 EFI_LIST_ENTRY
*ListHead
,
156 EFI_LIST_ENTRY
*Entry
162 Insert a Node into the start of a doubly linked list. The list must have
163 been initialized with InitializeListHead () before using this function.
167 ListHead - Head of doubly linked list
169 Entry - Element to insert to beginning of list
180 EFI_LIST_ENTRY
*Entry1
,
181 EFI_LIST_ENTRY
*Entry2
187 Swap the location of the two elements of a doubly linked list. Node2
188 is placed in front of Node1. The list must have been initialized with
189 InitializeListHead () before using this function.
193 Entry1 - Element in the doubly linked list in front of Node2.
195 Entry2 - Element in the doubly linked list behind Node1.
212 Return the first node pointed to by the list head. The list must
213 have been initialized with InitializeListHead () before using this
214 function and must contain data.
218 List - The head of the doubly linked list.
222 Pointer to the first node, if the list contains nodes. The list will
223 return a null value--that is, the value of List--when the list is empty.
224 See the description of IsNull for more information.
232 EFI_LIST_ENTRY
*List
,
239 Returns the node following Node in the list. The list must
240 have been initialized with InitializeListHead () before using this
241 function and must contain data.
245 List - The head of the list. MUST NOT be the literal value NULL.
246 Node - The node in the list. This value MUST NOT be the literal value NULL.
247 See the description of IsNull for more information.
251 Pointer to the next node, if one exists. Otherwise, returns a null value,
252 which is actually a pointer to List.
253 See the description of IsNull for more information.
260 EFI_LIST_ENTRY
*List
,
267 Determines whether the given node is null. Note that Node is null
268 when its value is equal to the value of List. It is an error for
269 Node to be the literal value NULL [(VOID*)0x0].
273 List - The head of the list. MUST NOT be the literal value NULL.
274 Node - The node to test. MUST NOT be the literal value NULL. See
275 the description above.
279 Returns true if the node is null.
286 EFI_LIST_ENTRY
*List
,
293 Determines whether the given node is at the end of the list. Used
294 to walk the list. The list must have been initialized with
295 InitializeListHead () before using this function and must contain
300 List - The head of the list. MUST NOT be the literal value NULL.
301 Node - The node to test. MUST NOT be the literal value NULL.
302 See the description of IsNull for more information.
306 Returns true if the list is the tail.