This commit is contained in:
2025-12-15 13:20:58 +01:00
parent 7e02e20878
commit b064038c2d
9 changed files with 27 additions and 10 deletions

View File

@@ -10,6 +10,7 @@
#include "../debug/output.h"
#include "../object/bbuffer.h"
#include "epilogues.h"
#include "../debug/copystream.h"
//! \brief The protected data for the epilogue level
static Vault global_vault;

View File

@@ -12,17 +12,21 @@
#include "../thread/scheduler.h"
#include "../types.h"
#include "./epilogues.h"
#include "../device/serialstream.h"
//! \brief The epilogue vault contains the protected data for the epilogue level
struct Vault {
TextStream kout = TextStream(0, 80, 0, 17, true);
//TextStream dout = TextStream(0, 80, 17, 25);
//SerialStream sout;
Scheduler scheduler;
Bellringer bellringer;
BBuffer<Key, 16> keys;
Semaphore keys_sem;
static constexpr int MAX_SEMS =32;
Semaphore sems[MAX_SEMS];
static constexpr int MAX_SEMS =32;
Semaphore sems[MAX_SEMS];
// Ignore this for now, this is for a bonus task
Graphics graphics;

View File

@@ -1,18 +1,19 @@
#include "./arch/lapic.h"
#include "./debug/copystream.h"
#include "./debug/output.h"
#include "./device/serialstream.h"
#include "./types.h" // This is actually used
#include "arch/core_interrupt.h"
#include "syscall/handler.h"
SerialStream sout;
#include "./device/textstream.h"
#include "./debug/copystream.h"
#include "./device/serialstream.h"
// Separate title window on first line (for simplicity at scrolling)
static TextStream tout(0, CGA::COLUMNS, 0, 1);
SerialStream sout;
TextStream dout(0, 80, 17, 25);
CopyStream copystream(&dout, &sout);
OutputStream* copyout = &copystream;
@@ -23,8 +24,8 @@ OutputStream* copyout = &copystream;
#include "./interrupt/guard.h"
#include "./sync/semaphore.h"
#include "./thread/thread.h"
Semaphore koutsem(1);
TextStream kout(0, 80, 1, 17, true);
//Semaphore koutsem(1);
//TextStream kout(0, 80, 1, 17, true);
// Applications
#include "./user/app1/appl.h"

View File

@@ -20,7 +20,9 @@ syscall_entry:
cld
; Call the high-level (C++) system call handler
sti
call syscall_handler
cli
; Optional: Prevent kernel information leakage
; by zeroing scratch registers

View File

@@ -36,6 +36,8 @@ namespace Syscall {
* instruction pointer)
* \return system call return value
*/
extern "C" size_t syscall_handler(size_t sysnum, size_t p1, size_t p2,
size_t p3, size_t p4, size_t p5,
InterruptContext *user) {

View File

@@ -68,6 +68,7 @@ size_t read(Vault &vault, uint32_t id, void *buf, size_t len) {
size_t read_cnt = 0;
while(read_cnt <= len){
Key key;
vault.keys_sem.p(vault);
vault.keys.consume(key);
if(key.valid())
((char*)buf)[read_cnt++] = key.ascii();

View File

@@ -21,6 +21,8 @@ void IdleThread::action() {
}
Core::idle();
// We woke up. Start ticking again
dout << "idle ";
LAPIC::Timer::setMasked(false);
} else {
Core::Interrupt::enable();

View File

@@ -19,7 +19,7 @@
*/
class IdleThread : public Thread {
public:
explicit IdleThread() : Thread() {}
explicit IdleThread() : Thread(true) {}
/*! \brief Wait for a thread to become ready and sleep in the meantime.
*

View File

@@ -12,9 +12,13 @@ void Application::action() { // NOLINT
text[4] = 0x30+id;
for (unsigned i = 1;; ++i) {
write(0, text, sizeof(text));
if(i==id)
write(1, text, sizeof(text));
if(i==id){
write(2, "kill", 4);
write(2, &text[4], 1);
write(2, " ", 1);
sys_exit();
}
sleep(1000);
}
}