diff options
-rw-r--r-- | Documentation/efi-stub.txt (renamed from Documentation/x86/efi-stub.txt) | 0 | ||||
-rw-r--r-- | Documentation/kernel-parameters.txt | 8 | ||||
-rw-r--r-- | arch/ia64/include/asm/io.h | 1 | ||||
-rw-r--r-- | arch/ia64/kernel/efi.c | 54 | ||||
-rw-r--r-- | arch/x86/Kconfig | 2 | ||||
-rw-r--r-- | arch/x86/Kconfig.debug | 10 | ||||
-rw-r--r-- | arch/x86/boot/compressed/eboot.c | 789 | ||||
-rw-r--r-- | arch/x86/boot/compressed/eboot.h | 9 | ||||
-rw-r--r-- | arch/x86/include/asm/efi.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/early_printk.c | 7 | ||||
-rw-r--r-- | arch/x86/platform/efi/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/platform/efi/early_printk.c | 191 | ||||
-rw-r--r-- | arch/x86/platform/efi/efi.c | 126 | ||||
-rw-r--r-- | drivers/firmware/efi/efi-stub-helper.c | 636 | ||||
-rw-r--r-- | drivers/firmware/efi/efi.c | 140 | ||||
-rw-r--r-- | drivers/firmware/efi/efivars.c | 2 | ||||
-rw-r--r-- | include/linux/efi.h | 58 |
17 files changed, 1245 insertions, 791 deletions
diff --git a/Documentation/x86/efi-stub.txt b/Documentation/efi-stub.txt index 44e6bb6ead10..44e6bb6ead10 100644 --- a/Documentation/x86/efi-stub.txt +++ b/Documentation/efi-stub.txt | |||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 203f4a9d9efe..0fbde71a1297 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -847,6 +847,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
847 | 847 | ||
848 | earlyprintk= [X86,SH,BLACKFIN,ARM] | 848 | earlyprintk= [X86,SH,BLACKFIN,ARM] |
849 | earlyprintk=vga | 849 | earlyprintk=vga |
850 | earlyprintk=efi | ||
850 | earlyprintk=xen | 851 | earlyprintk=xen |
851 | earlyprintk=serial[,ttySn[,baudrate]] | 852 | earlyprintk=serial[,ttySn[,baudrate]] |
852 | earlyprintk=serial[,0x...[,baudrate]] | 853 | earlyprintk=serial[,0x...[,baudrate]] |
@@ -860,7 +861,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
860 | Append ",keep" to not disable it when the real console | 861 | Append ",keep" to not disable it when the real console |
861 | takes over. | 862 | takes over. |
862 | 863 | ||
863 | Only vga or serial or usb debug port at a time. | 864 | Only one of vga, efi, serial, or usb debug port can |
865 | be used at a time. | ||
864 | 866 | ||
865 | Currently only ttyS0 and ttyS1 may be specified by | 867 | Currently only ttyS0 and ttyS1 may be specified by |
866 | name. Other I/O ports may be explicitly specified | 868 | name. Other I/O ports may be explicitly specified |
@@ -874,8 +876,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
874 | Interaction with the standard serial driver is not | 876 | Interaction with the standard serial driver is not |
875 | very good. | 877 | very good. |
876 | 878 | ||
877 | The VGA output is eventually overwritten by the real | 879 | The VGA and EFI output is eventually overwritten by |
878 | console. | 880 | the real console. |
879 | 881 | ||
880 | The xen output can only be used by Xen PV guests. | 882 | The xen output can only be used by Xen PV guests. |
881 | 883 | ||
diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index 74a7cc3293bc..0d2bcb37ec35 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h | |||
@@ -424,6 +424,7 @@ extern void __iomem * ioremap(unsigned long offset, unsigned long size); | |||
424 | extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); | 424 | extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); |
425 | extern void iounmap (volatile void __iomem *addr); | 425 | extern void iounmap (volatile void __iomem *addr); |
426 | extern void __iomem * early_ioremap (unsigned long phys_addr, unsigned long size); | 426 | extern void __iomem * early_ioremap (unsigned long phys_addr, unsigned long size); |
427 | #define early_memremap(phys_addr, size) early_ioremap(phys_addr, size) | ||
427 | extern void early_iounmap (volatile void __iomem *addr, unsigned long size); | 428 | extern void early_iounmap (volatile void __iomem *addr, unsigned long size); |
428 | static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) | 429 | static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned long size) |
429 | { | 430 | { |
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index 51bce594eb83..da5b462e6de6 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c | |||
@@ -44,10 +44,15 @@ | |||
44 | 44 | ||
45 | #define EFI_DEBUG 0 | 45 | #define EFI_DEBUG 0 |
46 | 46 | ||
47 | static __initdata unsigned long palo_phys; | ||
48 | |||
49 | static __initdata efi_config_table_type_t arch_tables[] = { | ||
50 | {PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID, "PALO", &palo_phys}, | ||
51 | {NULL_GUID, NULL, 0}, | ||
52 | }; | ||
53 | |||
47 | extern efi_status_t efi_call_phys (void *, ...); | 54 | extern efi_status_t efi_call_phys (void *, ...); |
48 | 55 | ||
49 | struct efi efi; | ||
50 | EXPORT_SYMBOL(efi); | ||
51 | static efi_runtime_services_t *runtime; | 56 | static efi_runtime_services_t *runtime; |
52 | static u64 mem_limit = ~0UL, max_addr = ~0UL, min_addr = 0UL; | 57 | static u64 mem_limit = ~0UL, max_addr = ~0UL, min_addr = 0UL; |
53 | 58 | ||
@@ -423,9 +428,9 @@ static u8 __init palo_checksum(u8 *buffer, u32 length) | |||
423 | * Parse and handle PALO table which is published at: | 428 | * Parse and handle PALO table which is published at: |
424 | * http://www.dig64.org/home/DIG64_PALO_R1_0.pdf | 429 | * http://www.dig64.org/home/DIG64_PALO_R1_0.pdf |
425 | */ | 430 | */ |
426 | static void __init handle_palo(unsigned long palo_phys) | 431 | static void __init handle_palo(unsigned long phys_addr) |
427 | { | 432 | { |
428 | struct palo_table *palo = __va(palo_phys); | 433 | struct palo_table *palo = __va(phys_addr); |
429 | u8 checksum; | 434 | u8 checksum; |
430 | 435 | ||
431 | if (strncmp(palo->signature, PALO_SIG, sizeof(PALO_SIG) - 1)) { | 436 | if (strncmp(palo->signature, PALO_SIG, sizeof(PALO_SIG) - 1)) { |
@@ -467,12 +472,10 @@ void __init | |||
467 | efi_init (void) | 472 | efi_init (void) |
468 | { | 473 | { |
469 | void *efi_map_start, *efi_map_end; | 474 | void *efi_map_start, *efi_map_end; |
470 | efi_config_table_t *config_tables; | ||
471 | efi_char16_t *c16; | 475 | efi_char16_t *c16; |
472 | u64 efi_desc_size; | 476 | u64 efi_desc_size; |
473 | char *cp, vendor[100] = "unknown"; | 477 | char *cp, vendor[100] = "unknown"; |
474 | int i; | 478 | int i; |
475 | unsigned long palo_phys; | ||
476 | 479 | ||
477 | /* | 480 | /* |
478 | * It's too early to be able to use the standard kernel command line | 481 | * It's too early to be able to use the standard kernel command line |
@@ -514,8 +517,6 @@ efi_init (void) | |||
514 | efi.systab->hdr.revision >> 16, | 517 | efi.systab->hdr.revision >> 16, |
515 | efi.systab->hdr.revision & 0xffff); | 518 | efi.systab->hdr.revision & 0xffff); |
516 | 519 | ||
517 | config_tables = __va(efi.systab->tables); | ||
518 | |||
519 | /* Show what we know for posterity */ | 520 | /* Show what we know for posterity */ |
520 | c16 = __va(efi.systab->fw_vendor); | 521 | c16 = __va(efi.systab->fw_vendor); |
521 | if (c16) { | 522 | if (c16) { |
@@ -528,43 +529,10 @@ efi_init (void) | |||
528 | efi.systab->hdr.revision >> 16, | 529 | efi.systab->hdr.revision >> 16, |
529 | efi.systab->hdr.revision & 0xffff, vendor); | 530 | efi.systab->hdr.revision & 0xffff, vendor); |
530 | 531 | ||
531 | efi.mps = EFI_INVALID_TABLE_ADDR; | ||
532 | efi.acpi = EFI_INVALID_TABLE_ADDR; | ||
533 | efi.acpi20 = EFI_INVALID_TABLE_ADDR; | ||
534 | efi.smbios = EFI_INVALID_TABLE_ADDR; | ||
535 | efi.sal_systab = EFI_INVALID_TABLE_ADDR; | ||
536 | efi.boot_info = EFI_INVALID_TABLE_ADDR; | ||
537 | efi.hcdp = EFI_INVALID_TABLE_ADDR; | ||
538 | efi.uga = EFI_INVALID_TABLE_ADDR; | ||
539 | |||
540 | palo_phys = EFI_INVALID_TABLE_ADDR; | 532 | palo_phys = EFI_INVALID_TABLE_ADDR; |
541 | 533 | ||
542 | for (i = 0; i < (int) efi.systab->nr_tables; i++) { | 534 | if (efi_config_init(arch_tables) != 0) |
543 | if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) { | 535 | return; |
544 | efi.mps = config_tables[i].table; | ||
545 | printk(" MPS=0x%lx", config_tables[i].table); | ||
546 | } else if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) { | ||
547 | efi.acpi20 = config_tables[i].table; | ||
548 | printk(" ACPI 2.0=0x%lx", config_tables[i].table); | ||
549 | } else if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) { | ||
550 | efi.acpi = config_tables[i].table; | ||
551 | printk(" ACPI=0x%lx", config_tables[i].table); | ||
552 | } else if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) { | ||
553 | efi.smbios = config_tables[i].table; | ||
554 | printk(" SMBIOS=0x%lx", config_tables[i].table); | ||
555 | } else if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) { | ||
556 | efi.sal_systab = config_tables[i].table; | ||
557 | printk(" SALsystab=0x%lx", config_tables[i].table); | ||
558 | } else if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) { | ||
559 | efi.hcdp = config_tables[i].table; | ||
560 | printk(" HCDP=0x%lx", config_tables[i].table); | ||
561 | } else if (efi_guidcmp(config_tables[i].guid, | ||
562 | PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID) == 0) { | ||
563 | palo_phys = config_tables[i].table; | ||
564 | printk(" PALO=0x%lx", config_tables[i].table); | ||
565 | } | ||
566 | } | ||
567 | printk("\n"); | ||
568 | 536 | ||
569 | if (palo_phys != EFI_INVALID_TABLE_ADDR) | 537 | if (palo_phys != EFI_INVALID_TABLE_ADDR) |
570 | handle_palo(palo_phys); | 538 | handle_palo(palo_phys); |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e6dde05e7eb0..dddba2663bbf 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -1597,7 +1597,7 @@ config EFI_STUB | |||
1597 | This kernel feature allows a bzImage to be loaded directly | 1597 | This kernel feature allows a bzImage to be loaded directly |
1598 | by EFI firmware without the use of a bootloader. | 1598 | by EFI firmware without the use of a bootloader. |
1599 | 1599 | ||
1600 | See Documentation/x86/efi-stub.txt for more information. | 1600 | See Documentation/efi-stub.txt for more information. |
1601 | 1601 | ||
1602 | config SECCOMP | 1602 | config SECCOMP |
1603 | def_bool y | 1603 | def_bool y |
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 78d91afb8e50..0f3621ed1db6 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug | |||
@@ -59,6 +59,16 @@ config EARLY_PRINTK_DBGP | |||
59 | with klogd/syslogd or the X server. You should normally N here, | 59 | with klogd/syslogd or the X server. You should normally N here, |
60 | unless you want to debug such a crash. You need usb debug device. | 60 | unless you want to debug such a crash. You need usb debug device. |
61 | 61 | ||
62 | config EARLY_PRINTK_EFI | ||
63 | bool "Early printk via the EFI framebuffer" | ||
64 | depends on EFI && EARLY_PRINTK | ||
65 | select FONT_SUPPORT | ||
66 | ---help--- | ||
67 | Write kernel log output directly into the EFI framebuffer. | ||
68 | |||
69 | This is useful for kernel debugging when your machine crashes very | ||
70 | early before the console code is initialized. | ||
71 | |||
62 | config X86_PTDUMP | 72 | config X86_PTDUMP |
63 | bool "Export kernel pagetable layout to userspace via debugfs" | 73 | bool "Export kernel pagetable layout to userspace via debugfs" |
64 | depends on DEBUG_KERNEL | 74 | depends on DEBUG_KERNEL |
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index b7388a425f09..a7677babf946 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c | |||
@@ -19,214 +19,10 @@ | |||
19 | 19 | ||
20 | static efi_system_table_t *sys_table; | 20 | static efi_system_table_t *sys_table; |
21 | 21 | ||
22 | static void efi_char16_printk(efi_char16_t *str) | ||
23 | { | ||
24 | struct efi_simple_text_output_protocol *out; | ||
25 | |||
26 | out = (struct efi_simple_text_output_protocol *)sys_table->con_out; | ||
27 | efi_call_phys2(out->output_string, out, str); | ||
28 | } | ||
29 | |||
30 | static void efi_printk(char *str) | ||
31 | { | ||
32 | char *s8; | ||
33 | |||
34 | for (s8 = str; *s8; s8++) { | ||
35 | efi_char16_t ch[2] = { 0 }; | ||
36 | |||
37 | ch[0] = *s8; | ||
38 | if (*s8 == '\n') { | ||
39 | efi_char16_t nl[2] = { '\r', 0 }; | ||
40 | efi_char16_printk(nl); | ||
41 | } | ||
42 | |||
43 | efi_char16_printk(ch); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | static efi_status_t __get_map(efi_memory_desc_t **map, unsigned long *map_size, | ||
48 | unsigned long *desc_size) | ||
49 | { | ||
50 | efi_memory_desc_t *m = NULL; | ||
51 | efi_status_t status; | ||
52 | unsigned long key; | ||
53 | u32 desc_version; | ||
54 | |||
55 | *map_size = sizeof(*m) * 32; | ||
56 | again: | ||
57 | /* | ||
58 | * Add an additional efi_memory_desc_t because we're doing an | ||
59 | * allocation which may be in a new descriptor region. | ||
60 | */ | ||
61 | *map_size += sizeof(*m); | ||
62 | status = efi_call_phys3(sys_table->boottime->allocate_pool, | ||
63 | EFI_LOADER_DATA, *map_size, (void **)&m); | ||
64 | if (status != EFI_SUCCESS) | ||
65 | goto fail; | ||
66 | |||
67 | status = efi_call_phys5(sys_table->boottime->get_memory_map, map_size, | ||
68 | m, &key, desc_size, &desc_version); | ||
69 | if (status == EFI_BUFFER_TOO_SMALL) { | ||
70 | efi_call_phys1(sys_table->boottime->free_pool, m); | ||
71 | goto again; | ||
72 | } | ||
73 | |||
74 | if (status != EFI_SUCCESS) | ||
75 | efi_call_phys1(sys_table->boottime->free_pool, m); | ||
76 | 22 | ||
77 | fail: | 23 | #include "../../../../drivers/firmware/efi/efi-stub-helper.c" |
78 | *map = m; | ||
79 | return status; | ||
80 | } | ||
81 | |||
82 | /* | ||
83 | * Allocate at the highest possible address that is not above 'max'. | ||
84 | */ | ||
85 | static efi_status_t high_alloc(unsigned long size, unsigned long align, | ||
86 | unsigned long *addr, unsigned long max) | ||
87 | { | ||
88 | unsigned long map_size, desc_size; | ||
89 | efi_memory_desc_t *map; | ||
90 | efi_status_t status; | ||
91 | unsigned long nr_pages; | ||
92 | u64 max_addr = 0; | ||
93 | int i; | ||
94 | |||
95 | status = __get_map(&map, &map_size, &desc_size); | ||
96 | if (status != EFI_SUCCESS) | ||
97 | goto fail; | ||
98 | |||
99 | nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
100 | again: | ||
101 | for (i = 0; i < map_size / desc_size; i++) { | ||
102 | efi_memory_desc_t *desc; | ||
103 | unsigned long m = (unsigned long)map; | ||
104 | u64 start, end; | ||
105 | |||
106 | desc = (efi_memory_desc_t *)(m + (i * desc_size)); | ||
107 | if (desc->type != EFI_CONVENTIONAL_MEMORY) | ||
108 | continue; | ||
109 | |||
110 | if (desc->num_pages < nr_pages) | ||
111 | continue; | ||
112 | 24 | ||
113 | start = desc->phys_addr; | ||
114 | end = start + desc->num_pages * (1UL << EFI_PAGE_SHIFT); | ||
115 | 25 | ||
116 | if ((start + size) > end || (start + size) > max) | ||
117 | continue; | ||
118 | |||
119 | if (end - size > max) | ||
120 | end = max; | ||
121 | |||
122 | if (round_down(end - size, align) < start) | ||
123 | continue; | ||
124 | |||
125 | start = round_down(end - size, align); | ||
126 | |||
127 | /* | ||
128 | * Don't allocate at 0x0. It will confuse code that | ||
129 | * checks pointers against NULL. | ||
130 | */ | ||
131 | if (start == 0x0) | ||
132 | continue; | ||
133 | |||
134 | if (start > max_addr) | ||
135 | max_addr = start; | ||
136 | } | ||
137 | |||
138 | if (!max_addr) | ||
139 | status = EFI_NOT_FOUND; | ||
140 | else { | ||
141 | status = efi_call_phys4(sys_table->boottime->allocate_pages, | ||
142 | EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, | ||
143 | nr_pages, &max_addr); | ||
144 | if (status != EFI_SUCCESS) { | ||
145 | max = max_addr; | ||
146 | max_addr = 0; | ||
147 | goto again; | ||
148 | } | ||
149 | |||
150 | *addr = max_addr; | ||
151 | } | ||
152 | |||
153 | free_pool: | ||
154 | efi_call_phys1(sys_table->boottime->free_pool, map); | ||
155 | |||
156 | fail: | ||
157 | return status; | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * Allocate at the lowest possible address. | ||
162 | */ | ||
163 | static efi_status_t low_alloc(unsigned long size, unsigned long align, | ||
164 | unsigned long *addr) | ||
165 | { | ||
166 | unsigned long map_size, desc_size; | ||
167 | efi_memory_desc_t *map; | ||
168 | efi_status_t status; | ||
169 | unsigned long nr_pages; | ||
170 | int i; | ||
171 | |||
172 | status = __get_map(&map, &map_size, &desc_size); | ||
173 | if (status != EFI_SUCCESS) | ||
174 | goto fail; | ||
175 | |||
176 | nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
177 | for (i = 0; i < map_size / desc_size; i++) { | ||
178 | efi_memory_desc_t *desc; | ||
179 | unsigned long m = (unsigned long)map; | ||
180 | u64 start, end; | ||
181 | |||
182 | desc = (efi_memory_desc_t *)(m + (i * desc_size)); | ||
183 | |||
184 | if (desc->type != EFI_CONVENTIONAL_MEMORY) | ||
185 | continue; | ||
186 | |||
187 | if (desc->num_pages < nr_pages) | ||
188 | continue; | ||
189 | |||
190 | start = desc->phys_addr; | ||
191 | end = start + desc->num_pages * (1UL << EFI_PAGE_SHIFT); | ||
192 | |||
193 | /* | ||
194 | * Don't allocate at 0x0. It will confuse code that | ||
195 | * checks pointers against NULL. Skip the first 8 | ||
196 | * bytes so we start at a nice even number. | ||
197 | */ | ||
198 | if (start == 0x0) | ||
199 | start += 8; | ||
200 | |||
201 | start = round_up(start, align); | ||
202 | if ((start + size) > end) | ||
203 | continue; | ||
204 | |||
205 | status = efi_call_phys4(sys_table->boottime->allocate_pages, | ||
206 | EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, | ||
207 | nr_pages, &start); | ||
208 | if (status == EFI_SUCCESS) { | ||
209 | *addr = start; | ||
210 | break; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | if (i == map_size / desc_size) | ||
215 | status = EFI_NOT_FOUND; | ||
216 | |||
217 | free_pool: | ||
218 | efi_call_phys1(sys_table->boottime->free_pool, map); | ||
219 | fail: | ||
220 | return status; | ||
221 | } | ||
222 | |||
223 | static void low_free(unsigned long size, unsigned long addr) | ||
224 | { | ||
225 | unsigned long nr_pages; | ||
226 | |||
227 | nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
228 | efi_call_phys2(sys_table->boottime->free_pages, addr, nr_pages); | ||
229 | } | ||
230 | 26 | ||
231 | static void find_bits(unsigned long mask, u8 *pos, u8 *size) | 27 | static void find_bits(unsigned long mask, u8 *pos, u8 *size) |
232 | { | 28 | { |
@@ -624,242 +420,6 @@ void setup_graphics(struct boot_params *boot_params) | |||
624 | } | 420 | } |
625 | } | 421 | } |
626 | 422 | ||
627 | struct initrd { | ||
628 | efi_file_handle_t *handle; | ||
629 | u64 size; | ||
630 | }; | ||
631 | |||
632 | /* | ||
633 | * Check the cmdline for a LILO-style initrd= arguments. | ||
634 | * | ||
635 | * We only support loading an initrd from the same filesystem as the | ||
636 | * kernel image. | ||
637 | */ | ||
638 | static efi_status_t handle_ramdisks(efi_loaded_image_t *image, | ||
639 | struct setup_header *hdr) | ||
640 | { | ||
641 | struct initrd *initrds; | ||
642 | unsigned long initrd_addr; | ||
643 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; | ||
644 | u64 initrd_total; | ||
645 | efi_file_io_interface_t *io; | ||
646 | efi_file_handle_t *fh; | ||
647 | efi_status_t status; | ||
648 | int nr_initrds; | ||
649 | char *str; | ||
650 | int i, j, k; | ||
651 | |||
652 | initrd_addr = 0; | ||
653 | initrd_total = 0; | ||
654 | |||
655 | str = (char *)(unsigned long)hdr->cmd_line_ptr; | ||
656 | |||
657 | j = 0; /* See close_handles */ | ||
658 | |||
659 | if (!str || !*str) | ||
660 | return EFI_SUCCESS; | ||
661 | |||
662 | for (nr_initrds = 0; *str; nr_initrds++) { | ||
663 | str = strstr(str, "initrd="); | ||
664 | if (!str) | ||
665 | break; | ||
666 | |||
667 | str += 7; | ||
668 | |||
669 | /* Skip any leading slashes */ | ||
670 | while (*str == '/' || *str == '\\') | ||
671 | str++; | ||
672 | |||
673 | while (*str && *str != ' ' && *str != '\n') | ||
674 | str++; | ||
675 | } | ||
676 | |||
677 | if (!nr_initrds) | ||
678 | return EFI_SUCCESS; | ||
679 | |||
680 | status = efi_call_phys3(sys_table->boottime->allocate_pool, | ||
681 | EFI_LOADER_DATA, | ||
682 | nr_initrds * sizeof(*initrds), | ||
683 | &initrds); | ||
684 | if (status != EFI_SUCCESS) { | ||
685 | efi_printk("Failed to alloc mem for initrds\n"); | ||
686 | goto fail; | ||
687 | } | ||
688 | |||
689 | str = (char *)(unsigned long)hdr->cmd_line_ptr; | ||
690 | for (i = 0; i < nr_initrds; i++) { | ||
691 | struct initrd *initrd; | ||
692 | efi_file_handle_t *h; | ||
693 | efi_file_info_t *info; | ||
694 | efi_char16_t filename_16[256]; | ||
695 | unsigned long info_sz; | ||
696 | efi_guid_t info_guid = EFI_FILE_INFO_ID; | ||
697 | efi_char16_t *p; | ||
698 | u64 file_sz; | ||
699 | |||
700 | str = strstr(str, "initrd="); | ||
701 | if (!str) | ||
702 | break; | ||
703 | |||
704 | str += 7; | ||
705 | |||
706 | initrd = &initrds[i]; | ||
707 | p = filename_16; | ||
708 | |||
709 | /* Skip any leading slashes */ | ||
710 | while (*str == '/' || *str == '\\') | ||
711 | str++; | ||
712 | |||
713 | while (*str && *str != ' ' && *str != '\n') { | ||
714 | if ((u8 *)p >= (u8 *)filename_16 + sizeof(filename_16)) | ||
715 | break; | ||
716 | |||
717 | if (*str == '/') { | ||
718 | *p++ = '\\'; | ||
719 | *str++; | ||
720 | } else { | ||
721 | *p++ = *str++; | ||
722 | } | ||
723 | } | ||
724 | |||
725 | *p = '\0'; | ||
726 | |||
727 | /* Only open the volume once. */ | ||
728 | if (!i) { | ||
729 | efi_boot_services_t *boottime; | ||
730 | |||
731 | boottime = sys_table->boottime; | ||
732 | |||
733 | status = efi_call_phys3(boottime->handle_protocol, | ||
734 | image->device_handle, &fs_proto, &io); | ||
735 | if (status != EFI_SUCCESS) { | ||
736 | efi_printk("Failed to handle fs_proto\n"); | ||
737 | goto free_initrds; | ||
738 | } | ||
739 | |||
740 | status = efi_call_phys2(io->open_volume, io, &fh); | ||
741 | if (status != EFI_SUCCESS) { | ||
742 | efi_printk("Failed to open volume\n"); | ||
743 | goto free_initrds; | ||
744 | } | ||
745 | } | ||
746 | |||
747 | status = efi_call_phys5(fh->open, fh, &h, filename_16, | ||
748 | EFI_FILE_MODE_READ, (u64)0); | ||
749 | if (status != EFI_SUCCESS) { | ||
750 | efi_printk("Failed to open initrd file: "); | ||
751 | efi_char16_printk(filename_16); | ||
752 | efi_printk("\n"); | ||
753 | goto close_handles; | ||
754 | } | ||
755 | |||
756 | initrd->handle = h; | ||
757 | |||
758 | info_sz = 0; | ||
759 | status = efi_call_phys4(h->get_info, h, &info_guid, | ||
760 | &info_sz, NULL); | ||
761 | if (status != EFI_BUFFER_TOO_SMALL) { | ||
762 | efi_printk("Failed to get initrd info size\n"); | ||
763 | goto close_handles; | ||
764 | } | ||
765 | |||
766 | grow: | ||
767 | status = efi_call_phys3(sys_table->boottime->allocate_pool, | ||
768 | EFI_LOADER_DATA, info_sz, &info); | ||
769 | if (status != EFI_SUCCESS) { | ||
770 | efi_printk("Failed to alloc mem for initrd info\n"); | ||
771 | goto close_handles; | ||
772 | } | ||
773 | |||
774 | status = efi_call_phys4(h->get_info, h, &info_guid, | ||
775 | &info_sz, info); | ||
776 | if (status == EFI_BUFFER_TOO_SMALL) { | ||
777 | efi_call_phys1(sys_table->boottime->free_pool, info); | ||
778 | goto grow; | ||
779 | } | ||
780 | |||
781 | file_sz = info->file_size; | ||
782 | efi_call_phys1(sys_table->boottime->free_pool, info); | ||
783 | |||
784 | if (status != EFI_SUCCESS) { | ||
785 | efi_printk("Failed to get initrd info\n"); | ||
786 | goto close_handles; | ||
787 | } | ||
788 | |||
789 | initrd->size = file_sz; | ||
790 | initrd_total += file_sz; | ||
791 | } | ||
792 | |||
793 | if (initrd_total) { | ||
794 | unsigned long addr; | ||
795 | |||
796 | /* | ||
797 | * Multiple initrd's need to be at consecutive | ||
798 | * addresses in memory, so allocate enough memory for | ||
799 | * all the initrd's. | ||
800 | */ | ||
801 | status = high_alloc(initrd_total, 0x1000, | ||
802 | &initrd_addr, hdr->initrd_addr_max); | ||
803 | if (status != EFI_SUCCESS) { | ||
804 | efi_printk("Failed to alloc highmem for initrds\n"); | ||
805 | goto close_handles; | ||
806 | } | ||
807 | |||
808 | /* We've run out of free low memory. */ | ||
809 | if (initrd_addr > hdr->initrd_addr_max) { | ||
810 | efi_printk("We've run out of free low memory\n"); | ||
811 | status = EFI_INVALID_PARAMETER; | ||
812 | goto free_initrd_total; | ||
813 | } | ||
814 | |||
815 | addr = initrd_addr; | ||
816 | for (j = 0; j < nr_initrds; j++) { | ||
817 | u64 size; | ||
818 | |||
819 | size = initrds[j].size; | ||
820 | while (size) { | ||
821 | u64 chunksize; | ||
822 | if (size > EFI_READ_CHUNK_SIZE) | ||
823 | chunksize = EFI_READ_CHUNK_SIZE; | ||
824 | else | ||
825 | chunksize = size; | ||
826 | status = efi_call_phys3(fh->read, | ||
827 | initrds[j].handle, | ||
828 | &chunksize, addr); | ||
829 | if (status != EFI_SUCCESS) { | ||
830 | efi_printk("Failed to read initrd\n"); | ||
831 | goto free_initrd_total; | ||
832 | } | ||
833 | addr += chunksize; | ||
834 | size -= chunksize; | ||
835 | } | ||
836 | |||
837 | efi_call_phys1(fh->close, initrds[j].handle); | ||
838 | } | ||
839 | |||
840 | } | ||
841 | |||
842 | efi_call_phys1(sys_table->boottime->free_pool, initrds); | ||
843 | |||
844 | hdr->ramdisk_image = initrd_addr; | ||
845 | hdr->ramdisk_size = initrd_total; | ||
846 | |||
847 | return status; | ||
848 | |||
849 | free_initrd_total: | ||
850 | low_free(initrd_total, initrd_addr); | ||
851 | |||
852 | close_handles: | ||
853 | for (k = j; k < i; k++) | ||
854 | efi_call_phys1(fh->close, initrds[k].handle); | ||
855 | free_initrds: | ||
856 | efi_call_phys1(sys_table->boottime->free_pool, initrds); | ||
857 | fail: | ||
858 | hdr->ramdisk_image = 0; | ||
859 | hdr->ramdisk_size = 0; | ||
860 | |||
861 | return status; | ||
862 | } | ||
863 | 423 | ||
864 | /* | 424 | /* |
865 | * Because the x86 boot code expects to be passed a boot_params we | 425 | * Because the x86 boot code expects to be passed a boot_params we |
@@ -875,14 +435,15 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) | |||
875 | struct efi_info *efi; | 435 | struct efi_info *efi; |
876 | efi_loaded_image_t *image; | 436 | efi_loaded_image_t *image; |
877 | void *options; | 437 | void *options; |
878 | u32 load_options_size; | ||
879 | efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID; | 438 | efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID; |
880 | int options_size = 0; | 439 | int options_size = 0; |
881 | efi_status_t status; | 440 | efi_status_t status; |
882 | unsigned long cmdline; | 441 | char *cmdline_ptr; |
883 | u16 *s2; | 442 | u16 *s2; |
884 | u8 *s1; | 443 | u8 *s1; |
885 | int i; | 444 | int i; |
445 | unsigned long ramdisk_addr; | ||
446 | unsigned long ramdisk_size; | ||
886 | 447 | ||
887 | sys_table = _table; | 448 | sys_table = _table; |
888 | 449 | ||
@@ -893,13 +454,14 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) | |||
893 | status = efi_call_phys3(sys_table->boottime->handle_protocol, | 454 | status = efi_call_phys3(sys_table->boottime->handle_protocol, |
894 | handle, &proto, (void *)&image); | 455 | handle, &proto, (void *)&image); |
895 | if (status != EFI_SUCCESS) { | 456 | if (status != EFI_SUCCESS) { |
896 | efi_printk("Failed to get handle for LOADED_IMAGE_PROTOCOL\n"); | 457 | efi_printk(sys_table, "Failed to get handle for LOADED_IMAGE_PROTOCOL\n"); |
897 | return NULL; | 458 | return NULL; |
898 | } | 459 | } |
899 | 460 | ||
900 | status = low_alloc(0x4000, 1, (unsigned long *)&boot_params); | 461 | status = efi_low_alloc(sys_table, 0x4000, 1, |
462 | (unsigned long *)&boot_params); | ||
901 | if (status != EFI_SUCCESS) { | 463 | if (status != EFI_SUCCESS) { |
902 | efi_printk("Failed to alloc lowmem for boot params\n"); | 464 | efi_printk(sys_table, "Failed to alloc lowmem for boot params\n"); |
903 | return NULL; | 465 | return NULL; |
904 | } | 466 | } |
905 | 467 | ||
@@ -926,40 +488,11 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) | |||
926 | hdr->type_of_loader = 0x21; | 488 | hdr->type_of_loader = 0x21; |
927 | 489 | ||
928 | /* Convert unicode cmdline to ascii */ | 490 | /* Convert unicode cmdline to ascii */ |
929 | options = image->load_options; | 491 | cmdline_ptr = efi_convert_cmdline_to_ascii(sys_table, image, |
930 | load_options_size = image->load_options_size / 2; /* ASCII */ | 492 | &options_size); |
931 | cmdline = 0; | 493 | if (!cmdline_ptr) |
932 | s2 = (u16 *)options; | 494 | goto fail; |
933 | 495 | hdr->cmd_line_ptr = (unsigned long)cmdline_ptr; | |
934 | if (s2) { | ||
935 | while (*s2 && *s2 != '\n' && options_size < load_options_size) { | ||
936 | s2++; | ||
937 | options_size++; | ||
938 | } | ||
939 | |||
940 | if (options_size) { | ||
941 | if (options_size > hdr->cmdline_size) | ||
942 | options_size = hdr->cmdline_size; | ||
943 | |||
944 | options_size++; /* NUL termination */ | ||
945 | |||
946 | status = low_alloc(options_size, 1, &cmdline); | ||
947 | if (status != EFI_SUCCESS) { | ||
948 | efi_printk("Failed to alloc mem for cmdline\n"); | ||
949 | goto fail; | ||
950 | } | ||
951 | |||
952 | s1 = (u8 *)(unsigned long)cmdline; | ||
953 | s2 = (u16 *)options; | ||
954 | |||
955 | for (i = 0; i < options_size - 1; i++) | ||
956 | *s1++ = *s2++; | ||
957 | |||
958 | *s1 = '\0'; | ||
959 | } | ||
960 | } | ||
961 | |||
962 | hdr->cmd_line_ptr = cmdline; | ||
963 | 496 | ||
964 | hdr->ramdisk_image = 0; | 497 | hdr->ramdisk_image = 0; |
965 | hdr->ramdisk_size = 0; | 498 | hdr->ramdisk_size = 0; |
@@ -969,96 +502,64 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) | |||
969 | 502 | ||
970 | memset(sdt, 0, sizeof(*sdt)); | 503 | memset(sdt, 0, sizeof(*sdt)); |
971 | 504 | ||
972 | status = handle_ramdisks(image, hdr); | 505 | status = handle_cmdline_files(sys_table, image, |
506 | (char *)(unsigned long)hdr->cmd_line_ptr, | ||
507 | "initrd=", hdr->initrd_addr_max, | ||
508 | &ramdisk_addr, &ramdisk_size); | ||
973 | if (status != EFI_SUCCESS) | 509 | if (status != EFI_SUCCESS) |
974 | goto fail2; | 510 | goto fail2; |
511 | hdr->ramdisk_image = ramdisk_addr; | ||
512 | hdr->ramdisk_size = ramdisk_size; | ||
975 | 513 | ||
976 | return boot_params; | 514 | return boot_params; |
977 | fail2: | 515 | fail2: |
978 | if (options_size) | 516 | efi_free(sys_table, options_size, hdr->cmd_line_ptr); |
979 | low_free(options_size, hdr->cmd_line_ptr); | ||
980 | fail: | 517 | fail: |
981 | low_free(0x4000, (unsigned long)boot_params); | 518 | efi_free(sys_table, 0x4000, (unsigned long)boot_params); |
982 | return NULL; | 519 | return NULL; |
983 | } | 520 | } |
984 | 521 | ||
985 | static efi_status_t exit_boot(struct boot_params *boot_params, | 522 | static void add_e820ext(struct boot_params *params, |
986 | void *handle) | 523 | struct setup_data *e820ext, u32 nr_entries) |
987 | { | 524 | { |
988 | struct efi_info *efi = &boot_params->efi_info; | 525 | struct setup_data *data; |
989 | struct e820entry *e820_map = &boot_params->e820_map[0]; | ||
990 | struct e820entry *prev = NULL; | ||
991 | unsigned long size, key, desc_size, _size; | ||
992 | efi_memory_desc_t *mem_map; | ||
993 | efi_status_t status; | 526 | efi_status_t status; |
994 | __u32 desc_version; | 527 | unsigned long size; |
995 | bool called_exit = false; | ||
996 | u8 nr_entries; | ||
997 | int i; | ||
998 | |||
999 | size = sizeof(*mem_map) * 32; | ||
1000 | |||
1001 | again: | ||
1002 | size += sizeof(*mem_map) * 2; | ||
1003 | _size = size; | ||
1004 | status = low_alloc(size, 1, (unsigned long *)&mem_map); | ||
1005 | if (status != EFI_SUCCESS) | ||
1006 | return status; | ||
1007 | |||
1008 | get_map: | ||
1009 | status = efi_call_phys5(sys_table->boottime->get_memory_map, &size, | ||
1010 | mem_map, &key, &desc_size, &desc_version); | ||
1011 | if (status == EFI_BUFFER_TOO_SMALL) { | ||
1012 | low_free(_size, (unsigned long)mem_map); | ||
1013 | goto again; | ||
1014 | } | ||
1015 | 528 | ||
1016 | if (status != EFI_SUCCESS) | 529 | e820ext->type = SETUP_E820_EXT; |
1017 | goto free_mem_map; | 530 | e820ext->len = nr_entries * sizeof(struct e820entry); |
531 | e820ext->next = 0; | ||
1018 | 532 | ||
1019 | memcpy(&efi->efi_loader_signature, EFI_LOADER_SIGNATURE, sizeof(__u32)); | 533 | data = (struct setup_data *)(unsigned long)params->hdr.setup_data; |
1020 | efi->efi_systab = (unsigned long)sys_table; | ||
1021 | efi->efi_memdesc_size = desc_size; | ||
1022 | efi->efi_memdesc_version = desc_version; | ||
1023 | efi->efi_memmap = (unsigned long)mem_map; | ||
1024 | efi->efi_memmap_size = size; | ||
1025 | |||
1026 | #ifdef CONFIG_X86_64 | ||
1027 | efi->efi_systab_hi = (unsigned long)sys_table >> 32; | ||
1028 | efi->efi_memmap_hi = (unsigned long)mem_map >> 32; | ||
1029 | #endif | ||
1030 | 534 | ||
1031 | /* Might as well exit boot services now */ | 535 | while (data && data->next) |
1032 | status = efi_call_phys2(sys_table->boottime->exit_boot_services, | 536 | data = (struct setup_data *)(unsigned long)data->next; |
1033 | handle, key); | ||
1034 | if (status != EFI_SUCCESS) { | ||
1035 | /* | ||
1036 | * ExitBootServices() will fail if any of the event | ||
1037 | * handlers change the memory map. In which case, we | ||
1038 | * must be prepared to retry, but only once so that | ||
1039 | * we're guaranteed to exit on repeated failures instead | ||
1040 | * of spinning forever. | ||
1041 | */ | ||
1042 | if (called_exit) | ||
1043 | goto free_mem_map; | ||
1044 | 537 | ||
1045 | called_exit = true; | 538 | if (data) |
1046 | goto get_map; | 539 | data->next = (unsigned long)e820ext; |
1047 | } | 540 | else |
541 | params->hdr.setup_data = (unsigned long)e820ext; | ||
542 | } | ||
1048 | 543 | ||
1049 | /* Historic? */ | 544 | static efi_status_t setup_e820(struct boot_params *params, |
1050 | boot_params->alt_mem_k = 32 * 1024; | 545 | struct setup_data *e820ext, u32 e820ext_size) |
546 | { | ||
547 | struct e820entry *e820_map = ¶ms->e820_map[0]; | ||
548 | struct efi_info *efi = ¶ms->efi_info; | ||
549 | struct e820entry *prev = NULL; | ||
550 | u32 nr_entries; | ||
551 | u32 nr_desc; | ||
552 | int i; | ||
1051 | 553 | ||
1052 | /* | ||
1053 | * Convert the EFI memory map to E820. | ||
1054 | */ | ||
1055 | nr_entries = 0; | 554 | nr_entries = 0; |
1056 | for (i = 0; i < size / desc_size; i++) { | 555 | nr_desc = efi->efi_memmap_size / efi->efi_memdesc_size; |
556 | |||
557 | for (i = 0; i < nr_desc; i++) { | ||
1057 | efi_memory_desc_t *d; | 558 | efi_memory_desc_t *d; |
1058 | unsigned int e820_type = 0; | 559 | unsigned int e820_type = 0; |
1059 | unsigned long m = (unsigned long)mem_map; | 560 | unsigned long m = efi->efi_memmap; |
1060 | 561 | ||
1061 | d = (efi_memory_desc_t *)(m + (i * desc_size)); | 562 | d = (efi_memory_desc_t *)(m + (i * efi->efi_memdesc_size)); |
1062 | switch (d->type) { | 563 | switch (d->type) { |
1063 | case EFI_RESERVED_TYPE: | 564 | case EFI_RESERVED_TYPE: |
1064 | case EFI_RUNTIME_SERVICES_CODE: | 565 | case EFI_RUNTIME_SERVICES_CODE: |
@@ -1095,61 +596,151 @@ get_map: | |||
1095 | 596 | ||
1096 | /* Merge adjacent mappings */ | 597 | /* Merge adjacent mappings */ |
1097 | if (prev && prev->type == e820_type && | 598 | if (prev && prev->type == e820_type && |
1098 | (prev->addr + prev->size) == d->phys_addr) | 599 | (prev->addr + prev->size) == d->phys_addr) { |
1099 | prev->size += d->num_pages << 12; | 600 | prev->size += d->num_pages << 12; |
1100 | else { | 601 | continue; |
1101 | e820_map->addr = d->phys_addr; | 602 | } |
1102 | e820_map->size = d->num_pages << 12; | 603 | |
1103 | e820_map->type = e820_type; | 604 | if (nr_entries == ARRAY_SIZE(params->e820_map)) { |
1104 | prev = e820_map++; | 605 | u32 need = (nr_desc - i) * sizeof(struct e820entry) + |
1105 | nr_entries++; | 606 | sizeof(struct setup_data); |
607 | |||
608 | if (!e820ext || e820ext_size < need) | ||
609 | return EFI_BUFFER_TOO_SMALL; | ||
610 | |||
611 | /* boot_params map full, switch to e820 extended */ | ||
612 | e820_map = (struct e820entry *)e820ext->data; | ||
1106 | } | 613 | } |
614 | |||
615 | e820_map->addr = d->phys_addr; | ||
616 | e820_map->size = d->num_pages << PAGE_SHIFT; | ||
617 | e820_map->type = e820_type; | ||
618 | prev = e820_map++; | ||
619 | nr_entries++; | ||
1107 | } | 620 | } |
1108 | 621 | ||
1109 | boot_params->e820_entries = nr_entries; | 622 | if (nr_entries > ARRAY_SIZE(params->e820_map)) { |
623 | u32 nr_e820ext = nr_entries - ARRAY_SIZE(params->e820_map); | ||
624 | |||
625 | add_e820ext(params, e820ext, nr_e820ext); | ||
626 | nr_entries -= nr_e820ext; | ||
627 | } | ||
628 | |||
629 | params->e820_entries = (u8)nr_entries; | ||
1110 | 630 | ||
1111 | return EFI_SUCCESS; | 631 | return EFI_SUCCESS; |
632 | } | ||
633 | |||
634 | static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext, | ||
635 | u32 *e820ext_size) | ||
636 | { | ||
637 | efi_status_t status; | ||
638 | unsigned long size; | ||
639 | |||
640 | size = sizeof(struct setup_data) + | ||
641 | sizeof(struct e820entry) * nr_desc; | ||
642 | |||
643 | if (*e820ext) { | ||
644 | efi_call_phys1(sys_table->boottime->free_pool, *e820ext); | ||
645 | *e820ext = NULL; | ||
646 | *e820ext_size = 0; | ||
647 | } | ||
648 | |||
649 | status = efi_call_phys3(sys_table->boottime->allocate_pool, | ||
650 | EFI_LOADER_DATA, size, e820ext); | ||
651 | |||
652 | if (status == EFI_SUCCESS) | ||
653 | *e820ext_size = size; | ||
1112 | 654 | ||
1113 | free_mem_map: | ||
1114 | low_free(_size, (unsigned long)mem_map); | ||
1115 | return status; | 655 | return status; |
1116 | } | 656 | } |
1117 | 657 | ||
1118 | static efi_status_t relocate_kernel(struct setup_header *hdr) | 658 | static efi_status_t exit_boot(struct boot_params *boot_params, |
659 | void *handle) | ||
1119 | { | 660 | { |
1120 | unsigned long start, nr_pages; | 661 | struct efi_info *efi = &boot_params->efi_info; |
662 | unsigned long map_sz, key, desc_size; | ||
663 | efi_memory_desc_t *mem_map; | ||
664 | struct setup_data *e820ext; | ||
665 | __u32 e820ext_size; | ||
666 | __u32 nr_desc, prev_nr_desc; | ||
1121 | efi_status_t status; | 667 | efi_status_t status; |
668 | __u32 desc_version; | ||
669 | bool called_exit = false; | ||
670 | u8 nr_entries; | ||
671 | int i; | ||
1122 | 672 | ||
1123 | /* | 673 | nr_desc = 0; |
1124 | * The EFI firmware loader could have placed the kernel image | 674 | e820ext = NULL; |
1125 | * anywhere in memory, but the kernel has various restrictions | 675 | e820ext_size = 0; |
1126 | * on the max physical address it can run at. Attempt to move | ||
1127 | * the kernel to boot_params.pref_address, or as low as | ||
1128 | * possible. | ||
1129 | */ | ||
1130 | start = hdr->pref_address; | ||
1131 | nr_pages = round_up(hdr->init_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
1132 | 676 | ||
1133 | status = efi_call_phys4(sys_table->boottime->allocate_pages, | 677 | get_map: |
1134 | EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, | 678 | status = efi_get_memory_map(sys_table, &mem_map, &map_sz, &desc_size, |
1135 | nr_pages, &start); | 679 | &desc_version, &key); |
1136 | if (status != EFI_SUCCESS) { | 680 | |
1137 | status = low_alloc(hdr->init_size, hdr->kernel_alignment, | 681 | if (status != EFI_SUCCESS) |
1138 | &start); | 682 | return status; |
683 | |||
684 | prev_nr_desc = nr_desc; | ||
685 | nr_desc = map_sz / desc_size; | ||
686 | if (nr_desc > prev_nr_desc && | ||
687 | nr_desc > ARRAY_SIZE(boot_params->e820_map)) { | ||
688 | u32 nr_e820ext = nr_desc - ARRAY_SIZE(boot_params->e820_map); | ||
689 | |||
690 | status = alloc_e820ext(nr_e820ext, &e820ext, &e820ext_size); | ||
1139 | if (status != EFI_SUCCESS) | 691 | if (status != EFI_SUCCESS) |
1140 | efi_printk("Failed to alloc mem for kernel\n"); | 692 | goto free_mem_map; |
693 | |||
694 | efi_call_phys1(sys_table->boottime->free_pool, mem_map); | ||
695 | goto get_map; /* Allocated memory, get map again */ | ||
1141 | } | 696 | } |
1142 | 697 | ||
1143 | if (status == EFI_SUCCESS) | 698 | memcpy(&efi->efi_loader_signature, EFI_LOADER_SIGNATURE, sizeof(__u32)); |
1144 | memcpy((void *)start, (void *)(unsigned long)hdr->code32_start, | 699 | efi->efi_systab = (unsigned long)sys_table; |
1145 | hdr->init_size); | 700 | efi->efi_memdesc_size = desc_size; |
701 | efi->efi_memdesc_version = desc_version; | ||
702 | efi->efi_memmap = (unsigned long)mem_map; | ||
703 | efi->efi_memmap_size = map_sz; | ||
704 | |||
705 | #ifdef CONFIG_X86_64 | ||
706 | efi->efi_systab_hi = (unsigned long)sys_table >> 32; | ||
707 | efi->efi_memmap_hi = (unsigned long)mem_map >> 32; | ||
708 | #endif | ||
1146 | 709 | ||
1147 | hdr->pref_address = hdr->code32_start; | 710 | /* Might as well exit boot services now */ |
1148 | hdr->code32_start = (__u32)start; | 711 | status = efi_call_phys2(sys_table->boottime->exit_boot_services, |
712 | handle, key); | ||
713 | if (status != EFI_SUCCESS) { | ||
714 | /* | ||
715 | * ExitBootServices() will fail if any of the event | ||
716 | * handlers change the memory map. In which case, we | ||
717 | * must be prepared to retry, but only once so that | ||
718 | * we're guaranteed to exit on repeated failures instead | ||
719 | * of spinning forever. | ||
720 | */ | ||
721 | if (called_exit) | ||
722 | goto free_mem_map; | ||
1149 | 723 | ||
724 | called_exit = true; | ||
725 | efi_call_phys1(sys_table->boottime->free_pool, mem_map); | ||
726 | goto get_map; | ||
727 | } | ||
728 | |||
729 | /* Historic? */ | ||
730 | boot_params->alt_mem_k = 32 * 1024; | ||
731 | |||
732 | status = setup_e820(boot_params, e820ext, e820ext_size); | ||
733 | if (status != EFI_SUCCESS) | ||
734 | return status; | ||
735 | |||
736 | return EFI_SUCCESS; | ||
737 | |||
738 | free_mem_map: | ||
739 | efi_call_phys1(sys_table->boottime->free_pool, mem_map); | ||
1150 | return status; | 740 | return status; |
1151 | } | 741 | } |
1152 | 742 | ||
743 | |||
1153 | /* | 744 | /* |
1154 | * On success we return a pointer to a boot_params structure, and NULL | 745 | * On success we return a pointer to a boot_params structure, and NULL |
1155 | * on failure. | 746 | * on failure. |
@@ -1157,7 +748,7 @@ static efi_status_t relocate_kernel(struct setup_header *hdr) | |||
1157 | struct boot_params *efi_main(void *handle, efi_system_table_t *_table, | 748 | struct boot_params *efi_main(void *handle, efi_system_table_t *_table, |
1158 | struct boot_params *boot_params) | 749 | struct boot_params *boot_params) |
1159 | { | 750 | { |
1160 | struct desc_ptr *gdt, *idt; | 751 | struct desc_ptr *gdt; |
1161 | efi_loaded_image_t *image; | 752 | efi_loaded_image_t *image; |
1162 | struct setup_header *hdr = &boot_params->hdr; | 753 | struct setup_header *hdr = &boot_params->hdr; |
1163 | efi_status_t status; | 754 | efi_status_t status; |
@@ -1177,37 +768,33 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table, | |||
1177 | EFI_LOADER_DATA, sizeof(*gdt), | 768 | EFI_LOADER_DATA, sizeof(*gdt), |
1178 | (void **)&gdt); | 769 | (void **)&gdt); |
1179 | if (status != EFI_SUCCESS) { | 770 | if (status != EFI_SUCCESS) { |
1180 | efi_printk("Failed to alloc mem for gdt structure\n"); | 771 | efi_printk(sys_table, "Failed to alloc mem for gdt structure\n"); |
1181 | goto fail; | 772 | goto fail; |
1182 | } | 773 | } |
1183 | 774 | ||
1184 | gdt->size = 0x800; | 775 | gdt->size = 0x800; |
1185 | status = low_alloc(gdt->size, 8, (unsigned long *)&gdt->address); | 776 | status = efi_low_alloc(sys_table, gdt->size, 8, |
1186 | if (status != EFI_SUCCESS) { | 777 | (unsigned long *)&gdt->address); |
1187 | efi_printk("Failed to alloc mem for gdt\n"); | ||
1188 | goto fail; | ||
1189 | } | ||
1190 | |||
1191 | status = efi_call_phys3(sys_table->boottime->allocate_pool, | ||
1192 | EFI_LOADER_DATA, sizeof(*idt), | ||
1193 | (void **)&idt); | ||
1194 | if (status != EFI_SUCCESS) { | 778 | if (status != EFI_SUCCESS) { |
1195 | efi_printk("Failed to alloc mem for idt structure\n"); | 779 | efi_printk(sys_table, "Failed to alloc mem for gdt\n"); |
1196 | goto fail; | 780 | goto fail; |
1197 | } | 781 | } |
1198 | 782 | ||
1199 | idt->size = 0; | ||
1200 | idt->address = 0; | ||
1201 | |||
1202 | /* | 783 | /* |
1203 | * If the kernel isn't already loaded at the preferred load | 784 | * If the kernel isn't already loaded at the preferred load |
1204 | * address, relocate it. | 785 | * address, relocate it. |
1205 | */ | 786 | */ |
1206 | if (hdr->pref_address != hdr->code32_start) { | 787 | if (hdr->pref_address != hdr->code32_start) { |
1207 | status = relocate_kernel(hdr); | 788 | unsigned long bzimage_addr = hdr->code32_start; |
1208 | 789 | status = efi_relocate_kernel(sys_table, &bzimage_addr, | |
790 | hdr->init_size, hdr->init_size, | ||
791 | hdr->pref_address, | ||
792 | hdr->kernel_alignment); | ||
1209 | if (status != EFI_SUCCESS) | 793 | if (status != EFI_SUCCESS) |
1210 | goto fail; | 794 | goto fail; |
795 | |||
796 | hdr->pref_address = hdr->code32_start; | ||
797 | hdr->code32_start = bzimage_addr; | ||
1211 | } | 798 | } |
1212 | 799 | ||
1213 | status = exit_boot(boot_params, handle); | 800 | status = exit_boot(boot_params, handle); |
@@ -1267,10 +854,8 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table, | |||
1267 | desc->base2 = 0x00; | 854 | desc->base2 = 0x00; |
1268 | #endif /* CONFIG_X86_64 */ | 855 | #endif /* CONFIG_X86_64 */ |
1269 | 856 | ||
1270 | asm volatile ("lidt %0" : : "m" (*idt)); | ||
1271 | asm volatile ("lgdt %0" : : "m" (*gdt)); | ||
1272 | |||
1273 | asm volatile("cli"); | 857 | asm volatile("cli"); |
858 | asm volatile ("lgdt %0" : : "m" (*gdt)); | ||
1274 | 859 | ||
1275 | return boot_params; | 860 | return boot_params; |
1276 | fail: | 861 | fail: |
diff --git a/arch/x86/boot/compressed/eboot.h b/arch/x86/boot/compressed/eboot.h index e5b0a8f91c5f..81b6b652b46a 100644 --- a/arch/x86/boot/compressed/eboot.h +++ b/arch/x86/boot/compressed/eboot.h | |||
@@ -11,9 +11,6 @@ | |||
11 | 11 | ||
12 | #define DESC_TYPE_CODE_DATA (1 << 0) | 12 | #define DESC_TYPE_CODE_DATA (1 << 0) |
13 | 13 | ||
14 | #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) | ||
15 | #define EFI_READ_CHUNK_SIZE (1024 * 1024) | ||
16 | |||
17 | #define EFI_CONSOLE_OUT_DEVICE_GUID \ | 14 | #define EFI_CONSOLE_OUT_DEVICE_GUID \ |
18 | EFI_GUID(0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, \ | 15 | EFI_GUID(0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, \ |
19 | 0x3f, 0xc1, 0x4d) | 16 | 0x3f, 0xc1, 0x4d) |
@@ -62,10 +59,4 @@ struct efi_uga_draw_protocol { | |||
62 | void *blt; | 59 | void *blt; |
63 | }; | 60 | }; |
64 | 61 | ||
65 | struct efi_simple_text_output_protocol { | ||
66 | void *reset; | ||
67 | void *output_string; | ||
68 | void *test_string; | ||
69 | }; | ||
70 | |||
71 | #endif /* BOOT_COMPRESSED_EBOOT_H */ | 62 | #endif /* BOOT_COMPRESSED_EBOOT_H */ |
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 0062a0125041..65c6e6e3a552 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h | |||
@@ -109,6 +109,8 @@ static inline bool efi_is_native(void) | |||
109 | return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT); | 109 | return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT); |
110 | } | 110 | } |
111 | 111 | ||
112 | extern struct console early_efi_console; | ||
113 | |||
112 | #else | 114 | #else |
113 | /* | 115 | /* |
114 | * IF EFI is not configured, have the EFI calls return -ENOSYS. | 116 | * IF EFI is not configured, have the EFI calls return -ENOSYS. |
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c index d15f575a861b..6d3d20073615 100644 --- a/arch/x86/kernel/early_printk.c +++ b/arch/x86/kernel/early_printk.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <asm/mrst.h> | 17 | #include <asm/mrst.h> |
18 | #include <asm/pgtable.h> | 18 | #include <asm/pgtable.h> |
19 | #include <linux/usb/ehci_def.h> | 19 | #include <linux/usb/ehci_def.h> |
20 | #include <linux/efi.h> | ||
21 | #include <asm/efi.h> | ||
20 | 22 | ||
21 | /* Simple VGA output */ | 23 | /* Simple VGA output */ |
22 | #define VGABASE (__ISA_IO_base + 0xb8000) | 24 | #define VGABASE (__ISA_IO_base + 0xb8000) |
@@ -234,6 +236,11 @@ static int __init setup_early_printk(char *buf) | |||
234 | early_console_register(&early_hsu_console, keep); | 236 | early_console_register(&early_hsu_console, keep); |
235 | } | 237 | } |
236 | #endif | 238 | #endif |
239 | #ifdef CONFIG_EARLY_PRINTK_EFI | ||
240 | if (!strncmp(buf, "efi", 3)) | ||
241 | early_console_register(&early_efi_console, keep); | ||
242 | #endif | ||
243 | |||
237 | buf++; | 244 | buf++; |
238 | } | 245 | } |
239 | return 0; | 246 | return 0; |
diff --git a/arch/x86/platform/efi/Makefile b/arch/x86/platform/efi/Makefile index 6db1cc4c7534..b7b0b35c1981 100644 --- a/arch/x86/platform/efi/Makefile +++ b/arch/x86/platform/efi/Makefile | |||
@@ -1,2 +1,3 @@ | |||
1 | obj-$(CONFIG_EFI) += efi.o efi_$(BITS).o efi_stub_$(BITS).o | 1 | obj-$(CONFIG_EFI) += efi.o efi_$(BITS).o efi_stub_$(BITS).o |
2 | obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o | 2 | obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o |
3 | obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o | ||
diff --git a/arch/x86/platform/efi/early_printk.c b/arch/x86/platform/efi/early_printk.c new file mode 100644 index 000000000000..6599a0027b76 --- /dev/null +++ b/arch/x86/platform/efi/early_printk.c | |||
@@ -0,0 +1,191 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2013 Intel Corporation; author Matt Fleming | ||
3 | * | ||
4 | * This file is part of the Linux kernel, and is made available under | ||
5 | * the terms of the GNU General Public License version 2. | ||
6 | */ | ||
7 | |||
8 | #include <linux/console.h> | ||
9 | #include <linux/efi.h> | ||
10 | #include <linux/font.h> | ||
11 | #include <linux/io.h> | ||
12 | #include <linux/kernel.h> | ||
13 | #include <asm/setup.h> | ||
14 | |||
15 | static const struct font_desc *font; | ||
16 | static u32 efi_x, efi_y; | ||
17 | |||
18 | static __init void early_efi_clear_scanline(unsigned int y) | ||
19 | { | ||
20 | unsigned long base, *dst; | ||
21 | u16 len; | ||
22 | |||
23 | base = boot_params.screen_info.lfb_base; | ||
24 | len = boot_params.screen_info.lfb_linelength; | ||
25 | |||
26 | dst = early_ioremap(base + y*len, len); | ||
27 | if (!dst) | ||
28 | return; | ||
29 | |||
30 | memset(dst, 0, len); | ||
31 | early_iounmap(dst, len); | ||
32 | } | ||
33 | |||
34 | static __init void early_efi_scroll_up(void) | ||
35 | { | ||
36 | unsigned long base, *dst, *src; | ||
37 | u16 len; | ||
38 | u32 i, height; | ||
39 | |||
40 | base = boot_params.screen_info.lfb_base; | ||
41 | len = boot_params.screen_info.lfb_linelength; | ||
42 | height = boot_params.screen_info.lfb_height; | ||
43 | |||
44 | for (i = 0; i < height - font->height; i++) { | ||
45 | dst = early_ioremap(base + i*len, len); | ||
46 | if (!dst) | ||
47 | return; | ||
48 | |||
49 | src = early_ioremap(base + (i + font->height) * len, len); | ||
50 | if (!src) { | ||
51 | early_iounmap(dst, len); | ||
52 | return; | ||
53 | } | ||
54 | |||
55 | memmove(dst, src, len); | ||
56 | |||
57 | early_iounmap(src, len); | ||
58 | early_iounmap(dst, len); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | static void early_efi_write_char(u32 *dst, unsigned char c, unsigned int h) | ||
63 | { | ||
64 | const u32 color_black = 0x00000000; | ||
65 | const u32 color_white = 0x00ffffff; | ||
66 | const u8 *src; | ||
67 | u8 s8; | ||
68 | int m; | ||
69 | |||
70 | src = font->data + c * font->height; | ||
71 | s8 = *(src + h); | ||
72 | |||
73 | for (m = 0; m < 8; m++) { | ||
74 | if ((s8 >> (7 - m)) & 1) | ||
75 | *dst = color_white; | ||
76 | else | ||
77 | *dst = color_black; | ||
78 | dst++; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static __init void | ||
83 | early_efi_write(struct console *con, const char *str, unsigned int num) | ||
84 | { | ||
85 | struct screen_info *si; | ||
86 | unsigned long base; | ||
87 | unsigned int len; | ||
88 | const char *s; | ||
89 | void *dst; | ||
90 | |||
91 | base = boot_params.screen_info.lfb_base; | ||
92 | si = &boot_params.screen_info; | ||
93 | len = si->lfb_linelength; | ||
94 | |||
95 | while (num) { | ||
96 | unsigned int linemax; | ||
97 | unsigned int h, count = 0; | ||
98 | |||
99 | for (s = str; *s && *s != '\n'; s++) { | ||
100 | if (count == num) | ||
101 | break; | ||
102 | count++; | ||
103 | } | ||
104 | |||
105 | linemax = (si->lfb_width - efi_x) / font->width; | ||
106 | if (count > linemax) | ||
107 | count = linemax; | ||
108 | |||
109 | for (h = 0; h < font->height; h++) { | ||
110 | unsigned int n, x; | ||
111 | |||
112 | dst = early_ioremap(base + (efi_y + h) * len, len); | ||
113 | if (!dst) | ||
114 | return; | ||
115 | |||
116 | s = str; | ||
117 | n = count; | ||
118 | x = efi_x; | ||
119 | |||
120 | while (n-- > 0) { | ||
121 | early_efi_write_char(dst + x*4, *s, h); | ||
122 | x += font->width; | ||
123 | s++; | ||
124 | } | ||
125 | |||
126 | early_iounmap(dst, len); | ||
127 | } | ||
128 | |||
129 | num -= count; | ||
130 | efi_x += count * font->width; | ||
131 | str += count; | ||
132 | |||
133 | if (num > 0 && *s == '\n') { | ||
134 | efi_x = 0; | ||
135 | efi_y += font->height; | ||
136 | str++; | ||
137 | num--; | ||
138 | } | ||
139 | |||
140 | if (efi_x >= si->lfb_width) { | ||
141 | efi_x = 0; | ||
142 | efi_y += font->height; | ||
143 | } | ||
144 | |||
145 | if (efi_y + font->height >= si->lfb_height) { | ||
146 | u32 i; | ||
147 | |||
148 | efi_y -= font->height; | ||
149 | early_efi_scroll_up(); | ||
150 | |||
151 | for (i = 0; i < font->height; i++) | ||
152 | early_efi_clear_scanline(efi_y + i); | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | |||
157 | static __init int early_efi_setup(struct console *con, char *options) | ||
158 | { | ||
159 | struct screen_info *si; | ||
160 | u16 xres, yres; | ||
161 | u32 i; | ||
162 | |||
163 | si = &boot_params.screen_info; | ||
164 | xres = si->lfb_width; | ||
165 | yres = si->lfb_height; | ||
166 | |||
167 | /* | ||
168 | * early_efi_write_char() implicitly assumes a framebuffer with | ||
169 | * 32-bits per pixel. | ||
170 | */ | ||
171 | if (si->lfb_depth != 32) | ||
172 | return -ENODEV; | ||
173 | |||
174 | font = get_default_font(xres, yres, -1, -1); | ||
175 | if (!font) | ||
176 | return -ENODEV; | ||
177 | |||
178 | efi_y = rounddown(yres, font->height) - font->height; | ||
179 | for (i = 0; i < (yres - efi_y) / font->height; i++) | ||
180 | early_efi_scroll_up(); | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | struct console early_efi_console = { | ||
186 | .name = "earlyefi", | ||
187 | .write = early_efi_write, | ||
188 | .setup = early_efi_setup, | ||
189 | .flags = CON_PRINTBUFFER, | ||
190 | .index = -1, | ||
191 | }; | ||
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index c7e22ab29a5a..92c02344a060 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
@@ -60,19 +60,6 @@ | |||
60 | 60 | ||
61 | static efi_char16_t efi_dummy_name[6] = { 'D', 'U', 'M', 'M', 'Y', 0 }; | 61 | static efi_char16_t efi_dummy_name[6] = { 'D', 'U', 'M', 'M', 'Y', 0 }; |
62 | 62 | ||
63 | struct efi __read_mostly efi = { | ||
64 | .mps = EFI_INVALID_TABLE_ADDR, | ||
65 | .acpi = EFI_INVALID_TABLE_ADDR, | ||
66 | .acpi20 = EFI_INVALID_TABLE_ADDR, | ||
67 | .smbios = EFI_INVALID_TABLE_ADDR, | ||
68 | .sal_systab = EFI_INVALID_TABLE_ADDR, | ||
69 | .boot_info = EFI_INVALID_TABLE_ADDR, | ||
70 | .hcdp = EFI_INVALID_TABLE_ADDR, | ||
71 | .uga = EFI_INVALID_TABLE_ADDR, | ||
72 | .uv_systab = EFI_INVALID_TABLE_ADDR, | ||
73 | }; | ||
74 | EXPORT_SYMBOL(efi); | ||
75 | |||
76 | struct efi_memory_map memmap; | 63 | struct efi_memory_map memmap; |
77 | 64 | ||
78 | static struct efi efi_phys __initdata; | 65 | static struct efi efi_phys __initdata; |
@@ -80,6 +67,13 @@ static efi_system_table_t efi_systab __initdata; | |||
80 | 67 | ||
81 | unsigned long x86_efi_facility; | 68 | unsigned long x86_efi_facility; |
82 | 69 | ||
70 | static __initdata efi_config_table_type_t arch_tables[] = { | ||
71 | #ifdef CONFIG_X86_UV | ||
72 | {UV_SYSTEM_TABLE_GUID, "UVsystab", &efi.uv_systab}, | ||
73 | #endif | ||
74 | {NULL_GUID, NULL, NULL}, | ||
75 | }; | ||
76 | |||
83 | /* | 77 | /* |
84 | * Returns 1 if 'facility' is enabled, 0 otherwise. | 78 | * Returns 1 if 'facility' is enabled, 0 otherwise. |
85 | */ | 79 | */ |
@@ -399,6 +393,8 @@ int __init efi_memblock_x86_reserve_range(void) | |||
399 | 393 | ||
400 | memblock_reserve(pmap, memmap.nr_map * memmap.desc_size); | 394 | memblock_reserve(pmap, memmap.nr_map * memmap.desc_size); |
401 | 395 | ||
396 | efi.memmap = &memmap; | ||
397 | |||
402 | return 0; | 398 | return 0; |
403 | } | 399 | } |
404 | 400 | ||
@@ -578,80 +574,6 @@ static int __init efi_systab_init(void *phys) | |||
578 | return 0; | 574 | return 0; |
579 | } | 575 | } |
580 | 576 | ||
581 | static int __init efi_config_init(u64 tables, int nr_tables) | ||
582 | { | ||
583 | void *config_tables, *tablep; | ||
584 | int i, sz; | ||
585 | |||
586 | if (efi_enabled(EFI_64BIT)) | ||
587 | sz = sizeof(efi_config_table_64_t); | ||
588 | else | ||
589 | sz = sizeof(efi_config_table_32_t); | ||
590 | |||
591 | /* | ||
592 | * Let's see what config tables the firmware passed to us. | ||
593 | */ | ||
594 | config_tables = early_ioremap(tables, nr_tables * sz); | ||
595 | if (config_tables == NULL) { | ||
596 | pr_err("Could not map Configuration table!\n"); | ||
597 | return -ENOMEM; | ||
598 | } | ||
599 | |||
600 | tablep = config_tables; | ||
601 | pr_info(""); | ||
602 | for (i = 0; i < efi.systab->nr_tables; i++) { | ||
603 | efi_guid_t guid; | ||
604 | unsigned long table; | ||
605 | |||
606 | if (efi_enabled(EFI_64BIT)) { | ||
607 | u64 table64; | ||
608 | guid = ((efi_config_table_64_t *)tablep)->guid; | ||
609 | table64 = ((efi_config_table_64_t *)tablep)->table; | ||
610 | table = table64; | ||
611 | #ifdef CONFIG_X86_32 | ||
612 | if (table64 >> 32) { | ||
613 | pr_cont("\n"); | ||
614 | pr_err("Table located above 4GB, disabling EFI.\n"); | ||
615 | early_iounmap(config_tables, | ||
616 | efi.systab->nr_tables * sz); | ||
617 | return -EINVAL; | ||
618 | } | ||
619 | #endif | ||
620 | } else { | ||
621 | guid = ((efi_config_table_32_t *)tablep)->guid; | ||
622 | table = ((efi_config_table_32_t *)tablep)->table; | ||
623 | } | ||
624 | if (!efi_guidcmp(guid, MPS_TABLE_GUID)) { | ||
625 | efi.mps = table; | ||
626 | pr_cont(" MPS=0x%lx ", table); | ||
627 | } else if (!efi_guidcmp(guid, ACPI_20_TABLE_GUID)) { | ||
628 | efi.acpi20 = table; | ||
629 | pr_cont(" ACPI 2.0=0x%lx ", table); | ||
630 | } else if (!efi_guidcmp(guid, ACPI_TABLE_GUID)) { | ||
631 | efi.acpi = table; | ||
632 | pr_cont(" ACPI=0x%lx ", table); | ||
633 | } else if (!efi_guidcmp(guid, SMBIOS_TABLE_GUID)) { | ||
634 | efi.smbios = table; | ||
635 | pr_cont(" SMBIOS=0x%lx ", table); | ||
636 | #ifdef CONFIG_X86_UV | ||
637 | } else if (!efi_guidcmp(guid, UV_SYSTEM_TABLE_GUID)) { | ||
638 | efi.uv_systab = table; | ||
639 | pr_cont(" UVsystab=0x%lx ", table); | ||
640 | #endif | ||
641 | } else if (!efi_guidcmp(guid, HCDP_TABLE_GUID)) { | ||
642 | efi.hcdp = table; | ||
643 | pr_cont(" HCDP=0x%lx ", table); | ||
644 | } else if (!efi_guidcmp(guid, UGA_IO_PROTOCOL_GUID)) { | ||
645 | efi.uga = table; | ||
646 | pr_cont(" UGA=0x%lx ", table); | ||
647 | } | ||
648 | tablep += sz; | ||
649 | } | ||
650 | pr_cont("\n"); | ||
651 | early_iounmap(config_tables, efi.systab->nr_tables * sz); | ||
652 | return 0; | ||
653 | } | ||
654 | |||
655 | static int __init efi_runtime_init(void) | 577 | static int __init efi_runtime_init(void) |
656 | { | 578 | { |
657 | efi_runtime_services_t *runtime; | 579 | efi_runtime_services_t *runtime; |
@@ -745,7 +667,7 @@ void __init efi_init(void) | |||
745 | efi.systab->hdr.revision >> 16, | 667 | efi.systab->hdr.revision >> 16, |
746 | efi.systab->hdr.revision & 0xffff, vendor); | 668 | efi.systab->hdr.revision & 0xffff, vendor); |
747 | 669 | ||
748 | if (efi_config_init(efi.systab->tables, efi.systab->nr_tables)) | 670 | if (efi_config_init(arch_tables)) |
749 | return; | 671 | return; |
750 | 672 | ||
751 | set_bit(EFI_CONFIG_TABLES, &x86_efi_facility); | 673 | set_bit(EFI_CONFIG_TABLES, &x86_efi_facility); |
@@ -816,34 +738,6 @@ static void __init runtime_code_page_mkexec(void) | |||
816 | } | 738 | } |
817 | } | 739 | } |
818 | 740 | ||
819 | /* | ||
820 | * We can't ioremap data in EFI boot services RAM, because we've already mapped | ||
821 | * it as RAM. So, look it up in the existing EFI memory map instead. Only | ||
822 | * callable after efi_enter_virtual_mode and before efi_free_boot_services. | ||
823 | */ | ||
824 | void __iomem *efi_lookup_mapped_addr(u64 phys_addr) | ||
825 | { | ||
826 | void *p; | ||
827 | if (WARN_ON(!memmap.map)) | ||
828 | return NULL; | ||
829 | for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { | ||
830 | efi_memory_desc_t *md = p; | ||
831 | u64 size = md->num_pages << EFI_PAGE_SHIFT; | ||
832 | u64 end = md->phys_addr + size; | ||
833 | if (!(md->attribute & EFI_MEMORY_RUNTIME) && | ||
834 | md->type != EFI_BOOT_SERVICES_CODE && | ||
835 | md->type != EFI_BOOT_SERVICES_DATA) | ||
836 | continue; | ||
837 | if (!md->virt_addr) | ||
838 | continue; | ||
839 | if (phys_addr >= md->phys_addr && phys_addr < end) { | ||
840 | phys_addr += md->virt_addr - md->phys_addr; | ||
841 | return (__force void __iomem *)(unsigned long)phys_addr; | ||
842 | } | ||
843 | } | ||
844 | return NULL; | ||
845 | } | ||
846 | |||
847 | void efi_memory_uc(u64 addr, unsigned long size) | 741 | void efi_memory_uc(u64 addr, unsigned long size) |
848 | { | 742 | { |
849 | unsigned long page_shift = 1UL << EFI_PAGE_SHIFT; | 743 | unsigned long page_shift = 1UL << EFI_PAGE_SHIFT; |
diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c new file mode 100644 index 000000000000..b6bffbfd3be7 --- /dev/null +++ b/drivers/firmware/efi/efi-stub-helper.c | |||
@@ -0,0 +1,636 @@ | |||
1 | /* | ||
2 | * Helper functions used by the EFI stub on multiple | ||
3 | * architectures. This should be #included by the EFI stub | ||
4 | * implementation files. | ||
5 | * | ||
6 | * Copyright 2011 Intel Corporation; author Matt Fleming | ||
7 | * | ||
8 | * This file is part of the Linux kernel, and is made available | ||
9 | * under the terms of the GNU General Public License version 2. | ||
10 | * | ||
11 | */ | ||
12 | #define EFI_READ_CHUNK_SIZE (1024 * 1024) | ||
13 | |||
14 | struct file_info { | ||
15 | efi_file_handle_t *handle; | ||
16 | u64 size; | ||
17 | }; | ||
18 | |||
19 | |||
20 | |||
21 | |||
22 | static void efi_char16_printk(efi_system_table_t *sys_table_arg, | ||
23 | efi_char16_t *str) | ||
24 | { | ||
25 | struct efi_simple_text_output_protocol *out; | ||
26 | |||
27 | out = (struct efi_simple_text_output_protocol *)sys_table_arg->con_out; | ||
28 | efi_call_phys2(out->output_string, out, str); | ||
29 | } | ||
30 | |||
31 | static void efi_printk(efi_system_table_t *sys_table_arg, char *str) | ||
32 | { | ||
33 | char *s8; | ||
34 | |||
35 | for (s8 = str; *s8; s8++) { | ||
36 | efi_char16_t ch[2] = { 0 }; | ||
37 | |||
38 | ch[0] = *s8; | ||
39 | if (*s8 == '\n') { | ||
40 | efi_char16_t nl[2] = { '\r', 0 }; | ||
41 | efi_char16_printk(sys_table_arg, nl); | ||
42 | } | ||
43 | |||
44 | efi_char16_printk(sys_table_arg, ch); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | |||
49 | static efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, | ||
50 | efi_memory_desc_t **map, | ||
51 | unsigned long *map_size, | ||
52 | unsigned long *desc_size, | ||
53 | u32 *desc_ver, | ||
54 | unsigned long *key_ptr) | ||
55 | { | ||
56 | efi_memory_desc_t *m = NULL; | ||
57 | efi_status_t status; | ||
58 | unsigned long key; | ||
59 | u32 desc_version; | ||
60 | |||
61 | *map_size = sizeof(*m) * 32; | ||
62 | again: | ||
63 | /* | ||
64 | * Add an additional efi_memory_desc_t because we're doing an | ||
65 | * allocation which may be in a new descriptor region. | ||
66 | */ | ||
67 | *map_size += sizeof(*m); | ||
68 | status = efi_call_phys3(sys_table_arg->boottime->allocate_pool, | ||
69 | EFI_LOADER_DATA, *map_size, (void **)&m); | ||
70 | if (status != EFI_SUCCESS) | ||
71 | goto fail; | ||
72 | |||
73 | status = efi_call_phys5(sys_table_arg->boottime->get_memory_map, | ||
74 | map_size, m, &key, desc_size, &desc_version); | ||
75 | if (status == EFI_BUFFER_TOO_SMALL) { | ||
76 | efi_call_phys1(sys_table_arg->boottime->free_pool, m); | ||
77 | goto again; | ||
78 | } | ||
79 | |||
80 | if (status != EFI_SUCCESS) | ||
81 | efi_call_phys1(sys_table_arg->boottime->free_pool, m); | ||
82 | if (key_ptr && status == EFI_SUCCESS) | ||
83 | *key_ptr = key; | ||
84 | if (desc_ver && status == EFI_SUCCESS) | ||
85 | *desc_ver = desc_version; | ||
86 | |||
87 | fail: | ||
88 | *map = m; | ||
89 | return status; | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * Allocate at the highest possible address that is not above 'max'. | ||
94 | */ | ||
95 | static efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, | ||
96 | unsigned long size, unsigned long align, | ||
97 | unsigned long *addr, unsigned long max) | ||
98 | { | ||
99 | unsigned long map_size, desc_size; | ||
100 | efi_memory_desc_t *map; | ||
101 | efi_status_t status; | ||
102 | unsigned long nr_pages; | ||
103 | u64 max_addr = 0; | ||
104 | int i; | ||
105 | |||
106 | status = efi_get_memory_map(sys_table_arg, &map, &map_size, &desc_size, | ||
107 | NULL, NULL); | ||
108 | if (status != EFI_SUCCESS) | ||
109 | goto fail; | ||
110 | |||
111 | /* | ||
112 | * Enforce minimum alignment that EFI requires when requesting | ||
113 | * a specific address. We are doing page-based allocations, | ||
114 | * so we must be aligned to a page. | ||
115 | */ | ||
116 | if (align < EFI_PAGE_SIZE) | ||
117 | align = EFI_PAGE_SIZE; | ||
118 | |||
119 | nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
120 | again: | ||
121 | for (i = 0; i < map_size / desc_size; i++) { | ||
122 | efi_memory_desc_t *desc; | ||
123 | unsigned long m = (unsigned long)map; | ||
124 | u64 start, end; | ||
125 | |||
126 | desc = (efi_memory_desc_t *)(m + (i * desc_size)); | ||
127 | if (desc->type != EFI_CONVENTIONAL_MEMORY) | ||
128 | continue; | ||
129 | |||
130 | if (desc->num_pages < nr_pages) | ||
131 | continue; | ||
132 | |||
133 | start = desc->phys_addr; | ||
134 | end = start + desc->num_pages * (1UL << EFI_PAGE_SHIFT); | ||
135 | |||
136 | if ((start + size) > end || (start + size) > max) | ||
137 | continue; | ||
138 | |||
139 | if (end - size > max) | ||
140 | end = max; | ||
141 | |||
142 | if (round_down(end - size, align) < start) | ||
143 | continue; | ||
144 | |||
145 | start = round_down(end - size, align); | ||
146 | |||
147 | /* | ||
148 | * Don't allocate at 0x0. It will confuse code that | ||
149 | * checks pointers against NULL. | ||
150 | */ | ||
151 | if (start == 0x0) | ||
152 | continue; | ||
153 | |||
154 | if (start > max_addr) | ||
155 | max_addr = start; | ||
156 | } | ||
157 | |||
158 | if (!max_addr) | ||
159 | status = EFI_NOT_FOUND; | ||
160 | else { | ||
161 | status = efi_call_phys4(sys_table_arg->boottime->allocate_pages, | ||
162 | EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, | ||
163 | nr_pages, &max_addr); | ||
164 | if (status != EFI_SUCCESS) { | ||
165 | max = max_addr; | ||
166 | max_addr = 0; | ||
167 | goto again; | ||
168 | } | ||
169 | |||
170 | *addr = max_addr; | ||
171 | } | ||
172 | |||
173 | efi_call_phys1(sys_table_arg->boottime->free_pool, map); | ||
174 | |||
175 | fail: | ||
176 | return status; | ||
177 | } | ||
178 | |||
179 | /* | ||
180 | * Allocate at the lowest possible address. | ||
181 | */ | ||
182 | static efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, | ||
183 | unsigned long size, unsigned long align, | ||
184 | unsigned long *addr) | ||
185 | { | ||
186 | unsigned long map_size, desc_size; | ||
187 | efi_memory_desc_t *map; | ||
188 | efi_status_t status; | ||
189 | unsigned long nr_pages; | ||
190 | int i; | ||
191 | |||
192 | status = efi_get_memory_map(sys_table_arg, &map, &map_size, &desc_size, | ||
193 | NULL, NULL); | ||
194 | if (status != EFI_SUCCESS) | ||
195 | goto fail; | ||
196 | |||
197 | /* | ||
198 | * Enforce minimum alignment that EFI requires when requesting | ||
199 | * a specific address. We are doing page-based allocations, | ||
200 | * so we must be aligned to a page. | ||
201 | */ | ||
202 | if (align < EFI_PAGE_SIZE) | ||
203 | align = EFI_PAGE_SIZE; | ||
204 | |||
205 | nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
206 | for (i = 0; i < map_size / desc_size; i++) { | ||
207 | efi_memory_desc_t *desc; | ||
208 | unsigned long m = (unsigned long)map; | ||
209 | u64 start, end; | ||
210 | |||
211 | desc = (efi_memory_desc_t *)(m + (i * desc_size)); | ||
212 | |||
213 | if (desc->type != EFI_CONVENTIONAL_MEMORY) | ||
214 | continue; | ||
215 | |||
216 | if (desc->num_pages < nr_pages) | ||
217 | continue; | ||
218 | |||
219 | start = desc->phys_addr; | ||
220 | end = start + desc->num_pages * (1UL << EFI_PAGE_SHIFT); | ||
221 | |||
222 | /* | ||
223 | * Don't allocate at 0x0. It will confuse code that | ||
224 | * checks pointers against NULL. Skip the first 8 | ||
225 | * bytes so we start at a nice even number. | ||
226 | */ | ||
227 | if (start == 0x0) | ||
228 | start += 8; | ||
229 | |||
230 | start = round_up(start, align); | ||
231 | if ((start + size) > end) | ||
232 | continue; | ||
233 | |||
234 | status = efi_call_phys4(sys_table_arg->boottime->allocate_pages, | ||
235 | EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, | ||
236 | nr_pages, &start); | ||
237 | if (status == EFI_SUCCESS) { | ||
238 | *addr = start; | ||
239 | break; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | if (i == map_size / desc_size) | ||
244 | status = EFI_NOT_FOUND; | ||
245 | |||
246 | efi_call_phys1(sys_table_arg->boottime->free_pool, map); | ||
247 | fail: | ||
248 | return status; | ||
249 | } | ||
250 | |||
251 | static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, | ||
252 | unsigned long addr) | ||
253 | { | ||
254 | unsigned long nr_pages; | ||
255 | |||
256 | if (!size) | ||
257 | return; | ||
258 | |||
259 | nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
260 | efi_call_phys2(sys_table_arg->boottime->free_pages, addr, nr_pages); | ||
261 | } | ||
262 | |||
263 | |||
264 | /* | ||
265 | * Check the cmdline for a LILO-style file= arguments. | ||
266 | * | ||
267 | * We only support loading a file from the same filesystem as | ||
268 | * the kernel image. | ||
269 | */ | ||
270 | static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, | ||
271 | efi_loaded_image_t *image, | ||
272 | char *cmd_line, char *option_string, | ||
273 | unsigned long max_addr, | ||
274 | unsigned long *load_addr, | ||
275 | unsigned long *load_size) | ||
276 | { | ||
277 | struct file_info *files; | ||
278 | unsigned long file_addr; | ||
279 | efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; | ||
280 | u64 file_size_total; | ||
281 | efi_file_io_interface_t *io; | ||
282 | efi_file_handle_t *fh; | ||
283 | efi_status_t status; | ||
284 | int nr_files; | ||
285 | char *str; | ||
286 | int i, j, k; | ||
287 | |||
288 | file_addr = 0; | ||
289 | file_size_total = 0; | ||
290 | |||
291 | str = cmd_line; | ||
292 | |||
293 | j = 0; /* See close_handles */ | ||
294 | |||
295 | if (!load_addr || !load_size) | ||
296 | return EFI_INVALID_PARAMETER; | ||
297 | |||
298 | *load_addr = 0; | ||
299 | *load_size = 0; | ||
300 | |||
301 | if (!str || !*str) | ||
302 | return EFI_SUCCESS; | ||
303 | |||
304 | for (nr_files = 0; *str; nr_files++) { | ||
305 | str = strstr(str, option_string); | ||
306 | if (!str) | ||
307 | break; | ||
308 | |||
309 | str += strlen(option_string); | ||
310 | |||
311 | /* Skip any leading slashes */ | ||
312 | while (*str == '/' || *str == '\\') | ||
313 | str++; | ||
314 | |||
315 | while (*str && *str != ' ' && *str != '\n') | ||
316 | str++; | ||
317 | } | ||
318 | |||
319 | if (!nr_files) | ||
320 | return EFI_SUCCESS; | ||
321 | |||
322 | status = efi_call_phys3(sys_table_arg->boottime->allocate_pool, | ||
323 | EFI_LOADER_DATA, | ||
324 | nr_files * sizeof(*files), | ||
325 | (void **)&files); | ||
326 | if (status != EFI_SUCCESS) { | ||
327 | efi_printk(sys_table_arg, "Failed to alloc mem for file handle list\n"); | ||
328 | goto fail; | ||
329 | } | ||
330 | |||
331 | str = cmd_line; | ||
332 | for (i = 0; i < nr_files; i++) { | ||
333 | struct file_info *file; | ||
334 | efi_file_handle_t *h; | ||
335 | efi_file_info_t *info; | ||
336 | efi_char16_t filename_16[256]; | ||
337 | unsigned long info_sz; | ||
338 | efi_guid_t info_guid = EFI_FILE_INFO_ID; | ||
339 | efi_char16_t *p; | ||
340 | u64 file_sz; | ||
341 | |||
342 | str = strstr(str, option_string); | ||
343 | if (!str) | ||
344 | break; | ||
345 | |||
346 | str += strlen(option_string); | ||
347 | |||
348 | file = &files[i]; | ||
349 | p = filename_16; | ||
350 | |||
351 | /* Skip any leading slashes */ | ||
352 | while (*str == '/' || *str == '\\') | ||
353 | str++; | ||
354 | |||
355 | while (*str && *str != ' ' && *str != '\n') { | ||
356 | if ((u8 *)p >= (u8 *)filename_16 + sizeof(filename_16)) | ||
357 | break; | ||
358 | |||
359 | if (*str == '/') { | ||
360 | *p++ = '\\'; | ||
361 | str++; | ||
362 | } else { | ||
363 | *p++ = *str++; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | *p = '\0'; | ||
368 | |||
369 | /* Only open the volume once. */ | ||
370 | if (!i) { | ||
371 | efi_boot_services_t *boottime; | ||
372 | |||
373 | boottime = sys_table_arg->boottime; | ||
374 | |||
375 | status = efi_call_phys3(boottime->handle_protocol, | ||
376 | image->device_handle, &fs_proto, | ||
377 | (void **)&io); | ||
378 | if (status != EFI_SUCCESS) { | ||
379 | efi_printk(sys_table_arg, "Failed to handle fs_proto\n"); | ||
380 | goto free_files; | ||
381 | } | ||
382 | |||
383 | status = efi_call_phys2(io->open_volume, io, &fh); | ||
384 | if (status != EFI_SUCCESS) { | ||
385 | efi_printk(sys_table_arg, "Failed to open volume\n"); | ||
386 | goto free_files; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | status = efi_call_phys5(fh->open, fh, &h, filename_16, | ||
391 | EFI_FILE_MODE_READ, (u64)0); | ||
392 | if (status != EFI_SUCCESS) { | ||
393 | efi_printk(sys_table_arg, "Failed to open file: "); | ||
394 | efi_char16_printk(sys_table_arg, filename_16); | ||
395 | efi_printk(sys_table_arg, "\n"); | ||
396 | goto close_handles; | ||
397 | } | ||
398 | |||
399 | file->handle = h; | ||
400 | |||
401 | info_sz = 0; | ||
402 | status = efi_call_phys4(h->get_info, h, &info_guid, | ||
403 | &info_sz, NULL); | ||
404 | if (status != EFI_BUFFER_TOO_SMALL) { | ||
405 | efi_printk(sys_table_arg, "Failed to get file info size\n"); | ||
406 | goto close_handles; | ||
407 | } | ||
408 | |||
409 | grow: | ||
410 | status = efi_call_phys3(sys_table_arg->boottime->allocate_pool, | ||
411 | EFI_LOADER_DATA, info_sz, | ||
412 | (void **)&info); | ||
413 | if (status != EFI_SUCCESS) { | ||
414 | efi_printk(sys_table_arg, "Failed to alloc mem for file info\n"); | ||
415 | goto close_handles; | ||
416 | } | ||
417 | |||
418 | status = efi_call_phys4(h->get_info, h, &info_guid, | ||
419 | &info_sz, info); | ||
420 | if (status == EFI_BUFFER_TOO_SMALL) { | ||
421 | efi_call_phys1(sys_table_arg->boottime->free_pool, | ||
422 | info); | ||
423 | goto grow; | ||
424 | } | ||
425 | |||
426 | file_sz = info->file_size; | ||
427 | efi_call_phys1(sys_table_arg->boottime->free_pool, info); | ||
428 | |||
429 | if (status != EFI_SUCCESS) { | ||
430 | efi_printk(sys_table_arg, "Failed to get file info\n"); | ||
431 | goto close_handles; | ||
432 | } | ||
433 | |||
434 | file->size = file_sz; | ||
435 | file_size_total += file_sz; | ||
436 | } | ||
437 | |||
438 | if (file_size_total) { | ||
439 | unsigned long addr; | ||
440 | |||
441 | /* | ||
442 | * Multiple files need to be at consecutive addresses in memory, | ||
443 | * so allocate enough memory for all the files. This is used | ||
444 | * for loading multiple files. | ||
445 | */ | ||
446 | status = efi_high_alloc(sys_table_arg, file_size_total, 0x1000, | ||
447 | &file_addr, max_addr); | ||
448 | if (status != EFI_SUCCESS) { | ||
449 | efi_printk(sys_table_arg, "Failed to alloc highmem for files\n"); | ||
450 | goto close_handles; | ||
451 | } | ||
452 | |||
453 | /* We've run out of free low memory. */ | ||
454 | if (file_addr > max_addr) { | ||
455 | efi_printk(sys_table_arg, "We've run out of free low memory\n"); | ||
456 | status = EFI_INVALID_PARAMETER; | ||
457 | goto free_file_total; | ||
458 | } | ||
459 | |||
460 | addr = file_addr; | ||
461 | for (j = 0; j < nr_files; j++) { | ||
462 | unsigned long size; | ||
463 | |||
464 | size = files[j].size; | ||
465 | while (size) { | ||
466 | unsigned long chunksize; | ||
467 | if (size > EFI_READ_CHUNK_SIZE) | ||
468 | chunksize = EFI_READ_CHUNK_SIZE; | ||
469 | else | ||
470 | chunksize = size; | ||
471 | status = efi_call_phys3(fh->read, | ||
472 | files[j].handle, | ||
473 | &chunksize, | ||
474 | (void *)addr); | ||
475 | if (status != EFI_SUCCESS) { | ||
476 | efi_printk(sys_table_arg, "Failed to read file\n"); | ||
477 | goto free_file_total; | ||
478 | } | ||
479 | addr += chunksize; | ||
480 | size -= chunksize; | ||
481 | } | ||
482 | |||
483 | efi_call_phys1(fh->close, files[j].handle); | ||
484 | } | ||
485 | |||
486 | } | ||
487 | |||
488 | efi_call_phys1(sys_table_arg->boottime->free_pool, files); | ||
489 | |||
490 | *load_addr = file_addr; | ||
491 | *load_size = file_size_total; | ||
492 | |||
493 | return status; | ||
494 | |||
495 | free_file_total: | ||
496 | efi_free(sys_table_arg, file_size_total, file_addr); | ||
497 | |||
498 | close_handles: | ||
499 | for (k = j; k < i; k++) | ||
500 | efi_call_phys1(fh->close, files[k].handle); | ||
501 | free_files: | ||
502 | efi_call_phys1(sys_table_arg->boottime->free_pool, files); | ||
503 | fail: | ||
504 | *load_addr = 0; | ||
505 | *load_size = 0; | ||
506 | |||
507 | return status; | ||
508 | } | ||
509 | /* | ||
510 | * Relocate a kernel image, either compressed or uncompressed. | ||
511 | * In the ARM64 case, all kernel images are currently | ||
512 | * uncompressed, and as such when we relocate it we need to | ||
513 | * allocate additional space for the BSS segment. Any low | ||
514 | * memory that this function should avoid needs to be | ||
515 | * unavailable in the EFI memory map, as if the preferred | ||
516 | * address is not available the lowest available address will | ||
517 | * be used. | ||
518 | */ | ||
519 | static efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, | ||
520 | unsigned long *image_addr, | ||
521 | unsigned long image_size, | ||
522 | unsigned long alloc_size, | ||
523 | unsigned long preferred_addr, | ||
524 | unsigned long alignment) | ||
525 | { | ||
526 | unsigned long cur_image_addr; | ||
527 | unsigned long new_addr = 0; | ||
528 | efi_status_t status; | ||
529 | unsigned long nr_pages; | ||
530 | efi_physical_addr_t efi_addr = preferred_addr; | ||
531 | |||
532 | if (!image_addr || !image_size || !alloc_size) | ||
533 | return EFI_INVALID_PARAMETER; | ||
534 | if (alloc_size < image_size) | ||
535 | return EFI_INVALID_PARAMETER; | ||
536 | |||
537 | cur_image_addr = *image_addr; | ||
538 | |||
539 | /* | ||
540 | * The EFI firmware loader could have placed the kernel image | ||
541 | * anywhere in memory, but the kernel has restrictions on the | ||
542 | * max physical address it can run at. Some architectures | ||
543 | * also have a prefered address, so first try to relocate | ||
544 | * to the preferred address. If that fails, allocate as low | ||
545 | * as possible while respecting the required alignment. | ||
546 | */ | ||
547 | nr_pages = round_up(alloc_size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; | ||
548 | status = efi_call_phys4(sys_table_arg->boottime->allocate_pages, | ||
549 | EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, | ||
550 | nr_pages, &efi_addr); | ||
551 | new_addr = efi_addr; | ||
552 | /* | ||
553 | * If preferred address allocation failed allocate as low as | ||
554 | * possible. | ||
555 | */ | ||
556 | if (status != EFI_SUCCESS) { | ||
557 | status = efi_low_alloc(sys_table_arg, alloc_size, alignment, | ||
558 | &new_addr); | ||
559 | } | ||
560 | if (status != EFI_SUCCESS) { | ||
561 | efi_printk(sys_table_arg, "ERROR: Failed to allocate usable memory for kernel.\n"); | ||
562 | return status; | ||
563 | } | ||
564 | |||
565 | /* | ||
566 | * We know source/dest won't overlap since both memory ranges | ||
567 | * have been allocated by UEFI, so we can safely use memcpy. | ||
568 | */ | ||
569 | memcpy((void *)new_addr, (void *)cur_image_addr, image_size); | ||
570 | |||
571 | /* Return the new address of the relocated image. */ | ||
572 | *image_addr = new_addr; | ||
573 | |||
574 | return status; | ||
575 | } | ||
576 | |||
577 | /* | ||
578 | * Convert the unicode UEFI command line to ASCII to pass to kernel. | ||
579 | * Size of memory allocated return in *cmd_line_len. | ||
580 | * Returns NULL on error. | ||
581 | */ | ||
582 | static char *efi_convert_cmdline_to_ascii(efi_system_table_t *sys_table_arg, | ||
583 | efi_loaded_image_t *image, | ||
584 | int *cmd_line_len) | ||
585 | { | ||
586 | u16 *s2; | ||
587 | u8 *s1 = NULL; | ||
588 | unsigned long cmdline_addr = 0; | ||
589 | int load_options_size = image->load_options_size / 2; /* ASCII */ | ||
590 | void *options = image->load_options; | ||
591 | int options_size = 0; | ||
592 | efi_status_t status; | ||
593 | int i; | ||
594 | u16 zero = 0; | ||
595 | |||
596 | if (options) { | ||
597 | s2 = options; | ||
598 | while (*s2 && *s2 != '\n' && options_size < load_options_size) { | ||
599 | s2++; | ||
600 | options_size++; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | if (options_size == 0) { | ||
605 | /* No command line options, so return empty string*/ | ||
606 | options_size = 1; | ||
607 | options = &zero; | ||
608 | } | ||
609 | |||
610 | options_size++; /* NUL termination */ | ||
611 | #ifdef CONFIG_ARM | ||
612 | /* | ||
613 | * For ARM, allocate at a high address to avoid reserved | ||
614 | * regions at low addresses that we don't know the specfics of | ||
615 | * at the time we are processing the command line. | ||
616 | */ | ||
617 | status = efi_high_alloc(sys_table_arg, options_size, 0, | ||
618 | &cmdline_addr, 0xfffff000); | ||
619 | #else | ||
620 | status = efi_low_alloc(sys_table_arg, options_size, 0, | ||
621 | &cmdline_addr); | ||
622 | #endif | ||
623 | if (status != EFI_SUCCESS) | ||
624 | return NULL; | ||
625 | |||
626 | s1 = (u8 *)cmdline_addr; | ||
627 | s2 = (u16 *)options; | ||
628 | |||
629 | for (i = 0; i < options_size - 1; i++) | ||
630 | *s1++ = *s2++; | ||
631 | |||
632 | *s1 = '\0'; | ||
633 | |||
634 | *cmd_line_len = options_size; | ||
635 | return (char *)cmdline_addr; | ||
636 | } | ||
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 5145fa344ad5..2e2fbdec0845 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
@@ -13,11 +13,27 @@ | |||
13 | * This file is released under the GPLv2. | 13 | * This file is released under the GPLv2. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
17 | |||
16 | #include <linux/kobject.h> | 18 | #include <linux/kobject.h> |
17 | #include <linux/module.h> | 19 | #include <linux/module.h> |
18 | #include <linux/init.h> | 20 | #include <linux/init.h> |
19 | #include <linux/device.h> | 21 | #include <linux/device.h> |
20 | #include <linux/efi.h> | 22 | #include <linux/efi.h> |
23 | #include <linux/io.h> | ||
24 | |||
25 | struct efi __read_mostly efi = { | ||
26 | .mps = EFI_INVALID_TABLE_ADDR, | ||
27 | .acpi = EFI_INVALID_TABLE_ADDR, | ||
28 | .acpi20 = EFI_INVALID_TABLE_ADDR, | ||
29 | .smbios = EFI_INVALID_TABLE_ADDR, | ||
30 | .sal_systab = EFI_INVALID_TABLE_ADDR, | ||
31 | .boot_info = EFI_INVALID_TABLE_ADDR, | ||
32 | .hcdp = EFI_INVALID_TABLE_ADDR, | ||
33 | .uga = EFI_INVALID_TABLE_ADDR, | ||
34 | .uv_systab = EFI_INVALID_TABLE_ADDR, | ||
35 | }; | ||
36 | EXPORT_SYMBOL(efi); | ||
21 | 37 | ||
22 | static struct kobject *efi_kobj; | 38 | static struct kobject *efi_kobj; |
23 | static struct kobject *efivars_kobj; | 39 | static struct kobject *efivars_kobj; |
@@ -132,3 +148,127 @@ err_put: | |||
132 | } | 148 | } |
133 | 149 | ||
134 | subsys_initcall(efisubsys_init); | 150 | subsys_initcall(efisubsys_init); |
151 | |||
152 | |||
153 | /* | ||
154 | * We can't ioremap data in EFI boot services RAM, because we've already mapped | ||
155 | * it as RAM. So, look it up in the existing EFI memory map instead. Only | ||
156 | * callable after efi_enter_virtual_mode and before efi_free_boot_services. | ||
157 | */ | ||
158 | void __iomem *efi_lookup_mapped_addr(u64 phys_addr) | ||
159 | { | ||
160 | struct efi_memory_map *map; | ||
161 | void *p; | ||
162 | map = efi.memmap; | ||
163 | if (!map) | ||
164 | return NULL; | ||
165 | if (WARN_ON(!map->map)) | ||
166 | return NULL; | ||
167 | for (p = map->map; p < map->map_end; p += map->desc_size) { | ||
168 | efi_memory_desc_t *md = p; | ||
169 | u64 size = md->num_pages << EFI_PAGE_SHIFT; | ||
170 | u64 end = md->phys_addr + size; | ||
171 | if (!(md->attribute & EFI_MEMORY_RUNTIME) && | ||
172 | md->type != EFI_BOOT_SERVICES_CODE && | ||
173 | md->type != EFI_BOOT_SERVICES_DATA) | ||
174 | continue; | ||
175 | if (!md->virt_addr) | ||
176 | continue; | ||
177 | if (phys_addr >= md->phys_addr && phys_addr < end) { | ||
178 | phys_addr += md->virt_addr - md->phys_addr; | ||
179 | return (__force void __iomem *)(unsigned long)phys_addr; | ||
180 | } | ||
181 | } | ||
182 | return NULL; | ||
183 | } | ||
184 | |||
185 | static __initdata efi_config_table_type_t common_tables[] = { | ||
186 | {ACPI_20_TABLE_GUID, "ACPI 2.0", &efi.acpi20}, | ||
187 | {ACPI_TABLE_GUID, "ACPI", &efi.acpi}, | ||
188 | {HCDP_TABLE_GUID, "HCDP", &efi.hcdp}, | ||
189 | {MPS_TABLE_GUID, "MPS", &efi.mps}, | ||
190 | {SAL_SYSTEM_TABLE_GUID, "SALsystab", &efi.sal_systab}, | ||
191 | {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios}, | ||
192 | {UGA_IO_PROTOCOL_GUID, "UGA", &efi.uga}, | ||
193 | {NULL_GUID, NULL, 0}, | ||
194 | }; | ||
195 | |||
196 | static __init int match_config_table(efi_guid_t *guid, | ||
197 | unsigned long table, | ||
198 | efi_config_table_type_t *table_types) | ||
199 | { | ||
200 | u8 str[EFI_VARIABLE_GUID_LEN + 1]; | ||
201 | int i; | ||
202 | |||
203 | if (table_types) { | ||
204 | efi_guid_unparse(guid, str); | ||
205 | |||
206 | for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) { | ||
207 | efi_guid_unparse(&table_types[i].guid, str); | ||
208 | |||
209 | if (!efi_guidcmp(*guid, table_types[i].guid)) { | ||
210 | *(table_types[i].ptr) = table; | ||
211 | pr_cont(" %s=0x%lx ", | ||
212 | table_types[i].name, table); | ||
213 | return 1; | ||
214 | } | ||
215 | } | ||
216 | } | ||
217 | |||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | int __init efi_config_init(efi_config_table_type_t *arch_tables) | ||
222 | { | ||
223 | void *config_tables, *tablep; | ||
224 | int i, sz; | ||
225 | |||
226 | if (efi_enabled(EFI_64BIT)) | ||
227 | sz = sizeof(efi_config_table_64_t); | ||
228 | else | ||
229 | sz = sizeof(efi_config_table_32_t); | ||
230 | |||
231 | /* | ||
232 | * Let's see what config tables the firmware passed to us. | ||
233 | */ | ||
234 | config_tables = early_memremap(efi.systab->tables, | ||
235 | efi.systab->nr_tables * sz); | ||
236 | if (config_tables == NULL) { | ||
237 | pr_err("Could not map Configuration table!\n"); | ||
238 | return -ENOMEM; | ||
239 | } | ||
240 | |||
241 | tablep = config_tables; | ||
242 | pr_info(""); | ||
243 | for (i = 0; i < efi.systab->nr_tables; i++) { | ||
244 | efi_guid_t guid; | ||
245 | unsigned long table; | ||
246 | |||
247 | if (efi_enabled(EFI_64BIT)) { | ||
248 | u64 table64; | ||
249 | guid = ((efi_config_table_64_t *)tablep)->guid; | ||
250 | table64 = ((efi_config_table_64_t *)tablep)->table; | ||
251 | table = table64; | ||
252 | #ifndef CONFIG_64BIT | ||
253 | if (table64 >> 32) { | ||
254 | pr_cont("\n"); | ||
255 | pr_err("Table located above 4GB, disabling EFI.\n"); | ||
256 | early_iounmap(config_tables, | ||
257 | efi.systab->nr_tables * sz); | ||
258 | return -EINVAL; | ||
259 | } | ||
260 | #endif | ||
261 | } else { | ||
262 | guid = ((efi_config_table_32_t *)tablep)->guid; | ||
263 | table = ((efi_config_table_32_t *)tablep)->table; | ||
264 | } | ||
265 | |||
266 | if (!match_config_table(&guid, table, common_tables)) | ||
267 | match_config_table(&guid, table, arch_tables); | ||
268 | |||
269 | tablep += sz; | ||
270 | } | ||
271 | pr_cont("\n"); | ||
272 | early_iounmap(config_tables, efi.systab->nr_tables * sz); | ||
273 | return 0; | ||
274 | } | ||
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 8a7432a4b413..933eb027d527 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c | |||
@@ -564,7 +564,7 @@ static int efivar_sysfs_destroy(struct efivar_entry *entry, void *data) | |||
564 | return 0; | 564 | return 0; |
565 | } | 565 | } |
566 | 566 | ||
567 | void efivars_sysfs_exit(void) | 567 | static void efivars_sysfs_exit(void) |
568 | { | 568 | { |
569 | /* Remove all entries and destroy */ | 569 | /* Remove all entries and destroy */ |
570 | __efivar_entry_iter(efivar_sysfs_destroy, &efivar_sysfs_list, NULL, NULL); | 570 | __efivar_entry_iter(efivar_sysfs_destroy, &efivar_sysfs_list, NULL, NULL); |
diff --git a/include/linux/efi.h b/include/linux/efi.h index 5f8f176154f7..bc5687d0f315 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h | |||
@@ -39,6 +39,8 @@ | |||
39 | typedef unsigned long efi_status_t; | 39 | typedef unsigned long efi_status_t; |
40 | typedef u8 efi_bool_t; | 40 | typedef u8 efi_bool_t; |
41 | typedef u16 efi_char16_t; /* UNICODE character */ | 41 | typedef u16 efi_char16_t; /* UNICODE character */ |
42 | typedef u64 efi_physical_addr_t; | ||
43 | typedef void *efi_handle_t; | ||
42 | 44 | ||
43 | 45 | ||
44 | typedef struct { | 46 | typedef struct { |
@@ -96,6 +98,7 @@ typedef struct { | |||
96 | #define EFI_MEMORY_DESCRIPTOR_VERSION 1 | 98 | #define EFI_MEMORY_DESCRIPTOR_VERSION 1 |
97 | 99 | ||
98 | #define EFI_PAGE_SHIFT 12 | 100 | #define EFI_PAGE_SHIFT 12 |
101 | #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) | ||
99 | 102 | ||
100 | typedef struct { | 103 | typedef struct { |
101 | u32 type; | 104 | u32 type; |
@@ -157,11 +160,13 @@ typedef struct { | |||
157 | efi_table_hdr_t hdr; | 160 | efi_table_hdr_t hdr; |
158 | void *raise_tpl; | 161 | void *raise_tpl; |
159 | void *restore_tpl; | 162 | void *restore_tpl; |
160 | void *allocate_pages; | 163 | efi_status_t (*allocate_pages)(int, int, unsigned long, |
161 | void *free_pages; | 164 | efi_physical_addr_t *); |
162 | void *get_memory_map; | 165 | efi_status_t (*free_pages)(efi_physical_addr_t, unsigned long); |
163 | void *allocate_pool; | 166 | efi_status_t (*get_memory_map)(unsigned long *, void *, unsigned long *, |
164 | void *free_pool; | 167 | unsigned long *, u32 *); |
168 | efi_status_t (*allocate_pool)(int, unsigned long, void **); | ||
169 | efi_status_t (*free_pool)(void *); | ||
165 | void *create_event; | 170 | void *create_event; |
166 | void *set_timer; | 171 | void *set_timer; |
167 | void *wait_for_event; | 172 | void *wait_for_event; |
@@ -171,7 +176,7 @@ typedef struct { | |||
171 | void *install_protocol_interface; | 176 | void *install_protocol_interface; |
172 | void *reinstall_protocol_interface; | 177 | void *reinstall_protocol_interface; |
173 | void *uninstall_protocol_interface; | 178 | void *uninstall_protocol_interface; |
174 | void *handle_protocol; | 179 | efi_status_t (*handle_protocol)(efi_handle_t, efi_guid_t *, void **); |
175 | void *__reserved; | 180 | void *__reserved; |
176 | void *register_protocol_notify; | 181 | void *register_protocol_notify; |
177 | void *locate_handle; | 182 | void *locate_handle; |
@@ -181,7 +186,7 @@ typedef struct { | |||
181 | void *start_image; | 186 | void *start_image; |
182 | void *exit; | 187 | void *exit; |
183 | void *unload_image; | 188 | void *unload_image; |
184 | void *exit_boot_services; | 189 | efi_status_t (*exit_boot_services)(efi_handle_t, unsigned long); |
185 | void *get_next_monotonic_count; | 190 | void *get_next_monotonic_count; |
186 | void *stall; | 191 | void *stall; |
187 | void *set_watchdog_timer; | 192 | void *set_watchdog_timer; |
@@ -404,6 +409,12 @@ typedef struct { | |||
404 | unsigned long table; | 409 | unsigned long table; |
405 | } efi_config_table_t; | 410 | } efi_config_table_t; |
406 | 411 | ||
412 | typedef struct { | ||
413 | efi_guid_t guid; | ||
414 | const char *name; | ||
415 | unsigned long *ptr; | ||
416 | } efi_config_table_type_t; | ||
417 | |||
407 | #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) | 418 | #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) |
408 | 419 | ||
409 | #define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) | 420 | #define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) |
@@ -488,10 +499,6 @@ typedef struct { | |||
488 | unsigned long unload; | 499 | unsigned long unload; |
489 | } efi_loaded_image_t; | 500 | } efi_loaded_image_t; |
490 | 501 | ||
491 | typedef struct { | ||
492 | u64 revision; | ||
493 | void *open_volume; | ||
494 | } efi_file_io_interface_t; | ||
495 | 502 | ||
496 | typedef struct { | 503 | typedef struct { |
497 | u64 size; | 504 | u64 size; |
@@ -504,20 +511,30 @@ typedef struct { | |||
504 | efi_char16_t filename[1]; | 511 | efi_char16_t filename[1]; |
505 | } efi_file_info_t; | 512 | } efi_file_info_t; |
506 | 513 | ||
507 | typedef struct { | 514 | typedef struct _efi_file_handle { |
508 | u64 revision; | 515 | u64 revision; |
509 | void *open; | 516 | efi_status_t (*open)(struct _efi_file_handle *, |
510 | void *close; | 517 | struct _efi_file_handle **, |
518 | efi_char16_t *, u64, u64); | ||
519 | efi_status_t (*close)(struct _efi_file_handle *); | ||
511 | void *delete; | 520 | void *delete; |
512 | void *read; | 521 | efi_status_t (*read)(struct _efi_file_handle *, unsigned long *, |
522 | void *); | ||
513 | void *write; | 523 | void *write; |
514 | void *get_position; | 524 | void *get_position; |
515 | void *set_position; | 525 | void *set_position; |
516 | void *get_info; | 526 | efi_status_t (*get_info)(struct _efi_file_handle *, efi_guid_t *, |
527 | unsigned long *, void *); | ||
517 | void *set_info; | 528 | void *set_info; |
518 | void *flush; | 529 | void *flush; |
519 | } efi_file_handle_t; | 530 | } efi_file_handle_t; |
520 | 531 | ||
532 | typedef struct _efi_file_io_interface { | ||
533 | u64 revision; | ||
534 | int (*open_volume)(struct _efi_file_io_interface *, | ||
535 | efi_file_handle_t **); | ||
536 | } efi_file_io_interface_t; | ||
537 | |||
521 | #define EFI_FILE_MODE_READ 0x0000000000000001 | 538 | #define EFI_FILE_MODE_READ 0x0000000000000001 |
522 | #define EFI_FILE_MODE_WRITE 0x0000000000000002 | 539 | #define EFI_FILE_MODE_WRITE 0x0000000000000002 |
523 | #define EFI_FILE_MODE_CREATE 0x8000000000000000 | 540 | #define EFI_FILE_MODE_CREATE 0x8000000000000000 |
@@ -552,6 +569,7 @@ extern struct efi { | |||
552 | efi_get_next_high_mono_count_t *get_next_high_mono_count; | 569 | efi_get_next_high_mono_count_t *get_next_high_mono_count; |
553 | efi_reset_system_t *reset_system; | 570 | efi_reset_system_t *reset_system; |
554 | efi_set_virtual_address_map_t *set_virtual_address_map; | 571 | efi_set_virtual_address_map_t *set_virtual_address_map; |
572 | struct efi_memory_map *memmap; | ||
555 | } efi; | 573 | } efi; |
556 | 574 | ||
557 | static inline int | 575 | static inline int |
@@ -587,6 +605,7 @@ static inline efi_status_t efi_query_variable_store(u32 attributes, unsigned lon | |||
587 | } | 605 | } |
588 | #endif | 606 | #endif |
589 | extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); | 607 | extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); |
608 | extern int efi_config_init(efi_config_table_type_t *arch_tables); | ||
590 | extern u64 efi_get_iobase (void); | 609 | extern u64 efi_get_iobase (void); |
591 | extern u32 efi_mem_type (unsigned long phys_addr); | 610 | extern u32 efi_mem_type (unsigned long phys_addr); |
592 | extern u64 efi_mem_attributes (unsigned long phys_addr); | 611 | extern u64 efi_mem_attributes (unsigned long phys_addr); |
@@ -784,6 +803,13 @@ struct efivar_entry { | |||
784 | struct kobject kobj; | 803 | struct kobject kobj; |
785 | }; | 804 | }; |
786 | 805 | ||
806 | |||
807 | struct efi_simple_text_output_protocol { | ||
808 | void *reset; | ||
809 | efi_status_t (*output_string)(void *, void *); | ||
810 | void *test_string; | ||
811 | }; | ||
812 | |||
787 | extern struct list_head efivar_sysfs_list; | 813 | extern struct list_head efivar_sysfs_list; |
788 | 814 | ||
789 | static inline void | 815 | static inline void |