From b5a24778844f41e38168d97761d72cf0d5b400b3 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Sat, 26 Jul 2025 16:23:58 +0200 Subject: Some minor cleanup --- src/aplos.h | 28 +++++++++++++++------------- src/boot.c | 12 ++++++------ src/error.c | 8 ++++++++ src/font.c | 2 -- 4 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 src/error.c (limited to 'src') diff --git a/src/aplos.h b/src/aplos.h index 4e663f4..a64e7cc 100644 --- a/src/aplos.h +++ b/src/aplos.h @@ -28,30 +28,32 @@ struct boot_info /* boot.c */ uint64_t cpu_count(void); - + +/* error.c */ +void assert(bool); + +/* font.c */ +void font_init(void); +void font_draw(char8_t *, uint32_t, uint32_t, uint32_t, uint32_t); + /* main.c */ void main(struct boot_info *); -#define ASSERT(chk) do{if(!(chk)) halt();}while(0) + +/* nasty.S */ +void halt(void); /* screen.c */ void screen_init(struct framebuffer *); void screen_draw_pixel(uint32_t, uint32_t, uint32_t); void print(char8_t *, ...); -/* font.c */ -void font_init(void); -void font_draw(char8_t *, uint32_t, uint32_t, uint32_t, uint32_t); +/* utf8.c */ +int utf8_char_length(const char8_t *); +int utf8_cmp_n(const char8_t *, const char8_t *, uint64_t); +uint32_t utf8_value(const char8_t *); /* util.c */ uint16_t read_uint16_le(const uint8_t *); uint16_t read_uint16_be(const uint8_t *); uint32_t read_uint32_le(const uint8_t *); int memcmp(const void *, const void *, size_t); - -/* utf8.c */ -int utf8_char_length(const char8_t *); -int utf8_cmp_n(const char8_t *, const char8_t *, uint64_t); -uint32_t utf8_value(const char8_t *); - -/* nasty.S */ -extern void halt(void); diff --git a/src/boot.c b/src/boot.c index 4bbe771..f3afb5e 100644 --- a/src/boot.c +++ b/src/boot.c @@ -55,13 +55,13 @@ bootmain(void) { struct boot_info info; - ASSERT(LIMINE_BASE_REVISION_SUPPORTED); - ASSERT(framebuffer_request.response); - ASSERT(memmap_request.response); - ASSERT(paging_request.response); - ASSERT(mp_request.response); + assert(LIMINE_BASE_REVISION_SUPPORTED); + assert(framebuffer_request.response); + assert(memmap_request.response); + assert(paging_request.response); + assert(mp_request.response); - ASSERT(framebuffer_request.response->framebuffer_count >= 1); + assert(framebuffer_request.response->framebuffer_count >= 1); struct limine_framebuffer *framebuffer = framebuffer_request.response->framebuffers[0]; diff --git a/src/error.c b/src/error.c new file mode 100644 index 0000000..2513645 --- /dev/null +++ b/src/error.c @@ -0,0 +1,8 @@ +#include "aplos.h" + +void +assert(bool check) +{ + if(!check) + halt(); +} diff --git a/src/font.c b/src/font.c index 33c81aa..16b13bc 100644 --- a/src/font.c +++ b/src/font.c @@ -2,8 +2,6 @@ static const uint8_t font_data[] = { #embed "../external/spleen/spleen-8x16.psfu" -// #embed "../external/spleen/spleen-12x24.psfu" -// #embed "../external/spleen/spleen-16x32.psfu" }; static uint32_t header_size; -- cgit v1.2.3