kernel: whatever changes i didn't keep track of lol

This commit is contained in:
Raphaël M. 2025-06-01 22:45:43 +02:00
parent b2cf9b4710
commit edbb5d106d
67 changed files with 340 additions and 88 deletions

0
kernel/src/lib/ansi.c Normal file → Executable file
View file

0
kernel/src/lib/ansi.h Normal file → Executable file
View file

4
kernel/src/lib/log.c Normal file → Executable file
View file

@ -6,10 +6,12 @@
*/
#include <stdarg.h>
#include <lib/log.h>
#include <lib/spinlock.h>
static int __logger_max_loglevel = 0;
static log_output_func __logger_outputs[16];
static int __logger_output_count = 0;
static spinlock_t __logger_lock;
static char* prelog[7] = {
"\033[38;2;169;68;66;mFAULT | \033[39m",
@ -41,6 +43,7 @@ void log(int loglevel, char *str, ...) {
if (loglevel > __logger_max_loglevel)
return; // The user does not want this type of log to show up.
sl_acquire(&__logger_lock);
va_list vl;
va_start(vl, str);
@ -50,4 +53,5 @@ void log(int loglevel, char *str, ...) {
}
va_end(vl);
sl_release(&__logger_lock);
}

0
kernel/src/lib/log.h Normal file → Executable file
View file

0
kernel/src/lib/logoutputs_sk.c Normal file → Executable file
View file

0
kernel/src/lib/logoutputs_sk.h Normal file → Executable file
View file

0
kernel/src/lib/npf.c Normal file → Executable file
View file

25
kernel/src/lib/spinlock.c Executable file
View file

@ -0,0 +1,25 @@
/*
* The Soaplin Kernel
* Copyright (C) 2025 The SILD Project
*
* spinlock.c - Spinlock implementation.
*/
#include <lib/spinlock.h>
void sl_acquire(spinlock_t volatile *plock)
{
while (!__sync_bool_compare_and_swap(plock, 0, 1))
{
while (*plock)
{
asm("pause");
}
}
}
void sl_release(spinlock_t volatile *plock)
{
__sync_lock_release(plock);
}

13
kernel/src/lib/spinlock.h Executable file
View file

@ -0,0 +1,13 @@
/*
* The Soaplin Kernel
* Copyright (C) 2025 The SILD Project
*
* spinlock.h - Spinlock definitions.
*/
#pragma once
typedef unsigned int spinlock_t;
void sl_acquire(spinlock_t volatile *plock);
void sl_release(spinlock_t volatile *plock);

0
kernel/src/lib/string.c Normal file → Executable file
View file

0
kernel/src/lib/string.h Normal file → Executable file
View file