[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XenPPC] [PATCH] detect platform (and non-hypervisor mode)
Signed-off-by: Maria Butrico <butrico@xxxxxxxxxxxxxx> summary: detect platform (and non-hypervisor mode). Detects the platform from the value of the compatible property (from ofd tree). Do not close OF stdout and close stdin only on a mac. diff -r 7516fd47bc59 xen/arch/ppc/Makefile --- a/xen/arch/ppc/Makefile Thu May 25 15:42:29 2006 -0400 +++ b/xen/arch/ppc/Makefile Thu May 25 16:40:57 2006 -0400 @@ -29,6 +29,7 @@ obj-y += of-devtree.o obj-y += of-devtree.o obj-y += of-devwalk.o obj-y += ofd_fixup.o +obj-y += platform.o obj-y += physdev.o obj-y += rtas.o obj-y += setup.o diff -r 7516fd47bc59 xen/arch/ppc/boot_of.c --- a/xen/arch/ppc/boot_of.c Thu May 25 15:42:29 2006 -0400 +++ b/xen/arch/ppc/boot_of.c Thu May 25 16:40:57 2006 -0400 @@ -30,6 +30,7 @@ #include <asm/io.h> #include "uart.h" #include "exceptions.h" +#include <asm/platform.h> static ulong of_vec; static ulong of_msr; @@ -1245,6 +1246,24 @@ static int __init boot_of_rtas(void) return 1; } +static void __init boot_of_platform(void) +{ + char compatible_string[256]; + int compatible_length; + int of_root; + + of_root = of_finddevice("/"); + if (of_root == OF_FAILURE) of_panic("no root package\n"); + + compatible_length = of_getprop(of_root, "compatible", compatible_string, + sizeof(compatible_string)); + + if (compatible_length == OF_FAILURE) + return; + + init_platform(compatible_string, compatible_length); +} + multiboot_info_t __init *boot_of_init( ulong r3, ulong r4, ulong vec, ulong r6, ulong r7, ulong orig_msr) { @@ -1280,16 +1299,18 @@ multiboot_info_t __init *boot_of_init( boot_of_bootargs(&mbi); boot_of_module(r3, r4, &mbi); boot_of_cpus(); + + boot_of_platform(); + boot_of_rtas(); /* end of OF */ - of_printf("closing OF stdout...\n"); - of_call("close", 1, 0, &of_out); - - of_getprop(bof_chosen, "stdin", &of_in, sizeof (of_in)); - - if (of_in != of_out) { - of_call("close", 1, 0, &of_in); + if (is_platform_pmac()) { + of_getprop(bof_chosen, "stdin", &of_in, sizeof (of_in)); + + if (of_in != of_out) { + of_call("close", 1, 0, &of_in); + } } of_call("quiesce", 0, 0, NULL); diff -r 7516fd47bc59 xen/arch/ppc/platform.c --- /dev/null Thu Jan 1 00:00:00 1970 +0000 +++ b/xen/arch/ppc/platform.c Thu May 25 16:40:57 2006 -0400 @@ -0,0 +1,99 @@ +#include <xen/config.h> +#include <xen/init.h> +#include <xen/lib.h> +#include <xen/compile.h> +#include <public/of-devtree.h> +#include "oftree.h" +#include <asm/platform.h> + +#define DEBUG +#ifdef DEBUG +#define DBG(fmt...) printk(fmt) +#else +#define DBG(fmt...) +#endif + +static void pmac_init(void); +static void maple_init(void); + +enum platform_type { pmac = 1, maple = 2 }; +struct platform { + enum platform_type type; + char *compat_s; + void (*init_func)(void); +}; +static struct platform platforms[] = { + { .type = pmac, .compat_s = "Power Macintosh", .init_func = pmac_init }, + { .type = maple, .compat_s = "Momentum,Maple", .init_func = maple_init }, +}; + +struct global_platform { + enum platform_type platform_type; + int hv_supported; +}; +static struct global_platform my_platform; + + +static void pmac_init(void) +{ + my_platform.hv_supported = 0; +} + +static void maple_init(void) +{ + my_platform.hv_supported = 1; +} + +int init_platform(char *compatible_string, int compatible_length) +{ + char *cmpstr; + int used_length; + + memset(&my_platform, 0, sizeof(my_platform)); + + // loop over each null terminated piece of the compatible property + for (cmpstr = compatible_string, used_length = 0; + used_length < compatible_length; + cmpstr = &compatible_string[used_length]) { + int i; + for (i = 0; i < ARRAY_SIZE(platforms); i++) { + if (strstr(cmpstr, platforms[i].compat_s)) { + DBG("Found platform %s.\n", platforms[i].compat_s); + my_platform.platform_type = platforms[i].type; + (void) platforms[i].init_func(); + return 0; + } + } + used_length += strlen(cmpstr) + 1; + } + + return -1; +} + +#ifdef not_used +void init_platform_2(void) +{ + void *oft_p; + char compatible_string[256]; + int compatible_length; + + oft_p = (void *)oftree; + compatible_length = ofd_getprop(oft_p, OFD_ROOT, "compatible", + compatible_string, sizeof(compatible_string)); + if (compatible_length < 0) { + return; + } + + (void) init_platform(compatible_string, compatible_length); +} +#endif + +int hv_supported(void) +{ + return my_platform.hv_supported; +} + +int is_platform_pmac(void) +{ + return (my_platform.platform_type == pmac); +} diff -r 7516fd47bc59 xen/include/asm-ppc/platform.h --- /dev/null Thu Jan 1 00:00:00 1970 +0000 +++ b/xen/include/asm-ppc/platform.h Thu May 25 16:40:57 2006 -0400 @@ -0,0 +1,7 @@ +#ifndef _PLATFORM_H +#define _PLATFORM_H + +int hv_supported(void); +int is_platform_pmac(void); +int init_platform(char *cs, int cl); +#endif /* #ifndef _PLATFORM_H */ _______________________________________________ Xen-ppc-devel mailing list Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-ppc-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |