~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to extras/mini-os/include/ia64/efi.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This is a short summary of declarations and definitions from different
 
3
 * efi header files of Intels' EFI_Toolkit_1.10.14.62 
 
4
 * used for the minimal implementation in mini-os.
 
5
 * Changes: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
 
6
 *
 
7
 ****************************************************************************
 
8
 * Copyright (C) 2001-2004, Intel Corporation.
 
9
 * THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO WARRANTIES WHATSOEVER,
 
10
 * INCLUDING ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR
 
11
 * ANY PARTICULAR PURPOSE, OR ANY WARRANTY OTHERWISE ARISING OUT OF ANY
 
12
 * PROPOSAL, SPECIFICATION OR SAMPLE. Except for a limited copyright license
 
13
 * to copy this specification for internal use only, no license, express or
 
14
 * implied, by estoppel or otherwise, to any intellectual property rights is
 
15
 * granted herein.  Intel disclaims all liability, including liability for
 
16
 * infringement of any proprietary rights, relating to implementation of
 
17
 * information in this specification. Intel does not warrant or represent
 
18
 * that such implementation(s) will not infringe such rights.  Designers must
 
19
 * not rely on the absence or characteristics of any features or instructions
 
20
 * marked "reserved" or "undefined." Intel reserves these for future
 
21
 * definition and shall have no responsibility whatsoever for conflicts or
 
22
 * incompatibilities arising from future changes to them.
 
23
 * This document is an intermediate draft for comment only and is subject to
 
24
 * change without notice. Readers should not design products based on this
 
25
 * document.
 
26
 * Intel, the Intel logo, and Itanium are trademarks or registered trademarks
 
27
 * of Intel Corporation or its subsidiaries in the United States and other
 
28
 * countries.
 
29
 * Other names and brands may be claimed as the property of others.
 
30
 */
 
31
 
 
32
#ifndef _EFI_H_
 
33
#define _EFI_H_
 
34
 
 
35
#include <mini-os/types.h>
 
36
 
 
37
 
 
38
#define EFIWARN(a)                      (a)
 
39
#define EFI_ERROR(a)                    (((int64_t) a) < 0)
 
40
 
 
41
 
 
42
#define EFI_SUCCESS                     0
 
43
#define EFI_LOAD_ERROR                  EFIERR(1)
 
44
#define EFI_INVALID_PARAMETER           EFIERR(2)
 
45
#define EFI_UNSUPPORTED                 EFIERR(3)
 
46
#define EFI_BAD_BUFFER_SIZE             EFIERR(4)
 
47
#define EFI_BUFFER_TOO_SMALL            EFIERR(5)
 
48
#define EFI_NOT_READY                   EFIERR(6)
 
49
#define EFI_DEVICE_ERROR                EFIERR(7)
 
50
#define EFI_WRITE_PROTECTED             EFIERR(8)
 
51
#define EFI_OUT_OF_RESOURCES            EFIERR(9)
 
52
#define EFI_VOLUME_CORRUPTED            EFIERR(10)
 
53
#define EFI_VOLUME_FULL                 EFIERR(11)
 
54
#define EFI_NO_MEDIA                    EFIERR(12)
 
55
#define EFI_MEDIA_CHANGED               EFIERR(13)
 
56
#define EFI_NOT_FOUND                   EFIERR(14)
 
57
#define EFI_ACCESS_DENIED               EFIERR(15)
 
58
#define EFI_NO_RESPONSE                 EFIERR(16)
 
59
#define EFI_NO_MAPPING                  EFIERR(17)
 
60
#define EFI_TIMEOUT                     EFIERR(18)
 
61
#define EFI_NOT_STARTED                 EFIERR(19)
 
62
#define EFI_ALREADY_STARTED             EFIERR(20)
 
63
#define EFI_ABORTED                     EFIERR(21)
 
64
#define EFI_ICMP_ERROR                  EFIERR(22)
 
65
#define EFI_TFTP_ERROR                  EFIERR(23)
 
66
#define EFI_PROTOCOL_ERROR              EFIERR(24)
 
67
 
 
68
#define EFI_WARN_UNKOWN_GLYPH           EFIWARN(1)
 
69
#define EFI_WARN_DELETE_FAILURE         EFIWARN(2)
 
70
#define EFI_WARN_WRITE_FAILURE          EFIWARN(3)
 
71
#define EFI_WARN_BUFFER_TOO_SMALL       EFIWARN(4)
 
72
 
 
73
 
 
74
typedef uint64_t        efi_status_t;
 
75
typedef void*           efi_handle_t;
 
76
typedef void*           efi_event_t;
 
77
typedef uint16_t        efi_char16_t;
 
78
 
 
79
 
 
80
/*
 
81
 * Standard EFI table header
 
82
 */
 
83
 
 
84
struct efi_table_header
 
85
{
 
86
        uint64_t        Signature;
 
87
        // Revision of EFI table specification,
 
88
        // upper 16 bit - major revision number
 
89
        // lower 16 bit - minor revision number
 
90
        uint32_t        Revision;
 
91
        uint32_t        HeaderSize;
 
92
        uint32_t        CRC32;
 
93
        uint32_t        Reserved;
 
94
};
 
95
typedef struct efi_table_header efi_table_header_t;
 
96
 
 
97
/*
 
98
 * EFI Time
 
99
 */
 
100
typedef struct
 
101
{          
 
102
        uint16_t        Year;       /* 1998 - 20XX */
 
103
        uint8_t         Month;      /* 1 - 12 */
 
104
        uint8_t         Day;        /* 1 - 31 */
 
105
        uint8_t         Hour;       /* 0 - 23 */
 
106
        uint8_t         Minute;     /* 0 - 59 */
 
107
        uint8_t         Second;     /* 0 - 59 */
 
108
        uint8_t         Pad1;
 
109
        uint32_t        Nanosecond; /* 0 - 999,999,999 */
 
110
        int16_t         TimeZone;   /* -1440 to 1440 or 2047 */
 
111
        uint8_t         Daylight;
 
112
        uint8_t         Pad2;
 
113
} efi_time_t;
 
114
 
 
115
/* Bit definitions for efi_time_t.Daylight */
 
116
#define EFI_TIME_ADJUST_DAYLIGHT    0x01
 
117
#define EFI_TIME_IN_DAYLIGHT        0x02
 
118
 
 
119
/* Value definition for efi_time_t.TimeZone */
 
120
#define EFI_UNSPECIFIED_TIMEZONE    0x07FF
 
121
 
 
122
 
 
123
 
 
124
typedef struct
 
125
{
 
126
        uint32_t        Resolution;     /* 1e-6 parts per million */
 
127
        uint32_t        Accuracy;       /* hertz */
 
128
        uint8_t         SetsToZero;     /* Set clears sub-second time */
 
129
} efi_time_capabilities_t;
 
130
 
 
131
 
 
132
typedef efi_status_t (*efi_get_time_t) (efi_time_t*, efi_time_capabilities_t*);
 
133
typedef efi_status_t (*efi_set_time_t) (efi_time_t*);
 
134
typedef efi_status_t (*efi_get_wakeup_time_t) (uint8_t*, uint8_t*, efi_time_t*);
 
135
typedef efi_status_t (*efi_set_wakeup_time_t) (uint8_t, efi_time_t*);
 
136
 
 
137
/*
 
138
 * Memory
 
139
 * Preseve the attr on any range supplied.
 
140
 * ConventialMemory must have WB,SR,SW when supplied.
 
141
 * When allocating from ConventialMemory always make it WB,SR,SW
 
142
 * When returning to ConventialMemory always make it WB,SR,SW
 
143
 * When getting the memory map, or on RT for runtime types
 
144
 */
 
145
 
 
146
typedef enum {
 
147
        EfiReservedMemoryType,          /* 0 */
 
148
        EfiLoaderCode,
 
149
        EfiLoaderData,
 
150
        EfiBootServicesCode,
 
151
        EfiBootServicesData,
 
152
        EfiRuntimeServicesCode,
 
153
        EfiRuntimeServicesData,         /* 6 */
 
154
        EfiConventionalMemory,          /* 7 */
 
155
        EfiUnusableMemory,
 
156
        EfiACPIReclaimMemory,           /* 9 */
 
157
        EfiACPIMemoryNVS,               /* 10, a */
 
158
        EfiMemoryMappedIO,
 
159
        EfiMemoryMappedIOPortSpace,     /* 12, c */
 
160
        EfiPalCode,                     /* 13, d */
 
161
        EfiMaxMemoryType                /* 14, e */
 
162
} efi_memory_type_t;
 
163
 
 
164
/* possible caching types for the memory range */
 
165
#define EFI_MEMORY_UC           0x0000000000000001
 
166
#define EFI_MEMORY_WC           0x0000000000000002
 
167
#define EFI_MEMORY_WT           0x0000000000000004
 
168
#define EFI_MEMORY_WB           0x0000000000000008
 
169
#define EFI_MEMORY_UCE          0x0000000000000010  
 
170
/* physical memory protection on range */
 
171
#define EFI_MEMORY_WP           0x0000000000001000
 
172
#define EFI_MEMORY_RP           0x0000000000002000
 
173
#define EFI_MEMORY_XP           0x0000000000004000
 
174
/* range requires a runtime mapping */
 
175
#define EFI_MEMORY_RUNTIME      0x8000000000000000
 
176
 
 
177
#define EFI_MEMORY_DESCRIPTOR_VERSION  1
 
178
 
 
179
typedef uint64_t efi_phys_addr_t;
 
180
typedef uint64_t efi_virt_addr_t;
 
181
 
 
182
typedef struct
 
183
{
 
184
        uint32_t        Type;           /* 32 bit padding */
 
185
        efi_phys_addr_t PhysicalStart;
 
186
        efi_virt_addr_t VirtualStart;
 
187
        uint64_t        NumberOfPages;
 
188
        uint64_t        Attribute;
 
189
} efi_memory_descriptor_t;
 
190
 
 
191
#define NextMemoryDescriptor(Ptr,Size)  ((efi_memory_descriptor_t*) (((uint8_t*) Ptr) + Size))
 
192
 
 
193
 
 
194
typedef efi_status_t (*efi_set_virtual_address_map_t)
 
195
        (
 
196
                uint64_t MemoryMapSize,
 
197
                uint64_t DescriptorSize,
 
198
                uint32_t DescriptorVersion,
 
199
                efi_memory_descriptor_t* VirtualMap
 
200
        );
 
201
 
 
202
typedef efi_status_t (*efi_convert_pointer_t)
 
203
        (
 
204
                uint64_t DebugDisposition,
 
205
                void** Address
 
206
        );
 
207
 
 
208
/*
 
209
 * A GUID
 
210
 */
 
211
 
 
212
typedef struct
 
213
{          
 
214
        uint32_t        Data1;
 
215
        uint16_t        Data2;
 
216
        uint16_t        Data3;
 
217
        uint8_t         Data4[8]; 
 
218
} efi_guid_t;
 
219
 
 
220
/*
 
221
 * EFI Configuration Table and GUID definitions
 
222
 */
 
223
 
 
224
#define MPS_TABLE_GUID                  \
 
225
        { 0xeb9d2d2f, 0x2d88, 0x11d3,   \
 
226
                { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
 
227
 
 
228
#define ACPI_TABLE_GUID                 \
 
229
        { 0xeb9d2d30, 0x2d88, 0x11d3,   \
 
230
                { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
 
231
 
 
232
#define ACPI_20_TABLE_GUID  \
 
233
        { 0x8868e871, 0xe4f1, 0x11d3,   \
 
234
                { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
 
235
 
 
236
#define SMBIOS_TABLE_GUID    \
 
237
        { 0xeb9d2d31, 0x2d88, 0x11d3,   \
 
238
                { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
 
239
 
 
240
#define SAL_SYSTEM_TABLE_GUID    \
 
241
        { 0xeb9d2d32, 0x2d88, 0x11d3,   \
 
242
                { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
 
243
 
 
244
/* DIG64 Headless Console & Debug Port Table. */
 
245
#define HCDP_TABLE_GUID         \
 
246
        {0xf951938d, 0x620b, 0x42ef,    \
 
247
                {0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } }
 
248
 
 
249
 
 
250
typedef struct efi_configuration_table
 
251
{
 
252
        efi_guid_t      VendorGuid;
 
253
        void*           VendorTable;
 
254
} efi_configuration_table_t;
 
255
 
 
256
 
 
257
/*
 
258
 * EFI platform variables
 
259
 */
 
260
 
 
261
#define EFI_GLOBAL_VARIABLE     \
 
262
    {   0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00,   \
 
263
        0xE0, 0x98, 0x03, 0x2B, 0x8C }
 
264
 
 
265
/* Variable attributes */
 
266
#define EFI_VARIABLE_NON_VOLATILE           0x00000001
 
267
#define EFI_VARIABLE_BOOTSERVICE_ACCESS     0x00000002
 
268
#define EFI_VARIABLE_RUNTIME_ACCESS         0x00000004
 
269
 
 
270
/* Variable size limitation */
 
271
#define EFI_MAXIMUM_VARIABLE_SIZE           1024
 
272
 
 
273
typedef efi_status_t (*efi_get_variable_t)
 
274
        (
 
275
                efi_char16_t*   VariableName,
 
276
                efi_guid_t      *VendorGuid,
 
277
                uint32_t*       Attributes,
 
278
                uint64_t*       DataSize,
 
279
                void*           Data
 
280
        );
 
281
 
 
282
typedef
 
283
efi_status_t (*efi_get_next_variable_name_t)
 
284
        (
 
285
                uint64_t*       VariableNameSize,
 
286
                efi_char16_t*   VariableName,
 
287
                efi_guid_t*     VendorGuid
 
288
        );
 
289
 
 
290
typedef efi_status_t (*efi_set_variable_t)
 
291
        (
 
292
                efi_char16_t*   VariableName,
 
293
                efi_guid_t*     VendorGuid,
 
294
                uint32_t        Attributes,
 
295
                uint64_t        DataSize,
 
296
                void*           Data
 
297
        );
 
298
 
 
299
/*
 
300
 * Misc
 
301
 */
 
302
 
 
303
typedef enum
 
304
{
 
305
        EfiResetCold,
 
306
        EfiResetWarm,
 
307
        EfiResetShutdown
 
308
} efi_reset_type_t;
 
309
 
 
310
 
 
311
typedef efi_status_t (*efi_reset_system_t)
 
312
        (
 
313
                efi_reset_type_t        ResetType,
 
314
                efi_status_t            ResetStatus,
 
315
                uint64_t                DataSize,
 
316
                efi_char16_t*           ResetData
 
317
        );
 
318
 
 
319
typedef efi_status_t (*efi_get_next_high_mono_count_t) (uint32_t* HighCount);
 
320
 
 
321
 
 
322
/*
 
323
 * EFI Runtime Serivces Table
 
324
 */
 
325
 
 
326
#define EFI_RUNTIME_SERVICES_SIGNATURE  0x5652453544e5552ULL
 
327
#define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION<<16) \
 
328
                                        | (EFI_SPECIFICATION_MINOR_REVISION))
 
329
 
 
330
typedef struct
 
331
{
 
332
        efi_table_header_t              Hdr;
 
333
        /* Time services */
 
334
        efi_get_time_t                  GetTime;
 
335
        efi_set_time_t                  SetTime;
 
336
        efi_get_wakeup_time_t           GetWakeupTime;
 
337
        efi_set_wakeup_time_t           SetWakeupTime;
 
338
        /* Virtual memory services */
 
339
        efi_set_virtual_address_map_t   SetVirtualAddressMap;
 
340
        efi_convert_pointer_t           ConvertPointer;
 
341
        /* Variable serviers */
 
342
        efi_get_variable_t              GetVariable;
 
343
        efi_get_next_variable_name_t    GetNextVariableName;
 
344
        efi_set_variable_t              SetVariable;
 
345
        /* Misc */
 
346
        efi_get_next_high_mono_count_t  GetNextHighMonotonicCount;
 
347
        efi_reset_system_t              ResetSystem;
 
348
 
 
349
} efi_runtime_services_t;
 
350
 
 
351
 
 
352
#define EFI_SPECIFICATION_MAJOR_REVISION 1
 
353
#define EFI_SYSTEM_TABLE_SIGNATURE      0x5453595320494249
 
354
#define EFI_SYSTEM_TABLE_REVISION  ((EFI_SPECIFICATION_MAJOR_REVISION<<16) \
 
355
                                        | (EFI_SPECIFICATION_MINOR_REVISION))
 
356
 
 
357
struct efi_system_table
 
358
{
 
359
        efi_table_header_t      Hdr;
 
360
 
 
361
        uint64_t        FirmwareVendor;         // phys addr of CHAR16
 
362
        uint32_t        FirmwareRevision;       // Firmware vendor specific
 
363
 
 
364
        efi_handle_t    ConsoleInHandle;
 
365
        uint64_t        ConIn;
 
366
 
 
367
        efi_handle_t    ConsoleOutHandle;
 
368
        uint64_t        ConOut;
 
369
 
 
370
        efi_handle_t    StandardErrorHandle;
 
371
        uint64_t        StdErr;
 
372
 
 
373
        uint64_t        RuntimeServices;        // phys addr
 
374
        uint64_t        BootServices;           // phys addr
 
375
 
 
376
        uint64_t        NumberOfTableEntries;   // Number of entries in Config
 
377
        uint64_t        ConfigurationTable;     // phys addr of ConfigTable
 
378
};
 
379
 
 
380
typedef struct efi_system_table efi_system_table_t;
 
381
 
 
382
 
 
383
#define EFI_PAGE_SIZE   4096
 
384
#define EFI_PAGE_MASK   0xFFF
 
385
#define EFI_PAGE_SHIFT  12
 
386
 
 
387
#define EFI_SIZE_TO_PAGES(a)  \
 
388
    ( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) )
 
389
 
 
390
 
 
391
void init_efi(void);
 
392
int efi_get_time(efi_time_t* tmP);
 
393
efi_status_t ia64_call_efi_physical(void *, ...);
 
394
 
 
395
 
 
396
#endif /* _EFI_H_ */