]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
mini-os: tidied up code
authorKarim Raslan <karim.allah.ahmed@gmail.com>
Wed, 11 Jun 2014 10:30:14 +0000 (11:30 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 12 Jun 2014 10:01:18 +0000 (11:01 +0100)
Signed-off-by: Karim Allah Ahmed <karim.allah.ahmed@gmail.com>
[talex5@gmail.com: separated from big ARM commit]
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
[talex5@gmail.com: use __func__ in DEBUG macro]
[talex5@gmail.com: drop text about "xm create"]
Signed-off-by: Thomas Leonard <talex5@gmail.com>
README
arch/x86/time.c
console/console.c
events.c
gntmap.c
include/x86/arch_spinlock.h
sched.c
xenbus/xenbus.c

diff --git a/README b/README
index 710a303d7adbf010c8aa2d14c51b3e4af3d573c3..796031462afe0560c1488426ce7808b77a2862c4 100644 (file)
--- a/README
+++ b/README
@@ -25,8 +25,8 @@ This includes:
 
 - to build it with much better libc support, see the stubdom/ directory
 
-- to start it do the following in domain0 (assuming xend is running)
-  # xm create domain_config
+- to start it do the following in domain0
+  # xl create -c domain_config
 
 This starts the kernel and prints out a bunch of stuff and then once every
 second the system time.
index 89bc3826e81abe257dc0e349b10644d3c810779d..2c8d03378783f3e42592b250283be1d50bd1126c 100644 (file)
@@ -212,7 +212,7 @@ void block_domain(s_time_t until)
 
 
 /*
- * Just a dummy 
+ * Just a dummy
  */
 static void timer_handler(evtchn_port_t ev, struct pt_regs *regs, void *ign)
 {
index 380f53ca177382fbbc87d9eac69882c46b330a65..5538bd400a19df8fa86065ee764effb714ff85a1 100644 (file)
@@ -124,7 +124,7 @@ void print(int direct, const char *fmt, va_list args)
     static char   buf[1024];
     
     (void)vsnprintf(buf, sizeof(buf), fmt, args);
+
     if(direct)
     {
         (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
index 036b84b6919208dd966a05c6cc5a40f26c2845ea..2da9b01f0d6673104677a392393f01bfdceb7e58 100644 (file)
--- a/events.c
+++ b/events.c
@@ -138,7 +138,8 @@ evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void *data)
        op.virq = virq;
        op.vcpu = smp_processor_id();
 
-       if ( (rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op)) != 0 )
+       rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &op);
+       if (rc != 0)
        {
                printk("Failed to bind virtual IRQ %d with rc=%d\n", virq, rc);
                return -1;
index 22ed450c8c02079696dfa7b2fcf3e73d5b1b0fb9..f6ab3ad360a8c4f69203e83de4a5c4789be75b02 100644 (file)
--- a/gntmap.c
+++ b/gntmap.c
 #include <inttypes.h>
 #include <mini-os/gntmap.h>
 
+//#define GNTMAP_DEBUG
+#ifdef GNTMAP_DEBUG
+#define DEBUG(_f, _a...) \
+    printk("MINI_OS(gntmap.c:%d): %s" _f "\n", __LINE__, __func__, ## _a)
+#else
+#define DEBUG(_f, _a...)    ((void)0)
+#endif
+
+
 #define DEFAULT_MAX_GRANTS 128
 
 struct gntmap_entry {
@@ -61,10 +70,8 @@ gntmap_find_free_entry(struct gntmap *map)
             return &map->entries[i];
     }
 
-#ifdef GNTMAP_DEBUG
-    printk("gntmap_find_free_entry(map=%p): all %d entries full\n",
+    DEBUG("(map=%p): all %d entries full",
            map, map->nentries);
-#endif
     return NULL;
 }
 
@@ -83,9 +90,7 @@ gntmap_find_entry(struct gntmap *map, unsigned long addr)
 int
 gntmap_set_max_grants(struct gntmap *map, int count)
 {
-#ifdef GNTMAP_DEBUG
-    printk("gntmap_set_max_grants(map=%p, count=%d)\n", map, count);
-#endif
+    DEBUG("(map=%p, count=%d)", map, count);
 
     if (map->nentries != 0)
         return -EBUSY;
@@ -157,10 +162,8 @@ gntmap_munmap(struct gntmap *map, unsigned long start_address, int count)
     int i, rc;
     struct gntmap_entry *ent;
 
-#ifdef GNTMAP_DEBUG
-    printk("gntmap_munmap(map=%p, start_address=%lx, count=%d)\n",
+    DEBUG("(map=%p, start_address=%lx, count=%d)",
            map, start_address, count);
-#endif
 
     for (i = 0; i < count; i++) {
         ent = gntmap_find_entry(map, start_address + PAGE_SIZE * i);
@@ -189,14 +192,12 @@ gntmap_map_grant_refs(struct gntmap *map,
     struct gntmap_entry *ent;
     int i;
 
-#ifdef GNTMAP_DEBUG
-    printk("gntmap_map_grant_refs(map=%p, count=%" PRIu32 ", "
+    DEBUG("(map=%p, count=%" PRIu32 ", "
            "domids=%p [%" PRIu32 "...], domids_stride=%d, "
-           "refs=%p [%" PRIu32 "...], writable=%d)\n",
+           "refs=%p [%" PRIu32 "...], writable=%d)",
            map, count,
            domids, domids == NULL ? 0 : domids[0], domids_stride,
            refs, refs == NULL ? 0 : refs[0], writable);
-#endif
 
     (void) gntmap_set_max_grants(map, DEFAULT_MAX_GRANTS);
 
@@ -224,9 +225,7 @@ gntmap_map_grant_refs(struct gntmap *map,
 void
 gntmap_init(struct gntmap *map)
 {
-#ifdef GNTMAP_DEBUG
-    printk("gntmap_init(map=%p)\n", map);
-#endif
+    DEBUG("(map=%p)", map);
     map->nentries = 0;
     map->entries = NULL;
 }
@@ -237,9 +236,7 @@ gntmap_fini(struct gntmap *map)
     struct gntmap_entry *ent;
     int i;
 
-#ifdef GNTMAP_DEBUG
-    printk("gntmap_fini(map=%p)\n", map);
-#endif
+    DEBUG("(map=%p)", map);
 
     for (i = 0; i < map->nentries; i++) {
         ent = &map->entries[i];
index c08b6f136ef0202261e35080944bf77dc6c07b89..59f7b638863be0adfe86f1f6f10b041aca1d8dfa 100644 (file)
@@ -61,7 +61,7 @@
 
 static inline void _raw_spin_unlock(spinlock_t *lock)
 {
-       char oldval = 1;
+       char oldval = ARCH_SPIN_LOCK_UNLOCKED;
        __asm__ __volatile__(
                spin_unlock_string
        );
diff --git a/sched.c b/sched.c
index 5ac5c1ccd8ab295c0fa0fc085b3ba137ee443902..174945ef7592cafa5e812f4ecbfb30231bf14fe4 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -85,6 +85,7 @@ void schedule(void)
         printk("Must not call schedule() from a callback\n");
         BUG();
     }
+
     if (flags) {
         printk("Must not call schedule() with IRQs disabled\n");
         BUG();
@@ -188,6 +189,8 @@ struct _reent *__getreent(void)
        }
     }
 #endif
+#else
+#error Not implemented yet
 #endif
     return _reent;
 }
index c5d9b028ab6dd70f19b9b4891c6908a2e71abcf1..934f23b2acf7b3fa14eeda9dd543ce23498e32b9 100644 (file)
@@ -276,7 +276,7 @@ static void xenbus_evtchn_handler(evtchn_port_t port, struct pt_regs *regs,
 }
 
 static int nr_live_reqs;
-static spinlock_t req_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(req_lock);
 static DECLARE_WAIT_QUEUE_HEAD(req_wq);
 
 /* Release a xenbus identifier */