Rev 2726 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2726 | vana | 1 | #ifndef _EFI_LINK_H |
2 | #define _EFI_LINK_H |
||
3 | |||
4 | /*++ |
||
5 | |||
6 | Copyright (c) 1998 Intel Corporation |
||
7 | |||
8 | Module Name: |
||
9 | |||
10 | link.h (renamed efilink.h to avoid conflicts) |
||
11 | |||
12 | Abstract: |
||
13 | |||
14 | EFI link list macro's |
||
15 | |||
16 | |||
17 | |||
18 | Revision History |
||
19 | |||
20 | --*/ |
||
21 | |||
22 | #ifndef EFI_NT_EMUL |
||
23 | |||
24 | // |
||
25 | // List entry - doubly linked list |
||
26 | // |
||
27 | |||
28 | typedef struct _LIST_ENTRY { |
||
29 | struct _LIST_ENTRY *Flink; |
||
30 | struct _LIST_ENTRY *Blink; |
||
31 | } LIST_ENTRY; |
||
32 | |||
33 | #endif |
||
34 | |||
35 | |||
36 | // |
||
37 | // VOID |
||
38 | // InitializeListHead( |
||
39 | // LIST_ENTRY *ListHead |
||
40 | // ); |
||
41 | // |
||
42 | |||
43 | #define InitializeListHead(ListHead) \ |
||
44 | (ListHead)->Flink = ListHead; \ |
||
45 | (ListHead)->Blink = ListHead; |
||
46 | |||
47 | // |
||
48 | // BOOLEAN |
||
49 | // IsListEmpty( |
||
50 | // PLIST_ENTRY ListHead |
||
51 | // ); |
||
52 | // |
||
53 | |||
54 | #define IsListEmpty(ListHead) \ |
||
55 | ((ListHead)->Flink == (ListHead)) |
||
56 | |||
57 | // |
||
58 | // VOID |
||
59 | // RemoveEntryList( |
||
60 | // PLIST_ENTRY Entry |
||
61 | // ); |
||
62 | // |
||
63 | |||
64 | #define _RemoveEntryList(Entry) { \ |
||
65 | LIST_ENTRY *_Blink, *_Flink; \ |
||
66 | _Flink = (Entry)->Flink; \ |
||
67 | _Blink = (Entry)->Blink; \ |
||
68 | _Blink->Flink = _Flink; \ |
||
69 | _Flink->Blink = _Blink; \ |
||
70 | } |
||
71 | |||
72 | #if EFI_DEBUG |
||
73 | #define RemoveEntryList(Entry) \ |
||
74 | _RemoveEntryList(Entry); \ |
||
75 | (Entry)->Flink = (LIST_ENTRY *) BAD_POINTER; \ |
||
76 | (Entry)->Blink = (LIST_ENTRY *) BAD_POINTER; |
||
77 | #else |
||
78 | #define RemoveEntryList(Entry) \ |
||
79 | _RemoveEntryList(Entry); |
||
80 | #endif |
||
81 | |||
82 | // |
||
83 | // VOID |
||
84 | // InsertTailList( |
||
85 | // PLIST_ENTRY ListHead, |
||
86 | // PLIST_ENTRY Entry |
||
87 | // ); |
||
88 | // |
||
89 | |||
90 | #define InsertTailList(ListHead,Entry) {\ |
||
91 | LIST_ENTRY *_ListHead, *_Blink; \ |
||
92 | _ListHead = (ListHead); \ |
||
93 | _Blink = _ListHead->Blink; \ |
||
94 | (Entry)->Flink = _ListHead; \ |
||
95 | (Entry)->Blink = _Blink; \ |
||
96 | _Blink->Flink = (Entry); \ |
||
97 | _ListHead->Blink = (Entry); \ |
||
98 | } |
||
99 | |||
100 | // |
||
101 | // VOID |
||
102 | // InsertHeadList( |
||
103 | // PLIST_ENTRY ListHead, |
||
104 | // PLIST_ENTRY Entry |
||
105 | // ); |
||
106 | // |
||
107 | |||
108 | #define InsertHeadList(ListHead,Entry) {\ |
||
109 | LIST_ENTRY *_ListHead, *_Flink; \ |
||
110 | _ListHead = (ListHead); \ |
||
111 | _Flink = _ListHead->Flink; \ |
||
112 | (Entry)->Flink = _Flink; \ |
||
113 | (Entry)->Blink = _ListHead; \ |
||
114 | _Flink->Blink = (Entry); \ |
||
115 | _ListHead->Flink = (Entry); \ |
||
116 | } |
||
117 | |||
118 | // VOID |
||
119 | // SwapListEntries( |
||
120 | // PLIST_ENTRY Entry1, |
||
121 | // PLIST_ENTRY Entry2 |
||
122 | // ); |
||
123 | // |
||
124 | // Put Entry2 before Entry1 |
||
125 | // |
||
126 | #define SwapListEntries(Entry1,Entry2) {\ |
||
127 | LIST_ENTRY *Entry1Flink, *Entry1Blink; \ |
||
128 | LIST_ENTRY *Entry2Flink, *Entry2Blink; \ |
||
129 | Entry2Flink = (Entry2)->Flink; \ |
||
130 | Entry2Blink = (Entry2)->Blink; \ |
||
131 | Entry1Flink = (Entry1)->Flink; \ |
||
132 | Entry1Blink = (Entry1)->Blink; \ |
||
133 | Entry2Blink->Flink = Entry2Flink; \ |
||
134 | Entry2Flink->Blink = Entry2Blink; \ |
||
135 | (Entry2)->Flink = Entry1; \ |
||
136 | (Entry2)->Blink = Entry1Blink; \ |
||
137 | Entry1Blink->Flink = (Entry2); \ |
||
138 | (Entry1)->Blink = (Entry2); \ |
||
139 | } |
||
140 | |||
141 | // |
||
142 | // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure |
||
143 | // |
||
144 | |||
145 | #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field))) |
||
146 | |||
147 | // |
||
148 | // CONTAINING_RECORD - returns a pointer to the structure |
||
149 | // from one of it's elements. |
||
150 | // |
||
151 | |||
152 | #define _CR(Record, TYPE, Field) \ |
||
153 | ((TYPE *) ( (CHAR8 *)(Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) |
||
154 | |||
155 | #if EFI_DEBUG |
||
156 | #define CR(Record, TYPE, Field, Sig) \ |
||
157 | _CR(Record, TYPE, Field)->Signature != Sig ? \ |
||
158 | (TYPE *) ASSERT_STRUCT(_CR(Record, TYPE, Field), Record) : \ |
||
159 | _CR(Record, TYPE, Field) |
||
160 | #else |
||
161 | #define CR(Record, TYPE, Field, Signature) \ |
||
162 | _CR(Record, TYPE, Field) |
||
163 | #endif |
||
164 | |||
165 | |||
166 | // |
||
167 | // A lock structure |
||
168 | // |
||
169 | |||
170 | typedef struct _FLOCK { |
||
171 | EFI_TPL Tpl; |
||
172 | EFI_TPL OwnerTpl; |
||
173 | UINTN Lock; |
||
174 | } FLOCK; |
||
175 | |||
176 | #endif |
||
177 |