xref: /freebsd-12.1/stand/efi/include/efidef.h (revision 952f1bb5)
1 /* $FreeBSD$ */
2 #ifndef _EFI_DEF_H
3 #define _EFI_DEF_H
4 
5 /*++
6 
7 Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
8 This software and associated documentation (if any) is furnished
9 under a license and may only be used or copied in accordance
10 with the terms of the license. Except as permitted by such
11 license, no part of this software or documentation may be
12 reproduced, stored in a retrieval system, or transmitted in any
13 form or by any means without the express written consent of
14 Intel Corporation.
15 
16 Module Name:
17 
18     efidef.h
19 
20 Abstract:
21 
22     EFI definitions
23 
24 
25 
26 
27 Revision History
28 
29 --*/
30 
31 typedef UINT16          CHAR16;
32 typedef UINT8           CHAR8;
33 #ifndef ACPI_THREAD_ID		/* ACPI's definitions are fine */
34 typedef UINT8           BOOLEAN;
35 #endif
36 
37 #ifndef TRUE
38     #define TRUE    ((BOOLEAN) 1)
39     #define FALSE   ((BOOLEAN) 0)
40 #endif
41 
42 #ifndef NULL
43     #define NULL    ((VOID *) 0)
44 #endif
45 
46 typedef UINTN           EFI_STATUS;
47 typedef UINT64          EFI_LBA;
48 typedef UINTN           EFI_TPL;
49 typedef VOID            *EFI_HANDLE;
50 typedef VOID            *EFI_EVENT;
51 
52 
53 //
54 // Prototype argument decoration for EFI parameters to indicate
55 // their direction
56 //
57 // IN - argument is passed into the function
58 // OUT - argument (pointer) is returned from the function
59 // OPTIONAL - argument is optional
60 //
61 
62 #ifndef IN
63     #define IN
64     #define OUT
65     #define OPTIONAL
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 //
125 // Memory
126 //
127 
128 typedef UINT64          EFI_PHYSICAL_ADDRESS;
129 typedef UINT64          EFI_VIRTUAL_ADDRESS;
130 
131 typedef enum {
132     AllocateAnyPages,
133     AllocateMaxAddress,
134     AllocateAddress,
135     MaxAllocateType
136 } EFI_ALLOCATE_TYPE;
137 
138 //Preseve the attr on any range supplied.
139 //ConventialMemory must have WB,SR,SW when supplied.
140 //When allocating from ConventialMemory always make it WB,SR,SW
141 //When returning to ConventialMemory always make it WB,SR,SW
142 //When getting the memory map, or on RT for runtime types
143 
144 
145 typedef enum {
146     EfiReservedMemoryType,
147     EfiLoaderCode,
148     EfiLoaderData,
149     EfiBootServicesCode,
150     EfiBootServicesData,
151     EfiRuntimeServicesCode,
152     EfiRuntimeServicesData,
153     EfiConventionalMemory,
154     EfiUnusableMemory,
155     EfiACPIReclaimMemory,
156     EfiACPIMemoryNVS,
157     EfiMemoryMappedIO,
158     EfiMemoryMappedIOPortSpace,
159     EfiPalCode,
160     EfiPersistentMemory,
161     EfiMaxMemoryType
162 } EFI_MEMORY_TYPE;
163 
164 // possible caching types for the memory range
165 #define EFI_MEMORY_UC			0x0000000000000001
166 #define EFI_MEMORY_WC			0x0000000000000002
167 #define EFI_MEMORY_WT			0x0000000000000004
168 #define EFI_MEMORY_WB			0x0000000000000008
169 #define EFI_MEMORY_UCE			0x0000000000000010
170 
171 // physical memory protection on range
172 #define EFI_MEMORY_WP			0x0000000000001000
173 #define EFI_MEMORY_RP			0x0000000000002000
174 #define EFI_MEMORY_XP			0x0000000000004000
175 #define	EFI_MEMORY_NV			0x0000000000008000
176 #define	EFI_MEMORY_MORE_RELIABLE	0x0000000000010000
177 #define	EFI_MEMORY_RO			0x0000000000020000
178 
179 // range requires a runtime mapping
180 #define EFI_MEMORY_RUNTIME		0x8000000000000000
181 
182 #define EFI_MEMORY_DESCRIPTOR_VERSION  1
183 typedef struct {
184     UINT32                          Type;           // Field size is 32 bits followed by 32 bit pad
185     UINT32                          Pad;
186     EFI_PHYSICAL_ADDRESS            PhysicalStart;  // Field size is 64 bits
187     EFI_VIRTUAL_ADDRESS             VirtualStart;   // Field size is 64 bits
188     UINT64                          NumberOfPages;  // Field size is 64 bits
189     UINT64                          Attribute;      // Field size is 64 bits
190 } EFI_MEMORY_DESCRIPTOR;
191 
192 //
193 // International Language
194 //
195 
196 typedef UINT8   ISO_639_2;
197 #define ISO_639_2_ENTRY_SIZE    3
198 
199 //
200 //
201 //
202 
203 #define EFI_PAGE_SIZE   4096
204 #define EFI_PAGE_MASK   0xFFF
205 #define EFI_PAGE_SHIFT  12
206 
207 #define EFI_SIZE_TO_PAGES(a)  \
208     ( ((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0) )
209 
210 #endif
211