Some unfinished changes + TODO chnages

This commit is contained in:
2025-03-18 20:40:29 +01:00
parent 244b83d370
commit 883cd5c1d4
11 changed files with 333 additions and 205 deletions
+44
View File
@@ -0,0 +1,44 @@
#ifndef _BOOTLOADER_H
#define _BOOTLOADER_H
#include <kernel.h>
// Boot protocols
#define BOOT_UNKNOWN 0 // Unknown
#define BOOT_MB1 1 // MultiBoot 1
#define BOOT_MB2 2 // MultiBoot 2
#define BOOT_LIMINE 3 // Limine
struct boot_memmapEntry {
uint64_t base;
uint64_t size;
uint32_t type;
uint32_t attr;
};
/*
* Some values may not be provided by the bootloader, in this case
* pointers will be NULL and integer values will be 0 if applicable.
* Some unprovided values may also be implied. Eg.:
* If 'memmap = NULL' then 'memmapLen' doesn't matter.
*/
struct boot_info {
uint32_t memLower;
uint32_t memUpper;
struct boot_memmapEntry* memmap;
size_t memmapLen;
};
/*
* This functions arguments depend on the boot protocol provided.
* This is the reason for the varargs thing. It runs on of the functions
* defined after it.
*/
int boot_init(int type, ...);
int boot_init_mb1(void* ptr, uint32_t magic);
// TODO:
// int boot_init_mb2(...);
// int boot_init_limine(...);
#endif
+7 -9
View File
@@ -76,17 +76,15 @@ extern uint32_t __kernel_start, __kernel_end;
/*
* Logging and errors
*/
// TODO: Logging with printk()
// TODO: Log levels & pr_*() wrappers for printk()
#define BUG() (panic("BUG()"))
// TODO
#define printk(_s) NULL
#define pr_dbg(_s) NULL
#define pr_wrn(_s) NULL
#define pr_err(_s) NULL
#define panic(_s) NULL
#define BUG() NULL
#define WARN() NULL
#define BUG_ON(_e) ((_e) ? BUG() : NULL)
#define WARN_ON(_e) ((_e) ? WARN() : NULL)
#include <serial.h>
__noreturn static inline void panic(char* s) {
serial_puts(COM1, s);
__asm__ volatile("cli");
while (1) __asm__ volatile ("hlt");
}
#endif
+1 -1
View File
@@ -68,7 +68,7 @@
/* is there a symbol table loaded? */
#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
/* is there an ELF section header table? */
#define MULTIBOOT_INFO_ELF_SHDR 0X00000020
#define MULTIBOOT_INFO_ELF_SHDR 0x00000020
/* is there a full memory map? */
#define MULTIBOOT_INFO_MEM_MAP 0x00000040
+10 -1
View File
@@ -1,6 +1,15 @@
#ifndef _PMM_H
#define _PMM_H
int pmm_init();
#include <multiboot.h>
#define PMM_BS 4096 // Block Size
#define PMM_BPB 8 // Blocks per byte
int pmm_init(void);
void pmm_initRegion(size_t base, size_t len);
void pmm_deinitRegion(size_t base, size_t len);
void* pmm_alloc(size_t blockCount);
void pmm_free(void* ptr, size_t blockCount);
#endif
+6
View File
@@ -8,6 +8,9 @@
#define COM3 0x3e8
#define COM4 0x2e8
// Buffer for (v)debugf()
#define DF_BUF_LEN 2048
int serial_init(int dev);
int serial_txem(int dev);
void serial_send(int dev, char data);
@@ -16,4 +19,7 @@ char serial_recv(int dev);
void serial_write(int dev, char* buf, size_t len);
void serial_puts(int dev, char* s);
int debugf(char* fmt, ...);
int vdebugf(char* fmt, va_list args);
#endif