Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/libsaio/efi.h

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

Archive Download this file

Revision: 2037