From 1f71b9576db536af84155363e14fc49e92de2eef Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Sun, 29 Aug 2021 02:52:48 -0500 Subject: backup 8.29.21 --- src/include/addr.h | 11 +++++++++++ src/include/int.h | 2 +- src/include/kernel.h | 10 +++------- src/include/klog.h | 20 ++++++++++++++++++++ src/include/panic.h | 3 +++ src/include/printf.h | 1 + src/include/serial.h | 27 --------------------------- src/include/smp_sync.h | 17 +++++++++++++++++ 8 files changed, 56 insertions(+), 35 deletions(-) create mode 100644 src/include/addr.h create mode 100644 src/include/klog.h delete mode 100644 src/include/serial.h create mode 100644 src/include/smp_sync.h (limited to 'src/include') diff --git a/src/include/addr.h b/src/include/addr.h new file mode 100644 index 0000000..039d11d --- /dev/null +++ b/src/include/addr.h @@ -0,0 +1,11 @@ +#ifndef ADDR_INCLUDED +#define ADDR_INCLUDED + +#include + +//couldn't get symbols working, fix later +#define PA_OFFSET 0xffff800000000000 +#define TXT_OFFSET 0xffffffff80000000 +#define PHYS_TO_VIRT(addr) ((void *)((uintptr_t)(addr) | PA_OFFSET)) + +#endif diff --git a/src/include/int.h b/src/include/int.h index 8cc6a88..32313bd 100644 --- a/src/include/int.h +++ b/src/include/int.h @@ -7,7 +7,7 @@ void usleep(unsigned int us); -void init_interrupts(); +void init_interrupts_bsp(); typedef uint32_t *lapic_t; diff --git a/src/include/kernel.h b/src/include/kernel.h index db0f049..ea1223a 100644 --- a/src/include/kernel.h +++ b/src/include/kernel.h @@ -2,14 +2,10 @@ #define KERNEL -#define PA_OFFSET 0xffff800000000000 -#define TXT_OFFSET 0xffffffff80000000 -#define PHYS_TO_VIRT(addr) ((void *)(addr) + PA_OFFSET) - -#define DEV_EMAIL "brett_weiland@bpcspace.com" - -void multicore_main(); +void smp_kinit(); +void kernel_init(); +void kmain(); #endif diff --git a/src/include/klog.h b/src/include/klog.h new file mode 100644 index 0000000..1a6d3af --- /dev/null +++ b/src/include/klog.h @@ -0,0 +1,20 @@ +#ifndef _SERIAL_H_ +#define _SERIAL_H_ + +#include +#include + + + + + +void init_klog(); +void serial_out(uint16_t port, char *string); +void _putchar_serial(uint16_t port, char character); +void move_cursor(unsigned int x, unsigned int y); + + +void clear_screen(); + + +#endif diff --git a/src/include/panic.h b/src/include/panic.h index 6a987f4..43712a2 100644 --- a/src/include/panic.h +++ b/src/include/panic.h @@ -52,6 +52,9 @@ void panic(int reason, void *frame_p, struct registers *regs); #define KERNEL_PANIC_INVALID_RSDT 35 #define KERNEL_PANIC_INVALID_IOAPIC_VEC 36 #define KERNEL_PANIC_HPET_REQUIRED 37 +#define KERNEL_PANIC_SMP_FAILED 38 + +#define DEV_EMAIL "brett_weiland@bpcspace.com" diff --git a/src/include/printf.h b/src/include/printf.h index 6104ccf..0733f55 100644 --- a/src/include/printf.h +++ b/src/include/printf.h @@ -61,6 +61,7 @@ void _putchar(char character); int printf_(const char* format, ...); + /** * Tiny sprintf implementation * Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING (V)SNPRINTF INSTEAD! diff --git a/src/include/serial.h b/src/include/serial.h deleted file mode 100644 index ef5eecf..0000000 --- a/src/include/serial.h +++ /dev/null @@ -1,27 +0,0 @@ -//these com values are just guesses! Figure out how to find em later if you want -#ifndef _SERIAL_H_ -#define _SERIAL_H_ - -#include -#include - -#define COM1 0x3f8 -#define COM2 0x2f8 -#define COM3 0x3e8 -#define COM4 0x2e8 - - - -bool init_serial(uint16_t port); -void serial_out(uint16_t port, char *string); -void _putchar_serial(uint16_t port, char character); -void move_cursor(unsigned int x, unsigned int y); - - -//TODO fix shitty header -void _putchar_screen(char character); - -void clear_screen(); - - -#endif diff --git a/src/include/smp_sync.h b/src/include/smp_sync.h new file mode 100644 index 0000000..92784b8 --- /dev/null +++ b/src/include/smp_sync.h @@ -0,0 +1,17 @@ +#ifndef SMP_SYNC_INCLUDED +#define SMP_SYNC_INCLUDED + +static inline void lock(uint8_t *lock) { + asm("mov al, 1\n" + "spinlock:\n" + "lock xchgb [%0], al\n" + "test al, al\n" + "jnz spinlock\n" + ::"r"(lock):"al"); +} + +static inline void unlock(uint8_t *lock) { + asm("lock andb [%0], 0"::"r"(lock)); +} + +#endif -- cgit v1.2.3