Chameleon

Chameleon Svn Source Tree

Root/tags/2.3/i386/libsaio/efi.h

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

Archive Download this file

Revision: HEAD