syscall test

This commit is contained in:
2025-11-26 08:24:31 +01:00
parent 3808f494af
commit da3f961edb
6 changed files with 51 additions and 28 deletions

View File

@@ -72,6 +72,8 @@ enum class Vector : uint8_t {
PANIC = 99, ///< Panic interrupt to stop CPU (default value for \ref IOAPIC PANIC = 99, ///< Panic interrupt to stop CPU (default value for \ref IOAPIC
///< devices) ///< devices)
TIMER = 32, ///< Periodic CPU local \ref LAPIC::Timer interrupt TIMER = 32, ///< Periodic CPU local \ref LAPIC::Timer interrupt
SYSCALL = 0x80
}; };
constexpr size_t VECTORS = 256; constexpr size_t VECTORS = 256;

View File

@@ -5,6 +5,7 @@
#include "./device/serialstream.h" #include "./device/serialstream.h"
#include "./types.h" // This is actually used #include "./types.h" // This is actually used
#include "arch/core_interrupt.h" #include "arch/core_interrupt.h"
#include "syscall/handler.h"
SerialStream sout; SerialStream sout;
#include "./device/textstream.h" #include "./device/textstream.h"
@@ -53,6 +54,8 @@ extern "C" int main() {
// Activate Keyboard // Activate Keyboard
PS2Controller::init(); PS2Controller::init();
Syscall::init();
// Enter Level 1/2 // Enter Level 1/2
Guarded g = Guard::enter(); Guarded g = Guard::enter();
@@ -73,7 +76,7 @@ extern "C" int main() {
* Therefore activate the LAPIC timer in level 1/2 after initialization * Therefore activate the LAPIC timer in level 1/2 after initialization
* (just before schedule()) * (just before schedule())
*/ */
LAPIC::Timer::activate(); //LAPIC::Timer::activate();
DBG_VERBOSE << "Schedule..." << endl; DBG_VERBOSE << "Schedule..." << endl;
// Schedule first app // Schedule first app

View File

@@ -1,14 +1,14 @@
#include "syscall/handler.h" #include "syscall/handler.h"
#include "arch/core.h" #include "../arch/core.h"
#include "arch/core_interrupt.h" #include "../arch/core_interrupt.h"
#include "arch/gdt.h" #include "../arch/gdt.h"
#include "arch/idt.h" #include "../arch/idt.h"
#include "debug/kernelpanic.h" #include "../debug/kernelpanic.h"
#include "debug/output.h" #include "../debug/output.h"
#include "interrupt/guard.h" #include "../interrupt/guard.h"
#include "syscall/skeleton.h" #include "../syscall/skeleton.h"
#include "syscall/stub.h" #include "../syscall/stub.h"
#include "types.h" #include "types.h"
/*! \brief Interrupt based system call entry function /*! \brief Interrupt based system call entry function
@@ -46,11 +46,22 @@ extern "C" size_t syscall_handler(size_t sysnum, size_t p1, size_t p2,
(void)p5; (void)p5;
(void)sysnum; (void)sysnum;
(void)user; (void)user;
switch ((Syscall::ID)sysnum) {
case Syscall::ID::TEST:
Syscall::Skeleton::test(Guard::enter().vault(), p1, p2, p3, p4, p5);
break;
case Syscall::ID::WRITE:
break;
}
return static_cast<size_t>(-1); return static_cast<size_t>(-1);
} }
void init() { void init() {
// Set interrupt based syscall handler // Set interrupt based syscall handler
IDT::set(Core::Interrupt::Vector::SYSCALL, IDT::InterruptDescriptor::Returning(syscall_entry, 0, IDT::DPL_USER));
IDT::load();
} }
} // namespace Syscall } // namespace Syscall

View File

@@ -6,5 +6,7 @@
align 8 align 8
sys_call: sys_call:
; BSB2 1 - Syscall stub ; BSB2 1 - Syscall stub
int 0x80
ret

View File

@@ -7,6 +7,7 @@ namespace Syscall {
*/ */
enum class ID : size_t { enum class ID : size_t {
TEST = 0, TEST = 0,
WRITE = 1,
}; };
} // namespace Syscall } // namespace Syscall

View File

@@ -1,6 +1,7 @@
// vim: set noet ts=4 sw=4: // vim: set noet ts=4 sw=4:
#include "appl.h" #include "appl.h"
#include "../../syscall/stub.h"
#include "../../arch/core.h" #include "../../arch/core.h"
#include "../../arch/system.h" #include "../../arch/system.h"
@@ -16,26 +17,29 @@ extern Application apps[];
void Application::action() { // NOLINT void Application::action() { // NOLINT
// Thread 1 may be an auxiliary thread // Thread 1 may be an auxiliary thread
sys_test(1,2,3,4,5);
unsigned id = 0; unsigned id = 0;
while (&apps[id++] != this); while (&apps[id++] != this);
for (unsigned i = 0;; ++i) { for (unsigned i = 0;; ++i) {
// Make sure that we can use kout exclusively due to the hardware cursor //// Make sure that we can use kout exclusively due to the hardware cursor
// otherwise we'd get a word jumble //// otherwise we'd get a word jumble
koutsem.p(Guard::enter().vault()); //koutsem.p(Guard::enter().vault());
kout.setPos(0U, id); //kout.setPos(0U, id);
kout << i; //kout << i;
kout.flush(); //kout.flush();
koutsem.v(Guard::enter().vault()); //koutsem.v(Guard::enter().vault());
// XXX: Doing this (the first time) in TASK 16 breaks all scheduling //// XXX: Doing this (the first time) in TASK 16 breaks all scheduling
if (i == 10000) { //if (i == 10000) {
if (id % 2 == 1) { // if (id % 2 == 1) {
Guard::enter().vault().scheduler.kill(&apps[id - 1]); // Guard::enter().vault().scheduler.kill(&apps[id - 1]);
} // }
} //}
Guard::enter().vault().scheduler.resume(); //Guard::enter().vault().scheduler.resume();
if (id > 1) { //if (id > 1) {
Guarded g = Guard::enter(); // Guarded g = Guard::enter();
g.vault().bellringer.sleep(g.vault(), id * id * 10); // g.vault().bellringer.sleep(g.vault(), id * id * 10);
} //}
} }
} }