static efi_status_t update_fdt(void *orig_fdt, unsignedlong orig_fdt_size, void *fdt, int new_fdt_size, char *cmdline_ptr)
{ int node, num_rsv; int status;
u32 fdt_val32;
u64 fdt_val64;
/* Do some checks on provided FDT, if it exists: */ if (orig_fdt) { if (fdt_check_header(orig_fdt)) {
efi_err("Device Tree header not valid!\n"); return EFI_LOAD_ERROR;
} /* *Wedon'tgetthesizeoftheFDTifwegetiffroma *configurationtable:
*/ if (orig_fdt_size && fdt_totalsize(orig_fdt) > orig_fdt_size) {
efi_err("Truncated device tree! foo!\n"); return EFI_LOAD_ERROR;
}
}
if (orig_fdt) {
status = fdt_open_into(orig_fdt, fdt, new_fdt_size);
} else {
status = fdt_create_empty_tree(fdt, new_fdt_size); if (status == 0) { /* *Anyfailurefromthefollowingfunctionis *non-critical:
*/
fdt_update_cell_size(fdt);
}
}
if (!efi_novamap) {
status = efi_alloc_virtmap(&priv.runtime_map, &desc_size,
&desc_ver); if (status != EFI_SUCCESS) {
efi_err("Unable to retrieve UEFI memory map.\n"); return status;
}
}
/* *Unauthenticateddevicetreedataisasecurityhazard,soignore *'dtb='unlessUEFISecureBootisdisabled.Weassumethatsecure *bootisenabledifwecan'tdetermineitsstate.
*/ if (!IS_ENABLED(CONFIG_EFI_ARMSTUB_DTB_LOADER) ||
efi_get_secureboot() != efi_secureboot_mode_disabled) { if (strstr(cmdline_ptr, "dtb="))
efi_err("Ignoring DTB from command line.\n");
} else {
status = efi_load_dtb(image, &fdt_addr, &fdt_size);
if (status != EFI_SUCCESS && status != EFI_NOT_READY) {
efi_err("Failed to load device tree!\n"); goto fail;
}
}
if (fdt_addr) {
efi_info("Using DTB from command line\n");
} else { /* Look for a device tree configuration table entry. */
fdt_addr = (uintptr_t)get_fdt(&fdt_size); if (fdt_addr)
efi_info("Using DTB from configuration table\n");
}
if (!fdt_addr)
efi_info("Generating empty DTB\n");
efi_info("Exiting boot services...\n");
status = efi_allocate_pages(MAX_FDT_SIZE, new_fdt_addr, ULONG_MAX); if (status != EFI_SUCCESS) {
efi_err("Unable to allocate memory for new device tree.\n"); goto fail;
}
status = update_fdt((void *)fdt_addr, fdt_size,
(void *)*new_fdt_addr, MAX_FDT_SIZE, cmdline_ptr);
if (status != EFI_SUCCESS) {
efi_err("Unable to construct new device tree.\n"); goto fail_free_new_fdt;
}
priv.new_fdt_addr = (void *)*new_fdt_addr;
status = efi_exit_boot_services(handle, &priv, exit_boot_func);
if (status == EFI_SUCCESS) {
efi_set_virtual_address_map_t *svam;
if (efi_novamap) return EFI_SUCCESS;
/* Install the new virtual address map */
svam = efi_system_table->runtime->set_virtual_address_map;
status = svam(priv.runtime_entry_count * desc_size, desc_size,
desc_ver, priv.runtime_map);
/* *Wearebeyondthepointofnoreturnhere,soifthecallto *SetVirtualAddressMap()failed,weneedtosignalthattothe *incomingkernelbutproceednormallyotherwise.
*/ if (status != EFI_SUCCESS) {
efi_memory_desc_t *p; int l;
/* *Setthevirtualaddressfieldofall *EFI_MEMORY_RUNTIMEentriestoU64_MAX.Thiswill *signaltheincomingkernelthatnovirtual *translationhasbeeninstalled.
*/ for (l = 0; l < priv.boot_memmap->map_size;
l += priv.boot_memmap->desc_size) {
p = (void *)priv.boot_memmap->map + l;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.