wip aufg 3
This commit is contained in:
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
namespace Epilogues {
|
namespace Epilogues {
|
||||||
|
|
||||||
void keyboard(Vault& g) { (void)g; }
|
void keyboard(Vault& g) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void timer(Vault& g) { (void)g; }
|
void timer(Vault& g) { (void)g; }
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../debug/output.h"
|
#include "../debug/output.h"
|
||||||
#include "../object/bbuffer.h"
|
#include "../object/bbuffer.h"
|
||||||
#include "../sync/ticketlock.h"
|
#include "../sync/ticketlock.h"
|
||||||
|
#include "../arch/core_interrupt.h"
|
||||||
#include "epilogues.h"
|
#include "epilogues.h"
|
||||||
|
|
||||||
#define FOR_CURRENT_CORE [Core::getID()]
|
#define FOR_CURRENT_CORE [Core::getID()]
|
||||||
@@ -21,10 +22,45 @@ Vault::Vault() {}
|
|||||||
|
|
||||||
Guarded::~Guarded() { Guard::leave(); }
|
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; }
|
const Vault &Guard::unsafeConstAccess() { return global_vault; }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "../device/ps2controller.h"
|
#include "../device/ps2controller.h"
|
||||||
|
|
||||||
#include "../sync/ticketlock.h"
|
#include "../sync/ticketlock.h"
|
||||||
|
#include "epilogues.h"
|
||||||
|
#include "guard.h"
|
||||||
|
|
||||||
void printContext(const InterruptContext *context) {
|
void printContext(const InterruptContext *context) {
|
||||||
DBG << "ip: " << hex << context->cs << ':' << context->ip
|
DBG << "ip: " << hex << context->cs << ':' << context->ip
|
||||||
@@ -71,12 +73,14 @@ enum PAGE_FAULT_ERROR {
|
|||||||
|
|
||||||
extern TextStream kout;
|
extern TextStream kout;
|
||||||
extern Ticketlock koutlock;
|
extern Ticketlock koutlock;
|
||||||
|
extern Vault keyboard_vault;
|
||||||
void handle_keyboard() {
|
void handle_keyboard() {
|
||||||
Key key = Key();
|
Key key = Key();
|
||||||
if (PS2Controller::fetch(key)) {
|
if (PS2Controller::fetch(key)) {
|
||||||
koutlock.lock();
|
Guard::relay(Epilogues::keyboard);
|
||||||
kout << key.ascii() << endl << flush ;
|
//koutlock.lock();
|
||||||
koutlock.unlock();
|
//kout << key.ascii() << endl << flush ;
|
||||||
|
//koutlock.unlock();
|
||||||
}
|
}
|
||||||
else if (key.ctrl() && key.alt() && key.scancode == Key::KEY_DEL)
|
else if (key.ctrl() && key.alt() && key.scancode == Key::KEY_DEL)
|
||||||
System::reboot();
|
System::reboot();
|
||||||
|
|||||||
1
main.cc
1
main.cc
@@ -14,6 +14,7 @@
|
|||||||
#include "arch/ioapic.h"
|
#include "arch/ioapic.h"
|
||||||
#include "user/app1/appl.h"
|
#include "user/app1/appl.h"
|
||||||
#include "sync/ticketlock.h"
|
#include "sync/ticketlock.h"
|
||||||
|
#include "interrupt/guard.h"
|
||||||
|
|
||||||
TextStream kout = TextStream(0, 80, 0, 10, true);
|
TextStream kout = TextStream(0, 80, 0, 10, true);
|
||||||
Ticketlock koutlock;
|
Ticketlock koutlock;
|
||||||
|
|||||||
Reference in New Issue
Block a user