Lines Matching +full:rom +full:- +full:14 +full:h

1 // SPDX-License-Identifier: GPL-2.0-only
3 /* -----------------------------------------------------------------------
7 * ----------------------------------------------------------------------- */
9 #include <linux/efi.h>
10 #include <linux/pci.h>
11 #include <linux/stddef.h>
13 #include <asm/efi.h>
14 #include <asm/e820/types.h>
15 #include <asm/setup.h>
16 #include <asm/desc.h>
17 #include <asm/boot.h>
18 #include <asm/kaslr.h>
19 #include <asm/sev.h>
21 #include "efistub.h"
22 #include "x86-stub.h"
45 struct pci_setup_rom *rom = NULL; in preserve_pci_rom_image() local
63 size = romsize + sizeof(*rom); in preserve_pci_rom_image()
66 (void **)&rom); in preserve_pci_rom_image()
68 efi_err("Failed to allocate memory for 'rom'\n"); in preserve_pci_rom_image()
72 memset(rom, 0, sizeof(*rom)); in preserve_pci_rom_image()
74 rom->data.type = SETUP_PCI; in preserve_pci_rom_image()
75 rom->data.len = size - sizeof(struct setup_data); in preserve_pci_rom_image()
76 rom->data.next = 0; in preserve_pci_rom_image()
77 rom->pcilen = romsize; in preserve_pci_rom_image()
78 *__rom = rom; in preserve_pci_rom_image()
81 PCI_VENDOR_ID, 1, &rom->vendor); in preserve_pci_rom_image()
84 efi_err("Failed to read rom->vendor\n"); in preserve_pci_rom_image()
89 PCI_DEVICE_ID, 1, &rom->devid); in preserve_pci_rom_image()
92 efi_err("Failed to read rom->devid\n"); in preserve_pci_rom_image()
96 status = efi_call_proto(pci, get_location, &rom->segment, &rom->bus, in preserve_pci_rom_image()
97 &rom->device, &rom->function); in preserve_pci_rom_image()
102 memcpy(rom->romdata, romimage, romsize); in preserve_pci_rom_image()
106 efi_bs_call(free_pool, rom); in preserve_pci_rom_image()
113 * done directly at the EFI function call-site.
126 efi_handle_t h; in setup_efi_pci() local
148 data = (struct setup_data *)(unsigned long)params->hdr.setup_data; in setup_efi_pci()
150 while (data && data->next) in setup_efi_pci()
151 data = (struct setup_data *)(unsigned long)data->next; in setup_efi_pci()
153 for_each_efi_handle(h, pci_handle, size, i) { in setup_efi_pci()
155 struct pci_setup_rom *rom; in setup_efi_pci() local
157 status = efi_bs_call(handle_protocol, h, &pci_proto, in setup_efi_pci()
162 status = preserve_pci_rom_image(pci, &rom); in setup_efi_pci()
167 data->next = (unsigned long)rom; in setup_efi_pci()
169 params->hdr.setup_data = (unsigned long)rom; in setup_efi_pci()
171 data = (struct setup_data *)rom; in setup_efi_pci()
208 status = efi_call_proto(p, get_all, new->data, &size); in retrieve_apple_device_properties()
214 new->type = SETUP_APPLE_PROPERTIES; in retrieve_apple_device_properties()
215 new->len = size; in retrieve_apple_device_properties()
216 new->next = 0; in retrieve_apple_device_properties()
218 data = (struct setup_data *)(unsigned long)boot_params->hdr.setup_data; in retrieve_apple_device_properties()
220 boot_params->hdr.setup_data = (unsigned long)new; in retrieve_apple_device_properties()
222 while (data->next) in retrieve_apple_device_properties()
223 data = (struct setup_data *)(unsigned long)data->next; in retrieve_apple_device_properties()
224 data->next = (unsigned long)new; in retrieve_apple_device_properties()
243 rounded_end - rounded_start, in efi_adjust_memory_range_protection()
252 rounded_end - rounded_start, in efi_adjust_memory_range_protection()
287 unprotect_size = min(rounded_end, next) - unprotect_start; in efi_adjust_memory_range_protection()
372 u32 w, h, depth, refresh; in setup_uga() local
383 status = efi_call_proto(uga, get_mode, &w, &h, &depth, &refresh); in setup_uga()
386 height = h; in setup_uga()
403 si->orig_video_isVGA = VIDEO_TYPE_EFI; in setup_uga()
405 si->lfb_depth = 32; in setup_uga()
406 si->lfb_width = width; in setup_uga()
407 si->lfb_height = height; in setup_uga()
409 si->red_size = 8; in setup_uga()
410 si->red_pos = 16; in setup_uga()
411 si->green_size = 8; in setup_uga()
412 si->green_pos = 8; in setup_uga()
413 si->blue_size = 8; in setup_uga()
414 si->blue_pos = 0; in setup_uga()
415 si->rsvd_size = 8; in setup_uga()
416 si->rsvd_pos = 24; in setup_uga()
434 si = &boot_params->screen_info; in setup_graphics()
481 memset(_bss, 0, _ebss - _bss); in efi_pe_entry()
486 if (efi_system_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) in efi_pe_entry()
500 hdr = &boot_params->hdr; in efi_pe_entry()
503 hdr->root_flags = 1; in efi_pe_entry()
504 hdr->vid_mode = 0xffff; in efi_pe_entry()
506 hdr->type_of_loader = 0x21; in efi_pe_entry()
507 hdr->initrd_addr_max = INT_MAX; in efi_pe_entry()
516 efi_set_u64_split((unsigned long)cmdline_ptr, &hdr->cmd_line_ptr, in efi_pe_entry()
517 &boot_params->ext_cmd_line_ptr); in efi_pe_entry()
528 e820ext->type = SETUP_E820_EXT; in add_e820ext()
529 e820ext->len = nr_entries * sizeof(struct boot_e820_entry); in add_e820ext()
530 e820ext->next = 0; in add_e820ext()
532 data = (struct setup_data *)(unsigned long)params->hdr.setup_data; in add_e820ext()
534 while (data && data->next) in add_e820ext()
535 data = (struct setup_data *)(unsigned long)data->next; in add_e820ext()
538 data->next = (unsigned long)e820ext; in add_e820ext()
540 params->hdr.setup_data = (unsigned long)e820ext; in add_e820ext()
546 struct boot_e820_entry *entry = params->e820_table; in setup_e820()
547 struct efi_info *efi = &params->efi_info; in setup_e820()
554 nr_desc = efi->efi_memmap_size / efi->efi_memdesc_size; in setup_e820()
559 unsigned long m = efi->efi_memmap; in setup_e820()
562 m |= (u64)efi->efi_memmap_hi << 32; in setup_e820()
565 d = efi_early_memdesc_ptr(m, efi->efi_memdesc_size, i); in setup_e820()
566 switch (d->type) { in setup_e820()
590 (d->attribute & EFI_MEMORY_SP)) in setup_e820()
608 process_unaccepted_memory(d->phys_addr, in setup_e820()
609 d->phys_addr + PAGE_SIZE * d->num_pages); in setup_e820()
616 if (prev && prev->type == e820_type && in setup_e820()
617 (prev->addr + prev->size) == d->phys_addr) { in setup_e820()
618 prev->size += d->num_pages << 12; in setup_e820()
622 if (nr_entries == ARRAY_SIZE(params->e820_table)) { in setup_e820()
623 u32 need = (nr_desc - i) * sizeof(struct e820_entry) + in setup_e820()
630 entry = (struct boot_e820_entry *)e820ext->data; in setup_e820()
633 entry->addr = d->phys_addr; in setup_e820()
634 entry->size = d->num_pages << PAGE_SHIFT; in setup_e820()
635 entry->type = e820_type; in setup_e820()
640 if (nr_entries > ARRAY_SIZE(params->e820_table)) { in setup_e820()
641 u32 nr_e820ext = nr_entries - ARRAY_SIZE(params->e820_table); in setup_e820()
644 nr_entries -= nr_e820ext; in setup_e820()
647 params->e820_entries = (u8)nr_entries; in setup_e820()
687 nr_desc = map->map_size / map->desc_size; in allocate_e820()
688 if (nr_desc > ARRAY_SIZE(params->e820_table) - EFI_MMAP_NR_SLACK_SLOTS) { in allocate_e820()
689 u32 nr_e820ext = nr_desc - ARRAY_SIZE(params->e820_table) + in allocate_e820()
715 memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32)); in exit_boot_func()
718 &p->efi->efi_systab, &p->efi->efi_systab_hi); in exit_boot_func()
719 p->efi->efi_memdesc_size = map->desc_size; in exit_boot_func()
720 p->efi->efi_memdesc_version = map->desc_ver; in exit_boot_func()
721 efi_set_u64_split((unsigned long)map->map, in exit_boot_func()
722 &p->efi->efi_memmap, &p->efi->efi_memmap_hi); in exit_boot_func()
723 p->efi->efi_memmap_size = map->map_size; in exit_boot_func()
736 priv.efi = &boot_params->efi_info; in exit_boot()
748 boot_params->alt_mem_k = 32 * 1024; in exit_boot()
763 efi_err("Unsupported SEV-SNP features detected: 0x%llx\n", in have_unsupported_snp_features()
775 * This only updates seed[0] when running on 32-bit, but in that case, in efi_get_seed()
776 * seed[1] is not used anyway, as there is no virtual KASLR on 32-bit. in efi_get_seed()
790 static const char opts[][14] = { in parse_options()
797 if (p == cmdline || (p > cmdline && isspace(p[-1]))) { in parse_options()
818 u64 range = KERNEL_IMAGE_SIZE - LOAD_PHYSICAL_ADDR - kernel_total_size; in efi_decompress_kernel()
824 virt_addr &= ~(CONFIG_PHYSICAL_ALIGN - 1); in efi_decompress_kernel()
833 if (efi_system_table->hdr.revision <= EFI_2_00_SYSTEM_TABLE_REVISION && in efi_decompress_kernel()
835 efi_debug("AMI firmware v2.0 or older detected - disabling physical KASLR\n"); in efi_decompress_kernel()
838 efi_info("%s detected on the kernel command line - disabling physical KASLR\n", in efi_decompress_kernel()
881 struct setup_header *hdr = &boot_params->hdr; in efi_stub_entry()
890 if (efi_system_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) in efi_stub_entry()
899 efi_dxe_table->hdr.signature != EFI_DXE_SERVICES_TABLE_SIGNATURE) { in efi_stub_entry()
922 unsigned long cmdline_paddr = ((u64)hdr->cmd_line_ptr | in efi_stub_entry()
923 ((u64)boot_params->ext_cmd_line_ptr << 32)); in efi_stub_entry()
932 hdr->xloadflags |= XLF_MEM_ENCRYPTION; in efi_stub_entry()
945 * If the device path is not present, any command-line initrd= in efi_stub_entry()
949 status = efi_load_initrd(image, hdr->initrd_addr_max, ULONG_MAX, in efi_stub_entry()
953 if (initrd && initrd->size > 0) { in efi_stub_entry()
954 efi_set_u64_split(initrd->base, &hdr->ramdisk_image, in efi_stub_entry()
955 &boot_params->ext_ramdisk_image); in efi_stub_entry()
956 efi_set_u64_split(initrd->size, &hdr->ramdisk_size, in efi_stub_entry()
957 &boot_params->ext_ramdisk_size); in efi_stub_entry()
965 if (boot_params->secure_boot == efi_secureboot_mode_unset) in efi_stub_entry()
966 boot_params->secure_boot = efi_get_secureboot(); in efi_stub_entry()
1008 memset(_bss, 0, _ebss - _bss); in efi_handover_entry()