xref: /freebsd/stand/efi/include/efidef.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 #ifndef _EFI_DEF_H
2 #define _EFI_DEF_H
3 
4 /*++
5 
6 Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
7 This software and associated documentation (if any) is furnished
8 under a license and may only be used or copied in accordance
9 with the terms of the license. Except as permitted by such
10 license, no part of this software or documentation may be
11 reproduced, stored in a retrieval system, or transmitted in any
12 form or by any means without the express written consent of
13 Intel Corporation.
14 
15 Module Name:
16 
17     efidef.h
18 
19 Abstract:
20 
21     EFI definitions
22 
23 
24 
25 
26 Revision History
27 
28 --*/
29 
30 typedef UINT16          CHAR16;
31 typedef UINT8           CHAR8;
32 #ifndef ACPI_THREAD_ID		/* ACPI's definitions are fine */
33 typedef UINT8           BOOLEAN;
34 #endif
35 
36 #ifndef TRUE
37     #define TRUE    ((BOOLEAN) 1)
38     #define FALSE   ((BOOLEAN) 0)
39 #endif
40 
41 #ifndef NULL
42     #define NULL    ((VOID *) 0)
43 #endif
44 
45 typedef UINTN           EFI_STATUS;
46 typedef UINT64          EFI_LBA;
47 typedef UINTN           EFI_TPL;
48 typedef VOID            *EFI_HANDLE;
49 typedef VOID            *EFI_EVENT;
50 
51 
52 //
53 // Prototype argument decoration for EFI parameters to indicate
54 // their direction
55 //
56 // IN - argument is passed into the function
57 // OUT - argument (pointer) is returned from the function
58 // OPTIONAL - argument is optional
59 //
60 
61 #ifndef IN
62     #define IN
63     #define OUT
64     #define OPTIONAL
65     #define CONST const
66 #endif
67 
68 
69 //
70 // A GUID
71 //
72 
73 typedef struct {
74     UINT32  Data1;
75     UINT16  Data2;
76     UINT16  Data3;
77     UINT8   Data4[8];
78 } EFI_GUID;
79 
80 
81 //
82 // Time
83 //
84 
85 typedef struct {
86     UINT16      Year;       // 1998 - 20XX
87     UINT8       Month;      // 1 - 12
88     UINT8       Day;        // 1 - 31
89     UINT8       Hour;       // 0 - 23
90     UINT8       Minute;     // 0 - 59
91     UINT8       Second;     // 0 - 59
92     UINT8       Pad1;
93     UINT32      Nanosecond; // 0 - 999,999,999
94     INT16       TimeZone;   // -1440 to 1440 or 2047
95     UINT8       Daylight;
96     UINT8       Pad2;
97 } EFI_TIME;
98 
99 // Bit definitions for EFI_TIME.Daylight
100 #define EFI_TIME_ADJUST_DAYLIGHT    0x01
101 #define EFI_TIME_IN_DAYLIGHT        0x02
102 
103 // Value definition for EFI_TIME.TimeZone
104 #define EFI_UNSPECIFIED_TIMEZONE    0x07FF
105 
106 
107 
108 //
109 // Networking
110 //
111 
112 typedef struct {
113     UINT8                   Addr[4];
114 } EFI_IPv4_ADDRESS;
115 
116 typedef struct {
117     UINT8                   Addr[16];
118 } EFI_IPv6_ADDRESS;
119 
120 typedef struct {
121     UINT8                   Addr[32];
122 } EFI_MAC_ADDRESS;
123 
124 typedef struct {
125     UINT32 ReceivedQueueTimeoutValue;
126     UINT32 TransmitQueueTimeoutValue;
127     UINT16 ProtocolTypeFilter;
128     BOOLEAN EnableUnicastReceive;
129     BOOLEAN EnableMulticastReceive;
130     BOOLEAN EnableBroadcastReceive;
131     BOOLEAN EnablePromiscuousReceive;
132     BOOLEAN FlushQueuesOnReset;
133     BOOLEAN EnableReceiveTimestamps;
134     BOOLEAN DisableBackgroundPolling;
135 } EFI_MANAGED_NETWORK_CONFIG_DATA;
136 
137 //
138 // Memory
139 //
140 
141 typedef UINT64          EFI_PHYSICAL_ADDRESS;
142 typedef UINT64          EFI_VIRTUAL_ADDRESS;
143 
144 typedef enum {
145     AllocateAnyPages,
146     AllocateMaxAddress,
147     AllocateAddress,
148     MaxAllocateType
149 } EFI_ALLOCATE_TYPE;
150 
151 //Preseve the attr on any range supplied.
152 //ConventialMemory must have WB,SR,SW when supplied.
153 //When allocating from ConventialMemory always make it WB,SR,SW
154 //When returning to ConventialMemory always make it WB,SR,SW
155 //When getting the memory map, or on RT for runtime types
156 
157 
158 typedef enum {
159     EfiReservedMemoryType,
160     EfiLoaderCode,
161     EfiLoaderData,
162     EfiBootServicesCode,
163     EfiBootServicesData,
164     EfiRuntimeServicesCode,
165     EfiRuntimeServicesData,
166     EfiConventionalMemory,
167     EfiUnusableMemory,
168     EfiACPIReclaimMemory,
169     EfiACPIMemoryNVS,
170     EfiMemoryMappedIO,
171     EfiMemoryMappedIOPortSpace,
172     EfiPalCode,
173     EfiPersistentMemory,
174     EfiMaxMemoryType
175 } EFI_MEMORY_TYPE;
176 
177 // possible caching types for the memory range
178 #define EFI_MEMORY_UC			0x0000000000000001
179 #define EFI_MEMORY_WC			0x0000000000000002
180 #define EFI_MEMORY_WT			0x0000000000000004
181 #define EFI_MEMORY_WB			0x0000000000000008
182 #define EFI_MEMORY_UCE			0x0000000000000010
183 
184 // physical memory protection on range
185 #define EFI_MEMORY_WP			0x0000000000001000
186 #define EFI_MEMORY_RP			0x0000000000002000
187 #define EFI_MEMORY_XP			0x0000000000004000
188 #define	EFI_MEMORY_NV			0x0000000000008000
189 #define	EFI_MEMORY_MORE_RELIABLE	0x0000000000010000
190 #define	EFI_MEMORY_RO			0x0000000000020000
191 
192 // range requires a runtime mapping
193 #define EFI_MEMORY_RUNTIME		0x8000000000000000
194 
195 #define EFI_MEMORY_DESCRIPTOR_VERSION  1
196 typedef struct {
197     UINT32                          Type;           // Field size is 32 bits followed by 32 bit pad
198     UINT32                          Pad;
199     EFI_PHYSICAL_ADDRESS            PhysicalStart;  // Field size is 64 bits
200     EFI_VIRTUAL_ADDRESS             VirtualStart;   // Field size is 64 bits
201     UINT64                          NumberOfPages;  // Field size is 64 bits
202     UINT64                          Attribute;      // Field size is 64 bits
203 } EFI_MEMORY_DESCRIPTOR;
204 
205 //
206 // International Language
207 //
208 
209 typedef UINT8   ISO_639_2;
210 #define ISO_639_2_ENTRY_SIZE    3
211 
212 //
213 //
214 //
215 
216 #define EFI_PAGE_SIZE   4096
217 #define EFI_PAGE_MASK   0xFFF
218 #define EFI_PAGE_SHIFT  12
219 
220 #define EFI_SIZE_TO_PAGES(a)  \
221     ( ((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0) )
222 
223 #endif
224