3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 EFI defined types. Use these types when ever possible!
26 // EFI Data Types based on ANSI C integer types in EfiBind.h
28 typedef uint8_t BOOLEAN
;
30 typedef uintn_t UINTN
;
32 typedef uint8_t UINT8
;
33 typedef int16_t INT16
;
34 typedef uint16_t UINT16
;
35 typedef int32_t INT32
;
36 typedef uint32_t UINT32
;
37 typedef int64_t INT64
;
38 typedef uint64_t UINT64
;
40 typedef uint16_t CHAR16
;
41 typedef UINT64 EFI_LBA
;
44 // Modifiers for EFI Data Types used to self document code.
45 // Please see EFI coding convention for proper usage.
49 // Some other envirnments use this construct, so #ifndef to prevent
50 // mulitple definition.
62 // Modifiers for EFI Runtime and Boot Services
64 #define EFI_RUNTIMESERVICE
65 #define EFI_BOOTSERVICE
68 // Boot Service add in EFI 1.1
70 #define EFI_BOOTSERVICE11
73 // Modifiers to absract standard types to aid in debug of problems
78 #define VOLATILE volatile
81 // Modifier to ensure that all protocol member functions and EFI intrinsics
82 // use the correct C calling convention. All protocol member functions and
83 // EFI intrinsics are required to modify thier member functions with EFIAPI.
85 #define EFIAPI _EFIAPI
88 // EFI Constants. They may exist in other build structures, so #ifndef them.
91 #define TRUE ((BOOLEAN) 1 == 1)
95 #define FALSE ((BOOLEAN) 0 == 1)
99 #define NULL ((VOID *) 0)
102 // EFI Data Types derived from other EFI data types.
104 typedef UINTN EFI_STATUS
;
106 typedef VOID
*EFI_HANDLE
;
107 #define NULL_HANDLE ((VOID *) 0)
109 typedef VOID
*EFI_EVENT
;
110 typedef UINTN EFI_TPL
;
125 // EFI Time Abstraction:
132 // Nanosecond: 0 - 999,999,999
133 // TimeZone: -1440 to 1440 or 2047
150 // Bit definitions for EFI_TIME.Daylight
152 #define EFI_TIME_ADJUST_DAYLIGHT 0x01
153 #define EFI_TIME_IN_DAYLIGHT 0x02
156 // Value definition for EFI_TIME.TimeZone
158 #define EFI_UNSPECIFIED_TIMEZONE 0x07FF
182 EfiReservedMemoryType
,
187 EfiRuntimeServicesCode
,
188 EfiRuntimeServicesData
,
189 EfiConventionalMemory
,
191 EfiACPIReclaimMemory
,
194 EfiMemoryMappedIOPortSpace
,
215 // possible caching types for the memory range
217 #define EFI_MEMORY_UC 0x0000000000000001
218 #define EFI_MEMORY_WC 0x0000000000000002
219 #define EFI_MEMORY_WT 0x0000000000000004
220 #define EFI_MEMORY_WB 0x0000000000000008
221 #define EFI_MEMORY_UCE 0x0000000000000010
224 // physical memory protection on range
226 #define EFI_MEMORY_WP 0x0000000000001000
227 #define EFI_MEMORY_RP 0x0000000000002000
228 #define EFI_MEMORY_XP 0x0000000000004000
231 // range requires a runtime mapping
233 #define EFI_MEMORY_RUNTIME 0x8000000000000000ULL
235 typedef UINT64 EFI_PHYSICAL_ADDRESS
;
236 typedef UINT64 EFI_VIRTUAL_ADDRESS
;
238 #define EFI_MEMORY_DESCRIPTOR_VERSION 1
242 EFI_PHYSICAL_ADDRESS PhysicalStart
;
243 EFI_VIRTUAL_ADDRESS VirtualStart
;
244 UINT64 NumberOfPages
;
246 } EFI_MEMORY_DESCRIPTOR
;
249 // The EFI memory allocation functions work in units of EFI_PAGEs that are
250 // 4K. This should in no way be confused with the page size of the processor.
251 // An EFI_PAGE is just the quanta of memory in EFI.
253 #define EFI_PAGE_SIZE 4096
254 #define EFI_PAGE_MASK 0xFFF
255 #define EFI_PAGE_SHIFT 12
257 #define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))
259 #define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)
262 // ALIGN_POINTER - aligns a pointer to the lowest boundry
264 #define ALIGN_POINTER(p, s) ((VOID *) (p + ((s - ((UINTN) p)) & (s - 1))))
267 // ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor
269 #define ALIGN_VARIABLE(Value, Adjustment) \
270 (UINTN) Adjustment = 0; \
271 if ((UINTN) Value % sizeof (UINTN)) { \
272 (UINTN) Adjustment = sizeof (UINTN) - ((UINTN) Value % sizeof (UINTN)); \
274 Value = (UINTN) Value + (UINTN) Adjustment
277 // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure
279 #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))
282 // CONTAINING_RECORD - returns a pointer to the structure
283 // from one of it's elements.
285 #define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
288 // Define macros to build data structure signatures from characters.
290 #define EFI_SIGNATURE_16(A, B) ((A) | (B << 8))
291 #define EFI_SIGNATURE_32(A, B, C, D) (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))
292 #define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \
293 (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))