diff --git a/kernel/boot.c b/kernel/boot.c new file mode 100644 index 0000000..2536dde --- /dev/null +++ b/kernel/boot.c @@ -0,0 +1,15 @@ +#include + +#include + +#include + +uint8_t parse_boot_data(const char* data) +{ + if (strlen(data) == 0) + { + return 0; + } + + return 0; +} diff --git a/kernel/kernel.c b/kernel/kernel.c new file mode 100644 index 0000000..dbbdf6a --- /dev/null +++ b/kernel/kernel.c @@ -0,0 +1,174 @@ +/* Check if the compiler thinks you are targeting the wrong operating system. */ +#if defined(__linux__) +#error "You are not using a cross-compiler, you will most certainly run into trouble" +#endif + +/* This tutorial will only work for the 32-bit ix86 targets. */ +#if !defined(__i386__) +#error "This kernel needs to be compiled with a ix86-elf compiler" +#endif + +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +#include +#include +//#include +#include +#include +#include +#include +#include + +#include + +#define DEBUG + +/*extern HBA_MEM *abar; +extern HBA_PORT *ahci_port;*/ + +extern void _hang_asm(void); + + +void kernel_main(multiboot_info_t* mbd, unsigned int magic) +{ + + /* --- BEGIN INITIALIZATION SECTION --- */ + + /* Make sure the magic number matches for memory mapping*/ + if(magic != MULTIBOOT_BOOTLOADER_MAGIC) { + printf("invalid magic number!"); + } + + /* Check bit 6 to see if we have a valid memory map */ + if(!(mbd->flags >> 6 & 0x1)) { + printf("invalid memory map given by GRUB bootloader"); + } + + gdt_install(); + idt_install(); + + terminal_initialize(); + + terminal_setcolor(VGA_COLOR_MAGENTA); + + printd("Initializing physical memory manager...\n"); + + pmm_init(mbd); + + printd("Physical memory manager initialized\n"); + + printd("Initializing paging...\n"); + paging_init(); + printd("Paging initialized\n"); + + printd("Initializing heap allocator...\n"); + heap_init(); + printd("Heap allocator initialized\n"); + + printd("Testing SSE...\n"); + int32_t sse_test_result = test_sse(); + if (sse_test_result != 0) + { + printf("[ DEBUG ] SSE test failed with RV %d\n", sse_test_result); + } + else + { + printd("SSE test succeeded\n"); + } + + /* + printd("Initalizing AHCI...\n"); + ahci_init(); + printd("AHCI initialized\n"); + */ + + /*printd("Initializing RAMFS...\n"); + ramfs_init(); + printd("RAMFS initialized.\n");*/ + + printd("Initializing IDE system...\n"); + ide_initialize(); + printd("IDE initialized\n"); + + printd("Initializing DuckFS...\n"); + int32_t duckfs_init_rv = duckfs_init(0); + printf("[ DEBUG ] DuckFS initialized with RV %d\n", duckfs_init_rv); + + + + /* --- END INITIALIZATION SECTION --- */ + + terminal_setcolor(VGA_COLOR_LIGHT_GREEN); + + printf("%i\n", (sizeof(duckfs_file_header_t))); + printf("%i\n", (sizeof(duckfs_superblock_t))); + + /* + printf("Making a file: %i\n", duckfs_makefile("HELLO.TXT", "RWX...", 1)); + */ + + /* + 512 Byte sectors; + + */ + /* + uint64_t lba = 0x00000000000000FF; + + + uint8_t boot_sector[512]; + ide_read48(0, lba, 1, boot_sector); + + for (uint16_t i = 0; i < 32; ++i) + { + if (ischar(boot_sector[i])) + { + printf("%c", (char)boot_sector[i]); + } + else + { + printf("%i", boot_sector[i]); + } + } + printf("\n"); + + uint8_t dt_sector[512] = "HELLO THERE\0"; + printf("Writing data to disk...\n"); + printf("ide_write48: %i\n", ide_write48(0, lba, 1, dt_sector)); + printf("Data written to disk\n"); + + for (uint16_t i = 0; i < 32; ++i) + { + if (ischar(boot_sector[i])) + { + printf("%c", (char)boot_sector[i]); + } + else + { + printf("%i", boot_sector[i]); + } + } + printf("\n");*/ + + + printf("Loading Espresso 0.0.1...\n"); + + + + //pci_enumerate(); + + + + _hang_asm(); +} diff --git a/kernel/syscalls.c b/kernel/syscalls.c new file mode 100644 index 0000000..8c734bf --- /dev/null +++ b/kernel/syscalls.c @@ -0,0 +1,10 @@ + +#include + +#include + + +int16_t syscall_write(int32_t fd, const void* buffer, int32_t length) +{ + return -1; +}