From 9b50b6672eb4f8d3c75368bb53ae70ed92f2b994 Mon Sep 17 00:00:00 2001 From: Kevin Alavik Date: Tue, 26 Mar 2024 13:55:00 +0000 Subject: [PATCH] stuff --- arch/x86_64/cpu/panic.c | 2 +- initrd/usr/share/paradox/bible_votd | 1 + kernel/entry/init.c | 12 +++++++----- kernel/entry/init.h | 5 +++-- kernel/entry/kernel.c | 25 +++++++++++++++++++++---- kernel/entry/kernel.h | 4 ++-- kernel/paradox.c | 4 ++-- kernel/system/pci/pci.c | 4 ++-- kernel/system/pci/pci.h | 2 +- kernel/tty/tty.c | 2 +- tools/build.sh | 4 +++- 11 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 initrd/usr/share/paradox/bible_votd diff --git a/arch/x86_64/cpu/panic.c b/arch/x86_64/cpu/panic.c index 4631f6d..5cc4052 100644 --- a/arch/x86_64/cpu/panic.c +++ b/arch/x86_64/cpu/panic.c @@ -12,7 +12,7 @@ void panic(const char *reason, int_frame_t frame) { - printf("\n\n* %s\n\n", reason); + printf("\n\n* %s\n", reason); printf("rax: 0x%.16llX, rbx: 0x%.16llX, rcx: 0x%.16llX, rdx: 0x%.16llX\n", frame.rax, frame.rbx, frame.rcx, frame.rdx); diff --git a/initrd/usr/share/paradox/bible_votd b/initrd/usr/share/paradox/bible_votd new file mode 100644 index 0000000..22ad2cf --- /dev/null +++ b/initrd/usr/share/paradox/bible_votd @@ -0,0 +1 @@ +Acts 1:8 But you will receive power when the Holy Spirit has come upon you, and you will be my witnesses in Jerusalem, and in all Judea and Samaria, and to the farthest parts of the earth.” \ No newline at end of file diff --git a/kernel/entry/init.c b/kernel/entry/init.c index e35e1e1..0093090 100644 --- a/kernel/entry/init.c +++ b/kernel/entry/init.c @@ -10,6 +10,7 @@ #include #include #include +#include volatile struct limine_module_request mod_request = { .id = LIMINE_MODULE_REQUEST, .revision = 0}; @@ -26,10 +27,8 @@ int_frame_t *cur_frame; ramdisk_t *rd; VFS_t *vfs; -void init_boot(int debug_info) +void init() { - (void)debug_info; // Eh, idc - hhdm_offset = hhdm_request.response->offset; framebuffer = framebuffer_request.response->framebuffers[0]; @@ -63,10 +62,13 @@ void init_boot(int debug_info) dprintf("[\e[0;32mVFS\e[0m] Mounted ramdisk\n"); - tty_init(vfs, framebuffer); - int kstatus = main(); // Launch the kernel + keyboard.out = false; + tty_spawn(0, FONT_SMALL); + register_pci(); + + int kstatus = kmain(); // Launch the kernel if (kstatus == KERNEL_QUIT_SUCCESS) { diff --git a/kernel/entry/init.h b/kernel/entry/init.h index 855f2bf..e933c6c 100644 --- a/kernel/entry/init.h +++ b/kernel/entry/init.h @@ -6,7 +6,8 @@ #include #include -#define DEFAULT_FONT "/usr/share/fonts/Uni3-Terminus12x6.psf" +#define FONT_SMALL "/usr/share/fonts/Uni3-Terminus12x6.psf" +#define FONT_BIG "/usr/share/fonts/Uni3-Terminus20x10.psf" extern volatile struct limine_module_request mod_request; extern volatile struct limine_framebuffer_request framebuffer_request; @@ -17,6 +18,6 @@ extern int_frame_t *cur_frame; extern ramdisk_t *rd; extern VFS_t *vfs; -void init_boot(int debug_info); +void init(); #endif // __INIT_H__ diff --git a/kernel/entry/kernel.c b/kernel/entry/kernel.c index 3474186..90e7c1e 100644 --- a/kernel/entry/kernel.c +++ b/kernel/entry/kernel.c @@ -24,16 +24,33 @@ return codes) #include #include #include +#include +#include // Corelib includes #include #include #include #include -int main() + +int kmain() { - keyboard.out = false; - tty_spawn(0, "/usr/share/fonts/Uni3-Terminus12x6.psf"); - register_pci(); + tty_spawn(1, FONT_BIG); + + vfs_op_status status; + char* votd = NULL; + + status = driver_read(vfs, 0, "/usr/share/paradox/bible_votd", &votd); + + if(status != STATUS_OK) + return KERNEL_QUIT_ERROR; + + if (votd != NULL) { + dprintf("BibleVOTD: \033[1m%s\033[0m\n", votd); + free(votd); + } + + keyboard.out = true; + return KERNEL_QUIT_HANG; } diff --git a/kernel/entry/kernel.h b/kernel/entry/kernel.h index 788e9dd..d170a0e 100644 --- a/kernel/entry/kernel.h +++ b/kernel/entry/kernel.h @@ -6,6 +6,6 @@ #define KERNEL_QUIT_PANIC 2 // Return this on kernel panic, shutdowns immediately #define KERNEL_QUIT_HANG 3 // Return this to do nothing -int main(); // ONLY RETURN TO QUIT +int kmain(); // ONLY RETURN TO QUIT -#endif // __KERNEL_H__ \ No newline at end of file +#endif // __KERNEL_H__ diff --git a/kernel/paradox.c b/kernel/paradox.c index 4858b38..5c148f3 100644 --- a/kernel/paradox.c +++ b/kernel/paradox.c @@ -6,8 +6,8 @@ void _start(void) { - init_boot(1); + init(); dprintf("[\e[0;32mSystem\e[0m] Oopsie something broke, init_boot got exited. " "When it shouldnt have\n"); shutdown(); -} \ No newline at end of file +} diff --git a/kernel/system/pci/pci.c b/kernel/system/pci/pci.c index b4d6558..111a81e 100644 --- a/kernel/system/pci/pci.c +++ b/kernel/system/pci/pci.c @@ -55,8 +55,8 @@ void register_pci() (uint8_t)(device & 0xFF), desc.device_id, ((uint8_t)((function & 0xFF))), - ((desc.class_id == 0x0C) && (desc.subclass_id == 0x03)) ? "true" : "false"); + ((desc.class_id == 0x0C) && (desc.subclass_id == 0x03)) ? "yes" : "no"); } } } -} \ No newline at end of file +} diff --git a/kernel/system/pci/pci.h b/kernel/system/pci/pci.h index 565c414..e48ec17 100644 --- a/kernel/system/pci/pci.h +++ b/kernel/system/pci/pci.h @@ -29,4 +29,4 @@ void write_pci(uint16_t bus, uint16_t device, uint16_t function, uint32_t regoff void register_pci(); device_descriptor get_device_descriptor(uint16_t bus, uint16_t device, uint16_t function); -#endif // __PCI_H__ \ No newline at end of file +#endif // __PCI_H__ diff --git a/kernel/tty/tty.c b/kernel/tty/tty.c index ab3be94..743efe5 100644 --- a/kernel/tty/tty.c +++ b/kernel/tty/tty.c @@ -102,7 +102,7 @@ void tty_switch(uint8_t id) { cur_tty = ttys[id]; cur_tty_id = id; - // tty_flush(); + tty_flush(); printf("Paradox 1.4.1-dev (tty%d)\n\n", cur_tty_id); } diff --git a/tools/build.sh b/tools/build.sh index 69db1af..78278a0 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -11,6 +11,8 @@ fi mkdir -p iso_root +curl -s "https://labs.bible.org/api/?passage=votd&type=text&formatting=plain" > initrd/usr/share/paradox/bible_votd + tar -cvf modules/ramdisk.tar initrd/* # PARADOX_VER=0.1.1 @@ -31,4 +33,4 @@ xorriso -as mkisofs -b limine-bios-cd.bin \ iso_root -o image.iso ./limine/limine bios-install image.iso -rm -rf iso_root \ No newline at end of file +rm -rf iso_root