aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot/compressed/eboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/boot/compressed/eboot.c')
-rw-r--r--arch/x86/boot/compressed/eboot.c155
1 files changed, 76 insertions, 79 deletions
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 5e1ba4fa3f79..1e6146137f8e 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -21,6 +21,9 @@ static efi_system_table_t *sys_table;
21 21
22static struct efi_config *efi_early; 22static struct efi_config *efi_early;
23 23
24#define efi_call_early(f, ...) \
25 efi_early->call(efi_early->f, __VA_ARGS__);
26
24#define BOOT_SERVICES(bits) \ 27#define BOOT_SERVICES(bits) \
25static void setup_boot_services##bits(struct efi_config *c) \ 28static void setup_boot_services##bits(struct efi_config *c) \
26{ \ 29{ \
@@ -78,8 +81,8 @@ __file_size32(void *__fh, efi_char16_t *filename_16,
78 } 81 }
79 82
80grow: 83grow:
81 status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, 84 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
82 info_sz, (void **)&info); 85 info_sz, (void **)&info);
83 if (status != EFI_SUCCESS) { 86 if (status != EFI_SUCCESS) {
84 efi_printk(sys_table, "Failed to alloc mem for file info\n"); 87 efi_printk(sys_table, "Failed to alloc mem for file info\n");
85 return status; 88 return status;
@@ -88,12 +91,12 @@ grow:
88 status = efi_early->call((unsigned long)h->get_info, h, &info_guid, 91 status = efi_early->call((unsigned long)h->get_info, h, &info_guid,
89 &info_sz, info); 92 &info_sz, info);
90 if (status == EFI_BUFFER_TOO_SMALL) { 93 if (status == EFI_BUFFER_TOO_SMALL) {
91 efi_early->call(efi_early->free_pool, info); 94 efi_call_early(free_pool, info);
92 goto grow; 95 goto grow;
93 } 96 }
94 97
95 *file_sz = info->file_size; 98 *file_sz = info->file_size;
96 efi_early->call(efi_early->free_pool, info); 99 efi_call_early(free_pool, info);
97 100
98 if (status != EFI_SUCCESS) 101 if (status != EFI_SUCCESS)
99 efi_printk(sys_table, "Failed to get initrd info\n"); 102 efi_printk(sys_table, "Failed to get initrd info\n");
@@ -131,8 +134,8 @@ __file_size64(void *__fh, efi_char16_t *filename_16,
131 } 134 }
132 135
133grow: 136grow:
134 status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, 137 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
135 info_sz, (void **)&info); 138 info_sz, (void **)&info);
136 if (status != EFI_SUCCESS) { 139 if (status != EFI_SUCCESS) {
137 efi_printk(sys_table, "Failed to alloc mem for file info\n"); 140 efi_printk(sys_table, "Failed to alloc mem for file info\n");
138 return status; 141 return status;
@@ -141,12 +144,12 @@ grow:
141 status = efi_early->call((unsigned long)h->get_info, h, &info_guid, 144 status = efi_early->call((unsigned long)h->get_info, h, &info_guid,
142 &info_sz, info); 145 &info_sz, info);
143 if (status == EFI_BUFFER_TOO_SMALL) { 146 if (status == EFI_BUFFER_TOO_SMALL) {
144 efi_early->call(efi_early->free_pool, info); 147 efi_call_early(free_pool, info);
145 goto grow; 148 goto grow;
146 } 149 }
147 150
148 *file_sz = info->file_size; 151 *file_sz = info->file_size;
149 efi_early->call(efi_early->free_pool, info); 152 efi_call_early(free_pool, info);
150 153
151 if (status != EFI_SUCCESS) 154 if (status != EFI_SUCCESS)
152 efi_printk(sys_table, "Failed to get initrd info\n"); 155 efi_printk(sys_table, "Failed to get initrd info\n");
@@ -204,8 +207,8 @@ static inline efi_status_t __open_volume32(void *__image, void **__fh)
204 void *handle = (void *)(unsigned long)image->device_handle; 207 void *handle = (void *)(unsigned long)image->device_handle;
205 unsigned long func; 208 unsigned long func;
206 209
207 status = efi_early->call(efi_early->handle_protocol, handle, 210 status = efi_call_early(handle_protocol, handle,
208 &fs_proto, (void **)&io); 211 &fs_proto, (void **)&io);
209 if (status != EFI_SUCCESS) { 212 if (status != EFI_SUCCESS) {
210 efi_printk(sys_table, "Failed to handle fs_proto\n"); 213 efi_printk(sys_table, "Failed to handle fs_proto\n");
211 return status; 214 return status;
@@ -230,8 +233,8 @@ static inline efi_status_t __open_volume64(void *__image, void **__fh)
230 void *handle = (void *)(unsigned long)image->device_handle; 233 void *handle = (void *)(unsigned long)image->device_handle;
231 unsigned long func; 234 unsigned long func;
232 235
233 status = efi_early->call(efi_early->handle_protocol, handle, 236 status = efi_call_early(handle_protocol, handle,
234 &fs_proto, (void **)&io); 237 &fs_proto, (void **)&io);
235 if (status != EFI_SUCCESS) { 238 if (status != EFI_SUCCESS) {
236 efi_printk(sys_table, "Failed to handle fs_proto\n"); 239 efi_printk(sys_table, "Failed to handle fs_proto\n");
237 return status; 240 return status;
@@ -325,9 +328,7 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom)
325 328
326 size = pci->romsize + sizeof(*rom); 329 size = pci->romsize + sizeof(*rom);
327 330
328 status = efi_early->call(efi_early->allocate_pool, 331 status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom);
329 EFI_LOADER_DATA, size, &rom);
330
331 if (status != EFI_SUCCESS) 332 if (status != EFI_SUCCESS)
332 return status; 333 return status;
333 334
@@ -361,7 +362,7 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom)
361 return status; 362 return status;
362 363
363free_struct: 364free_struct:
364 efi_early->call(efi_early->free_pool, rom); 365 efi_call_early(free_pool, rom);
365 return status; 366 return status;
366} 367}
367 368
@@ -387,8 +388,8 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle,
387 struct pci_setup_rom *rom = NULL; 388 struct pci_setup_rom *rom = NULL;
388 u32 h = handles[i]; 389 u32 h = handles[i];
389 390
390 status = efi_early->call(efi_early->handle_protocol, h, 391 status = efi_call_early(handle_protocol, h,
391 &pci_proto, (void **)&pci); 392 &pci_proto, (void **)&pci);
392 393
393 if (status != EFI_SUCCESS) 394 if (status != EFI_SUCCESS)
394 continue; 395 continue;
@@ -431,9 +432,7 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom)
431 432
432 size = pci->romsize + sizeof(*rom); 433 size = pci->romsize + sizeof(*rom);
433 434
434 status = efi_early->call(efi_early->allocate_pool, 435 status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom);
435 EFI_LOADER_DATA, size, &rom);
436
437 if (status != EFI_SUCCESS) 436 if (status != EFI_SUCCESS)
438 return status; 437 return status;
439 438
@@ -465,7 +464,7 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom)
465 return status; 464 return status;
466 465
467free_struct: 466free_struct:
468 efi_early->call(efi_early->free_pool, rom); 467 efi_call_early(free_pool, rom);
469 return status; 468 return status;
470 469
471} 470}
@@ -492,8 +491,8 @@ setup_efi_pci64(struct boot_params *params, void **pci_handle,
492 struct pci_setup_rom *rom = NULL; 491 struct pci_setup_rom *rom = NULL;
493 u64 h = handles[i]; 492 u64 h = handles[i];
494 493
495 status = efi_early->call(efi_early->handle_protocol, h, 494 status = efi_call_early(handle_protocol, h,
496 &pci_proto, (void **)&pci); 495 &pci_proto, (void **)&pci);
497 496
498 if (status != EFI_SUCCESS) 497 if (status != EFI_SUCCESS)
499 continue; 498 continue;
@@ -524,21 +523,21 @@ static efi_status_t setup_efi_pci(struct boot_params *params)
524 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; 523 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID;
525 unsigned long size = 0; 524 unsigned long size = 0;
526 525
527 status = efi_early->call(efi_early->locate_handle, 526 status = efi_call_early(locate_handle,
528 EFI_LOCATE_BY_PROTOCOL, 527 EFI_LOCATE_BY_PROTOCOL,
529 &pci_proto, NULL, &size, pci_handle); 528 &pci_proto, NULL, &size, pci_handle);
530 529
531 if (status == EFI_BUFFER_TOO_SMALL) { 530 if (status == EFI_BUFFER_TOO_SMALL) {
532 status = efi_early->call(efi_early->allocate_pool, 531 status = efi_call_early(allocate_pool,
533 EFI_LOADER_DATA, 532 EFI_LOADER_DATA,
534 size, (void **)&pci_handle); 533 size, (void **)&pci_handle);
535 534
536 if (status != EFI_SUCCESS) 535 if (status != EFI_SUCCESS)
537 return status; 536 return status;
538 537
539 status = efi_early->call(efi_early->locate_handle, 538 status = efi_call_early(locate_handle,
540 EFI_LOCATE_BY_PROTOCOL, &pci_proto, 539 EFI_LOCATE_BY_PROTOCOL, &pci_proto,
541 NULL, &size, pci_handle); 540 NULL, &size, pci_handle);
542 } 541 }
543 542
544 if (status != EFI_SUCCESS) 543 if (status != EFI_SUCCESS)
@@ -550,7 +549,7 @@ static efi_status_t setup_efi_pci(struct boot_params *params)
550 status = setup_efi_pci32(params, pci_handle, size); 549 status = setup_efi_pci32(params, pci_handle, size);
551 550
552free_handle: 551free_handle:
553 efi_early->call(efi_early->free_pool, pci_handle); 552 efi_call_early(free_pool, pci_handle);
554 return status; 553 return status;
555} 554}
556 555
@@ -651,13 +650,13 @@ setup_gop32(struct screen_info *si, efi_guid_t *proto,
651 void *dummy = NULL; 650 void *dummy = NULL;
652 u32 h = handles[i]; 651 u32 h = handles[i];
653 652
654 status = efi_early->call(efi_early->handle_protocol, h, 653 status = efi_call_early(handle_protocol, h,
655 proto, (void **)&gop32); 654 proto, (void **)&gop32);
656 if (status != EFI_SUCCESS) 655 if (status != EFI_SUCCESS)
657 continue; 656 continue;
658 657
659 status = efi_early->call(efi_early->handle_protocol, h, 658 status = efi_call_early(handle_protocol, h,
660 &conout_proto, &dummy); 659 &conout_proto, &dummy);
661 if (status == EFI_SUCCESS) 660 if (status == EFI_SUCCESS)
662 conout_found = true; 661 conout_found = true;
663 662
@@ -754,13 +753,13 @@ setup_gop64(struct screen_info *si, efi_guid_t *proto,
754 void *dummy = NULL; 753 void *dummy = NULL;
755 u64 h = handles[i]; 754 u64 h = handles[i];
756 755
757 status = efi_early->call(efi_early->handle_protocol, h, 756 status = efi_call_early(handle_protocol, h,
758 proto, (void **)&gop64); 757 proto, (void **)&gop64);
759 if (status != EFI_SUCCESS) 758 if (status != EFI_SUCCESS)
760 continue; 759 continue;
761 760
762 status = efi_early->call(efi_early->handle_protocol, h, 761 status = efi_call_early(handle_protocol, h,
763 &conout_proto, &dummy); 762 &conout_proto, &dummy);
764 if (status == EFI_SUCCESS) 763 if (status == EFI_SUCCESS)
765 conout_found = true; 764 conout_found = true;
766 765
@@ -819,14 +818,14 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
819 efi_status_t status; 818 efi_status_t status;
820 void **gop_handle = NULL; 819 void **gop_handle = NULL;
821 820
822 status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, 821 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
823 size, (void **)&gop_handle); 822 size, (void **)&gop_handle);
824 if (status != EFI_SUCCESS) 823 if (status != EFI_SUCCESS)
825 return status; 824 return status;
826 825
827 status = efi_early->call(efi_early->locate_handle, 826 status = efi_call_early(locate_handle,
828 EFI_LOCATE_BY_PROTOCOL, 827 EFI_LOCATE_BY_PROTOCOL,
829 proto, NULL, &size, gop_handle); 828 proto, NULL, &size, gop_handle);
830 if (status != EFI_SUCCESS) 829 if (status != EFI_SUCCESS)
831 goto free_handle; 830 goto free_handle;
832 831
@@ -836,7 +835,7 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
836 status = setup_gop32(si, proto, size, gop_handle); 835 status = setup_gop32(si, proto, size, gop_handle);
837 836
838free_handle: 837free_handle:
839 efi_early->call(efi_early->free_pool, gop_handle); 838 efi_call_early(free_pool, gop_handle);
840 return status; 839 return status;
841} 840}
842 841
@@ -858,13 +857,12 @@ setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
858 void *pciio; 857 void *pciio;
859 u32 handle = handles[i]; 858 u32 handle = handles[i];
860 859
861 status = efi_early->call(efi_early->handle_protocol, handle, 860 status = efi_call_early(handle_protocol, handle,
862 &uga_proto, (void **)&uga); 861 &uga_proto, (void **)&uga);
863 if (status != EFI_SUCCESS) 862 if (status != EFI_SUCCESS)
864 continue; 863 continue;
865 864
866 efi_early->call(efi_early->handle_protocol, handle, 865 efi_call_early(handle_protocol, handle, &pciio_proto, &pciio);
867 &pciio_proto, &pciio);
868 866
869 status = efi_early->call((unsigned long)uga->get_mode, uga, 867 status = efi_early->call((unsigned long)uga->get_mode, uga,
870 &w, &h, &depth, &refresh); 868 &w, &h, &depth, &refresh);
@@ -904,13 +902,12 @@ setup_uga64(void **uga_handle, unsigned long size, u32 *width, u32 *height)
904 void *pciio; 902 void *pciio;
905 u64 handle = handles[i]; 903 u64 handle = handles[i];
906 904
907 status = efi_early->call(efi_early->handle_protocol, handle, 905 status = efi_call_early(handle_protocol, handle,
908 &uga_proto, (void **)&uga); 906 &uga_proto, (void **)&uga);
909 if (status != EFI_SUCCESS) 907 if (status != EFI_SUCCESS)
910 continue; 908 continue;
911 909
912 efi_early->call(efi_early->handle_protocol, handle, 910 efi_call_early(handle_protocol, handle, &pciio_proto, &pciio);
913 &pciio_proto, &pciio);
914 911
915 status = efi_early->call((unsigned long)uga->get_mode, uga, 912 status = efi_early->call((unsigned long)uga->get_mode, uga,
916 &w, &h, &depth, &refresh); 913 &w, &h, &depth, &refresh);
@@ -942,14 +939,14 @@ static efi_status_t setup_uga(struct screen_info *si, efi_guid_t *uga_proto,
942 u32 width, height; 939 u32 width, height;
943 void **uga_handle = NULL; 940 void **uga_handle = NULL;
944 941
945 status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, 942 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
946 size, (void **)&uga_handle); 943 size, (void **)&uga_handle);
947 if (status != EFI_SUCCESS) 944 if (status != EFI_SUCCESS)
948 return status; 945 return status;
949 946
950 status = efi_early->call(efi_early->locate_handle, 947 status = efi_call_early(locate_handle,
951 EFI_LOCATE_BY_PROTOCOL, 948 EFI_LOCATE_BY_PROTOCOL,
952 uga_proto, NULL, &size, uga_handle); 949 uga_proto, NULL, &size, uga_handle);
953 if (status != EFI_SUCCESS) 950 if (status != EFI_SUCCESS)
954 goto free_handle; 951 goto free_handle;
955 952
@@ -981,7 +978,7 @@ static efi_status_t setup_uga(struct screen_info *si, efi_guid_t *uga_proto,
981 si->rsvd_pos = 24; 978 si->rsvd_pos = 24;
982 979
983free_handle: 980free_handle:
984 efi_early->call(efi_early->free_pool, uga_handle); 981 efi_call_early(free_pool, uga_handle);
985 return status; 982 return status;
986} 983}
987 984
@@ -999,17 +996,17 @@ void setup_graphics(struct boot_params *boot_params)
999 memset(si, 0, sizeof(*si)); 996 memset(si, 0, sizeof(*si));
1000 997
1001 size = 0; 998 size = 0;
1002 status = efi_early->call(efi_early->locate_handle, 999 status = efi_call_early(locate_handle,
1003 EFI_LOCATE_BY_PROTOCOL, 1000 EFI_LOCATE_BY_PROTOCOL,
1004 &graphics_proto, NULL, &size, gop_handle); 1001 &graphics_proto, NULL, &size, gop_handle);
1005 if (status == EFI_BUFFER_TOO_SMALL) 1002 if (status == EFI_BUFFER_TOO_SMALL)
1006 status = setup_gop(si, &graphics_proto, size); 1003 status = setup_gop(si, &graphics_proto, size);
1007 1004
1008 if (status != EFI_SUCCESS) { 1005 if (status != EFI_SUCCESS) {
1009 size = 0; 1006 size = 0;
1010 status = efi_early->call(efi_early->locate_handle, 1007 status = efi_call_early(locate_handle,
1011 EFI_LOCATE_BY_PROTOCOL, 1008 EFI_LOCATE_BY_PROTOCOL,
1012 &uga_proto, NULL, &size, uga_handle); 1009 &uga_proto, NULL, &size, uga_handle);
1013 if (status == EFI_BUFFER_TOO_SMALL) 1010 if (status == EFI_BUFFER_TOO_SMALL)
1014 setup_uga(si, &uga_proto, size); 1011 setup_uga(si, &uga_proto, size);
1015 } 1012 }
@@ -1052,8 +1049,8 @@ struct boot_params *make_boot_params(struct efi_config *c)
1052 else 1049 else
1053 setup_boot_services32(efi_early); 1050 setup_boot_services32(efi_early);
1054 1051
1055 status = efi_early->call(efi_early->handle_protocol, handle, 1052 status = efi_call_early(handle_protocol, handle,
1056 &proto, (void *)&image); 1053 &proto, (void *)&image);
1057 if (status != EFI_SUCCESS) { 1054 if (status != EFI_SUCCESS) {
1058 efi_printk(sys_table, "Failed to get handle for LOADED_IMAGE_PROTOCOL\n"); 1055 efi_printk(sys_table, "Failed to get handle for LOADED_IMAGE_PROTOCOL\n");
1059 return NULL; 1056 return NULL;
@@ -1242,13 +1239,13 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext,
1242 sizeof(struct e820entry) * nr_desc; 1239 sizeof(struct e820entry) * nr_desc;
1243 1240
1244 if (*e820ext) { 1241 if (*e820ext) {
1245 efi_early->call(efi_early->free_pool, *e820ext); 1242 efi_call_early(free_pool, *e820ext);
1246 *e820ext = NULL; 1243 *e820ext = NULL;
1247 *e820ext_size = 0; 1244 *e820ext_size = 0;
1248 } 1245 }
1249 1246
1250 status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, 1247 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
1251 size, (void **)e820ext); 1248 size, (void **)e820ext);
1252 if (status == EFI_SUCCESS) 1249 if (status == EFI_SUCCESS)
1253 *e820ext_size = size; 1250 *e820ext_size = size;
1254 1251
@@ -1292,7 +1289,7 @@ get_map:
1292 if (status != EFI_SUCCESS) 1289 if (status != EFI_SUCCESS)
1293 goto free_mem_map; 1290 goto free_mem_map;
1294 1291
1295 efi_early->call(efi_early->free_pool, mem_map); 1292 efi_call_early(free_pool, mem_map);
1296 goto get_map; /* Allocated memory, get map again */ 1293 goto get_map; /* Allocated memory, get map again */
1297 } 1294 }
1298 1295
@@ -1311,7 +1308,7 @@ get_map:
1311#endif 1308#endif
1312 1309
1313 /* Might as well exit boot services now */ 1310 /* Might as well exit boot services now */
1314 status = efi_early->call(efi_early->exit_boot_services, handle, key); 1311 status = efi_call_early(exit_boot_services, handle, key);
1315 if (status != EFI_SUCCESS) { 1312 if (status != EFI_SUCCESS) {
1316 /* 1313 /*
1317 * ExitBootServices() will fail if any of the event 1314 * ExitBootServices() will fail if any of the event
@@ -1324,7 +1321,7 @@ get_map:
1324 goto free_mem_map; 1321 goto free_mem_map;
1325 1322
1326 called_exit = true; 1323 called_exit = true;
1327 efi_early->call(efi_early->free_pool, mem_map); 1324 efi_call_early(free_pool, mem_map);
1328 goto get_map; 1325 goto get_map;
1329 } 1326 }
1330 1327
@@ -1338,7 +1335,7 @@ get_map:
1338 return EFI_SUCCESS; 1335 return EFI_SUCCESS;
1339 1336
1340free_mem_map: 1337free_mem_map:
1341 efi_early->call(efi_early->free_pool, mem_map); 1338 efi_call_early(free_pool, mem_map);
1342 return status; 1339 return status;
1343} 1340}
1344 1341
@@ -1379,8 +1376,8 @@ struct boot_params *efi_main(struct efi_config *c,
1379 1376
1380 setup_efi_pci(boot_params); 1377 setup_efi_pci(boot_params);
1381 1378
1382 status = efi_early->call(efi_early->allocate_pool, EFI_LOADER_DATA, 1379 status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
1383 sizeof(*gdt), (void **)&gdt); 1380 sizeof(*gdt), (void **)&gdt);
1384 if (status != EFI_SUCCESS) { 1381 if (status != EFI_SUCCESS) {
1385 efi_printk(sys_table, "Failed to alloc mem for gdt structure\n"); 1382 efi_printk(sys_table, "Failed to alloc mem for gdt structure\n");
1386 goto fail; 1383 goto fail;