The read_file() function updated some multiboot specific data structures as it was loading a file. These changes make read_file() more generic, and create a load_file() wrapper for x86 that updates the multiboot data structures. read_file() no longer does special handling of the configuration file, as this was only needed to avoid adding it to the multiboot structures.
Signed-off-by: Roy Franz roy.franz@linaro.org --- xen/arch/x86/efi/boot.c | 58 +++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 24 deletions(-)
diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 89d7954..8904a4e 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -173,11 +173,11 @@ static bool_t __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, CHAR16 *what = NULL;
if ( !name ) - PrintErrMesgExit(L"No filename", EFI_OUT_OF_RESOURCES); + PrintErrMesgExit(L"No Filename", EFI_OUT_OF_RESOURCES); + ret = dir_handle->Open(dir_handle, &FileHandle, name, EFI_FILE_MODE_READ, 0); - if ( file == &cfg && ret == EFI_NOT_FOUND ) - return 0; + if ( EFI_ERROR(ret) ) what = L"Open"; else @@ -206,40 +206,50 @@ static bool_t __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, } else { - if ( file != &cfg ) - { - PrintStr(name); - PrintStr(L": "); - DisplayUint(file->addr, 2 * sizeof(file->addr)); - PrintStr(L"-"); - DisplayUint(file->addr + size, 2 * sizeof(file->addr)); - PrintStr(newline); - mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT; - mb_modules[mbi.mods_count].mod_end = size; - ++mbi.mods_count; - }
file->size = size; ret = FileHandle->Read(FileHandle, &file->size, file->ptr); if ( !EFI_ERROR(ret) && file->size != size ) ret = EFI_ABORTED; if ( EFI_ERROR(ret) ) - what = L"Read"; + { + what = what ?: L"Read"; + efi_bs->FreePages(file->addr, PFN_UP(file->size)); + file->addr = 0; + } }
if ( FileHandle ) FileHandle->Close(FileHandle);
+ if ( what ) { - PrintErr(what); - PrintErr(L" failed for "); - PrintErrMesgExit(name, ret); + PrintErrMesg(what, ret); + blexit(L"Unable to load file"); + } + else + { + PrintStr(name); + PrintStr(L": "); + DisplayUint(file->addr, 2 * sizeof(file->addr)); + PrintStr(L"-"); + DisplayUint(file->addr + file->size, 2 * sizeof(file->addr)); + PrintStr(newline); + return 1; }
- return 1; }
+/* Only call with non-config files. */ +void __init load_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, + struct file *file) +{ + read_file(dir_handle, name, file); + mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT; + mb_modules[mbi.mods_count].mod_end = file->size; + ++mbi.mods_count; +}
static void __init split_value(char *s) { @@ -640,7 +650,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( !name.s ) blexit(L"No Dom0 kernel image specified."); split_value(name.s); - read_file(dir_handle, s2w(&name), &kernel); + load_file(dir_handle, s2w(&name), &kernel); efi_bs->FreePool(name.w);
if ( !EFI_ERROR(efi_bs->LocateProtocol(&shim_lock_guid, NULL, @@ -652,7 +662,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( name.s ) { split_value(name.s); - read_file(dir_handle, s2w(&name), &ramdisk); + load_file(dir_handle, s2w(&name), &ramdisk); efi_bs->FreePool(name.w); }
@@ -663,7 +673,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { microcode_set_module(mbi.mods_count); split_value(name.s); - read_file(dir_handle, s2w(&name), &ucode); + load_file(dir_handle, s2w(&name), &ucode); efi_bs->FreePool(name.w); }
@@ -671,7 +681,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if ( name.s ) { split_value(name.s); - read_file(dir_handle, s2w(&name), &xsm); + load_file(dir_handle, s2w(&name), &xsm); efi_bs->FreePool(name.w); }