wip aufg 3
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
|
||||
namespace Epilogues {
|
||||
|
||||
void keyboard(Vault& g) { (void)g; }
|
||||
void keyboard(Vault& g) {
|
||||
|
||||
}
|
||||
|
||||
void timer(Vault& g) { (void)g; }
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../debug/output.h"
|
||||
#include "../object/bbuffer.h"
|
||||
#include "../sync/ticketlock.h"
|
||||
#include "../arch/core_interrupt.h"
|
||||
#include "epilogues.h"
|
||||
|
||||
#define FOR_CURRENT_CORE [Core::getID()]
|
||||
@@ -21,10 +22,45 @@ Vault::Vault() {}
|
||||
|
||||
Guarded::~Guarded() { Guard::leave(); }
|
||||
|
||||
Guarded Guard::enter() { while (true); }
|
||||
Guarded Guard::enter() {
|
||||
epi_flag FOR_CURRENT_CORE = true;
|
||||
Core::Interrupt::enable();
|
||||
global_lock.lock();
|
||||
}
|
||||
|
||||
void Guard::leave() {}
|
||||
void Guard::leave() {
|
||||
bool istate = Core::Interrupt::disable();
|
||||
|
||||
void Guard::relay(Epilogue handler) { (void)handler; }
|
||||
Epilogue next;
|
||||
while(epilogue_queue FOR_CURRENT_CORE.consume(next)){
|
||||
Core::Interrupt::enable();
|
||||
next(global_vault);
|
||||
Core::Interrupt::disable();
|
||||
}
|
||||
epi_flag FOR_CURRENT_CORE = false;
|
||||
global_lock.unlock();
|
||||
Core::Interrupt::restore(istate);
|
||||
}
|
||||
|
||||
void Guard::relay(Epilogue handler) {
|
||||
if(!epilogue_queue FOR_CURRENT_CORE.consume(handler))
|
||||
return; // enqueue, but dont execute
|
||||
if(epi_flag FOR_CURRENT_CORE){
|
||||
enter();
|
||||
Core::Interrupt::disable();
|
||||
leave();
|
||||
}
|
||||
//Core::Interrupt::enable(); // goto level 0.5
|
||||
//if(epi_flag FOR_CURRENT_CORE){
|
||||
// epilogue_queue->produce(handler);
|
||||
//}
|
||||
//else{
|
||||
// epi_flag FOR_CURRENT_CORE = true;
|
||||
// handler(global_vault);
|
||||
// leave(); // maybe not needed since destructor also calls leave
|
||||
//}
|
||||
}
|
||||
|
||||
const Vault &Guard::unsafeConstAccess() { return global_vault; }
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "../device/ps2controller.h"
|
||||
|
||||
#include "../sync/ticketlock.h"
|
||||
#include "epilogues.h"
|
||||
#include "guard.h"
|
||||
|
||||
void printContext(const InterruptContext *context) {
|
||||
DBG << "ip: " << hex << context->cs << ':' << context->ip
|
||||
@@ -71,12 +73,14 @@ enum PAGE_FAULT_ERROR {
|
||||
|
||||
extern TextStream kout;
|
||||
extern Ticketlock koutlock;
|
||||
extern Vault keyboard_vault;
|
||||
void handle_keyboard() {
|
||||
Key key = Key();
|
||||
if (PS2Controller::fetch(key)) {
|
||||
koutlock.lock();
|
||||
kout << key.ascii() << endl << flush ;
|
||||
koutlock.unlock();
|
||||
Guard::relay(Epilogues::keyboard);
|
||||
//koutlock.lock();
|
||||
//kout << key.ascii() << endl << flush ;
|
||||
//koutlock.unlock();
|
||||
}
|
||||
else if (key.ctrl() && key.alt() && key.scancode == Key::KEY_DEL)
|
||||
System::reboot();
|
||||
|
||||
Reference in New Issue
Block a user