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

Archive Download this file

Revision: 2045