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_
31 typedef struct _EFI_LIST_ENTRY
{
32 struct _EFI_LIST_ENTRY
*ForwardLink
;
33 struct _EFI_LIST_ENTRY
*BackLink
;
36 typedef EFI_LIST_ENTRY EFI_LIST
;
37 typedef EFI_LIST_ENTRY EFI_LIST_NODE
;
39 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
42 // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure
45 #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))
65 Initialize the head of the List. The caller must allocate the memory
66 for the EFI_LIST. This function must be called before the other linked
67 list macros can be used.
71 List - Pointer to list head to initialize
88 Return TRUE is the list contains zero nodes. Otherzise return FALSE.
89 The list must have been initialized with InitializeListHead () before using
94 List - Pointer to list head to test
99 Return TRUE is the list contains zero nodes. Otherzise return FALSE.
106 EFI_LIST_ENTRY
*Entry
112 Remove Node from the doubly linked list. It is the caller's responsibility
113 to free any memory used by the entry if needed. The list must have been
114 initialized with InitializeListHead () before using this function.
118 Entry - Element to remove from the list.
129 EFI_LIST_ENTRY
*ListHead
,
130 EFI_LIST_ENTRY
*Entry
136 Insert a Node into the end of a doubly linked list. The list must have
137 been initialized with InitializeListHead () before using this function.
141 ListHead - Head of doubly linked list
143 Entry - Element to insert at the end of the list.
154 EFI_LIST_ENTRY
*ListHead
,
155 EFI_LIST_ENTRY
*Entry
161 Insert a Node into the start of a doubly linked list. The list must have
162 been initialized with InitializeListHead () before using this function.
166 ListHead - Head of doubly linked list
168 Entry - Element to insert to beginning of list
179 EFI_LIST_ENTRY
*Entry1
,
180 EFI_LIST_ENTRY
*Entry2
186 Swap the location of the two elements of a doubly linked list. Node2
187 is placed in front of Node1. The list must have been initialized with
188 InitializeListHead () before using this function.
192 Entry1 - Element in the doubly linked list in front of Node2.
194 Entry2 - Element in the doubly linked list behind Node1.
211 Return the first node pointed to by the list head. The list must
212 have been initialized with InitializeListHead () before using this
213 function and must contain data.
217 List - The head of the doubly linked list.
221 Pointer to the first node, if the list contains nodes. The list will
222 return a null value--that is, the value of List--when the list is empty.
223 See the description of IsNull for more information.
231 EFI_LIST_ENTRY
*List
,
238 Returns the node following Node in the list. The list must
239 have been initialized with InitializeListHead () before using this
240 function and must contain data.
244 List - The head of the list. MUST NOT be the literal value NULL.
245 Node - The node in the list. This value MUST NOT be the literal value NULL.
246 See the description of IsNull for more information.
250 Pointer to the next node, if one exists. Otherwise, returns a null value,
251 which is actually a pointer to List.
252 See the description of IsNull for more information.
259 EFI_LIST_ENTRY
*List
,
266 Determines whether the given node is null. Note that Node is null
267 when its value is equal to the value of List. It is an error for
268 Node to be the literal value NULL [(VOID*)0x0].
272 List - The head of the list. MUST NOT be the literal value NULL.
273 Node - The node to test. MUST NOT be the literal value NULL. See
274 the description above.
278 Returns true if the node is null.
285 EFI_LIST_ENTRY
*List
,
292 Determines whether the given node is at the end of the list. Used
293 to walk the list. The list must have been initialized with
294 InitializeListHead () before using this function and must contain
299 List - The head of the list. MUST NOT be the literal value NULL.
300 Node - The node to test. MUST NOT be the literal value NULL.
301 See the description of IsNull for more information.
305 Returns true if the list is the tail.