Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch/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 EFI_SMBIOS_TABLE_GUID \
149 {0xEB9D2D31, 0x2D88, 0x11D3, {0x9A, 0x16, 0x0, 0x90, 0x27, 0x3F, 0xC1, 0x4D} }
150
151// ACPI 1.0 Table GUID in EFI System Table
152#define EFI_ACPI_TABLE_GUID \
153 {0xEB9D2D30, 0x2D88, 0x11D3, {0x9A, 0x16, 0x0, 0x90, 0x27, 0x3F, 0xC1, 0x4D} }
154
155// ACPI 2.0 Table GUID in EFI System Table
156#define EFI_ACPI_20_TABLE_GUID \
157 {0x8868E871, 0xE4f1, 0x11D3, {0xBC, 0x22, 0x0, 0x80, 0xC7, 0x3C, 0x88, 0x81} }
158
159// ACPI 3.0 Table GUID in EFI System Table
160#define EFI_ACPI_30_TABLE_GUID EFI_ACPI_20_TABLE_GUID
161
162typedef union {
163 EFI_GUID Guid;
164 EFI_UINT8 Raw[16];
165} EFI_GUID_UNION;
166
167//
168// EFI Time Abstraction:
169// Year: 2000 - 20XX
170// Month: 1 - 12
171// Day: 1 - 31
172// Hour: 0 - 23
173// Minute: 0 - 59
174// Second: 0 - 59
175// Nanosecond: 0 - 999,999,999
176// TimeZone: -1440 to 1440 or 2047
177//
178typedef struct {
179EFI_UINT16 Year;
180EFI_UINT8 Month;
181EFI_UINT8 Day;
182EFI_UINT8 Hour;
183EFI_UINT8 Minute;
184EFI_UINT8 Second;
185EFI_UINT8 Pad1;
186EFI_UINT32 Nanosecond;
187EFI_INT16 TimeZone;
188EFI_UINT8 Daylight;
189EFI_UINT8 Pad2;
190} EFI_TIME;
191
192
193// Bit definitions for EFI_TIME.Daylight
194
195#define EFI_TIME_ADJUST_DAYLIGHT 0x01
196#define EFI_TIME_IN_DAYLIGHT 0x02
197
198
199// Value definition for EFI_TIME.TimeZone
200
201#define EFI_UNSPECIFIED_TIMEZONE 0x07FF
202
203typedef enum {
204EfiReservedMemoryType,// 0
205EfiLoaderCode,
206EfiLoaderData,
207EfiBootServicesCode,
208EfiBootServicesData,
209EfiRuntimeServicesCode,
210EfiRuntimeServicesData,
211EfiConventionalMemory,
212EfiUnusableMemory,
213EfiACPIReclaimMemory,
214EfiACPIMemoryNVS,
215EfiMemoryMappedIO,
216EfiMemoryMappedIOPortSpace,
217EfiPalCode,
218EfiMaxMemoryType// 14
219} EFI_MEMORY_TYPE;
220
221typedef struct {
222EFI_UINT64Signature;
223EFI_UINT32Revision;
224EFI_UINT32HeaderSize;
225EFI_UINT32CRC32;
226EFI_UINT32Reserved;
227} __attribute__((aligned(8))) EFI_TABLE_HEADER;
228
229// possible caching types for the memory range
230#define EFI_MEMORY_UC0x0000000000000001ULL/* uncached */
231#define EFI_MEMORY_WC0x0000000000000002ULL/* write-coalescing */
232#define EFI_MEMORY_WT0x0000000000000004ULL/* write-through */
233#define EFI_MEMORY_WB0x0000000000000008ULL/* write-back */
234#define EFI_MEMORY_UCE0x0000000000000010ULL/* uncached, exported */
235
236// physical memory protection on range
237
238#define EFI_MEMORY_WP0x0000000000001000ULL/* write-protect */
239#define EFI_MEMORY_RP0x0000000000002000ULL/* read-protect */
240#define EFI_MEMORY_XP0x0000000000004000ULL/* execute-protect */
241
242// range requires a runtime mapping
243
244#define EFI_MEMORY_RUNTIME 0x8000000000000000ULL
245#define EFI_MEMORY_KERN_RESERVED (1ULL << 59)
246typedef EFI_UINT64 EFI_PHYSICAL_ADDRESS;
247typedef EFI_UINT64 EFI_VIRTUAL_ADDRESS;
248
249#define EFI_MEMORY_DESCRIPTOR_VERSION 1
250typedef struct {
251EFI_UINT32 Type;
252EFI_UINT32 Pad;
253EFI_PHYSICAL_ADDRESS PhysicalStart;
254EFI_VIRTUAL_ADDRESS VirtualStart;
255EFI_UINT64 NumberOfPages;
256EFI_UINT64 Attribute;
257} __attribute__((aligned(8))) EFI_MEMORY_DESCRIPTOR;
258
259
260typedef
261EFI_RUNTIMESERVICE
262EFI_STATUS
263(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
264 IN EFI_UINTN MemoryMapSize,
265 IN EFI_UINTN DescriptorSize,
266 IN EFI_UINT32 DescriptorVersion,
267 IN EFI_MEMORY_DESCRIPTOR * VirtualMap
268 ) __attribute__((regparm(0)));
269
270typedef
271EFI_RUNTIMESERVICE
272EFI_STATUS
273(EFIAPI *EFI_CONVERT_POINTER) (
274 IN EFI_UINTN DebugDisposition,
275 IN OUT VOID **Address
276 ) __attribute__((regparm(0)));
277
278
279// Variable attributes
280
281#define EFI_VARIABLE_NON_VOLATILE 0x00000001
282#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
283#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
284#define EFI_VARIABLE_READ_ONLY 0x00000008
285
286typedef
287EFI_RUNTIMESERVICE
288EFI_STATUS
289(EFIAPI *EFI_GET_VARIABLE) (
290 IN EFI_CHAR16 * VariableName,
291 IN EFI_GUID * VendorGuid,
292 OUT EFI_UINT32 * Attributes OPTIONAL,
293 IN OUT EFI_UINTN * DataSize,
294 OUT VOID * Data
295 ) __attribute__((regparm(0)));
296
297typedef
298EFI_RUNTIMESERVICE
299EFI_STATUS
300(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
301 IN OUT EFI_UINTN * VariableNameSize,
302 IN OUT EFI_CHAR16 * VariableName,
303 IN OUT EFI_GUID * VendorGuid
304 ) __attribute__((regparm(0)));
305
306typedef
307EFI_RUNTIMESERVICE
308EFI_STATUS
309(EFIAPI *EFI_SET_VARIABLE) (
310 IN EFI_CHAR16 * VariableName,
311 IN EFI_GUID * VendorGuid,
312 IN EFI_UINT32 Attributes,
313 IN EFI_UINTN DataSize,
314 IN VOID * Data
315 ) __attribute__((regparm(0)));
316
317
318// EFI Time
319
320typedef struct {
321EFI_UINT32 Resolution;
322EFI_UINT32 Accuracy;
323EFI_BOOLEAN SetsToZero;
324} __attribute__((aligned(4))) EFI_TIME_CAPABILITIES;
325
326typedef
327EFI_RUNTIMESERVICE
328EFI_STATUS
329(EFIAPI *EFI_GET_TIME) (
330 OUT EFI_TIME * Time,
331 OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL
332 ) __attribute__((regparm(0)));
333
334typedef
335EFI_RUNTIMESERVICE
336EFI_STATUS
337(EFIAPI *EFI_SET_TIME) (
338 IN EFI_TIME * Time
339 ) __attribute__((regparm(0)));
340
341typedef
342EFI_RUNTIMESERVICE
343EFI_STATUS
344(EFIAPI *EFI_GET_WAKEUP_TIME) (
345 OUT EFI_BOOLEAN * Enabled,
346 OUT EFI_BOOLEAN * Pending,
347 OUT EFI_TIME * Time
348 ) __attribute__((regparm(0)));
349
350typedef
351EFI_RUNTIMESERVICE
352EFI_STATUS
353(EFIAPI *EFI_SET_WAKEUP_TIME) (
354 IN EFI_BOOLEAN Enable,
355 IN EFI_TIME * Time OPTIONAL
356 ) __attribute((regparm(0)));
357
358typedef enum {
359 EfiResetCold,
360 EfiResetWarm,
361 EfiResetShutdown,
362
363#ifdef TIANO_EXTENSION_FLAG
364 EfiResetUpdate
365#endif
366
367} EFI_RESET_TYPE;
368
369typedef
370EFI_RUNTIMESERVICE
371VOID
372(EFIAPI *EFI_RESET_SYSTEM) (
373 IN EFI_RESET_TYPE ResetType,
374 IN EFI_STATUS ResetStatus,
375 IN EFI_UINTN DataSize,
376 IN EFI_CHAR16 * ResetData OPTIONAL
377 ) __attribute__((regparm(0)));
378
379typedef
380EFI_RUNTIMESERVICE
381EFI_STATUS
382(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
383 OUT EFI_UINT32 * HighCount
384 ) __attribute__((regparm(0)));
385
386// Definition of Status Code extended data header
387
388// HeaderSize The size of the architecture. This is specified to enable the future expansion
389
390// Size The size of the data in bytes. This does not include the size of the header structure.
391
392// Type A GUID defining the type of the data
393
394#ifdef TIANO_EXTENSION_FLAG
395
396typedef
397EFI_RUNTIMESERVICE
398EFI_STATUS
399(EFIAPI *EFI_REPORT_STATUS_CODE) (
400 IN EFI_STATUS_CODE_TYPE Type,
401 IN EFI_STATUS_CODE_VALUE Value,
402 IN EFI_UINT32 Instance,
403 IN EFI_GUID * CallerId OPTIONAL,
404 IN EFI_STATUS_CODE_DATA * Data OPTIONAL
405 ) __attribute__((regparm(0)));
406
407#endif
408//
409// EFI Runtime Services Table
410//
411#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL
412#define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
413
414typedef struct {
415EFI_TABLE_HEADERHdr;
416
417// Time Services
418EFI_PTR32GetTime;
419EFI_PTR32SetTime;
420EFI_PTR32GetWakeupTime;
421EFI_PTR32SetWakeupTime;
422
423// Virtual Memory Services
424
425EFI_PTR32 SetVirtualAddressMap;
426EFI_PTR32 ConvertPointer;
427
428
429// Variable Services
430EFI_PTR32 GetVariable;
431EFI_PTR32 GetNextVariableName;
432EFI_PTR32 SetVariable;
433
434// Miscellaneous Services
435EFI_PTR32 GetNextHighMonotonicCount;
436EFI_PTR32 ResetSystem;
437
438#ifdef TIANO_EXTENSION_FLAG
439
440// ////////////////////////////////////////////////////
441// Extended EFI Services
442//////////////////////////////////////////////////////
443
444EFI_PTR32 ReportStatusCode;
445#endif
446
447} __attribute__((aligned(8))) EFI_RUNTIME_SERVICES_32;
448
449typedef struct {
450EFI_TABLE_HEADER Hdr;
451
452
453// Time services
454
455EFI_PTR64 GetTime;
456EFI_PTR64 SetTime;
457EFI_PTR64 GetWakeupTime;
458EFI_PTR64 SetWakeupTime;
459
460// Virtual memory services
461
462EFI_PTR64 SetVirtualAddressMap;
463EFI_PTR64 ConvertPointer;
464
465// Variable services
466
467EFI_PTR64 GetVariable;
468EFI_PTR64 GetNextVariableName;
469EFI_PTR64 SetVariable;
470
471// Misc
472
473EFI_PTR64 GetNextHighMonotonicCount;
474EFI_PTR64 ResetSystem;
475
476#ifdef TIANO_EXTENSION_FLAG
477
478// ////////////////////////////////////////////////////
479// Extended EFI Services
480//////////////////////////////////////////////////////
481
482EFI_PTR64 ReportStatusCode;
483#endif
484
485} __attribute__((aligned(8))) EFI_RUNTIME_SERVICES_64;
486
487//
488// EFI Configuration Table
489//
490typedef struct {
491EFI_GUID VendorGuid;
492EFI_PTR32 VendorTable;
493} EFI_CONFIGURATION_TABLE_32;
494
495typedef struct {
496EFI_GUID VendorGuid;
497EFI_PTR64 VendorTable;
498} __attribute__((aligned(8))) EFI_CONFIGURATION_TABLE_64;
499
500
501// EFI System Table
502
503#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249ULL
504#define EFI_SYSTEM_TABLE_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) | (EFI_SPECIFICATION_MINOR_REVISION))
505#define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30))
506#define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20))
507#define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10))
508#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00))
509#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10))
510#define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02))
511
512typedef struct EFI_SYSTEM_TABLE_32 {
513EFI_TABLE_HEADER Hdr;
514
515EFI_PTR32 FirmwareVendor;
516EFI_UINT32 FirmwareRevision;
517
518EFI_HANDLE32 ConsoleInHandle;
519EFI_PTR32 ConIn;
520
521EFI_HANDLE32 ConsoleOutHandle;
522EFI_PTR32 ConOut;
523
524EFI_HANDLE32 StandardErrorHandle;
525EFI_PTR32 StdErr;
526
527EFI_PTR32 RuntimeServices;
528EFI_PTR32 BootServices;
529
530EFI_UINT32 NumberOfTableEntries;
531EFI_PTR32 ConfigurationTable;
532
533} __attribute__((aligned(8))) EFI_SYSTEM_TABLE_32;
534
535typedef struct EFI_SYSTEM_TABLE_64 {
536EFI_TABLE_HEADER Hdr;
537
538EFI_PTR64 FirmwareVendor;
539EFI_UINT32 FirmwareRevision;
540
541EFI_UINT32 __pad;
542EFI_HANDLE64 ConsoleInHandle;
543EFI_PTR64 ConIn;
544
545EFI_HANDLE64 ConsoleOutHandle;
546EFI_PTR64 ConOut;
547
548EFI_HANDLE64 StandardErrorHandle;
549EFI_PTR64 StdErr;
550
551EFI_PTR64 RuntimeServices;
552EFI_PTR64 BootServices;
553
554EFI_UINT64 NumberOfTableEntries;
555EFI_PTR64 ConfigurationTable;
556} __attribute__((aligned(8))) EFI_SYSTEM_TABLE_64;
557
558#endif /* _PEXPERT_I386_EFI_H */
559

Archive Download this file

Revision: 2763