const __be32 *cell;
bootmodule_kind kind;
paddr_t start, size;
- const char *cmdline;
int len;
/* sizeof("/chosen/") + DT_MAX_NAME + '/' + DT_MAX_NAME + '/0' => 92 */
char path[92];
- int ret;
+ int parent_node, ret;
+
+ parent_node = fdt_parent_offset(fdt, node);
+ ASSERT(parent_node >= 0);
/* Check that the node is under "/chosen" (first 7 chars of path) */
ret = fdt_get_path(fdt, node, path, sizeof (path));
kind = BOOTMOD_XSM;
}
- prop = fdt_get_property(fdt, node, "bootargs", &len);
- if ( prop )
- {
- if ( len > BOOTMOD_MAX_CMDLINE )
- panic("module %s command line too long\n", name);
- cmdline = prop->data;
- }
- else
- cmdline = NULL;
+ add_boot_module(kind, start, size);
- add_boot_module(kind, start, size, cmdline);
+ prop = fdt_get_property(fdt, node, "bootargs", &len);
+ if ( !prop )
+ return;
+ add_boot_cmdline(fdt_get_name(fdt, parent_node, &len), prop->data, kind);
}
static void __init process_chosen_node(const void *fdt, int node,
printk("Initrd %"PRIpaddr"-%"PRIpaddr"\n", start, end);
- add_boot_module(BOOTMOD_RAMDISK, start, end-start, NULL);
+ add_boot_module(BOOTMOD_RAMDISK, start, end-start);
}
static int __init early_scan_node(const void *fdt,
{
struct meminfo *mi = &bootinfo.mem;
struct bootmodules *mods = &bootinfo.modules;
+ struct bootcmdlines *cmds = &bootinfo.cmdlines;
int i, nr_rsvd;
for ( i = 0; i < mi->nr_banks; i++ )
mi->bank[i].start + mi->bank[i].size - 1);
printk("\n");
for ( i = 0 ; i < mods->nr_mods; i++ )
- printk("MODULE[%d]: %"PRIpaddr" - %"PRIpaddr" %-12s %s\n",
+ printk("MODULE[%d]: %"PRIpaddr" - %"PRIpaddr" %-12s\n",
i,
mods->module[i].start,
mods->module[i].start + mods->module[i].size,
- boot_module_kind_as_string(mods->module[i].kind),
- mods->module[i].cmdline);
+ boot_module_kind_as_string(mods->module[i].kind));
+
nr_rsvd = fdt_num_mem_rsv(device_tree_flattened);
for ( i = 0; i < nr_rsvd; i++ )
{
i, s, e);
}
printk("\n");
+ for ( i = 0 ; i < cmds->nr_mods; i++ )
+ printk("CMDLINE[%d]:%s %s\n", i,
+ cmds->cmdline[i].dt_name,
+ &cmds->cmdline[i].cmdline[0]);
+ printk("\n");
}
/**
if ( ret < 0 )
panic("No valid device tree\n");
- add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), NULL);
+ add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt));
device_tree_for_each_node((void *)fdt, early_scan_node, NULL);
early_print_info();
prop = fdt_get_property(fdt, node, "xen,xen-bootargs", NULL);
if ( prop == NULL )
{
- struct bootmodule *dom0_mod =
- boot_module_find_by_kind(BOOTMOD_KERNEL);
+ struct bootcmdline *dom0_cmdline =
+ boot_cmdline_find_by_kind(BOOTMOD_KERNEL);
if (fdt_get_property(fdt, node, "xen,dom0-bootargs", NULL) ||
- ( dom0_mod && dom0_mod->cmdline[0] ) )
+ ( dom0_cmdline && dom0_cmdline->cmdline[0] ) )
prop = fdt_get_property(fdt, node, "bootargs", NULL);
}
if ( prop == NULL )
int res = 0;
int had_dom0_bootargs = 0;
- const struct bootmodule *kernel = kinfo->kernel_bootmodule;
-
- if ( kernel && kernel->cmdline[0] )
- bootargs = &kernel->cmdline[0];
+ if ( kinfo->cmdline && kinfo->cmdline[0] )
+ bootargs = &kinfo->cmdline[0];
dt_for_each_property_node (node, prop)
{
if ( res )
return res;
- if ( mod && mod->cmdline[0] )
+ if ( kinfo->cmdline && kinfo->cmdline[0] )
{
- bootargs = &mod->cmdline[0];
+ bootargs = &kinfo->cmdline[0];
res = fdt_property(fdt, "bootargs", bootargs, strlen(bootargs) + 1);
if ( res )
return res;
int __init construct_dom0(struct domain *d)
{
+ const struct bootcmdline *kernel = boot_cmdline_find_by_kind(BOOTMOD_KERNEL);
struct kernel_info kinfo = {};
struct vcpu *saved_current;
int rc, i, cpu;
#endif
+ kinfo.cmdline = (kernel != NULL) ? &kernel->cmdline[0] : NULL;
allocate_memory(d, &kinfo);
find_gnttab_region(d, &kinfo);
/* boot blob load addresses */
const struct bootmodule *kernel_bootmodule, *initrd_bootmodule;
+ const char* cmdline;
paddr_t dtb_paddr;
paddr_t initrd_paddr;
}
struct bootmodule __init *add_boot_module(bootmodule_kind kind,
- paddr_t start, paddr_t size,
- const char *cmdline)
+ paddr_t start, paddr_t size)
{
struct bootmodules *mods = &bootinfo.modules;
struct bootmodule *mod;
mod->kind = kind;
mod->start = start;
mod->size = size;
- if ( cmdline )
- safe_strcpy(mod->cmdline, cmdline);
- else
- mod->cmdline[0] = 0;
return mod;
}
return NULL;
}
+void __init add_boot_cmdline(const char *name, const char *cmdline,
+ bootmodule_kind kind)
+{
+ struct bootcmdlines *cmds = &bootinfo.cmdlines;
+ struct bootcmdline *cmd;
+
+ if ( cmds->nr_mods == MAX_MODULES )
+ {
+ printk("Ignoring %s cmdline (too many)\n", name);
+ return;
+ }
+
+ cmd = &cmds->cmdline[cmds->nr_mods++];
+ cmd->kind = kind;
+
+ ASSERT(strlen(name) <= DT_MAX_NAME);
+ safe_strcpy(cmd->dt_name, name);
+
+ if ( strlen(cmdline) > BOOTMOD_MAX_CMDLINE )
+ panic("module %s command line too long\n", name);
+ safe_strcpy(cmd->cmdline, cmdline);
+}
+
+struct bootcmdline * __init boot_cmdline_find_by_kind(bootmodule_kind kind)
+{
+ struct bootcmdlines *cmds = &bootinfo.cmdlines;
+ struct bootcmdline *cmd;
+ int i;
+
+ for ( i = 0 ; i < cmds->nr_mods ; i++ )
+ {
+ cmd = &cmds->cmdline[i];
+ if ( cmd->kind == kind )
+ return cmd;
+ }
+ return NULL;
+}
+
const char * __init boot_module_kind_as_string(bootmodule_kind kind)
{
switch ( kind )
/* Register Xen's load address as a boot module. */
xen_bootmodule = add_boot_module(BOOTMOD_XEN,
(paddr_t)(uintptr_t)(_start + boot_phys_offset),
- (paddr_t)(uintptr_t)(_end - _start + 1), NULL);
+ (paddr_t)(uintptr_t)(_end - _start + 1));
BUG_ON(!xen_bootmodule);
xen_paddr = get_xen_paddr();
bootmodule_kind kind;
paddr_t start;
paddr_t size;
+};
+
+/* DT_MAX_NAME is the node name max length according the DT spec */
+#define DT_MAX_NAME 41
+struct bootcmdline {
+ bootmodule_kind kind;
+ char dt_name[DT_MAX_NAME];
char cmdline[BOOTMOD_MAX_CMDLINE];
};
struct bootmodule module[MAX_MODULES];
};
+struct bootcmdlines {
+ unsigned int nr_mods;
+ struct bootcmdline cmdline[MAX_MODULES];
+};
+
struct bootinfo {
struct meminfo mem;
struct bootmodules modules;
+ struct bootcmdlines cmdlines;
#ifdef CONFIG_ACPI
struct meminfo acpi;
#endif
const char *boot_fdt_cmdline(const void *fdt);
struct bootmodule *add_boot_module(bootmodule_kind kind,
- paddr_t start, paddr_t size,
- const char *cmdline);
+ paddr_t start, paddr_t size);
struct bootmodule *boot_module_find_by_kind(bootmodule_kind kind);
+void add_boot_cmdline(const char *name, const char *cmdline,
+ bootmodule_kind kind);
+struct bootcmdline *boot_cmdline_find_by_kind(bootmodule_kind kind);
const char *boot_module_kind_as_string(bootmodule_kind kind);
extern uint32_t hyp_traps_vector[];