From 82f81f4784479df17a80caff4a7156da0a2f7dea Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Tue, 15 May 2007 15:19:34 +0900 Subject: sh: Kill off machvec aliases. We now throw all of the machvecs in to .machvec.init and either select one on the command line, or copy out the first (and usually only) one to sh_mv. The rest are freed as usual. This gets rid of all of the silly sh_mv aliasing and makes the selection explicit rather than link-order dependent. Signed-off-by: Paul Mundt --- arch/sh/kernel/machvec.c | 45 +++++++++++++++++++++++++++++++-------------- arch/sh/kernel/setup.c | 7 +++++++ 2 files changed, 38 insertions(+), 14 deletions(-) (limited to 'arch/sh/kernel') diff --git a/arch/sh/kernel/machvec.c b/arch/sh/kernel/machvec.c index 1e78191154e..e8121de5faa 100644 --- a/arch/sh/kernel/machvec.c +++ b/arch/sh/kernel/machvec.c @@ -29,7 +29,7 @@ static struct sh_machine_vector * __init get_mv_byname(const char *name) struct sh_machine_vector *mv; for_each_mv(mv) - if (strcasecmp(name, get_system_type()) == 0) + if (strcasecmp(name, mv->mv_name) == 0) return mv; return NULL; @@ -55,26 +55,43 @@ static int __init early_parse_mv(char *from) mv_name[mv_len] = '\0'; from = mv_end; - if (strcmp(sh_mv.mv_name, mv_name) != 0) { - mvp = get_mv_byname(mv_name); - if (unlikely(!mvp)) { - printk("Available vectors:\n\n\t"); - for_each_mv(mvp) - printk("'%s', ", mvp->mv_name); - printk("\n\n"); - panic("Failed to select machvec '%s' -- halting.\n", - mv_name); - } else - sh_mv = *mvp; - } + mvp = get_mv_byname(mv_name); + if (unlikely(!mvp)) { + printk("Available vectors:\n\n\t"); + for_each_mv(mvp) + printk("'%s', ", mvp->mv_name); + printk("\n\n"); + panic("Failed to select machvec '%s' -- halting.\n", + mv_name); + } else + sh_mv = *mvp; - printk(KERN_NOTICE "Booting machvec: %s\n", sh_mv.mv_name); return 0; } early_param("sh_mv", early_parse_mv); void __init sh_mv_setup(void) { + /* + * Only overload the machvec if one hasn't been selected on + * the command line with sh_mv= + */ + if (strcmp(sh_mv.mv_name, "Unknown") != 0) { + unsigned long machvec_size; + + machvec_size = ((unsigned long)&__machvec_end - + (unsigned long)&__machvec_start); + + /* + * If the machvec hasn't been preselected, use the first + * vector (usually the only one) from .machvec.init. + */ + if (machvec_size >= sizeof(struct sh_machine_vector)) + sh_mv = *(struct sh_machine_vector *)&__machvec_start; + } + + printk(KERN_NOTICE "Booting machvec: %s\n", get_system_type()); + /* * Manually walk the vec, fill in anything that the board hasn't yet * by hand, wrapping to the generic implementation. diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 65c093145da..55ed653c7a6 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -42,6 +42,13 @@ extern void * __rd_start, * __rd_end; * The bigger value means no problem. */ struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, }; + +/* + * The machine vector. First entry in .machvec.init, or clobbered by + * sh_mv= on the command line, prior to .machvec.init teardown. + */ +struct sh_machine_vector sh_mv = { .mv_name = "Unknown", }; + #ifdef CONFIG_VT struct screen_info screen_info; #endif -- cgit v1.2.3