Cosmetic cleanups.
[dragonfly.git] / sys / boot / efi / include / efidef.h
1 /*
2  * $FreeBSD: src/sys/boot/efi/include/efidef.h,v 1.2 2002/05/19 03:17:20 marcel Exp $
3  * $DragonFly: src/sys/boot/efi/include/efidef.h,v 1.1 2003/11/10 06:08:32 dillon Exp $
4  */
5 #ifndef _EFI_DEF_H
6 #define _EFI_DEF_H
7
8 /*++
9
10 Copyright (c) 1998  Intel Corporation
11
12 Module Name:
13
14     efidef.h
15
16 Abstract:
17
18     EFI definitions
19
20
21
22
23 Revision History
24
25 --*/
26
27 typedef UINT16          CHAR16;
28 typedef UINT8           CHAR8;
29 typedef UINT8           BOOLEAN;
30
31 #ifndef TRUE
32     #define TRUE    ((BOOLEAN) 1)
33     #define FALSE   ((BOOLEAN) 0)
34 #endif
35
36 #ifndef NULL
37     #define NULL    ((VOID *) 0)
38 #endif
39
40 typedef UINTN           EFI_STATUS;
41 typedef UINT64          EFI_LBA;
42 typedef UINTN           EFI_TPL;
43 typedef VOID            *EFI_HANDLE;
44 typedef VOID            *EFI_EVENT;
45
46
47 /*
48  * Prototype argument decoration for EFI parameters to indicate
49  * their direction
50  *
51  * IN - argument is passed into the function
52  * OUT - argument (pointer) is returned from the function
53  * OPTIONAL - argument is optional
54  */
55
56 #ifndef IN
57     #define IN
58     #define OUT
59     #define OPTIONAL
60 #endif
61
62
63 /*
64  * A GUID
65  */
66
67 typedef struct {          
68     UINT32  Data1;
69     UINT16  Data2;
70     UINT16  Data3;
71     UINT8   Data4[8]; 
72 } EFI_GUID;
73
74
75 /*
76  * Time
77  */
78
79 typedef struct {          
80         UINT16      Year;       /* 1998 - 20XX */
81         UINT8       Month;      /* 1 - 12 */
82         UINT8       Day;        /* 1 - 31 */
83         UINT8       Hour;       /* 0 - 23 */
84         UINT8       Minute;     /* 0 - 59 */
85         UINT8       Second;     /* 0 - 59 */
86         UINT8       Pad1;
87         UINT32      Nanosecond; /* 0 - 999,999,999 */
88         INT16       TimeZone;   /* -1440 to 1440 or 2047 */
89         UINT8       Daylight;
90         UINT8       Pad2;
91 } EFI_TIME;
92
93 /* Bit definitions for EFI_TIME.Daylight */
94 #define EFI_TIME_ADJUST_DAYLIGHT    0x01
95 #define EFI_TIME_IN_DAYLIGHT        0x02
96
97 /* Value definition for EFI_TIME.TimeZone */
98 #define EFI_UNSPECIFIED_TIMEZONE    0x07FF
99
100
101
102 /*
103  * Networking
104  */
105
106 typedef struct {
107     UINT8                   Addr[4];
108 } EFI_IPv4_ADDRESS;
109
110 typedef struct {
111     UINT8                   Addr[16];
112 } EFI_IPv6_ADDRESS;
113
114 typedef struct {
115     UINT8                   Addr[32];
116 } EFI_MAC_ADDRESS;
117
118 /*
119  * Memory
120  */
121
122 typedef UINT64          EFI_PHYSICAL_ADDRESS;
123 typedef UINT64          EFI_VIRTUAL_ADDRESS;
124
125 typedef enum {
126     AllocateAnyPages,
127     AllocateMaxAddress,
128     AllocateAddress,
129     MaxAllocateType
130 } EFI_ALLOCATE_TYPE;
131
132 /*
133  * Preseve the attr on any range supplied.
134  * ConventialMemory must have WB,SR,SW when supplied.
135  * When allocating from ConventialMemory always make it WB,SR,SW
136  * When returning to ConventialMemory always make it WB,SR,SW
137  * When getting the memory map, or on RT for runtime types
138  */
139
140 typedef enum {
141     EfiReservedMemoryType,
142     EfiLoaderCode,
143     EfiLoaderData,
144     EfiBootServicesCode,
145     EfiBootServicesData,
146     EfiRuntimeServicesCode,
147     EfiRuntimeServicesData,
148     EfiConventionalMemory,
149     EfiUnusableMemory,
150     EfiACPIReclaimMemory,
151     EfiACPIMemoryNVS,
152     EfiMemoryMappedIO,
153     EfiMemoryMappedIOPortSpace,
154     EfiPalCode,
155     EfiMaxMemoryType
156 } EFI_MEMORY_TYPE;
157
158 /* possible caching types for the memory range */
159 #define EFI_MEMORY_UC           0x0000000000000001
160 #define EFI_MEMORY_WC           0x0000000000000002
161 #define EFI_MEMORY_WT           0x0000000000000004
162 #define EFI_MEMORY_WB           0x0000000000000008
163 #define EFI_MEMORY_UCE          0x0000000000000010  
164
165 /* physical memory protection on range */
166 #define EFI_MEMORY_WP           0x0000000000001000
167 #define EFI_MEMORY_RP           0x0000000000002000
168 #define EFI_MEMORY_XP           0x0000000000004000
169
170 /* range requires a runtime mapping */
171 #define EFI_MEMORY_RUNTIME      0x8000000000000000
172
173 #define EFI_MEMORY_DESCRIPTOR_VERSION  1
174 typedef struct {
175         UINT32                          Type;           /* 32 bit padding */
176         EFI_PHYSICAL_ADDRESS            PhysicalStart;
177         EFI_VIRTUAL_ADDRESS             VirtualStart;
178         UINT64                          NumberOfPages;
179         UINT64                          Attribute;
180 } EFI_MEMORY_DESCRIPTOR;
181
182 /*
183  * International Language
184  */
185
186 typedef UINT8   ISO_639_2;
187 #define ISO_639_2_ENTRY_SIZE    3
188
189 #define EFI_PAGE_SIZE   4096
190 #define EFI_PAGE_MASK   0xFFF
191 #define EFI_PAGE_SHIFT  12
192
193 #define EFI_SIZE_TO_PAGES(a)  \
194     ( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) )
195
196 #endif