1 /*
2  * Extensible Firmware Interface
3  * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation;
8  * version 2.1 of the License.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Copyright (C) 1999 VA Linux Systems
19  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
20  * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
21  *      David Mosberger-Tang <davidm@hpl.hp.com>
22  *      Stephane Eranian <eranian@hpl.hp.com>
23  */
24 
25 #ifndef XC_EFI_H
26 #define XC_EFI_H
27 
28 /* definitions from xen/include/asm-ia64/linux-xen/linux/efi.h */
29 
30 typedef struct {
31         uint8_t b[16];
32 } efi_guid_t;
33 
34 #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
35 ((efi_guid_t) \
36 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
37   (b) & 0xff, ((b) >> 8) & 0xff, \
38   (c) & 0xff, ((c) >> 8) & 0xff, \
39   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
40 
41 /*
42  * Generic EFI table header
43  */
44 typedef struct {
45 	uint64_t signature;
46 	uint32_t revision;
47 	uint32_t headersize;
48 	uint32_t crc32;
49 	uint32_t reserved;
50 } efi_table_hdr_t;
51 
52 /*
53  * Memory map descriptor:
54  */
55 
56 /* Memory types: */
57 #define EFI_RESERVED_TYPE                0
58 #define EFI_LOADER_CODE                  1
59 #define EFI_LOADER_DATA                  2
60 #define EFI_BOOT_SERVICES_CODE           3
61 #define EFI_BOOT_SERVICES_DATA           4
62 #define EFI_RUNTIME_SERVICES_CODE        5
63 #define EFI_RUNTIME_SERVICES_DATA        6
64 #define EFI_CONVENTIONAL_MEMORY          7
65 #define EFI_UNUSABLE_MEMORY              8
66 #define EFI_ACPI_RECLAIM_MEMORY          9
67 #define EFI_ACPI_MEMORY_NVS             10
68 #define EFI_MEMORY_MAPPED_IO            11
69 #define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12
70 #define EFI_PAL_CODE                    13
71 #define EFI_MAX_MEMORY_TYPE             14
72 
73 /* Attribute values: */
74 #define EFI_MEMORY_UC           ((uint64_t)0x0000000000000001ULL)    /* uncached */
75 #define EFI_MEMORY_WC           ((uint64_t)0x0000000000000002ULL)    /* write-coalescing */
76 #define EFI_MEMORY_WT           ((uint64_t)0x0000000000000004ULL)    /* write-through */
77 #define EFI_MEMORY_WB           ((uint64_t)0x0000000000000008ULL)    /* write-back */
78 #define EFI_MEMORY_WP           ((uint64_t)0x0000000000001000ULL)    /* write-protect */
79 #define EFI_MEMORY_RP           ((uint64_t)0x0000000000002000ULL)    /* read-protect */
80 #define EFI_MEMORY_XP           ((uint64_t)0x0000000000004000ULL)    /* execute-protect */
81 #define EFI_MEMORY_RUNTIME      ((uint64_t)0x8000000000000000ULL)    /* range requires runtime mapping */
82 #define EFI_MEMORY_DESCRIPTOR_VERSION   1
83 
84 #define EFI_PAGE_SHIFT          12
85 
86 /*
87  * For current x86 implementations of EFI, there is
88  * additional padding in the mem descriptors.  This is not
89  * the case in ia64.  Need to have this fixed in the f/w.
90  */
91 typedef struct {
92         uint32_t type;
93         uint32_t pad;
94         uint64_t phys_addr;
95         uint64_t virt_addr;
96         uint64_t num_pages;
97         uint64_t attribute;
98 #if defined (__i386__)
99         uint64_t pad1;
100 #endif
101 } efi_memory_desc_t;
102 
103 /*
104  * EFI Runtime Services table
105  */
106 #define EFI_RUNTIME_SERVICES_SIGNATURE	((uint64_t)0x5652453544e5552ULL)
107 #define EFI_RUNTIME_SERVICES_REVISION	0x00010000
108 
109 typedef struct {
110 	efi_table_hdr_t hdr;
111 	unsigned long get_time;
112 	unsigned long set_time;
113 	unsigned long get_wakeup_time;
114 	unsigned long set_wakeup_time;
115 	unsigned long set_virtual_address_map;
116 	unsigned long convert_pointer;
117 	unsigned long get_variable;
118 	unsigned long get_next_variable;
119 	unsigned long set_variable;
120 	unsigned long get_next_high_mono_count;
121 	unsigned long reset_system;
122 } efi_runtime_services_t;
123 
124 /*
125  *  EFI Configuration Table and GUID definitions
126  */
127 #define NULL_GUID \
128     EFI_GUID(  0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
129 #define ACPI_20_TABLE_GUID    \
130     EFI_GUID(  0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 )
131 #define SAL_SYSTEM_TABLE_GUID    \
132     EFI_GUID(  0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
133 
134 typedef struct {
135 	efi_guid_t guid;
136 	unsigned long table;
137 } efi_config_table_t;
138 
139 #define EFI_SYSTEM_TABLE_SIGNATURE ((uint64_t)0x5453595320494249ULL)
140 #define EFI_SYSTEM_TABLE_REVISION  ((1 << 16) | 00)
141 
142 typedef struct {
143 	efi_table_hdr_t hdr;
144 	unsigned long fw_vendor;	/* physical addr of CHAR16 vendor string */
145 	uint32_t fw_revision;
146 	unsigned long con_in_handle;
147 	unsigned long con_in;
148 	unsigned long con_out_handle;
149 	unsigned long con_out;
150 	unsigned long stderr_handle;
151 	unsigned long stderr;
152 	efi_runtime_services_t *runtime;
153 	unsigned long boottime;
154 	unsigned long nr_tables;
155 	unsigned long tables;
156 } efi_system_table_t;
157 
158 #endif /* XC_EFI_H */
159