Chameleon

Chameleon Svn Source Tree

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