diff options
author | Brett Weiland <brett_weiland@bpcspace.com> | 2021-08-29 02:52:48 -0500 |
---|---|---|
committer | Brett Weiland <brett_weiland@bpcspace.com> | 2021-08-29 02:52:48 -0500 |
commit | 1f71b9576db536af84155363e14fc49e92de2eef (patch) | |
tree | 23f65a31cc89785befb70517b203625e2296326f /src/include | |
parent | dc0e84d5779db68e081c667faadc19a20de861ea (diff) |
backup 8.29.21
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/addr.h | 11 | ||||
-rw-r--r-- | src/include/int.h | 2 | ||||
-rw-r--r-- | src/include/kernel.h | 10 | ||||
-rw-r--r-- | src/include/klog.h (renamed from src/include/serial.h) | 11 | ||||
-rw-r--r-- | src/include/panic.h | 3 | ||||
-rw-r--r-- | src/include/printf.h | 1 | ||||
-rw-r--r-- | src/include/smp_sync.h | 17 |
7 files changed, 38 insertions, 17 deletions
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 <stdint.h> + +//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/serial.h b/src/include/klog.h index ef5eecf..1a6d3af 100644 --- a/src/include/serial.h +++ b/src/include/klog.h @@ -1,26 +1,19 @@ -//these com values are just guesses! Figure out how to find em later if you want #ifndef _SERIAL_H_ #define _SERIAL_H_ #include <stdint.h> #include <stdbool.h> -#define COM1 0x3f8 -#define COM2 0x2f8 -#define COM3 0x3e8 -#define COM4 0x2e8 -bool init_serial(uint16_t port); + +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); -//TODO fix shitty header -void _putchar_screen(char character); - void clear_screen(); 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/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 |