Skip to contentSkip to conversation

vtpm Mini-Os domain: mini-os defines

PATCH In review Matthew Fioravante 3 participants 3 messages Aug 25, 2010 – Aug 30, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 3/7 vtpm Mini-Os domain: mini-os defines

This patch adds some #defines to mini-os
NO_BLKFRONT
NO_FSFRONT
NO_NETFRONT
NO_FBFRONT
NO_PCIFRONT

These disable their respective drivers if defined. The vtpm domain does not need a framebuffer, network, fsfront, or pci so I added these to disable unneeded drivers.

extras/mini-os/blkfront.c +2 -0
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/blkfront.c
@@ -1,3 +1,4 @@
+#ifndef NO_BLKFRONT
 /* Minimal block driver for Mini-OS. 
  * Copyright (c) 2007-2008 Samuel Thibault.
  * Based on netfront.c.
@@ -552,3 +553,4 @@
     return dev->fd;
 }
 #endif
+#endif
extras/mini-os/fbfront.c +2 -1
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/fbfront.c
@@ -1,3 +1,4 @@
+#ifndef NO_FBFRONT
 /*
  * Frame Buffer + Keyboard driver for Mini-OS. 
  * Samuel Thibault <[email protected]>, 2008
@@ -694,4 +695,4 @@
     return dev->fd;
 }
 #endif
-
+#endif
extras/mini-os/fs-front.c +2 -0
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/fs-front.c
@@ -1,3 +1,4 @@
+#ifndef NO_FSFRONT
 /******************************************************************************
  * fs-front.c
  * 
@@ -1295,3 +1296,4 @@
 }
 
 /* TODO: shutdown */
+#endif
extras/mini-os/kernel.c +40 -0
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/kernel.c
@@ -37,17 +37,27 @@
 #include <mini-os/sched.h>
 #include <mini-os/xenbus.h>
 #include <mini-os/gnttab.h>
+#ifndef NO_NETFRONT
 #include <mini-os/netfront.h>
+#endif
+#ifndef NO_BLKFRONT
 #include <mini-os/blkfront.h>
+#endif
+#ifndef NO_FBFRONT
 #include <mini-os/fbfront.h>
+#endif
+#ifndef NO_PCIFRONT
 #include <mini-os/pcifront.h>
+#endif
 #include <mini-os/fs.h>
 #include <mini-os/xmalloc.h>
 #include <fcntl.h>
 #include <xen/features.h>
 #include <xen/version.h>
 
+#ifndef NO_NETFRONT
 static struct netfront_dev *net_dev;
+#endif
 
 uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32];
 
@@ -87,11 +97,14 @@
     }
 }
 
+#ifndef NO_NETFRONT
 static void netfront_thread(void *p)
 {
     net_dev = init_netfront(NULL, NULL, NULL, NULL);
 }
+#endif
 
+#ifndef NO_BLKFRONT
 static struct blkfront_dev *blk_dev;
 static struct blkfront_info blk_info;
 static uint64_t blk_size_read;
@@ -256,7 +269,9 @@
 #endif
     }
 }
+#endif
 
+#ifndef NO_FBFRONT
 #define WIDTH 800
 #define HEIGHT 600
 #define DEPTH 32
@@ -432,7 +447,9 @@
             schedule();
     }
 }
+#endif
 
+#ifndef NO_PCIFRONT
 static struct pcifront_dev *pci_dev;
 
 static void print_pcidev(unsigned int domain, unsigned int bus, unsigned int slot, unsigned int fun)
@@ -455,11 +472,14 @@
     printk("PCI devices:\n");
     pcifront_scan(pci_dev, print_pcidev);
 }
+#endif
 
+#ifndef NO_FSFRONT
 static void fs_thread(void *p)
 {
     init_fs_frontend();
 }
+#endif
 
 /* This should be overridden by the application we are linked against. */
 __attribute__((weak)) int app_main(start_info_t *si)
@@ -467,12 +487,22 @@
     printk("Dummy main: start_info=%p\n", si);
     create_thread("xenbus_tester", xenbus_tester, si);
     create_thread("periodic_thread", periodic_thread, si);
+#ifndef NO_NETFRONT
     create_thread("netfront", netfront_thread, si);
+#endif
+#ifndef NO_BLKFRONT
     create_thread("blkfront", blkfront_thread, si);
+#endif
+#ifndef NO_FBFRONT
     create_thread("fbfront", fbfront_thread, si);
     create_thread("kbdfront", kbdfront_thread, si);
+#endif
+#ifndef NO_PCIFRONT
     create_thread("pcifront", pcifront_thread, si);
+#endif
+#ifndef NO_FSFRONT
     create_thread("fs-frontend", fs_thread, si);
+#endif
     return 0;
 }
 
@@ -540,22 +570,32 @@
 
 void stop_kernel(void)
 {
+#ifndef NO_NETFRONT
     if (net_dev)
         shutdown_netfront(net_dev);
+#endif
 
+#ifndef NO_BLKFRONT
     if (blk_dev)
         shutdown_blkfront(blk_dev);
+#endif
 
+#ifndef NO_FBFRONT
     if (fb_dev)
         shutdown_fbfront(fb_dev);
 
     if (kbd_dev)
         shutdown_kbdfront(kbd_dev);
+#endif
 
+#ifndef NO_PCIFRONT
     if (pci_dev)
         shutdown_pcifront(pci_dev);
+#endif
 
+#ifndef NO_FSFRONT
     /* TODO: fs import */
+#endif
 
     local_irq_disable();
 
extras/mini-os/lib/sys.c +74 -0

315 lines not on this page · raw message

extras/mini-os/main.c +2 -0
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/main.c
@@ -66,8 +66,10 @@
 #if defined(HAVE_LWIP) && !defined(CONFIG_QEMU)
     start_networking();
 #endif
+#ifndef NO_FSFRONT
     init_fs_frontend();
 #endif
+#endif
     create_thread("pcifront", pcifront_watches, NULL);
 
 #ifdef CONFIG_QEMU
extras/mini-os/netfront.c +2 -0
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/netfront.c
@@ -1,3 +1,4 @@
+#ifndef NO_NETFRONT
 /* Minimal network driver for Mini-OS. 
  * Copyright (c) 2006-2007 Jacob Gorm Hansen, University of Copenhagen.
  * Based on netfront.c from Xen Linux.
@@ -672,3 +673,4 @@
     return dev->rlen;
 }
 #endif
+#endif
extras/mini-os/pcifront.c +2 -0
diff -r c84db039be86 -r 6615dd4045c7 extras/mini-os/pcifront.c
@@ -1,3 +1,4 @@
+#ifndef NO_PCIFRONT
 /* Minimal PCI driver for Mini-OS. 
  * Copyright (c) 2007-2008 Samuel Thibault.
  * Based on blkfront.c.
@@ -611,3 +612,4 @@
     
     return op.err;
 }
+#endif
extras/mini-os/lib/sys.c +4 -1
diff -r 22a23fed2920 -r bb97efd3e952 extras/mini-os/lib/sys.c
@@ -197,7 +197,10 @@
 
 int open(const char *pathname, int flags, ...)
 {
-    int fs_fd, fd;
+#ifndef NO_FSFRONT
+    int fs_fd;
+#endif
+    int fd;
     /* Ugly, but fine.  */
     if (!strncmp(pathname,LOG_PATH,strlen(LOG_PATH))) {
 	fd = alloc_fd(FTYPE_CONSOLE);
extras/mini-os/main.c +6 -0
diff -r 22a23fed2920 -r bb97efd3e952 extras/mini-os/main.c
@@ -8,8 +8,12 @@
 #include <os.h>
 #include <sched.h>
 #include <console.h>
+#ifndef NO_NETFRONT
 #include <netfront.h>
+#endif
+#ifndef NO_PCIFRONT
 #include <pcifront.h>
+#endif
 #include <time.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -70,7 +74,9 @@
     init_fs_frontend();
 #endif
 #endif
+#ifndef NO_PCIFRONT
     create_thread("pcifront", pcifront_watches, NULL);
+#endif
 
 #ifdef CONFIG_QEMU
     /* Fetch argc, argv from XenStore */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

The principle is probably useful indeed.

Quoted 2 lines · Matthew Fioravante, le Wed 25 Aug 2010 11:15:04 -0400, a écrit :

This patch adds some #defines to mini-os
NO_BLKFRONT

I tend to frown upon "negative" flags, as they're less readable. I know that using "positive" will require adding them to all other stubdom projects, but it's probably still better that way: we'll realize for instance that pv-grub doesn't actually need pcifront :)

samuel

#2 lore raw
Quoted 11 lines · Samuel Thibault

The principle is probably useful indeed.

Matthew Fioravante, le Wed 25 Aug 2010 11:15:04 -0400, a ??crit :

Quoted 2 lines

This patch adds some #defines to mini-os
NO_BLKFRONT

I tend to frown upon "negative" flags, as they're less readable. I know that using "positive" will require adding them to all other stubdom projects, but it's probably still better that way: we'll realize for instance that pv-grub doesn't actually need pcifront :)

I agree, also all those ifdef's make the code difficult to read. Wouldn't it be possible to enable/disable the compilation of those files altogether and provide stubs for the export functions instead?