+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- LinkedList.h\r
-\r
-Abstract:\r
-\r
- This implementation of a linked list provides data structures for the\r
- list itself and for list nodes. It provides operations for initializing\r
- the list, modifying the list, and walking the list. \r
- \r
---*/\r
-\r
-//\r
-// Prevent multiple includes in the same source file\r
-//\r
-#ifndef _LINKED_LIST_H_\r
-#define _LINKED_LIST_H_\r
-\r
-#ifndef _SHELL_LINKED_LIST_H_\r
-\r
-typedef struct _EFI_LIST_ENTRY {\r
- struct _EFI_LIST_ENTRY *ForwardLink;\r
- struct _EFI_LIST_ENTRY *BackLink;\r
-} EFI_LIST_ENTRY;\r
-\r
-typedef EFI_LIST_ENTRY EFI_LIST; \r
-typedef EFI_LIST_ENTRY EFI_LIST_NODE;\r
-\r
-#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}\r
-\r
-//\r
-// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure\r
-//\r
- \r
-#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))\r
-\r
-//\r
-// A lock structure\r
-//\r
-\r
-typedef struct {\r
- EFI_TPL Tpl;\r
- EFI_TPL OwnerTpl;\r
- UINTN Lock;\r
-} FLOCK;\r
-\r
-VOID\r
-InitializeListHead (\r
- EFI_LIST_ENTRY *List\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Initialize the head of the List. The caller must allocate the memory \r
- for the EFI_LIST. This function must be called before the other linked\r
- list macros can be used.\r
- \r
-Arguments:\r
-\r
- List - Pointer to list head to initialize\r
- \r
-Returns:\r
-\r
- None.\r
-\r
---*/\r
-;\r
-\r
-BOOLEAN\r
-IsListEmpty (\r
- EFI_LIST_ENTRY *List\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
- The list must have been initialized with InitializeListHead () before using \r
- this function.\r
- \r
-Arguments:\r
-\r
- List - Pointer to list head to test\r
-\r
- \r
-Returns:\r
-\r
- Return TRUE is the list contains zero nodes. Otherzise return FALSE.\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-RemoveEntryList (\r
- EFI_LIST_ENTRY *Entry\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Remove Node from the doubly linked list. It is the caller's responsibility\r
- to free any memory used by the entry if needed. The list must have been \r
- initialized with InitializeListHead () before using this function.\r
- \r
-Arguments:\r
-\r
- Entry - Element to remove from the list.\r
- \r
-Returns:\r
- \r
- None\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-InsertTailList (\r
- EFI_LIST_ENTRY *ListHead,\r
- EFI_LIST_ENTRY *Entry\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Insert a Node into the end of a doubly linked list. The list must have \r
- been initialized with InitializeListHead () before using this function.\r
- \r
-Arguments:\r
-\r
- ListHead - Head of doubly linked list\r
-\r
- Entry - Element to insert at the end of the list.\r
- \r
-Returns:\r
- \r
- None\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-InsertHeadList (\r
- EFI_LIST_ENTRY *ListHead,\r
- EFI_LIST_ENTRY *Entry\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Insert a Node into the start of a doubly linked list. The list must have \r
- been initialized with InitializeListHead () before using this function.\r
- \r
-Arguments:\r
-\r
- ListHead - Head of doubly linked list\r
-\r
- Entry - Element to insert to beginning of list\r
- \r
-Returns:\r
- \r
- None\r
-\r
---*/\r
-;\r
-\r
-VOID\r
-SwapListEntries (\r
- EFI_LIST_ENTRY *Entry1,\r
- EFI_LIST_ENTRY *Entry2\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Swap the location of the two elements of a doubly linked list. Node2 \r
- is placed in front of Node1. The list must have been initialized with \r
- InitializeListHead () before using this function.\r
- \r
-Arguments:\r
-\r
- Entry1 - Element in the doubly linked list in front of Node2. \r
-\r
- Entry2 - Element in the doubly linked list behind Node1.\r
- \r
-Returns:\r
- \r
- None\r
-\r
---*/\r
-;\r
-\r
-EFI_LIST_ENTRY *\r
-GetFirstNode (\r
- EFI_LIST_ENTRY *List \r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Return the first node pointed to by the list head. The list must \r
- have been initialized with InitializeListHead () before using this \r
- function and must contain data.\r
- \r
-Arguments:\r
-\r
- List - The head of the doubly linked list.\r
- \r
-Returns:\r
- \r
- Pointer to the first node, if the list contains nodes. The list will\r
- return a null value--that is, the value of List--when the list is empty.\r
- See the description of IsNull for more information.\r
-\r
-\r
---*/\r
-;\r
-\r
-EFI_LIST_ENTRY *\r
-GetNextNode (\r
- EFI_LIST_ENTRY *List,\r
- EFI_LIST_ENTRY *Node\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Returns the node following Node in the list. The list must \r
- have been initialized with InitializeListHead () before using this \r
- function and must contain data.\r
- \r
-Arguments:\r
-\r
- List - The head of the list. MUST NOT be the literal value NULL.\r
- Node - The node in the list. This value MUST NOT be the literal value NULL.\r
- See the description of IsNull for more information.\r
- \r
-Returns:\r
- \r
- Pointer to the next node, if one exists. Otherwise, returns a null value,\r
- which is actually a pointer to List.\r
- See the description of IsNull for more information.\r
-\r
---*/\r
-;\r
-\r
-BOOLEAN \r
-IsNull ( \r
- EFI_LIST_ENTRY *List,\r
- EFI_LIST_ENTRY *Node \r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Determines whether the given node is null. Note that Node is null\r
- when its value is equal to the value of List. It is an error for\r
- Node to be the literal value NULL [(VOID*)0x0].\r
-\r
-Arguments:\r
-\r
- List - The head of the list. MUST NOT be the literal value NULL.\r
- Node - The node to test. MUST NOT be the literal value NULL. See\r
- the description above.\r
- \r
-Returns:\r
- \r
- Returns true if the node is null.\r
-\r
---*/\r
-;\r
-\r
-BOOLEAN \r
-IsNodeAtEnd ( \r
- EFI_LIST_ENTRY *List, \r
- EFI_LIST_ENTRY *Node \r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Determines whether the given node is at the end of the list. Used\r
- to walk the list. The list must have been initialized with \r
- InitializeListHead () before using this function and must contain \r
- data.\r
-\r
-Arguments:\r
-\r
- List - The head of the list. MUST NOT be the literal value NULL.\r
- Node - The node to test. MUST NOT be the literal value NULL.\r
- See the description of IsNull for more information.\r
- \r
-Returns:\r
- \r
- Returns true if the list is the tail.\r
-\r
---*/\r
-;\r
-\r
-#endif\r
-#endif\r