]> xenbits.xensource.com Git - xenclient/ioemu.git/commitdiff
- Fix dom0_driver
authorJean Guyader <jean.guyader@eu.citrix.com>
Mon, 20 Oct 2008 10:53:10 +0000 (11:53 +0100)
committerJean Guyader <jean.guyader@eu.citrix.com>
Mon, 20 Oct 2008 10:53:10 +0000 (11:53 +0100)
dom0_driver.c

index d4c0acecbe7076d7ca0a84cf6daf1e05877ce476..e4897e9f8bbb72777495e469e36966117a37f225 100644 (file)
@@ -51,8 +51,7 @@
 # define DEBUG(_format_, args...) (void)0
 #endif
 
-#define INTEL_FB_PAGES  ((16 * 1024 * 1024) / (4 * 1024))
-#define INTEL_FB_BASE   0xd8000
+#define NB_SLOTS        10
 
 static void             dom0_read(void *opaque);
 
@@ -170,8 +169,7 @@ static void dom0_get_positions(int *positions)
     unsigned long len;
     int pos = 0;
     
-    for (int i = 0; i < DOM0_OUT; i++)
-        positions[i] = 0;
+    memset(positions, 0, NB_SLOTS * 4);
 
     /* Get all the positions */
     domids = xenstore_get_domids(&num);
@@ -182,19 +180,18 @@ static void dom0_get_positions(int *positions)
                 continue;
             pos = strtol(tmp, NULL, 10);
             free(tmp);
-            assert(pos >= 0 && pos <= 5);
 
             positions[pos] = domids[i];
         }
     free(domids);
-    for (pos = 0; pos < DOM0_OUT; pos++)
+    for (pos = 0; pos < NB_SLOTS; pos++)
         DEBUG("pos %d -> %d\n", pos, positions[pos]);
 }
 
 static int dom0_get_next_domid(int dir, int id)
 {
     int pos = 0, next_pos = 0;
-    int positions[6];
+    int positions[NB_SLOTS];
 
     dom0_get_positions(positions);
     /* Find current domain pos */
@@ -313,7 +310,7 @@ static int dom0_dom_alive(int id)
     return (i < len);
 }
 
-static void dom0_probe_xenstore(void *opaque)
+static void dom0_probe_xenstore_location(void *opaque)
 {
     char        *tmp = NULL;
     char        *dir = NULL;
@@ -375,14 +372,30 @@ out:
     qemu_mod_timer(driver.xs_timer, qemu_get_clock(rt_clock) + XS_REFRESH_INTERVAL);
 }
 
-static void dom0_driver_event_init(const char *position)
+static void dom0_driver_location_init(const char *arg)
 {
-    char                dev_name[strlen(EVENT_PATH) + 3];
-    int                 fd = -1;
     int                 pos = 0, i = 0;
-    int                 positions[6];
+    int                 positions[NB_SLOTS];
     char                str[10];
 
+
+
+    /* Register the xenstore probing */
+    driver.xs_timer = qemu_new_timer(rt_clock, dom0_probe_xenstore, NULL);
+    qemu_mod_timer(driver.xs_timer, qemu_get_clock(rt_clock) + XS_REFRESH_INTERVAL);
+}
+
+static void dom0_driver_slot_init(int slot)
+{
+    
+}
+
+static void dom0_driver_event_init(const char *str_arg)
+{
+    char                dev_name[strlen(EVENT_PATH) + 3];
+    int                 fd = -1;
+    int                 arg = 0;
+
     do
     {
         snprintf(dev_name, sizeof (dev_name), "%s%d", EVENT_PATH, i++);
@@ -405,18 +418,23 @@ static void dom0_driver_event_init(const char *position)
 
     if (driver.event_nb == 0)
         return;
-    
+
+    pos = strtol(str_arg, NULL, 10);
     /* Register position */
-    DEBUG("Register the position inside xenstore\n");
-    for (pos = 0; pos < DOM0_OUT; pos++)
-        if (strcmp(str2pos[pos], position) == 0)
-            break;
-    DEBUG("Get the position %s\n", str2pos[pos]);
-    if (pos == DOM0_OUT)
+    if (errno == EINVAL) // position mode
     {
-        DEBUG("position must be left, right, center, top or bottom\n");
-        exit(1);
+        DEBUG("Register the position inside xenstore\n");
+        for (pos = 0; pos < DOM0_OUT; pos++)
+            if (strcmp(str2pos[pos], str_arg) == 0)
+                break;
+        DEBUG("Get the position %s\n", str2pos[pos]);
+        if (pos == DOM0_OUT)
+        {
+            DEBUG("position must be left, right, center, top or bottom\n");
+            exit(1);
+        }
     }
+    
     dom0_get_positions(positions);
     if (positions[pos])
     {
@@ -430,9 +448,11 @@ static void dom0_driver_event_init(const char *position)
         xenstore_dom_write(domid, "dom0_input", str);
     }
 
-    /* Register the xenstore probing */
-    driver.xs_timer = qemu_new_timer(rt_clock, dom0_probe_xenstore, NULL);
-    qemu_mod_timer(driver.xs_timer, qemu_get_clock(rt_clock) + XS_REFRESH_INTERVAL);
+    arg = strtol(str_arg, NULL, 10);
+    if (errno == EINVAL)
+        dom0_driver_location_init(str_arg);
+    else
+        dom0_driver_slot_init(arg);
 }
 
 static void dom0_driver_cleanup(void)