Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/loader/bootinfo.c
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
#if defined(LOADER_FDT_SUPPORT) | #if defined(LOADER_FDT_SUPPORT) | ||||
#include <fdt_platform.h> | #include <fdt_platform.h> | ||||
#endif | #endif | ||||
#ifdef LOADER_GELI_SUPPORT | #ifdef LOADER_GELI_SUPPORT | ||||
#include "geliboot.h" | #include "geliboot.h" | ||||
#endif | #endif | ||||
int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); | int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, | ||||
bool exit_bs); | |||||
extern EFI_SYSTEM_TABLE *ST; | extern EFI_SYSTEM_TABLE *ST; | ||||
static int | static int | ||||
bi_getboothowto(char *kargs) | bi_getboothowto(char *kargs) | ||||
{ | { | ||||
const char *sw, *tmp; | const char *sw, *tmp; | ||||
char *opts; | char *opts; | ||||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | for (curr = 0; curr < ndesc; | ||||
} | } | ||||
} | } | ||||
ret = RS->SetVirtualAddressMap(nset * mmsz, mmsz, mmver, vmap); | ret = RS->SetVirtualAddressMap(nset * mmsz, mmsz, mmver, vmap); | ||||
free(vmap); | free(vmap); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
static int | static int | ||||
bi_load_efi_data(struct preloaded_file *kfp) | bi_load_efi_data(struct preloaded_file *kfp, bool exit_bs) | ||||
{ | { | ||||
EFI_MEMORY_DESCRIPTOR *mm; | EFI_MEMORY_DESCRIPTOR *mm; | ||||
EFI_PHYSICAL_ADDRESS addr = 0; | EFI_PHYSICAL_ADDRESS addr = 0; | ||||
EFI_STATUS status; | EFI_STATUS status; | ||||
const char *efi_novmap; | const char *efi_novmap; | ||||
size_t efisz; | size_t efisz; | ||||
UINTN efi_mapkey; | UINTN efi_mapkey; | ||||
UINTN dsz, pages, retry, sz; | UINTN dsz, pages, retry, sz; | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | for (;;) { | ||||
* memory map on a 16-byte boundary (the bootinfo block is page | * memory map on a 16-byte boundary (the bootinfo block is page | ||||
* aligned). | * aligned). | ||||
*/ | */ | ||||
efihdr = (struct efi_map_header *)(uintptr_t)addr; | efihdr = (struct efi_map_header *)(uintptr_t)addr; | ||||
mm = (void *)((uint8_t *)efihdr + efisz); | mm = (void *)((uint8_t *)efihdr + efisz); | ||||
sz = (EFI_PAGE_SIZE * pages) - efisz; | sz = (EFI_PAGE_SIZE * pages) - efisz; | ||||
} | } | ||||
if (!exit_bs) | |||||
break; | |||||
status = BS->ExitBootServices(IH, efi_mapkey); | status = BS->ExitBootServices(IH, efi_mapkey); | ||||
if (!EFI_ERROR(status)) | if (!EFI_ERROR(status)) | ||||
break; | break; | ||||
} | } | ||||
if (retry == 0) { | if (retry == 0) { | ||||
BS->FreePages(addr, pages); | BS->FreePages(addr, pages); | ||||
printf("ExitBootServices error %lu\n", EFI_ERROR_CODE(status)); | printf("ExitBootServices error %lu\n", EFI_ERROR_CODE(status)); | ||||
Show All 22 Lines | |||||
* | * | ||||
* - The 'boothowto' argument is constructed. | * - The 'boothowto' argument is constructed. | ||||
* - The 'bootdev' argument is constructed. | * - The 'bootdev' argument is constructed. | ||||
* - The 'bootinfo' struct is constructed, and copied into the kernel space. | * - The 'bootinfo' struct is constructed, and copied into the kernel space. | ||||
* - The kernel environment is copied into kernel space. | * - The kernel environment is copied into kernel space. | ||||
* - Module metadata are formatted and placed in kernel space. | * - Module metadata are formatted and placed in kernel space. | ||||
*/ | */ | ||||
int | int | ||||
bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) | bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs) | ||||
{ | { | ||||
struct preloaded_file *xp, *kfp; | struct preloaded_file *xp, *kfp; | ||||
struct devdesc *rootdev; | struct devdesc *rootdev; | ||||
struct file_metadata *md; | struct file_metadata *md; | ||||
vm_offset_t addr; | vm_offset_t addr; | ||||
uint64_t kernend; | uint64_t kernend; | ||||
uint64_t envp; | uint64_t envp; | ||||
vm_offset_t size; | vm_offset_t size; | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | else | ||||
printf("WARNING! Trying to fire up the kernel, but no " | printf("WARNING! Trying to fire up the kernel, but no " | ||||
"device tree blob found!\n"); | "device tree blob found!\n"); | ||||
#endif | #endif | ||||
file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof(kernend), &kernend); | file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof(kernend), &kernend); | ||||
file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(ST), &ST); | file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof(ST), &ST); | ||||
#ifdef LOADER_GELI_SUPPORT | #ifdef LOADER_GELI_SUPPORT | ||||
geli_export_key_metadata(kfp); | geli_export_key_metadata(kfp); | ||||
#endif | #endif | ||||
bi_load_efi_data(kfp); | bi_load_efi_data(kfp, exit_bs); | ||||
/* Figure out the size and location of the metadata. */ | /* Figure out the size and location of the metadata. */ | ||||
*modulep = addr; | *modulep = addr; | ||||
size = bi_copymodules(0); | size = bi_copymodules(0); | ||||
kernend = roundup(addr + size, PAGE_SIZE); | kernend = roundup(addr + size, PAGE_SIZE); | ||||
*kernendp = kernend; | *kernendp = kernend; | ||||
/* patch MODINFOMD_KERNEND */ | /* patch MODINFOMD_KERNEND */ | ||||
Show All 24 Lines |