From c24a9376b4a048a3f9408df2d47eaad367459bd7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 25 Jan 2023 20:56:36 +0100 Subject: kernel: consolidate some header files --- src/kernel/arch/amd64/32/gdt.c | 2 +- src/kernel/arch/amd64/32/gdt.h | 18 ------------------ src/kernel/arch/amd64/boot.c | 1 - src/kernel/arch/amd64/boot.h | 19 +++++++++++++++++++ src/kernel/arch/amd64/driver/pata.c | 1 - src/kernel/arch/amd64/driver/ps2.c | 1 - src/kernel/arch/amd64/driver/rtl8139.c | 1 - src/kernel/arch/amd64/driver/serial.c | 2 -- src/kernel/arch/amd64/driver/util.c | 8 +++++++- src/kernel/arch/amd64/driver/util.h | 2 ++ src/kernel/arch/amd64/driver/video.c | 1 - src/kernel/arch/amd64/interrupts/idt.c | 3 +-- src/kernel/arch/amd64/interrupts/idt.h | 3 --- 13 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 src/kernel/arch/amd64/32/gdt.h delete mode 100644 src/kernel/arch/amd64/interrupts/idt.h (limited to 'src/kernel/arch/amd64') 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 #include +#include #include #include 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 #include #include -#include #include #include #include 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 #include #include -#include #include #include #include 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 #include #include -#include #include #include 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 #include #include -#include #include #include #include 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 #include #include -#include #include #include -#include #include #include 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 #include -#include #include #include #include @@ -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 #include #include -#include #include #include #include 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 -#include +#include #include #include #include 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); -- cgit v1.2.3