Chameleon

Chameleon Svn Source Tree

Root/trunk/i386/libsaio/efi.h

1/*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#ifndef _PEXPERT_I386_EFI_H
30#define _PEXPERT_I386_EFI_H
31
32#include <stdint.h>
33
34typedef uint8_t EFI_UINT8;
35typedef uint16_t EFI_UINT16;
36typedef uint32_t EFI_UINT32;
37typedef uint64_t EFI_UINT64;
38
39typedef uint32_t EFI_UINTN; /* natural size for firmware, not kernel */
40
41typedef int8_t EFI_INT8;
42typedef int16_t EFI_INT16;
43typedef int32_t EFI_INT32;
44typedef int64_t EFI_INT64;
45
46typedef int8_t EFI_CHAR8;
47typedef int16_t EFI_CHAR16;
48typedef int32_t EFI_CHAR32;
49typedef int64_t EFI_CHAR64;
50
51typedef uint32_t EFI_STATUS;
52typedef uint8_t EFI_BOOLEAN;
53typedef void VOID;
54
55typedef uint32_t EFI_PTR32;
56typedef uint32_t EFI_HANDLE32;
57
58typedef uint64_t EFI_PTR64;
59typedef uint64_t EFI_HANDLE64;
60/*
61
62Portions Copyright 2004, Intel Corporation
63All rights reserved. This program and the accompanying materials
64are licensed and made available under the terms and conditions of the BSD License
65which accompanies this distribution. The full text of the license may be found at
66 http://opensource.org/licenses/bsd-license.php
67
68THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
69WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
70
71*/
72
73
74// Modifiers for EFI Runtime and Boot Services
75
76#define EFI_RUNTIMESERVICE
77#define EFIAPI
78#define IN
79#define OUT
80#define OPTIONAL
81
82#define EFI_MAX_BIT 0x80000000
83
84// Set the upper bit to indicate EFI Error.
85#define EFIERR(a) (EFI_MAX_BIT | (a))
86
87#define EFIWARN(a) (a)
88#define EFI_ERROR(a) (((INTN) (a)) < 0)
89
90#define EFI_SUCCESS 0
91#define EFI_LOAD_ERROR EFIERR (1)
92#define EFI_INVALID_PARAMETER EFIERR (2)
93#define EFI_UNSUPPORTED EFIERR (3)
94#define EFI_BAD_BUFFER_SIZE EFIERR (4)
95#define EFI_BUFFER_TOO_SMALL EFIERR (5)
96#define EFI_NOT_READY EFIERR (6)
97#define EFI_DEVICE_ERROR EFIERR (7)
98#define EFI_WRITE_PROTECTED EFIERR (8)
99#define EFI_OUT_OF_RESOURCES EFIERR (9)
100#define EFI_VOLUME_CORRUPTED EFIERR (10)
101#define EFI_VOLUME_FULL EFIERR (11)
102#define EFI_NO_MEDIA EFIERR (12)
103#define EFI_MEDIA_CHANGED EFIERR (13)
104#define EFI_NOT_FOUND EFIERR (14)
105#define EFI_ACCESS_DENIED EFIERR (15)
106#define EFI_NO_RESPONSE EFIERR (16)
107#define EFI_NO_MAPPING EFIERR (17)
108#define EFI_TIMEOUT EFIERR (18)
109#define EFI_NOT_STARTED EFIERR (19)
110#define EFI_ALREADY_STARTED EFIERR (20)
111#define EFI_ABORTED EFIERR (21)
112#define EFI_ICMP_ERROR EFIERR (22)
113#define EFI_TFTP_ERROR EFIERR (23)
114#define EFI_PROTOCOL_ERROR EFIERR (24)
115#define EFI_INCOMPATIBLE_VERSION EFIERR (25)
116#define EFI_SECURITY_VIOLATION EFIERR (26)
117#define EFI_CRC_ERROR EFIERR (27)
118#define EFI_END_OF_MEDIA EFIERR (28)
119#define EFI_END_OF_FILE EFIERR (31)
120#define EFI_INVALID_LANGUAGE EFIERR (32)
121#define EFI_COMPROMISED_DATA EFIERR (33)
122
123#define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1)
124#define EFI_WARN_DELETE_FAILURE EFIWARN (2)
125#define EFI_WARN_WRITE_FAILURE EFIWARN (3)
126#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4)
127#define EFI_WARN_STALE_DATA EFIWARN (5)
128
129//
130// EFI Specification Revision information
131//
132#define EFI_SPECIFICATION_MAJOR_REVISION 1
133#define EFI_SPECIFICATION_MINOR_REVISION 10
134
135typedef struct {
136 EFI_UINT32 Data1;
137 EFI_UINT16 Data2;
138 EFI_UINT16 Data3;
139 EFI_UINT8 Data4[8];
140} EFI_GUID;
141
142#define APPLE_VENDOR_GUID \
143 {0xAC39C713, 0x7E50, 0x423D, {0x88, 0x9D, 0x27, 0x8F, 0xCC, 0x34, 0x22, 0xB6} }
144
145#define EFI_GLOBAL_VARIABLE_GUID \
146 {0x8BE4DF61, 0x93CA, 0x11D2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
147
148#define SMBIOS_TABLE_GUID \
149 {0xEB9D2D31, 0x2D88, 0x11D3, {0x9A, 0x16, 0x0, 0x90, 0x27, 0x3F, 0xC1, 0x4D} }
150
151#define ACPI_TABLE_GUID \
152 {0xEB9D2D30, 0x2D88, 0x11D3, {0x9A, 0x16, 0x0, 0x90, 0x27, 0x3F, 0xC1, 0x4D} }
153
154#define ACPI_20_TABLE_GUID \
155 {0x8868E871, 0xE4f1, 0x11D3, {0xBC, 0x22, 0x0, 0x80, 0xC7, 0x3C, 0x88, 0x81} }
156
157typedef union {
158 EFI_GUID Guid;
159 EFI_UINT8 Raw[16];
160} EFI_GUID_UNION;
161
162//
163// EFI Time Abstraction:
164// Year: 2000 - 20XX
165// Month: 1 - 12
166// Day: 1 - 31
167// Hour: 0 - 23
168// Minute: 0 - 59
169// Second: 0 - 59
170// Nanosecond: 0 - 999,999,999
171// TimeZone: -1440 to 1440 or 2047
172//
173typedef struct {
174EFI_UINT16 Year;
175EFI_UINT8 Month;
176EFI_UINT8 Day;
177EFI_UINT8 Hour;
178EFI_UINT8 Minute;
179EFI_UINT8 Second;
180EFI_UINT8 Pad1;
181EFI_UINT32 Nanosecond;
182EFI_INT16 TimeZone;
183EFI_UINT8 Daylight;
184EFI_UINT8 Pad2;
185} EFI_TIME;
186
187
188// Bit definitions for EFI_TIME.Daylight
189
190#define EFI_TIME_ADJUST_DAYLIGHT 0x01
191#define EFI_TIME_IN_DAYLIGHT 0x02
192
193
194// Value definition for EFI_TIME.TimeZone
195
196#define EFI_UNSPECIFIED_TIMEZONE 0x07FF
197
198typedef enum {
199EfiReservedMemoryType,// 0
200EfiLoaderCode,
201EfiLoaderData,
202EfiBootServicesCode,
203EfiBootServicesData,
204EfiRuntimeServicesCode,
205EfiRuntimeServicesData,
206EfiConventionalMemory,
207EfiUnusableMemory,
208EfiACPIReclaimMemory,
209EfiACPIMemoryNVS,
210EfiMemoryMappedIO,
211EfiMemoryMappedIOPortSpace,
212EfiPalCode,
213EfiMaxMemoryType// 14
214} EFI_MEMORY_TYPE;
215
216typedef struct {
217EFI_UINT64Signature;
218EFI_UINT32Revision;
219EFI_UINT32HeaderSize;
220EFI_UINT32CRC32;
221EFI_UINT32Reserved;
222} __attribute__((aligned(8))) EFI_TABLE_HEADER;
223
224// possible caching types for the memory range
225#define EFI_MEMORY_UC0x0000000000000001ULL/* uncached */
226#define EFI_MEMORY_WC0x0000000000000002ULL/* write-coalescing */
227#define EFI_MEMORY_WT0x0000000000000004ULL/* write-through */
228#define EFI_MEMORY_WB0x0000000000000008ULL/* write-back */
229#define EFI_MEMORY_UCE0x0000000000000010ULL/* uncached, exported */
230
231// physical memory protection on range
232
233#define EFI_MEMORY_WP 0x0000000000001000ULL
234#define EFI_MEMORY_RP 0x0000000000002000ULL
235#define EFI_MEMORY_XP 0x0000000000004000ULL
236
237
238// range requires a runtime mapping
239
240#define EFI_MEMORY_RUNTIME 0x8000000000000000ULL
241#define EFI_MEMORY_KERN_RESERVED (1ULL << 59)
242typedef EFI_UINT64 EFI_PHYSICAL_ADDRESS;
243typedef EFI_UINT64 EFI_VIRTUAL_ADDRESS;
244
245#define EFI_MEMORY_DESCRIPTOR_VERSION 1
246typedef struct {
247EFI_UINT32 Type;
248EFI_UINT32 Pad;
249EFI_PHYSICAL_ADDRESS PhysicalStart;
250EFI_VIRTUAL_ADDRESS VirtualStart;
251EFI_UINT64 NumberOfPages;
252EFI_UINT64 Attribute;
253} __attribute__((aligned(8))) EFI_MEMORY_DESCRIPTOR;
254
255
256typedef
257EFI_RUNTIMESERVICE
258EFI_STATUS
259(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
260 IN EFI_UINTN MemoryMapSize,
261 IN EFI_UINTN DescriptorSize,
262 IN EFI_UINT32 DescriptorVersion,
263 IN EFI_MEMORY_DESCRIPTOR * VirtualMap
264 ) __attribute__((regparm(0)));
265
266typedef
267EFI_RUNTIMESERVICE
268EFI_STATUS
269(EFIAPI *EFI_CONVERT_POINTER) (
270 IN EFI_UINTN DebugDisposition,
271 IN OUT VOID **Address
272 ) __attribute__((regparm(0)));
273
274
275// Variable attributes
276
277#define EFI_VARIABLE_NON_VOLATILE 0x00000001
278#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
279#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
280#define EFI_VARIABLE_READ_ONLY 0x00000008
281
282typedef
283EFI_RUNTIMESERVICE
284EFI_STATUS
285(EFIAPI *EFI_GET_VARIABLE) (
286 IN EFI_CHAR16 * VariableName,
287 IN EFI_GUID * VendorGuid,
288 OUT EFI_UINT32 * Attributes OPTIONAL,
289 IN OUT EFI_UINTN * DataSize,
290 OUT VOID * Data
291 ) __attribute__((regparm(0)));
292
293typedef
294EFI_RUNTIMESERVICE
295EFI_STATUS
296(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
297 IN OUT EFI_UINTN * VariableNameSize,
298 IN OUT EFI_CHAR16 * VariableName,
299 IN OUT EFI_GUID * VendorGuid
300 ) __attribute__((regparm(0)));
301
302typedef
303EFI_RUNTIMESERVICE
304EFI_STATUS
305(EFIAPI *EFI_SET_VARIABLE) (
306 IN EFI_CHAR16 * VariableName,
307 IN EFI_GUID * VendorGuid,
308 IN EFI_UINT32 Attributes,
309 IN EFI_UINTN DataSize,
310 IN VOID * Data
311 ) __attribute__((regparm(0)));
312
313
314// EFI Time
315
316typedef struct {
317EFI_UINT32 Resolution;
318EFI_UINT32 Accuracy;
319EFI_BOOLEAN SetsToZero;
320} __attribute__((aligned(4))) EFI_TIME_CAPABILITIES;
321
322typedef
323EFI_RUNTIMESERVICE
324EFI_STATUS
325(EFIAPI *EFI_GET_TIME) (
326 OUT EFI_TIME * Time,
327 OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL
328 ) __attribute__((regparm(0)));
329
330typedef
331EFI_RUNTIMESERVICE
332EFI_STATUS
333(EFIAPI *EFI_SET_TIME) (
334 IN EFI_TIME * Time
335 ) __attribute__((regparm(0)));
336
337typedef
338EFI_RUNTIMESERVICE
339EFI_STATUS
340(EFIAPI *EFI_GET_WAKEUP_TIME) (
341 OUT EFI_BOOLEAN * Enabled,
342 OUT EFI_BOOLEAN * Pending,
343 OUT EFI_TIME * Time
344 ) __attribute__((regparm(0)));
345
346typedef
347EFI_RUNTIMESERVICE
348EFI_STATUS
349(EFIAPI *EFI_SET_WAKEUP_TIME) (
350 IN EFI_BOOLEAN Enable,
351 IN EFI_TIME * Time OPTIONAL
352 ) __attribute((regparm(0)));
353
354typedef enum {
355 EfiResetCold,
356 EfiResetWarm,
357 EfiResetShutdown,
358
359#ifdef TIANO_EXTENSION_FLAG
360 EfiResetUpdate
361#endif
362
363} EFI_RESET_TYPE;
364
365typedef
366EFI_RUNTIMESERVICE
367VOID
368(EFIAPI *EFI_RESET_SYSTEM) (
369 IN EFI_RESET_TYPE ResetType,
370 IN EFI_STATUS ResetStatus,
371 IN EFI_UINTN DataSize,
372 IN EFI_CHAR16 * ResetData OPTIONAL
373 ) __attribute__((regparm(0)));
374
375typedef
376EFI_RUNTIMESERVICE
377EFI_STATUS
378(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
379 OUT EFI_UINT32 * HighCount
380 ) __attribute__((regparm(0)));
381
382// Definition of Status Code extended data header
383
384// HeaderSize The size of the architecture. This is specified to enable the future expansion
385
386// Size The size of the data in bytes. This does not include the size of the header structure.
387
388// Type A GUID defining the type of the data
389
390#ifdef TIANO_EXTENSION_FLAG
391
392typedef
393EFI_RUNTIMESERVICE
394EFI_STATUS
395(EFIAPI *EFI_REPORT_STATUS_CODE) (
396 IN EFI_STATUS_CODE_TYPE Type,
397 IN EFI_STATUS_CODE_VALUE Value,
398 IN EFI_UINT32 Instance,
399 IN EFI_GUID * CallerId OPTIONAL,
400 IN EFI_STATUS_CODE_DATA * Data OPTIONAL
401 ) __attribute__((regparm(0)));
402
403#endif
404//
405// EFI Runtime Services Table
406//
407#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL
408#define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
409
410typedef struct {
411EFI_TABLE_HEADERHdr;
412
413// Time Services
414EFI_PTR32GetTime;
415EFI_PTR32SetTime;
416EFI_PTR32GetWakeupTime;
417EFI_PTR32SetWakeupTime;
418
419// Virtual Memory Services
420
421EFI_PTR32 SetVirtualAddressMap;
422EFI_PTR32 ConvertPointer;
423
424
425// Variable Services
426EFI_PTR32 GetVariable;
427EFI_PTR32 GetNextVariableName;
428EFI_PTR32 SetVariable;
429
430// Miscellaneous Services
431EFI_PTR32 GetNextHighMonotonicCount;
432EFI_PTR32 ResetSystem;
433
434#ifdef TIANO_EXTENSION_FLAG
435
436// ////////////////////////////////////////////////////
437// Extended EFI Services
438//////////////////////////////////////////////////////
439
440EFI_PTR32 ReportStatusCode;
441#endif
442
443} __attribute__((aligned(8))) EFI_RUNTIME_SERVICES_32;
444
445typedef struct {
446EFI_TABLE_HEADER Hdr;
447
448
449// Time services
450
451EFI_PTR64 GetTime;
452EFI_PTR64 SetTime;
453EFI_PTR64 GetWakeupTime;
454EFI_PTR64 SetWakeupTime;
455
456// Virtual memory services
457
458EFI_PTR64 SetVirtualAddressMap;
459EFI_PTR64 ConvertPointer;
460
461// Variable services
462
463EFI_PTR64 GetVariable;
464EFI_PTR64 GetNextVariableName;
465EFI_PTR64 SetVariable;
466
467// Misc
468
469EFI_PTR64 GetNextHighMonotonicCount;
470EFI_PTR64 ResetSystem;
471
472#ifdef TIANO_EXTENSION_FLAG
473
474// ////////////////////////////////////////////////////
475// Extended EFI Services
476//////////////////////////////////////////////////////
477
478EFI_PTR64 ReportStatusCode;
479#endif
480
481} __attribute__((aligned(8))) EFI_RUNTIME_SERVICES_64;
482
483//
484// EFI Configuration Table
485//
486typedef struct {
487EFI_GUID VendorGuid;
488EFI_PTR32 VendorTable;
489} EFI_CONFIGURATION_TABLE_32;
490
491typedef struct {
492EFI_GUID VendorGuid;
493EFI_PTR64 VendorTable;
494} __attribute__((aligned(8))) EFI_CONFIGURATION_TABLE_64;
495
496
497// EFI System Table
498
499#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249ULL
500#define EFI_SYSTEM_TABLE_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
501#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | 00)
502#define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | 02)
503#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | 10)
504
505typedef struct EFI_SYSTEM_TABLE_32 {
506EFI_TABLE_HEADER Hdr;
507
508EFI_PTR32 FirmwareVendor;
509EFI_UINT32 FirmwareRevision;
510
511EFI_HANDLE32 ConsoleInHandle;
512EFI_PTR32 ConIn;
513
514EFI_HANDLE32 ConsoleOutHandle;
515EFI_PTR32 ConOut;
516
517EFI_HANDLE32 StandardErrorHandle;
518EFI_PTR32 StdErr;
519
520EFI_PTR32 RuntimeServices;
521EFI_PTR32 BootServices;
522
523EFI_UINT32 NumberOfTableEntries;
524EFI_PTR32 ConfigurationTable;
525
526} __attribute__((aligned(8))) EFI_SYSTEM_TABLE_32;
527
528typedef struct EFI_SYSTEM_TABLE_64 {
529EFI_TABLE_HEADER Hdr;
530
531EFI_PTR64 FirmwareVendor;
532EFI_UINT32 FirmwareRevision;
533
534EFI_UINT32 __pad;
535EFI_HANDLE64 ConsoleInHandle;
536EFI_PTR64 ConIn;
537
538EFI_HANDLE64 ConsoleOutHandle;
539EFI_PTR64 ConOut;
540
541EFI_HANDLE64 StandardErrorHandle;
542EFI_PTR64 StdErr;
543
544EFI_PTR64 RuntimeServices;
545EFI_PTR64 BootServices;
546
547EFI_UINT64 NumberOfTableEntries;
548EFI_PTR64 ConfigurationTable;
549} __attribute__((aligned(8))) EFI_SYSTEM_TABLE_64;
550
551#endif /* _PEXPERT_I386_EFI_H */
552

Archive Download this file

Revision: 2636