diff options
author | dzwdz | 2023-01-25 20:56:36 +0100 |
---|---|---|
committer | dzwdz | 2023-01-25 20:56:36 +0100 |
commit | c24a9376b4a048a3f9408df2d47eaad367459bd7 (patch) | |
tree | 74388b8b575719ab94e6f8eed9ad834abe7ba36b /src/kernel/arch/amd64 | |
parent | 93194f8645ecd9f280372ec99497ede5f0ce7cee (diff) |
kernel: consolidate some header files
Diffstat (limited to 'src/kernel/arch/amd64')
-rw-r--r-- | src/kernel/arch/amd64/32/gdt.c | 2 | ||||
-rw-r--r-- | src/kernel/arch/amd64/32/gdt.h | 18 | ||||
-rw-r--r-- | src/kernel/arch/amd64/boot.c | 1 | ||||
-rw-r--r-- | src/kernel/arch/amd64/boot.h | 19 | ||||
-rw-r--r-- | src/kernel/arch/amd64/driver/pata.c | 1 | ||||
-rw-r--r-- | src/kernel/arch/amd64/driver/ps2.c | 1 | ||||
-rw-r--r-- | src/kernel/arch/amd64/driver/rtl8139.c | 1 | ||||
-rw-r--r-- | src/kernel/arch/amd64/driver/serial.c | 2 | ||||
-rw-r--r-- | src/kernel/arch/amd64/driver/util.c | 8 | ||||
-rw-r--r-- | src/kernel/arch/amd64/driver/util.h | 2 | ||||
-rw-r--r-- | src/kernel/arch/amd64/driver/video.c | 1 | ||||
-rw-r--r-- | src/kernel/arch/amd64/interrupts/idt.c | 3 | ||||
-rw-r--r-- | src/kernel/arch/amd64/interrupts/idt.h | 3 |
13 files changed, 30 insertions, 32 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); |