From e06cf9993b5a40abcf6c1d6c77b497ff69a9fd44 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 25 Jan 2023 21:58:18 +0100 Subject: kernel/driver: consolidate most header files into driver.h --- src/kernel/arch/amd64/boot.c | 5 +---- src/kernel/arch/amd64/driver/driver.h | 18 ++++++++++++++++++ src/kernel/arch/amd64/driver/fsroot.c | 2 +- src/kernel/arch/amd64/driver/fsroot.h | 2 -- src/kernel/arch/amd64/driver/pata.c | 2 +- src/kernel/arch/amd64/driver/pata.h | 3 --- src/kernel/arch/amd64/driver/ps2.c | 5 +++-- src/kernel/arch/amd64/driver/ps2.h | 5 ----- src/kernel/arch/amd64/driver/rtl8139.c | 5 +++-- src/kernel/arch/amd64/driver/rtl8139.h | 4 ---- src/kernel/arch/amd64/driver/serial.c | 3 ++- src/kernel/arch/amd64/driver/serial.h | 4 ---- src/kernel/arch/amd64/driver/video.c | 2 +- src/kernel/arch/amd64/driver/video.h | 12 ------------ src/kernel/arch/amd64/pci.c | 2 +- 15 files changed, 31 insertions(+), 43 deletions(-) create mode 100644 src/kernel/arch/amd64/driver/driver.h delete mode 100644 src/kernel/arch/amd64/driver/fsroot.h delete mode 100644 src/kernel/arch/amd64/driver/pata.h delete mode 100644 src/kernel/arch/amd64/driver/ps2.h delete mode 100644 src/kernel/arch/amd64/driver/rtl8139.h delete mode 100644 src/kernel/arch/amd64/driver/video.h (limited to 'src/kernel') diff --git a/src/kernel/arch/amd64/boot.c b/src/kernel/arch/amd64/boot.c index bc9a675..c645fb6 100644 --- a/src/kernel/arch/amd64/boot.c +++ b/src/kernel/arch/amd64/boot.c @@ -1,10 +1,7 @@ #include #include -#include -#include -#include +#include #include -#include #include #include #include diff --git a/src/kernel/arch/amd64/driver/driver.h b/src/kernel/arch/amd64/driver/driver.h new file mode 100644 index 0000000..0c4ecd5 --- /dev/null +++ b/src/kernel/arch/amd64/driver/driver.h @@ -0,0 +1,18 @@ +#pragma once +#include +#include +#include + +struct GfxInfo { + char *b; + uint32_t width, height; + uint32_t pitch; /* width in bytes of a single scanline */ + size_t size; + uint8_t bpp; +}; + +void pata_init(void); +void ps2_init(void); +void rtl8139_init(uint32_t bdf); +void vfs_root_init(void); +void video_init(GfxInfo); diff --git a/src/kernel/arch/amd64/driver/fsroot.c b/src/kernel/arch/amd64/driver/fsroot.c index 6d3676d..0b0e2ef 100644 --- a/src/kernel/arch/amd64/driver/fsroot.c +++ b/src/kernel/arch/amd64/driver/fsroot.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/src/kernel/arch/amd64/driver/fsroot.h b/src/kernel/arch/amd64/driver/fsroot.h deleted file mode 100644 index dd72202..0000000 --- a/src/kernel/arch/amd64/driver/fsroot.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -void vfs_root_init(void); diff --git a/src/kernel/arch/amd64/driver/pata.c b/src/kernel/arch/amd64/driver/pata.c index 3e9fa7a..99c3102 100644 --- a/src/kernel/arch/amd64/driver/pata.c +++ b/src/kernel/arch/amd64/driver/pata.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/kernel/arch/amd64/driver/pata.h b/src/kernel/arch/amd64/driver/pata.h deleted file mode 100644 index f74712b..0000000 --- a/src/kernel/arch/amd64/driver/pata.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void pata_init(void); diff --git a/src/kernel/arch/amd64/driver/ps2.c b/src/kernel/arch/amd64/driver/ps2.c index 4aa17ff..06825d6 100644 --- a/src/kernel/arch/amd64/driver/ps2.c +++ b/src/kernel/arch/amd64/driver/ps2.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -17,6 +17,7 @@ static volatile uint8_t mouse_buf[64]; static volatile ring_t mouse_backlog = {(void*)mouse_buf, sizeof mouse_buf, 0, 0}; static void accept(VfsReq *req); +static void ps2_irq(void); static VfsReq *kb_queue = NULL; static VfsReq *mouse_queue = NULL; @@ -60,7 +61,7 @@ void ps2_init(void) { vfs_root_register("/ps2", accept); } -void ps2_irq(void) { +static void ps2_irq(void) { for (;;) { uint64_t status = port_in8(PS2 + 4); if (!(status & 1)) break; /* read while data available */ diff --git a/src/kernel/arch/amd64/driver/ps2.h b/src/kernel/arch/amd64/driver/ps2.h deleted file mode 100644 index e1b1521..0000000 --- a/src/kernel/arch/amd64/driver/ps2.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include - -void ps2_irq(void); -void ps2_init(void); diff --git a/src/kernel/arch/amd64/driver/rtl8139.c b/src/kernel/arch/amd64/driver/rtl8139.c index bf8a67a..8a40f28 100644 --- a/src/kernel/arch/amd64/driver/rtl8139.c +++ b/src/kernel/arch/amd64/driver/rtl8139.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -11,6 +11,7 @@ #define WAIT -1000 static void accept(VfsReq *req); +static void rtl8139_irq(void); static VfsReq *blocked_on = NULL; @@ -85,7 +86,7 @@ void rtl8139_init(uint32_t bdf) { vfs_root_register("/eth", accept); } -void rtl8139_irq(void) { +static void rtl8139_irq(void) { uint16_t status = port_in16(iobase + INTRSTATUS); if (!(status & 1)) { kprintf("bad rtl8139 status 0x%x\n", status); diff --git a/src/kernel/arch/amd64/driver/rtl8139.h b/src/kernel/arch/amd64/driver/rtl8139.h deleted file mode 100644 index 2677d82..0000000 --- a/src/kernel/arch/amd64/driver/rtl8139.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include -void rtl8139_init(uint32_t bdf); -void rtl8139_irq(void); diff --git a/src/kernel/arch/amd64/driver/serial.c b/src/kernel/arch/amd64/driver/serial.c index e8774b6..5b42d8d 100644 --- a/src/kernel/arch/amd64/driver/serial.c +++ b/src/kernel/arch/amd64/driver/serial.c @@ -13,6 +13,7 @@ static volatile ring_t backlog = {(void*)backlog_buf, sizeof backlog_buf, 0, 0}; 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); } @@ -43,7 +44,7 @@ void serial_preinit(void) { } -void serial_irq(void) { +static void serial_irq(void) { ring_put1b((void*)&backlog, port_in8(COM1)); postqueue_ringreadall(&hung_reads, (void*)&backlog); } diff --git a/src/kernel/arch/amd64/driver/serial.h b/src/kernel/arch/amd64/driver/serial.h index 6a4876e..2b4c104 100644 --- a/src/kernel/arch/amd64/driver/serial.h +++ b/src/kernel/arch/amd64/driver/serial.h @@ -1,10 +1,6 @@ #pragma once -#include -#include #include void serial_preinit(void); -void serial_irq(void); void serial_write(const char *buf, size_t len); - void serial_init(void); diff --git a/src/kernel/arch/amd64/driver/video.c b/src/kernel/arch/amd64/driver/video.c index ecf713f..cb70931 100644 --- a/src/kernel/arch/amd64/driver/video.c +++ b/src/kernel/arch/amd64/driver/video.c @@ -1,7 +1,7 @@ #include #include +#include #include -#include #include #include #include diff --git a/src/kernel/arch/amd64/driver/video.h b/src/kernel/arch/amd64/driver/video.h deleted file mode 100644 index e9dd8ae..0000000 --- a/src/kernel/arch/amd64/driver/video.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include - -struct GfxInfo { - char *b; - uint32_t width, height; - uint32_t pitch; /* width in bytes of a single scanline */ - size_t size; - uint8_t bpp; -}; - -void video_init(GfxInfo); diff --git a/src/kernel/arch/amd64/pci.c b/src/kernel/arch/amd64/pci.c index 23cd457..a6f1fab 100644 --- a/src/kernel/arch/amd64/pci.c +++ b/src/kernel/arch/amd64/pci.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include -- cgit v1.2.3