Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
#ifndef _LINUX_EFI_H
2
#define _LINUX_EFI_H
3
 
4
/*
5
 * Extensible Firmware Interface
6
 * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999
7
 *
8
 * Copyright (C) 1999 VA Linux Systems
9
 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
10
 * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
11
 *      David Mosberger-Tang <davidm@hpl.hp.com>
12
 *      Stephane Eranian <eranian@hpl.hp.com>
13
 */
14
#include <linux/init.h>
15
#include <linux/string.h>
16
#include <linux/time.h>
17
#include <linux/types.h>
18
#include <linux/proc_fs.h>
19
 
20
#include <asm/page.h>
21
#include <asm/system.h>
22
 
23
#define EFI_SUCCESS             0
24
#define EFI_LOAD_ERROR          ( 1 | (1UL << (BITS_PER_LONG-1)))
25
#define EFI_INVALID_PARAMETER   ( 2 | (1UL << (BITS_PER_LONG-1)))
26
#define EFI_UNSUPPORTED         ( 3 | (1UL << (BITS_PER_LONG-1)))
27
#define EFI_BAD_BUFFER_SIZE     ( 4 | (1UL << (BITS_PER_LONG-1)))
28
#define EFI_BUFFER_TOO_SMALL    ( 5 | (1UL << (BITS_PER_LONG-1)))
29
#define EFI_NOT_FOUND           (14 | (1UL << (BITS_PER_LONG-1)))
30
 
31
typedef unsigned long efi_status_t;
32
typedef u8 efi_bool_t;
33
typedef u16 efi_char16_t;               /* UNICODE character */
34
 
35
 
36
typedef struct {
37
        u8 b[16];
38
} efi_guid_t;
39
 
40
#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
41
((efi_guid_t) \
42
{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
43
  (b) & 0xff, ((b) >> 8) & 0xff, \
44
  (c) & 0xff, ((c) >> 8) & 0xff, \
45
  (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
46
 
47
/*
48
 * Generic EFI table header
49
 */
50
typedef struct {
51
        u64 signature;
52
        u32 revision;
53
        u32 headersize;
54
        u32 crc32;
55
        u32 reserved;
56
} efi_table_hdr_t;
57
 
58
/*
59
 * Memory map descriptor:
60
 */
61
 
62
/* Memory types: */
63
#define EFI_RESERVED_TYPE                0
64
#define EFI_LOADER_CODE                  1
65
#define EFI_LOADER_DATA                  2
66
#define EFI_BOOT_SERVICES_CODE           3
67
#define EFI_BOOT_SERVICES_DATA           4
68
#define EFI_RUNTIME_SERVICES_CODE        5
69
#define EFI_RUNTIME_SERVICES_DATA        6
70
#define EFI_CONVENTIONAL_MEMORY          7
71
#define EFI_UNUSABLE_MEMORY              8
72
#define EFI_ACPI_RECLAIM_MEMORY          9
73
#define EFI_ACPI_MEMORY_NVS             10
74
#define EFI_MEMORY_MAPPED_IO            11
75
#define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12
76
#define EFI_PAL_CODE                    13
77
#define EFI_MAX_MEMORY_TYPE             14
78
 
79
/* Attribute values: */
80
#define EFI_MEMORY_UC           0x0000000000000001      /* uncached */
81
#define EFI_MEMORY_WC           0x0000000000000002      /* write-coalescing */
82
#define EFI_MEMORY_WT           0x0000000000000004      /* write-through */
83
#define EFI_MEMORY_WB           0x0000000000000008      /* write-back */
84
#define EFI_MEMORY_WP           0x0000000000001000      /* write-protect */
85
#define EFI_MEMORY_RP           0x0000000000002000      /* read-protect */
86
#define EFI_MEMORY_XP           0x0000000000004000      /* execute-protect */
87
#define EFI_MEMORY_RUNTIME      0x8000000000000000      /* range requires runtime mapping */
88
#define EFI_MEMORY_DESCRIPTOR_VERSION   1
89
 
90
#define EFI_PAGE_SHIFT          12
91
 
92
typedef struct {
93
        u32 type;
94
        u32 pad;
95
        u64 phys_addr;
96
        u64 virt_addr;
97
        u64 num_pages;
98
        u64 attribute;
99
} efi_memory_desc_t;
100
 
101
typedef int efi_freemem_callback_t (unsigned long start, unsigned long end, void *arg);
102
 
103
/*
104
 * Types and defines for Time Services
105
 */
106
#define EFI_TIME_ADJUST_DAYLIGHT 0x1
107
#define EFI_TIME_IN_DAYLIGHT     0x2
108
#define EFI_UNSPECIFIED_TIMEZONE 0x07ff
109
 
110
typedef struct {
111
        u16 year;
112
        u8 month;
113
        u8 day;
114
        u8 hour;
115
        u8 minute;
116
        u8 second;
117
        u8 pad1;
118
        u32 nanosecond;
119
        s16 timezone;
120
        u8 daylight;
121
        u8 pad2;
122
} efi_time_t;
123
 
124
typedef struct {
125
        u32 resolution;
126
        u32 accuracy;
127
        u8 sets_to_zero;
128
} efi_time_cap_t;
129
 
130
/*
131
 * Types and defines for EFI ResetSystem
132
 */
133
#define EFI_RESET_COLD 0
134
#define EFI_RESET_WARM 1
135
 
136
/*
137
 * EFI Runtime Services table
138
 */
139
#define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552
140
#define EFI_RUNTIME_SERVICES_REVISION  0x00010000
141
 
142
typedef struct {
143
        efi_table_hdr_t hdr;
144
        unsigned long get_time;
145
        unsigned long set_time;
146
        unsigned long get_wakeup_time;
147
        unsigned long set_wakeup_time;
148
        unsigned long set_virtual_address_map;
149
        unsigned long convert_pointer;
150
        unsigned long get_variable;
151
        unsigned long get_next_variable;
152
        unsigned long set_variable;
153
        unsigned long get_next_high_mono_count;
154
        unsigned long reset_system;
155
} efi_runtime_services_t;
156
 
157
typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc);
158
typedef efi_status_t efi_set_time_t (efi_time_t *tm);
159
typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending,
160
                                            efi_time_t *tm);
161
typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm);
162
typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr,
163
                                         unsigned long *data_size, void *data);
164
typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name,
165
                                              efi_guid_t *vendor);
166
typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor,
167
                                         unsigned long attr, unsigned long data_size,
168
                                         void *data);
169
typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);
170
typedef void efi_reset_system_t (int reset_type, efi_status_t status,
171
                                 unsigned long data_size, efi_char16_t *data);
172
 
173
/*
174
 *  EFI Configuration Table and GUID definitions
175
 */
176
#define NULL_GUID \
177
    EFI_GUID(  0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
178
 
179
#define MPS_TABLE_GUID    \
180
    EFI_GUID(  0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
181
 
182
#define ACPI_TABLE_GUID    \
183
    EFI_GUID(  0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
184
 
185
#define ACPI_20_TABLE_GUID    \
186
    EFI_GUID(  0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 )
187
 
188
#define SMBIOS_TABLE_GUID    \
189
    EFI_GUID(  0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
190
 
191
#define SAL_SYSTEM_TABLE_GUID    \
192
    EFI_GUID(  0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
193
 
194
#define HCDP_TABLE_GUID \
195
    EFI_GUID(  0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 )
196
 
197
typedef struct {
198
        efi_guid_t guid;
199
        unsigned long table;
200
} efi_config_table_t;
201
 
202
#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
203
#define EFI_SYSTEM_TABLE_REVISION  ((1 << 16) | 00)
204
 
205
typedef struct {
206
        efi_table_hdr_t hdr;
207
        unsigned long fw_vendor;        /* physical addr of CHAR16 vendor string */
208
        u32 fw_revision;
209
        unsigned long con_in_handle;
210
        unsigned long con_in;
211
        unsigned long con_out_handle;
212
        unsigned long con_out;
213
        unsigned long stderr_handle;
214
        unsigned long stderr;
215
        efi_runtime_services_t *runtime;
216
        unsigned long boottime;
217
        unsigned long nr_tables;
218
        unsigned long tables;
219
} efi_system_table_t;
220
 
221
/*
222
 * All runtime access to EFI goes through this structure:
223
 */
224
extern struct efi {
225
        efi_system_table_t *systab;     /* EFI system table */
226
        void *mps;                      /* MPS table */
227
        void *acpi;                     /* ACPI table  (IA64 ext 0.71) */
228
        void *acpi20;                   /* ACPI table  (ACPI 2.0) */
229
        void *smbios;                   /* SM BIOS table */
230
        void *sal_systab;               /* SAL system table */
231
        void *boot_info;                /* boot info table */
232
        void *hcdp;                     /* HCDP table */
233
        efi_get_time_t *get_time;
234
        efi_set_time_t *set_time;
235
        efi_get_wakeup_time_t *get_wakeup_time;
236
        efi_set_wakeup_time_t *set_wakeup_time;
237
        efi_get_variable_t *get_variable;
238
        efi_get_next_variable_t *get_next_variable;
239
        efi_set_variable_t *set_variable;
240
        efi_get_next_high_mono_count_t *get_next_high_mono_count;
241
        efi_reset_system_t *reset_system;
242
} efi;
243
 
244
static inline int
245
efi_guidcmp (efi_guid_t left, efi_guid_t right)
246
{
247
        return memcmp(&left, &right, sizeof (efi_guid_t));
248
}
249
 
250
static inline char *
251
efi_guid_unparse(efi_guid_t *guid, char *out)
252
{
253
        sprintf(out, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
254
                guid->b[3], guid->b[2], guid->b[1], guid->b[0],
255
                guid->b[5], guid->b[4], guid->b[7], guid->b[6],
256
                guid->b[8], guid->b[9], guid->b[10], guid->b[11],
257
                guid->b[12], guid->b[13], guid->b[14], guid->b[15]);
258
        return out;
259
}
260
 
261
extern void efi_init (void);
262
extern void efi_map_pal_code (void);
263
extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
264
extern void efi_gettimeofday (struct timespec *ts);
265
extern void efi_enter_virtual_mode (void);      /* switch EFI to virtual mode, if possible */
266
extern u64 efi_get_iobase (void);
267
extern u32 efi_mem_type (unsigned long phys_addr);
268
extern u64 efi_mem_attributes (unsigned long phys_addr);
269
 
270
/*
271
 * Variable Attributes
272
 */
273
#define EFI_VARIABLE_NON_VOLATILE       0x0000000000000001
274
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
275
#define EFI_VARIABLE_RUNTIME_ACCESS     0x0000000000000004
276
 
277
 
278
/*
279
 * efi_dir is allocated in arch/ia64/kernel/efi.c.
280
 */
281
#ifdef CONFIG_PROC_FS
282
extern struct proc_dir_entry *efi_dir;
283
#endif
284
 
285
#endif /* _LINUX_EFI_H */