@@ -514,53 +514,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
if ( EFI_ERROR(status) )
gop = NULL;
- /* Read and parse the config file. */
- if ( !cfg_file_name )
- {
- CHAR16 *tail;
+ read_config_file(&dir_handle, &cfg, cfg_file_name,
+ §ion, file_name);
- while ( (tail = point_tail(file_name)) != NULL )
- {
- wstrcpy(tail, L".cfg");
- if ( read_file(dir_handle, file_name, &cfg) )
- break;
- *tail = 0;
- }
- if ( !tail )
- blexit(L"No configuration file found.");
- PrintStr(L"Using configuration file '");
- PrintStr(file_name);
- PrintStr(L"'\r\n");
- }
- else if ( !read_file(dir_handle, cfg_file_name, &cfg) )
- blexit(L"Configuration file not found.");
- pre_parse(&cfg);
-
- if ( section.w )
- w2s(§ion);
- else
- section.s = get_value(&cfg, "global", "default");
-
- for ( ; ; )
- {
- name.s = get_value(&cfg, section.s, "kernel");
- if ( name.s )
- break;
- name.s = get_value(&cfg, "global", "chain");
- if ( !name.s )
- break;
- efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
- cfg.addr = 0;
- if ( !read_file(dir_handle, s2w(&name), &cfg) )
- {
- PrintStr(L"Chained configuration file '");
- PrintStr(name.w);
- efi_bs->FreePool(name.w);
- blexit(L"'not found.");
- }
- pre_parse(&cfg);
- efi_bs->FreePool(name.w);
- }
+ name.s = get_value(&cfg, section.s, "kernel");
if ( !name.s )
blexit(L"No Dom0 kernel image specified.");
place_string(&mb_modules[mbi.mods_count].string, name.s);
@@ -200,6 +200,69 @@ char * __init truncate_string(char *s)
return(NULL);
}
+
+
+void __init read_config_file(EFI_FILE_HANDLE *cfg_dir_handle,
+ struct file *cfg, CHAR16 *cfg_file_name,
+ union string *section,
+ CHAR16 *xen_file_name)
+{
+
+ /* Read and parse the config file. */
+ if ( !cfg_file_name )
+ {
+ CHAR16 *tail;
+
+ while ( (tail = point_tail(xen_file_name)) != NULL )
+ {
+ wstrcpy(tail, L".cfg");
+ if ( read_file(*cfg_dir_handle, xen_file_name, cfg) )
+ break;
+ *tail = 0;
+ }
+ if ( !tail )
+ blexit(L"No configuration file found.");
+ PrintStr(L"Using configuration file '");
+ PrintStr(xen_file_name);
+ PrintStr(L"'\r\n");
+ }
+ else if ( !read_file(*cfg_dir_handle, cfg_file_name, cfg) )
+ blexit(L"Configuration file not found.");
+ pre_parse(cfg);
+
+ if ( section->w )
+ w2s(section);
+ else
+ section->s = get_value(cfg, "global", "default");
+
+
+ for ( ; ; )
+ {
+ union string dom0_kernel_name;
+ // RFRANZ_TODO - would like to get rid of this kernel lookup,
+ // but can't as it allows both kernel _and_ chain to be specified
+ // with kernel overriding chain.
+ // !! different sections....
+ dom0_kernel_name.s = get_value(cfg, section->s, "kernel");
+ if ( dom0_kernel_name.s )
+ break;
+ dom0_kernel_name.s = get_value(cfg, "global", "chain");
+ if ( !dom0_kernel_name.s )
+ break;
+ efi_bs->FreePages(cfg->addr, PFN_UP(cfg->size));
+ cfg->addr = 0;
+ if ( !read_file(*cfg_dir_handle, s2w(&dom0_kernel_name), cfg) )
+ {
+ PrintStr(L"Chained configuration file '");
+ PrintStr(dom0_kernel_name.w);
+ efi_bs->FreePool(dom0_kernel_name.w);
+ blexit(L"'not found.");
+ }
+ pre_parse(cfg);
+ efi_bs->FreePool(dom0_kernel_name.w);
+ }
+}
+
EFI_FILE_HANDLE __init get_parent_handle(EFI_LOADED_IMAGE *loaded_image,
CHAR16 **leaf)
{
@@ -57,4 +57,8 @@ void __init noreturn blexit(const CHAR16 *str);
bool_t __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name,
struct file *file);
char * __init truncate_string(char *s);
+void __init read_config_file(EFI_FILE_HANDLE *cfg_dir_handle,
+ struct file *cfg, CHAR16 *cfg_file_name,
+ union string *section,
+ CHAR16 *xen_file_name);
#endif
Move open-coded reading of the XEN EFI configuration file into a shared fuction read_config_file(). The open-coded version returned the dom0 kernel name in a global variable. This has been replaced by an explicit lookup of the dom0 kernel name after the initial processing of the config file has completed. Signed-off-by: Roy Franz <roy.franz@linaro.org> --- xen/arch/x86/efi/boot.c | 49 +++------------------------------ xen/arch/x86/efi/efi-shared.c | 63 +++++++++++++++++++++++++++++++++++++++++++ xen/include/efi/efi-shared.h | 4 +++ 3 files changed, 70 insertions(+), 46 deletions(-)