Compile in devtab and alarm device
authorRonald G. Minnich <rminnich@google.com>
Thu, 16 Jan 2014 23:24:41 +0000 (15:24 -0800)
committerRonald G. Minnich <rminnich@google.com>
Thu, 16 Jan 2014 23:24:41 +0000 (15:24 -0800)
but what is NUMSIZExx?

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/drivers/dev/tab.c [new file with mode: 0644]

diff --git a/kern/drivers/dev/tab.c b/kern/drivers/dev/tab.c
new file mode 100644 (file)
index 0000000..d494be8
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Stub.
+ */
+//#define DEBUG
+#include <vfs.h>
+#include <kfs.h>
+#include <slab.h>
+#include <kmalloc.h>
+#include <kref.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include <error.h>
+#include <cpio.h>
+#include <pmap.h>
+#include <smp.h>
+#include <umem.h>
+
+/* at some point this will be done via ldscript Hackes. */
+//extern struct dev* devtab[];
+// the sooner the better!
+
+extern struct dev alarmdevtab;
+extern struct dev regressdevtab;
+extern struct dev pipedevtab;
+extern struct dev procdevtab;
+extern struct dev miscdevtab;
+extern struct dev etherdevtab;
+extern struct dev rootdevtab;
+extern struct dev ipdevtab;
+extern struct dev mntdevtab;
+extern struct dev srvdevtab;
+extern struct dev vmdevtab;
+struct dev *devtab[] = {
+       &alarmdevtab,
+       &rootdevtab,
+       &miscdevtab,
+       &regressdevtab,
+       &pipedevtab,
+       &procdevtab,
+       &etherdevtab,
+       &ipdevtab,
+       &mntdevtab,
+       &srvdevtab,
+       &vmdevtab,
+       NULL,
+};
+
+void devtabreset()
+{
+       int i;
+       printk("devtabresets\n");
+
+       for (i = 0; devtab[i] != NULL; i++)
+               devtab[i]->reset(current);
+}
+
+void devtabinit()
+{
+       int i;
+
+       printk("devtabinit\n");
+       for (i = 0; devtab[i] != NULL; i++)
+               devtab[i]->init(current);
+}
+
+void devtabshutdown()
+{
+       int i;
+
+       /*
+        * Shutdown in reverse order.
+        */
+       for (i = 0; devtab[i] != NULL; i++) ;
+       for (i--; i >= 0; i--)
+               devtab[i]->shutdown(current);
+}
+
+struct dev *devtabget(int dc, int user)
+{
+       int i;
+
+       for (i = 0; devtab[i] != NULL; i++) {
+               if (devtab[i]->dc == dc)
+                       return devtab[i];
+       }
+
+       printk("devtabget FAILED %c\n", dc);
+       error(Enonexist);
+}
+
+long
+devtabread(struct chan *c, void *buf, long n, int64_t off)
+{
+       ERRSTACK(1);
+
+       int i;
+       struct dev *dev;
+       char *alloc, *e, *p;
+
+       alloc = kzmalloc(READSTR, KMALLOC_WAIT);
+       if (alloc == NULL)
+               error(Enomem);
+
+       p = alloc;
+       e = p + READSTR;
+       for (i = 0; devtab[i] != NULL; i++) {
+               dev = devtab[i];
+               printd("p %p e %p e-p %d\n", p, e, e - p);
+               printd("do %d %c %s\n", i, dev->dc, dev->name);
+               p += snprintf(p, e - p, "#%c %s\n", dev->dc, dev->name);
+       }
+
+       if (waserror()) {
+               kfree(alloc);
+               nexterror();
+       }
+       n = readstr(off, buf, n, alloc);
+
+       kfree(alloc);
+       poperror();
+
+       return n;
+}