From fc13fb2ba5993d06d9d6ae5e80bc337aebbdc119 Mon Sep 17 00:00:00 2001 From: aqua Date: Sun, 8 Oct 2023 19:50:00 +0300 Subject: Use meson build system --- devices/include/keyboard.h | 4 ++++ devices/include/mouse.h | 3 +++ devices/include/pic.h | 5 +++++ devices/include/ps2_controller.h | 5 +++++ devices/include/uart.h | 32 ++++++++++++++++++++++++++++++++ devices/include/vga.h | 33 +++++++++++++++++++++++++++++++++ devices/keyboard.h | 4 ---- devices/meson.build | 27 +++++++++++++++++++++++++++ devices/mk | 14 -------------- devices/mouse.h | 3 --- devices/pic.h | 5 ----- devices/ps2_controller.h | 5 ----- devices/uart.h | 32 -------------------------------- devices/uart/uart_16550.h | 2 +- devices/uart/unittest_uart_16550.cc | 2 +- devices/vga.h | 33 --------------------------------- 16 files changed, 111 insertions(+), 98 deletions(-) create mode 100644 devices/include/keyboard.h create mode 100644 devices/include/mouse.h create mode 100644 devices/include/pic.h create mode 100644 devices/include/ps2_controller.h create mode 100644 devices/include/uart.h create mode 100644 devices/include/vga.h delete mode 100644 devices/keyboard.h create mode 100644 devices/meson.build delete mode 100755 devices/mk delete mode 100644 devices/mouse.h delete mode 100644 devices/pic.h delete mode 100644 devices/ps2_controller.h delete mode 100644 devices/uart.h delete mode 100644 devices/vga.h (limited to 'devices') diff --git a/devices/include/keyboard.h b/devices/include/keyboard.h new file mode 100644 index 0000000..5f4fcc2 --- /dev/null +++ b/devices/include/keyboard.h @@ -0,0 +1,4 @@ +#pragma once + +void ps2_keyboard_init(); +void ps2_keyboard_irq_handler(); diff --git a/devices/include/mouse.h b/devices/include/mouse.h new file mode 100644 index 0000000..a34ecb4 --- /dev/null +++ b/devices/include/mouse.h @@ -0,0 +1,3 @@ +#pragma once + +void mouse_init(); diff --git a/devices/include/pic.h b/devices/include/pic.h new file mode 100644 index 0000000..c545c60 --- /dev/null +++ b/devices/include/pic.h @@ -0,0 +1,5 @@ +#pragma once + +void pic_init(); +void pic_enable(); +void pic_clear(unsigned char irq); diff --git a/devices/include/ps2_controller.h b/devices/include/ps2_controller.h new file mode 100644 index 0000000..d2f7e80 --- /dev/null +++ b/devices/include/ps2_controller.h @@ -0,0 +1,5 @@ +#pragma once + +void ps2_ctrl_init(); +unsigned char ps2_read_port1(); +unsigned char ps2_read_port2(); diff --git a/devices/include/uart.h b/devices/include/uart.h new file mode 100644 index 0000000..8b44519 --- /dev/null +++ b/devices/include/uart.h @@ -0,0 +1,32 @@ +#pragma once + +#ifdef __ARCH__ +#include +#include + +#else +/* from stdio */ +typedef struct FILE { + int id; + void (*putc)(const struct FILE *, char); + int (*puts)(const struct FILE *, const char *, int); + void (*flush)(const struct FILE *); +} FILE; + +/* from sys/io */ +unsigned char inb(unsigned short); +void outb(unsigned char, unsigned short); + +enum UART { + COM1 = 0x3f8, + COM2 = 0x2f8, + COM3 = 0x3e8, + COM4 = 0x2e8, + COM5 = 0x5f8, + COM6 = 0x4f8, + COM7 = 0x5e8, + COM8 = 0x4e8, +}; +#endif + +FILE *uart_init(unsigned short port); diff --git a/devices/include/vga.h b/devices/include/vga.h new file mode 100644 index 0000000..df0d921 --- /dev/null +++ b/devices/include/vga.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +/** Hardware text mode color constants. */ +enum vga_color { + VGA_COLOR_BLACK = 0, + VGA_COLOR_BLUE = 1, + VGA_COLOR_GREEN = 2, + VGA_COLOR_CYAN = 3, + VGA_COLOR_RED = 4, + VGA_COLOR_MAGENTA = 5, + VGA_COLOR_BROWN = 6, + VGA_COLOR_LIGHT_GREY = 7, + VGA_COLOR_DARK_GREY = 8, + VGA_COLOR_LIGHT_BLUE = 9, + VGA_COLOR_LIGHT_GREEN = 10, + VGA_COLOR_LIGHT_CYAN = 11, + VGA_COLOR_LIGHT_RED = 12, + VGA_COLOR_LIGHT_MAGENTA = 13, + VGA_COLOR_LIGHT_BROWN = 14, + VGA_COLOR_WHITE = 15 +}; + +FILE *vga_init(void *addr); +void vga_clear(enum vga_color foreground, enum vga_color background); + +/* void vga_putc(char a); */ +/* void vga_puts(const char *string, int len); */ + +/* void vga_enable_cursor(unsigned char start, unsigned char end); */ +/* void vga_disable_cursor(); */ +void vga_update_cursor(void); diff --git a/devices/keyboard.h b/devices/keyboard.h deleted file mode 100644 index 5f4fcc2..0000000 --- a/devices/keyboard.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void ps2_keyboard_init(); -void ps2_keyboard_irq_handler(); diff --git a/devices/meson.build b/devices/meson.build new file mode 100644 index 0000000..d6f4739 --- /dev/null +++ b/devices/meson.build @@ -0,0 +1,27 @@ +devs_srcs = files( + 'pic_8259.c', + 'uart/uart_16550.c', + 'vga.c', + 'i8042.c', + 'pckbd.c', + 'mouse.c', +) +devs_incl = include_directories('include') + +devs = declare_dependency( + link_with: static_library('devs', devs_srcs, + include_directories: devs_incl, + dependencies: [ libk, i686 ], + ), + include_directories: devs_incl, +) + +# tests +test('uart_16550', + executable('test_uart_16550', 'uart/uart_16550.c', 'uart/unittest_uart_16550.cc', + include_directories: devs_incl, + dependencies: [ gtest, gmock ], + native: true), + suite: 'dev' +) + diff --git a/devices/mk b/devices/mk deleted file mode 100755 index b27d945..0000000 --- a/devices/mk +++ /dev/null @@ -1,14 +0,0 @@ -#!../mach - -INCLUDES := -I../${ARCH} -${ARCH}_CFLAGS += ${INCLUDES} -${ARCH}_CXXFLAGS += ${INCLUDES} - -TARGETLIB += devs -devs.SRCS = pic_8259.c uart/uart_16550.c vga.c i8042.c pckbd.c mouse.c - -HOSTTARGETBIN += uart/test_uart_16550 -uart/test_uart_16550.SRCS = uart/uart_16550.c uart/unittest_uart_16550.cc - -TESTS += uart/test_uart_16550 - diff --git a/devices/mouse.h b/devices/mouse.h deleted file mode 100644 index a34ecb4..0000000 --- a/devices/mouse.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -void mouse_init(); diff --git a/devices/pic.h b/devices/pic.h deleted file mode 100644 index c545c60..0000000 --- a/devices/pic.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -void pic_init(); -void pic_enable(); -void pic_clear(unsigned char irq); diff --git a/devices/ps2_controller.h b/devices/ps2_controller.h deleted file mode 100644 index d2f7e80..0000000 --- a/devices/ps2_controller.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -void ps2_ctrl_init(); -unsigned char ps2_read_port1(); -unsigned char ps2_read_port2(); diff --git a/devices/uart.h b/devices/uart.h deleted file mode 100644 index 53a4f41..0000000 --- a/devices/uart.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#ifdef __ARCH__ -#include -#include - -#else -// from stdio -typedef struct FILE { - int id; - void (*putc)(const struct FILE *, char); - int (*puts)(const struct FILE *, const char *, int); - void (*flush)(const struct FILE *); -} FILE; - -// from sys/io -unsigned char inb(unsigned short); -void outb(unsigned char, unsigned short); - -enum UART { - COM1 = 0x3f8, - COM2 = 0x2f8, - COM3 = 0x3e8, - COM4 = 0x2e8, - COM5 = 0x5f8, - COM6 = 0x4f8, - COM7 = 0x5e8, - COM8 = 0x4e8, -}; -#endif - -FILE *uart_init(unsigned short port); diff --git a/devices/uart/uart_16550.h b/devices/uart/uart_16550.h index d4f470e..bbeb9b7 100644 --- a/devices/uart/uart_16550.h +++ b/devices/uart/uart_16550.h @@ -1,6 +1,6 @@ #pragma once -#include "../uart.h" +#include "uart.h" int uart_thre(unsigned short port); void uart_putc(const FILE *self, char a); diff --git a/devices/uart/unittest_uart_16550.cc b/devices/uart/unittest_uart_16550.cc index 16e7202..f8124bb 100644 --- a/devices/uart/unittest_uart_16550.cc +++ b/devices/uart/unittest_uart_16550.cc @@ -7,7 +7,7 @@ using ::testing::Return; namespace k { extern "C" { -#include "../uart.h" +#include "uart.h" #include "uart_16550.h" } } // namespace k diff --git a/devices/vga.h b/devices/vga.h deleted file mode 100644 index df0d921..0000000 --- a/devices/vga.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include - -/** Hardware text mode color constants. */ -enum vga_color { - VGA_COLOR_BLACK = 0, - VGA_COLOR_BLUE = 1, - VGA_COLOR_GREEN = 2, - VGA_COLOR_CYAN = 3, - VGA_COLOR_RED = 4, - VGA_COLOR_MAGENTA = 5, - VGA_COLOR_BROWN = 6, - VGA_COLOR_LIGHT_GREY = 7, - VGA_COLOR_DARK_GREY = 8, - VGA_COLOR_LIGHT_BLUE = 9, - VGA_COLOR_LIGHT_GREEN = 10, - VGA_COLOR_LIGHT_CYAN = 11, - VGA_COLOR_LIGHT_RED = 12, - VGA_COLOR_LIGHT_MAGENTA = 13, - VGA_COLOR_LIGHT_BROWN = 14, - VGA_COLOR_WHITE = 15 -}; - -FILE *vga_init(void *addr); -void vga_clear(enum vga_color foreground, enum vga_color background); - -/* void vga_putc(char a); */ -/* void vga_puts(const char *string, int len); */ - -/* void vga_enable_cursor(unsigned char start, unsigned char end); */ -/* void vga_disable_cursor(); */ -void vga_update_cursor(void); -- cgit v1.2.1