if ( name.s )
{
microcode_set_module(mbi.mods_count);
- split_value(name.s);
- read_file(dir_handle, s2w(&name), &ucode);
+ split_string(name.s);
+ read_file(dir_handle, s2w(&name), &ucode, NULL);
efi_bs->FreePool(name.w);
}
}
l3_bootmap[l3_table_offset(xen_phys_start + (8 << L2_PAGETABLE_SHIFT) - 1)] =
l3e_from_paddr((UINTN)l2_bootmap, __PAGE_HYPERVISOR);
}
+
+static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name,
+ char *options)
+{
+ union string local_name;
+ void *ptr;
+
+ /*
+ * Make a copy, as conversion is destructive, and caller still wants
+ * wide string available after this call returns.
+ */
+ if ( efi_bs->AllocatePool(EfiLoaderData, (wstrlen(name) + 1) * sizeof(*name),
+ &ptr) != EFI_SUCCESS )
+ blexit(L"Unable to allocate string buffer");
+
+ local_name.w = ptr;
+ wstrcpy(local_name.w, name);
+ w2s(&local_name);
+
+ /*
+ * If options are provided, put them in
+ * mb_modules[mbi.mods_count].string after the filename, with a space
+ * separating them. place_string() prepends strings and adds separating
+ * spaces, so the call order is reversed.
+ */
+ if ( options )
+ place_string(&mb_modules[mbi.mods_count].string, options);
+ place_string(&mb_modules[mbi.mods_count].string, local_name.s);
+ mb_modules[mbi.mods_count].mod_start = file->addr >> PAGE_SHIFT;
+ mb_modules[mbi.mods_count].mod_end = file->size;
+ ++mbi.mods_count;
+ efi_bs->FreePool(ptr);
+}
static void PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode);
static char *get_value(const struct file *cfg, const char *section,
const char *item);
-static void split_value(char *s);
+static char *split_string(char *s);
static CHAR16 *s2w(union string *str);
static char *w2s(const union string *str);
-static bool_t read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name,
- struct file *file);
+static bool_t read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name,
+ struct file *file, char *options);
+static size_t wstrlen(const CHAR16 * s);
static int set_color(u32 mask, int bpp, u8 *pos, u8 *sz);
static EFI_BOOT_SERVICES *__initdata efi_bs;
PrintStr(PrintString);
}
+static size_t __init wstrlen(const CHAR16 *s)
+{
+ const CHAR16 *sc;
+
+ for ( sc = s; *sc != L'\0'; ++sc )
+ /* nothing */;
+ return sc - s;
+}
+
static CHAR16 *__init wstrcpy(CHAR16 *d, const CHAR16 *s)
{
CHAR16 *r = d;
break;
}
}
+/*
+ * Truncate string at first space, and return pointer
+ * to remainder of string, if any/ NULL returned if
+ * no remainder after space.
+ */
+static char * __init split_string(char *s)
+{
+ while ( *s && !isspace(*s) )
+ ++s;
+ if ( *s )
+ {
+ *s = 0;
+ return s + 1;
+ }
+ return NULL;
+}
static bool_t __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name,
- struct file *file)
+ struct file *file, char *options)
{
EFI_FILE_HANDLE FileHandle = NULL;
UINT64 size;
}
else
{
+ file->size = size;
if ( file != &cfg )
{
PrintStr(name);
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;
+ efi_arch_handle_module(file, name, options);
}
- file->size = size;
ret = FileHandle->Read(FileHandle, &file->size, file->ptr);
if ( !EFI_ERROR(ret) && file->size != size )
ret = EFI_ABORTED;
break;
default:
if ( match && strncmp(ptr, item, ilen) == 0 && ptr[ilen] == '=' )
- return ptr + ilen + 1;
+ {
+ ptr += ilen + 1;
+ /* strip off any leading spaces */
+ while ( *ptr && isspace(*ptr) )
+ ptr++;
+ return ptr;
+ }
break;
}
ptr += strlen(ptr);
return NULL;
}
-static void __init split_value(char *s)
-{
- while ( *s && isspace(*s) )
- ++s;
- place_string(&mb_modules[mbi.mods_count].string, s);
- while ( *s && !isspace(*s) )
- ++s;
- *s = 0;
-}
-
static void __init setup_efi_pci(void)
{
EFI_STATUS status;
EFI_FILE_HANDLE dir_handle;
union string section = { NULL }, name;
bool_t base_video = 0;
+ char *option_str;
efi_ih = ImageHandle;
efi_bs = SystemTable->BootServices;
while ( (tail = point_tail(file_name)) != NULL )
{
wstrcpy(tail, L".cfg");
- if ( read_file(dir_handle, file_name, &cfg) )
+ if ( read_file(dir_handle, file_name, &cfg, NULL) )
break;
*tail = 0;
}
PrintStr(file_name);
PrintStr(L"'\r\n");
}
- else if ( !read_file(dir_handle, cfg_file_name, &cfg) )
+ else if ( !read_file(dir_handle, cfg_file_name, &cfg, NULL) )
blexit(L"Configuration file not found.");
pre_parse(&cfg);
break;
efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
cfg.addr = 0;
- if ( !read_file(dir_handle, s2w(&name), &cfg) )
+ if ( !read_file(dir_handle, s2w(&name), &cfg, NULL) )
{
PrintStr(L"Chained configuration file '");
PrintStr(name.w);
efi_arch_cfg_file_early(dir_handle, section.s);
- split_value(name.s);
- read_file(dir_handle, s2w(&name), &kernel);
+ option_str = split_string(name.s);
+ read_file(dir_handle, s2w(&name), &kernel, option_str);
efi_bs->FreePool(name.w);
if ( !EFI_ERROR(efi_bs->LocateProtocol(&shim_lock_guid, NULL,
name.s = get_value(&cfg, section.s, "ramdisk");
if ( name.s )
{
- split_value(name.s);
- read_file(dir_handle, s2w(&name), &ramdisk);
+ read_file(dir_handle, s2w(&name), &ramdisk, NULL);
efi_bs->FreePool(name.w);
}
name.s = get_value(&cfg, section.s, "xsm");
if ( name.s )
{
- split_value(name.s);
- read_file(dir_handle, s2w(&name), &xsm);
+ read_file(dir_handle, s2w(&name), &xsm, NULL);
efi_bs->FreePool(name.w);
}