summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kernel/arch/amd64/driver/fsroot.c36
-rw-r--r--src/kernel/arch/amd64/driver/pata.c2
-rw-r--r--src/kernel/arch/amd64/driver/ps2.c2
-rw-r--r--src/kernel/arch/amd64/driver/rtl8139.c2
-rw-r--r--src/kernel/arch/amd64/driver/serial.c2
-rw-r--r--src/kernel/arch/amd64/driver/video.c2
-rw-r--r--src/kernel/arch/amd64/interrupts/isr.c1
-rw-r--r--src/user/bootstrap/main.c8
8 files changed, 35 insertions, 20 deletions
diff --git a/src/kernel/arch/amd64/driver/fsroot.c b/src/kernel/arch/amd64/driver/fsroot.c
index 0b0e2ef..d59edf3 100644
--- a/src/kernel/arch/amd64/driver/fsroot.c
+++ b/src/kernel/arch/amd64/driver/fsroot.c
@@ -8,26 +8,48 @@
#include <kernel/vfs/request.h>
#include <shared/mem.h>
-static int handle(VfsReq *req) {
+static long handle(VfsReq *req) {
// TODO document directory read format
// TODO don't hardcode
- const char dir[] =
+ static const char base[] = "kdev/";
+ static const char dir[] =
"com1\0"
"ps2/\0"
"ata/\0"
"eth/\0"
"video/";
+ const char *id;
+ int len;
+
if (!req->caller) return -1;
+ if (req->type != VFSOP_OPEN) {
+ /* otherwise, uninitialized, to cause compiler warnings if used */
+ /* this operates under the assumption that base and dir never change
+ * but even if they do, that will just result in a crash. */
+ id = (void *__force)req->id;
+ if (id == base) {
+ len = sizeof base;
+ } else if (id == dir) {
+ len = sizeof dir;
+ } else {
+ kprintf("%p %p %p\n", base, dir, id);
+ assert(false);
+ }
+ }
+
switch (req->type) {
case VFSOP_OPEN:
- return req->input.len == 1 ? 0 : -1;
+ if (reqpathcmp(req, "/")) return (long)base;
+ if (reqpathcmp(req, "/kdev/")) return (long)dir;
+ return -ENOENT;
case VFSOP_READ:
- return req_readcopy(req, dir, sizeof dir);
-
+ return req_readcopy(req, id, len);
// TODO getsize for the other kernel provided directories
- case VFSOP_GETSIZE: return sizeof dir;
- default: return -ENOSYS;
+ case VFSOP_GETSIZE:
+ return len;
+ default:
+ return -ENOSYS;
}
}
diff --git a/src/kernel/arch/amd64/driver/pata.c b/src/kernel/arch/amd64/driver/pata.c
index 99c3102..b0058f8 100644
--- a/src/kernel/arch/amd64/driver/pata.c
+++ b/src/kernel/arch/amd64/driver/pata.c
@@ -13,7 +13,7 @@ static const int root_id = 100;
static void accept(VfsReq *req);
void pata_init(void) {
ata_init();
- vfs_root_register("/ata", accept);
+ vfs_root_register("/kdev/ata", accept);
}
static void accept(VfsReq *req) {
diff --git a/src/kernel/arch/amd64/driver/ps2.c b/src/kernel/arch/amd64/driver/ps2.c
index 06825d6..e314477 100644
--- a/src/kernel/arch/amd64/driver/ps2.c
+++ b/src/kernel/arch/amd64/driver/ps2.c
@@ -58,7 +58,7 @@ void ps2_init(void) {
irq_fn[IRQ_PS2KB] = ps2_irq;
irq_fn[IRQ_PS2MOUSE] = ps2_irq;
- vfs_root_register("/ps2", accept);
+ vfs_root_register("/kdev/ps2", accept);
}
static void ps2_irq(void) {
diff --git a/src/kernel/arch/amd64/driver/rtl8139.c b/src/kernel/arch/amd64/driver/rtl8139.c
index 09b0ca5..737053e 100644
--- a/src/kernel/arch/amd64/driver/rtl8139.c
+++ b/src/kernel/arch/amd64/driver/rtl8139.c
@@ -83,7 +83,7 @@ void rtl8139_init(uint32_t bdf) {
uint64_t mac = (((uint64_t)port_in32(iobase + MAC + 4) & 0xFFFF) << 32) + port_in32(iobase + MAC);
kprintf("rtl8139 mac %012x\n", mac);
- vfs_root_register("/eth", accept);
+ vfs_root_register("/kdev/eth", accept);
}
static void rtl8139_irq(void) {
diff --git a/src/kernel/arch/amd64/driver/serial.c b/src/kernel/arch/amd64/driver/serial.c
index 5b42d8d..36b7cfa 100644
--- a/src/kernel/arch/amd64/driver/serial.c
+++ b/src/kernel/arch/amd64/driver/serial.c
@@ -15,7 +15,7 @@ static const int COM1 = 0x3f8;
static void accept(VfsReq *req);
static void serial_irq(void);
static VfsReq *hung_reads = NULL;
-void serial_init(void) { vfs_root_register("/com1", accept); }
+void serial_init(void) { vfs_root_register("/kdev/com1", accept); }
static void serial_selftest(void) {
diff --git a/src/kernel/arch/amd64/driver/video.c b/src/kernel/arch/amd64/driver/video.c
index cb70931..5a7fc8f 100644
--- a/src/kernel/arch/amd64/driver/video.c
+++ b/src/kernel/arch/amd64/driver/video.c
@@ -65,5 +65,5 @@ void video_init(GfxInfo fb_) {
fb = fb_;
snprintf(namebuf, sizeof namebuf, "%ux%ux%u", fb.width, fb.height, fb.bpp);
namelen = strlen(namebuf);
- vfs_root_register("/video", accept);
+ vfs_root_register("/kdev/video", accept);
}
diff --git a/src/kernel/arch/amd64/interrupts/isr.c b/src/kernel/arch/amd64/interrupts/isr.c
index ff00f2f..4ea80c6 100644
--- a/src/kernel/arch/amd64/interrupts/isr.c
+++ b/src/kernel/arch/amd64/interrupts/isr.c
@@ -40,6 +40,7 @@ void isr_stage3(uint8_t interrupt, uint64_t *stackframe) {
log_interrupt(interrupt, stackframe);
cpu_halt();
} else { /* in user */
+ log_interrupt(interrupt, stackframe);
proc_kill(proc_cur, interrupt);
proc_switch_any();
}
diff --git a/src/user/bootstrap/main.c b/src/user/bootstrap/main.c
index 4e900f5..348486c 100644
--- a/src/user/bootstrap/main.c
+++ b/src/user/bootstrap/main.c
@@ -17,16 +17,8 @@ int main(void) {
_sys_memflag(_psdata_loc, 1, MEMFLAG_PRESENT);
setprogname("bootstrap");
- /* move everything provided by the kernel to /kdev */
- MOUNT_AT("/kdev/") { fs_passthru(NULL); }
- MOUNT_AT("/") {
- const char *l[] = {"/kdev/", NULL};
- fs_whitelist(l);
- }
-
_sys_mount(HANDLE_PROCFS, "/proc/", strlen("/proc/"));
MOUNT_AT("/") { fs_dirinject("/proc/"); }
-
MOUNT_AT("/init/") { tar_driver(&_initrd); }
const char *initpath = "bin/amd64/init";