WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ppc-devel

Re: [XenPPC] [PATCH] detect platform (and non-hypervisor mode)

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [XenPPC] [PATCH] detect platform (and non-hypervisor mode)
From: Maria Butrico <butrico@xxxxxxxxxxxxx>
Date: Tue, 23 May 2006 08:20:44 -0400
Delivery-date: Tue, 23 May 2006 05:21:18 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <E1FiGWo-00039U-1D@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
References: <E1FiGWo-00039U-1D@xxxxxxxxxxxxxxxxxxxxx>
Reply-to: butrico@xxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.2 (Windows/20060308)
I have two comments about this patch. I would rename 'compatible.c' 'platform.c' but most important, we might need this information in boot_of. Thus I proposed to go back on this one and initialize the platform with the value of /compatible from the OF tree, early in boot_of. This would allow us to make the decision on wheter to close OF stdout and stdin.

Also as the interface to this we have two choices (probably about 112, but two are the ones I am thinking of). The first is to add methods such as is_platform_pmac(), that is in the current patch. The second is to expose the possible values of platform type, add a method get_platform_type() and macros such as IS_PLATFORM_PMAC as you might imagine. Is there a preference on this one?

What I am pretty sure we need is a way to tell what platform we are on to choose little things such as closing OF stdin, does the machine have a broken U3, etc.
Maria Butrico wrote:
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).

diff -r a0fa2ce45bae xen/arch/ppc/Makefile
--- a/xen/arch/ppc/Makefile     Mon May 22 11:01:31 2006 -0400
+++ b/xen/arch/ppc/Makefile     Mon May 22 15:53:36 2006 -0400
@@ -8,6 +8,7 @@ obj-y += audit.o
 obj-y += audit.o
 obj-y += bitops.o
 obj-y += boot_of.o
+obj-y += compatible.o
 obj-y += dart.o
 obj-y += dart_u3.o
 obj-y += dart_u4.o
diff -r a0fa2ce45bae xen/arch/ppc/setup.c
--- a/xen/arch/ppc/setup.c      Mon May 22 11:01:31 2006 -0400
+++ b/xen/arch/ppc/setup.c      Mon May 22 15:53:36 2006 -0400
@@ -272,6 +272,9 @@ static void __init __start_xen(multiboot
         debugger_trap_immediate();
 #endif
+ extern void init_platform (void);
+    init_platform();
+
     start_of_day();
/* Create initial domain 0. */
diff -r a0fa2ce45bae xen/arch/ppc/compatible.c
--- /dev/null   Thu Jan  1 00:00:00 1970 +0000
+++ b/xen/arch/ppc/compatible.c Mon May 22 15:53:36 2006 -0400
@@ -0,0 +1,104 @@
+#include <xen/config.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/compile.h>
+#include <public/of-devtree.h>
+#include "oftree.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;
+}
+
+void init_platform(void)
+{
+    void *oft_p;
+    char compatible_string[256];
+    int compatible_length;
+    char *cmpstr;
+    int used_length;
+
+    memset(&my_platform, 0, sizeof(my_platform));
+
+    oft_p = (void *)oftree;
+    compatible_length = ofd_getprop(oft_p, OFD_ROOT, "compatible",
+                                    compatible_string, 
sizeof(compatible_string));
+    if (compatible_length < 0) {
+        return;
+    }
+
+    // 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();
+                DBG("%s: platform type=%d  hv=%d\n",
+                    __func__,
+                    my_platform.platform_type,
+                    my_platform.hv_supported);
+
+                return;
+            }
+        }
+        used_length += strlen(cmpstr) + 1;
+    }
+
+    DBG("Warning: %s is not aware of this machine type.  "
+              "Compatible is:\n", __func__);
+    for (used_length = 0; used_length < compatible_length; used_length++) {
+        if (compatible_string[used_length] == '\0' ) {
+            DBG(" NULL ");
+        } else {
+            DBG("%c", compatible_string[used_length]);
+        }
+    }
+    DBG("\n");
+}
+
+int hv_supported(void)
+{
+    return my_platform.hv_supported;
+}
+
+int is_platform_pmac(void)
+{
+    return (my_platform.platform_type == pmac);
+}

_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel



_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel

<Prev in Thread] Current Thread [Next in Thread>