Changeset View
Changeset View
Standalone View
Standalone View
stand/kboot/arch/aarch64/load_addr.c
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (u64p == NULL) | ||||
goto errout; | goto errout; | ||||
mmap_pa = fdt64_to_cpu(*u64p); | mmap_pa = fdt64_to_cpu(*u64p); | ||||
free(buf); | free(buf); | ||||
printf("UEFI MMAP: Ver %d Ent Size %d Tot Size %d PA %#lx\n", | printf("UEFI MMAP: Ver %d Ent Size %d Tot Size %d PA %#lx\n", | ||||
ver, esz, sz, mmap_pa); | ver, esz, sz, mmap_pa); | ||||
/* | /* | ||||
* We have no ability to read the PA that this map is in, so | * We may have no ability to read the PA that this map is in, so pass | ||||
* pass the address to FreeBSD via a rather odd flag entry as | * the address to FreeBSD via a rather odd flag entry as the first map | ||||
* the first map so early boot can copy the memory map into | * so early boot can copy the memory map into this space and have the | ||||
* this space and have the rest of the code cope. | * rest of the code cope. | ||||
*/ | */ | ||||
efisz = (sizeof(*efihdr) + 0xf) & ~0xf; | efisz = (sizeof(*efihdr) + 0xf) & ~0xf; | ||||
buf = malloc(sz + efisz); | buf = malloc(sz + efisz); | ||||
if (buf == NULL) | if (buf == NULL) | ||||
return false; | return false; | ||||
efihdr = (struct efi_map_header *)buf; | efihdr = (struct efi_map_header *)buf; | ||||
map = (struct efi_md *)((uint8_t *)efihdr + efisz); | map = (struct efi_md *)((uint8_t *)efihdr + efisz); | ||||
bzero(map, sz); | bzero(map, sz); | ||||
efihdr->memory_size = sz; | efihdr->memory_size = sz; | ||||
efihdr->descriptor_size = esz; | efihdr->descriptor_size = esz; | ||||
efihdr->descriptor_version = ver; | efihdr->descriptor_version = ver; | ||||
efi_map_phys_src = mmap_pa; | |||||
/* | |||||
* Save EFI table. Either this will be an empty table filled in by the trampiline, | |||||
tsoome: trampoline ? | |||||
Done Inline Actionsindeed. imp: indeed. | |||||
* or we'll read it below. Either way, set these two variables so we share the best | |||||
* UEFI memory map with the kernel. | |||||
*/ | |||||
efi_map_hdr = efihdr; | efi_map_hdr = efihdr; | ||||
efi_map_size = sz + efisz; | efi_map_size = sz + efisz; | ||||
return true; | /* | ||||
* Try to read in the actual UEFI map. | |||||
*/ | |||||
fd2 = open("host:/dev/mem", O_RDONLY); | |||||
if (fd2 < 0) { | |||||
printf("Will read UEFI mem map in tramp: no /dev/mem, need CONFIG_DEVMEM=y\n"); | |||||
goto no_read; | |||||
} | |||||
if (lseek(fd2, mmap_pa, SEEK_SET) < 0) { | |||||
printf("Will read UEFI mem map in tramp: lseek failed\n"); | |||||
goto no_read; | |||||
} | |||||
len = read(fd2, map, sz); | |||||
if (len != sz) { | |||||
if (len < 0 && errno == EPERM) | |||||
printf("Will read UEFI mem map in tramp: kernel needs CONFIG_STRICT_DEVMEM=n\n"); | |||||
else | |||||
printf("Will read UEFI mem map in tramp: lean = %d errno = %d\n", len, errno); | |||||
goto no_read; | |||||
} | |||||
printf("Read UEFI mem map from physmem\n"); | |||||
efi_map_phys_src = 0; /* Mark MODINFOMD_EFI_MAP as valid */ | |||||
close(fd2); | |||||
return true; /* OK, we really have the memory map */ | |||||
no_read: | |||||
efi_map_phys_src = mmap_pa; | |||||
close(fd2); | |||||
return true; /* We can get it the trampoline */ | |||||
errout: | errout: | ||||
free(buf); | free(buf); | ||||
return false; | return false; | ||||
} | } | ||||
bool | bool | ||||
enumerate_memory_arch(void) | enumerate_memory_arch(void) | ||||
{ | { | ||||
Show All 35 Lines | #define KERN_ALIGN (2ul << 20) | ||||
printf("Falling back to crazy address %#lx\n", s); | printf("Falling back to crazy address %#lx\n", s); | ||||
return (s); | return (s); | ||||
} | } | ||||
void | void | ||||
bi_loadsmap(struct preloaded_file *kfp) | bi_loadsmap(struct preloaded_file *kfp) | ||||
{ | { | ||||
/* | |||||
* Make a note of a systbl. This is nearly mandatory on AARCH64. | |||||
*/ | |||||
if (efi_systbl_phys) | if (efi_systbl_phys) | ||||
file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(efi_systbl_phys), &efi_systbl_phys); | file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(efi_systbl_phys), &efi_systbl_phys); | ||||
/* | /* | ||||
* If we have efi_map_hdr, then it's a pointer to the PA where this | * If we have efi_map_hdr, then it's a pointer to the PA where this | ||||
* memory map lives. The trampoline code will copy it over. If we don't | * memory map lives. The trampoline code will copy it over. If we don't | ||||
* have it, we use whatever we found in /proc/iomap. | * have it, we use whatever we found in /proc/iomap. | ||||
*/ | */ | ||||
if (efi_map_hdr != NULL) { | if (efi_map_hdr != NULL) { | ||||
file_addmetadata(kfp, MODINFOMD_EFI_MAP, efi_map_size, efi_map_hdr); | file_addmetadata(kfp, MODINFOMD_EFI_MAP, efi_map_size, efi_map_hdr); | ||||
return; | return; | ||||
} | } | ||||
panic("Can't get UEFI memory map, nor a pointer to it, can't proceed.\n"); | panic("Can't get UEFI memory map, nor a pointer to it, can't proceed.\n"); | ||||
} | } |
trampoline ?