From d017412af5ebec7438fbc09d07ca2a560c273b6f Mon Sep 17 00:00:00 2001 From: RaphProductions <81994075+RaphProductions@users.noreply.github.com> Date: Sat, 17 May 2025 11:51:28 +0200 Subject: [PATCH] kmod: prepare for kernel module loading --- README.md | 8 ++++---- kernel/linker-x86_64.ld | 5 +++++ kernel/src/dbg/export.h | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 kernel/src/dbg/export.h diff --git a/README.md b/README.md index fa0230d..29cc83b 100755 --- a/README.md +++ b/README.md @@ -9,9 +9,12 @@ The Soaplin kernel is a new Unix-like operating system kernel. * ELF loader * ACPI * Symetric Multiprocessing (It runs code, but the scheduler is running on 1 processor.) +* Recovers from a faulty userspace process. + +## Nearly done +* Virtual File System ## In the works -* Virtual File System * FPU support ## To come @@ -21,9 +24,6 @@ The Soaplin kernel is a new Unix-like operating system kernel. * TAR-based init ram disk * Video driver for Bochs graphics adapter, and the VMware display adapter. -## Known bugs -* If a user process calls the syscall handler by using interrupts, the system may crash due to a Page Fault. - ## Building To build Soaplin, you must ensure you have these: * The Netwide Assembler (nasm) diff --git a/kernel/linker-x86_64.ld b/kernel/linker-x86_64.ld index 8fe5465..41c5989 100755 --- a/kernel/linker-x86_64.ld +++ b/kernel/linker-x86_64.ld @@ -57,6 +57,11 @@ SECTIONS .data : { data_start_ld = .; *(.data .data.*) + + /* Exported kernel symbols */ + __start_ksyms = .; + KEEP(*(.ksyms)) + __stop_ksyms = .; } :data /* NOTE: .bss needs to be the last thing mapped to :data, otherwise lots of */ diff --git a/kernel/src/dbg/export.h b/kernel/src/dbg/export.h new file mode 100644 index 0000000..39b9fa9 --- /dev/null +++ b/kernel/src/dbg/export.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +// At Soaplin, we aren't doing module racism based on the license. (Ḭ̸̡̢̨̧̨̛͍͚̙̺̦̩͕̮̙̙̳̮͉̝̙̜͓̪͇̠̪̣̻̰͕̲̲̘̖̦͖͕͎̲̹͖̮̳̻̞̌͋̋̆͛̉͆ ̸̨͕͎̣̥͖͔̳̫̳͚̯̬̙̘͓̹̼̻̼̈̓̉ͅͅs̶̟͉̠̣̞͎͍̘̟̝̱̩̃͛̽͛̆͌̆̒̔̈́̎̿̐̈́͐̓̓͒͌̈̀̓͗̋̕͜͜͝͠͝͠ͅȩ̸̡̛͔̦̲̦̼̹̙̲͖͎̼̝̯̦̞̜͍̀̈́̈́͂̈́̍́̆̆̔͗́̆̀͑̀̔͆̄͐͐̆͠ę̸̨̢̢̧̛̛͕̱̯̲̦͕͖̦̝̯̮̤̫͙͔̲̬̯̗̗͈̬̳̙͙̼͉̩͚̼̮͚̖̰̗̤͓̘͂̾̒͋̀͂̏́̂̋̅̆̋̈̔̈́̀̔̈́̊̓͂͌̋̂́̍̀͒͊͊̓͌̃̚͘͜͝͠ ̸̧̡̧͍̼̹͇̞̘͇̯̞̣̝̲̳̦̟̱͇̥͈̟̝̹̳̫͕̜̬̥̯̬̟̤̖̹̙̩̰̈͗͆͌̊̽̾͝͝ͅy̵̡̡̢̞̭͔̰͔͔̖̥͕̙̳̯͍͉̦̦͓̥̞̝͖͕̰̼͖̲̮͚̲̜̰̱̘̯̤̌́̏̄̏́̈́̓ͅỡ̵̢̢̢̖̠͉̖̺̻̣̜̬̮͓̫͎͖͎̤̪̝̗̰͕͍͖̖̟͙͍̻̑͊̃̃̒̍̆̎̋̿͐̋̉̇̾͆̿̌̃̏̽̊̀͒̇̏̓̾̏̈́̓̿̏̚͠͝͝͝ͅu̸̧͕̟͉͉͖̰̝͕̞̪̖͙͙̅̒̅̂̑́,̶̢̡̡̧̛̲̬̞̘̻̗̩̫̗͓̪̬͚̗̖͕̰̣͙͍̯͇̩̭͎̖̝̬̻͖̟̩̙̩̝͓̤́̄̆̍̂̈̊̄͆̽̑̑̊̓̋͐̔̉̍͌̏̀̿͘͜͜͜ͅͅ ̴̢̛̛͈͚̳̣̮̬̲̲͈̮͓̭̗̈́̽̄͌̾̒́̔̌̐̽͋̓̄̉̆̑̃́̏̉̔̓̂̽̊͆̽̎̍̈͑́̌͑̍̕͘͘͝͠ͅL̵̙̯̦̬̱͍̣̹̱̝̓̒i̵̢̨̨̧̨̛̗̲͍͇̖̥̯͔̙̪̱͓̝̦̼̭̬̟̞̩̭͙̐̐͊̒͑̊͌̽̂̉͊̈́̌͒̆̐͐͒̉̀́̑́̅͛͐̕̕͝͝ͅͅņ̵̛͓̲͆̏̃̊̒̇̑̑̾̽͊̃͌̔́̌̈́̈́͛͆̒̀̿̎͒̑̃̈́̈́͂͐͂̕̚̕͘͜͠͠ư̸̧̯̤̲͚͖̯͖͈̠̽̏̈́̄̀͒̐̅̽̋̓̂̑̋̽͒̄̑̇̈́̆̈͛͆̿̈̉͆͗͊̎͂̇̽̋̅͊̀̚̚͝ś̶̛̗̥͇̖̠͓͆̀̅̓̓͆͆̐́̄͛̃͑̔̑̒͒͋͂̂́͋͂́͗̐͆̐̕͝͝͠) + +typedef struct { + const char* name; + uint64_t addr; + uint64_t size; +} kernel_symbol_t; + +#define EXPORT_SYMBOL(sym) \ + static const kernel_symbol_t __ksym_##sym \ + __attribute__((section(".ksyms"), used)) = { \ + .name = #sym, \ + .addr = (uint64_t)&sym, \ + .size = sizeof(sym) \ + } + +extern const kernel_symbol_t __start_ksyms[]; +extern const kernel_symbol_t __stop_ksyms[];