summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kernel/arch/amd64/32/gdt.c2
-rw-r--r--src/kernel/arch/amd64/32/gdt.h18
-rw-r--r--src/kernel/arch/amd64/boot.c1
-rw-r--r--src/kernel/arch/amd64/boot.h19
-rw-r--r--src/kernel/arch/amd64/driver/pata.c1
-rw-r--r--src/kernel/arch/amd64/driver/ps2.c1
-rw-r--r--src/kernel/arch/amd64/driver/rtl8139.c1
-rw-r--r--src/kernel/arch/amd64/driver/serial.c2
-rw-r--r--src/kernel/arch/amd64/driver/util.c8
-rw-r--r--src/kernel/arch/amd64/driver/util.h2
-rw-r--r--src/kernel/arch/amd64/driver/video.c1
-rw-r--r--src/kernel/arch/amd64/interrupts/idt.c3
-rw-r--r--src/kernel/arch/amd64/interrupts/idt.h3
-rw-r--r--src/kernel/mem/virt.h12
-rw-r--r--src/kernel/pcpy.c (renamed from src/kernel/mem/virt.c)1
-rw-r--r--src/kernel/pipe.c1
-rw-r--r--src/kernel/proc.c1
-rw-r--r--src/kernel/proc.h8
-rw-r--r--src/kernel/ring.c9
-rw-r--r--src/kernel/ring.h6
-rw-r--r--src/kernel/syscalls.c1
-rw-r--r--src/kernel/vfs/procfs.c1
-rw-r--r--src/kernel/vfs/request.c1
23 files changed, 38 insertions, 65 deletions
diff --git a/src/kernel/arch/amd64/32/gdt.c b/src/kernel/arch/amd64/32/gdt.c
index 33fcf7b..bd5fa48 100644
--- a/src/kernel/arch/amd64/32/gdt.c
+++ b/src/kernel/arch/amd64/32/gdt.c
@@ -1,5 +1,5 @@
-#include <kernel/arch/amd64/32/gdt.h>
#include <kernel/arch/amd64/32/util.h>
+#include <kernel/arch/amd64/boot.h>
#include <stdbool.h>
#include <stdint.h>
diff --git a/src/kernel/arch/amd64/32/gdt.h b/src/kernel/arch/amd64/32/gdt.h
deleted file mode 100644
index 4e08c88..0000000
--- a/src/kernel/arch/amd64/32/gdt.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-enum {
- SEG_null,
- // order dictated by SYSENTER
- SEG_r0code,
- SEG_r0data,
- SEG_r3code,
- SEG_r3data,
- SEG_TSS,
- SEG_TSS2,
-
- SEG_end
-};
-
-void gdt_init(void);
-
-extern struct lgdt_arg lgdt_arg; // used by amd64/32/boot.s
diff --git a/src/kernel/arch/amd64/boot.c b/src/kernel/arch/amd64/boot.c
index d78d4f6..32d0452 100644
--- a/src/kernel/arch/amd64/boot.c
+++ b/src/kernel/arch/amd64/boot.c
@@ -5,7 +5,6 @@
#include <kernel/arch/amd64/driver/ps2.h>
#include <kernel/arch/amd64/driver/serial.h>
#include <kernel/arch/amd64/driver/video.h>
-#include <kernel/arch/amd64/interrupts/idt.h>
#include <kernel/arch/amd64/interrupts/irq.h>
#include <kernel/arch/amd64/pci.h>
#include <kernel/arch/amd64/tty/tty.h>
diff --git a/src/kernel/arch/amd64/boot.h b/src/kernel/arch/amd64/boot.h
index 251086c..b68f52b 100644
--- a/src/kernel/arch/amd64/boot.h
+++ b/src/kernel/arch/amd64/boot.h
@@ -1,2 +1,21 @@
#pragma once
+
+enum gdt_segs {
+ SEG_null,
+ /* order dictated by SYSENTER */
+ SEG_r0code,
+ SEG_r0data,
+ SEG_r3code,
+ SEG_r3data,
+ SEG_TSS,
+ SEG_TSS2,
+
+ SEG_end
+};
+
void kmain_early(void *mbi);
+void gdt_init(void);
+void idt_init(void);
+
+/* used from asm */
+extern struct lgdt_arg lgdt_arg;
diff --git a/src/kernel/arch/amd64/driver/pata.c b/src/kernel/arch/amd64/driver/pata.c
index b0ed592..3e9fa7a 100644
--- a/src/kernel/arch/amd64/driver/pata.c
+++ b/src/kernel/arch/amd64/driver/pata.c
@@ -3,7 +3,6 @@
#include <kernel/arch/amd64/ata.h>
#include <kernel/arch/amd64/driver/pata.h>
#include <kernel/arch/amd64/driver/util.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/request.h>
diff --git a/src/kernel/arch/amd64/driver/ps2.c b/src/kernel/arch/amd64/driver/ps2.c
index cdcbf19..971d7d1 100644
--- a/src/kernel/arch/amd64/driver/ps2.c
+++ b/src/kernel/arch/amd64/driver/ps2.c
@@ -5,7 +5,6 @@
#include <kernel/arch/amd64/port_io.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
-#include <kernel/ring.h>
#include <kernel/vfs/request.h>
#include <shared/mem.h>
diff --git a/src/kernel/arch/amd64/driver/rtl8139.c b/src/kernel/arch/amd64/driver/rtl8139.c
index dd11102..d0e4d90 100644
--- a/src/kernel/arch/amd64/driver/rtl8139.c
+++ b/src/kernel/arch/amd64/driver/rtl8139.c
@@ -2,7 +2,6 @@
#include <kernel/arch/amd64/driver/util.h>
#include <kernel/arch/amd64/pci.h>
#include <kernel/arch/amd64/port_io.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/request.h>
diff --git a/src/kernel/arch/amd64/driver/serial.c b/src/kernel/arch/amd64/driver/serial.c
index 6fe4500..5004c31 100644
--- a/src/kernel/arch/amd64/driver/serial.c
+++ b/src/kernel/arch/amd64/driver/serial.c
@@ -2,10 +2,8 @@
#include <kernel/arch/amd64/driver/util.h>
#include <kernel/arch/amd64/interrupts/irq.h>
#include <kernel/arch/amd64/port_io.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
-#include <kernel/ring.h>
#include <kernel/util.h>
#include <stdint.h>
diff --git a/src/kernel/arch/amd64/driver/util.c b/src/kernel/arch/amd64/driver/util.c
index 957005c..1462258 100644
--- a/src/kernel/arch/amd64/driver/util.c
+++ b/src/kernel/arch/amd64/driver/util.c
@@ -1,6 +1,5 @@
#include <camellia/fsutil.h>
#include <kernel/arch/amd64/driver/util.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/request.h>
@@ -53,3 +52,10 @@ void postqueue_ringreadall(VfsReq **queue, ring_t *r) {
}
*queue = NULL;
}
+
+size_t ring_to_virt(ring_t *r, Proc *proc, void __user *ubuf, size_t max) {
+ char tmp[32];
+ if (max > sizeof tmp) max = sizeof tmp;
+ max = ring_get(r, tmp, max);
+ return pcpy_to(proc, ubuf, tmp, max);
+}
diff --git a/src/kernel/arch/amd64/driver/util.h b/src/kernel/arch/amd64/driver/util.h
index 5827fa9..0f7db7a 100644
--- a/src/kernel/arch/amd64/driver/util.h
+++ b/src/kernel/arch/amd64/driver/util.h
@@ -19,3 +19,5 @@ bool postqueue_pop(VfsReq **queue, void (*accept)(VfsReq *));
/** If there are any pending read requests, and the ring buffer isn't empty, fulfill them
* all with a single read. */
void postqueue_ringreadall(VfsReq **queue, ring_t *r);
+
+size_t ring_to_virt(ring_t *r, Proc *proc, void __user *ubuf, size_t max);
diff --git a/src/kernel/arch/amd64/driver/video.c b/src/kernel/arch/amd64/driver/video.c
index d7046b4..ecf713f 100644
--- a/src/kernel/arch/amd64/driver/video.c
+++ b/src/kernel/arch/amd64/driver/video.c
@@ -2,7 +2,6 @@
#include <camellia/fsutil.h>
#include <kernel/arch/amd64/driver/util.h>
#include <kernel/arch/amd64/driver/video.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/request.h>
diff --git a/src/kernel/arch/amd64/interrupts/idt.c b/src/kernel/arch/amd64/interrupts/idt.c
index f9f3073..622ac1a 100644
--- a/src/kernel/arch/amd64/interrupts/idt.c
+++ b/src/kernel/arch/amd64/interrupts/idt.c
@@ -1,5 +1,4 @@
-#include <kernel/arch/amd64/32/gdt.h>
-#include <kernel/arch/amd64/interrupts/idt.h>
+#include <kernel/arch/amd64/boot.h>
#include <kernel/arch/amd64/interrupts/isr.h>
#include <kernel/panic.h>
#include <stdbool.h>
diff --git a/src/kernel/arch/amd64/interrupts/idt.h b/src/kernel/arch/amd64/interrupts/idt.h
deleted file mode 100644
index 6576cf9..0000000
--- a/src/kernel/arch/amd64/interrupts/idt.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-void idt_init(void);
diff --git a/src/kernel/mem/virt.h b/src/kernel/mem/virt.h
deleted file mode 100644
index 7c9380e..0000000
--- a/src/kernel/mem/virt.h
+++ /dev/null
@@ -1,12 +0,0 @@
-// move this to proc.h, maybe?
-#pragma once
-#include <kernel/types.h>
-#include <stddef.h>
-
-size_t pcpy_to(Proc *p, __user void *dst, const void *src, size_t len);
-size_t pcpy_from(Proc *p, void *dst, const __user void *src, size_t len);
-size_t pcpy_bi(
- Proc *dstp, __user void *dst,
- Proc *srcp, const __user void *src,
- size_t len
-);
diff --git a/src/kernel/mem/virt.c b/src/kernel/pcpy.c
index 1ac6fbc..9cf7c37 100644
--- a/src/kernel/mem/virt.c
+++ b/src/kernel/pcpy.c
@@ -4,7 +4,6 @@
// TODO ensure the behaviour of kernel vs user fs on faults is the same
#include <kernel/arch/generic.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/util.h>
diff --git a/src/kernel/pipe.c b/src/kernel/pipe.c
index 3ac52d3..6325369 100644
--- a/src/kernel/pipe.c
+++ b/src/kernel/pipe.c
@@ -1,4 +1,3 @@
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/pipe.h>
#include <kernel/util.h>
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 93fef1a..836490b 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -3,7 +3,6 @@
#include <kernel/arch/generic.h>
#include <kernel/execbuf.h>
#include <kernel/mem/alloc.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/mount.h>
diff --git a/src/kernel/proc.h b/src/kernel/proc.h
index 5120778..8a19d8f 100644
--- a/src/kernel/proc.h
+++ b/src/kernel/proc.h
@@ -128,3 +128,11 @@ Handle *proc_hid_take(Proc *, hid_t);
hid_t proc_handle_put(Proc *, Handle *);
void proc_setstate(Proc *, enum proc_state);
+
+size_t pcpy_to(Proc *p, __user void *dst, const void *src, size_t len);
+size_t pcpy_from(Proc *p, void *dst, const __user void *src, size_t len);
+size_t pcpy_bi(
+ Proc *dstp, __user void *dst,
+ Proc *srcp, const __user void *src,
+ size_t len
+);
diff --git a/src/kernel/ring.c b/src/kernel/ring.c
index 2cb6961..e69de29 100644
--- a/src/kernel/ring.c
+++ b/src/kernel/ring.c
@@ -1,9 +0,0 @@
-#include <kernel/mem/virt.h>
-#include <kernel/ring.h>
-
-size_t ring_to_virt(ring_t *r, Proc *proc, void __user *ubuf, size_t max) {
- char tmp[32];
- if (max > sizeof tmp) max = sizeof tmp;
- max = ring_get(r, tmp, max);
- return pcpy_to(proc, ubuf, tmp, max);
-}
diff --git a/src/kernel/ring.h b/src/kernel/ring.h
deleted file mode 100644
index 89770d0..0000000
--- a/src/kernel/ring.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-// TODO merge into driver/util.h
-#include <kernel/types.h>
-#include <shared/container/ring.h>
-
-size_t ring_to_virt(ring_t *r, Proc *proc, void __user *ubuf, size_t max);
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index 1ab2efd..72d19f0 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -5,7 +5,6 @@
#include <camellia/syscalls.h>
#include <kernel/arch/generic.h>
#include <kernel/mem/alloc.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/pipe.h>
#include <kernel/proc.h>
diff --git a/src/kernel/vfs/procfs.c b/src/kernel/vfs/procfs.c
index 2a8dd93..ecca839 100644
--- a/src/kernel/vfs/procfs.c
+++ b/src/kernel/vfs/procfs.c
@@ -1,6 +1,5 @@
#include <camellia/errno.h>
#include <kernel/mem/alloc.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/procfs.h>
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 7e5877d..35df29c 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -1,7 +1,6 @@
#include <camellia/errno.h>
#include <camellia/flags.h>
#include <kernel/mem/alloc.h>
-#include <kernel/mem/virt.h>
#include <kernel/panic.h>
#include <kernel/proc.h>
#include <kernel/vfs/request.h>