Compare commits
5 Commits
c4d7ca3cf0
...
7c1f380184
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c1f380184 | ||
|
|
0a150eb84b | ||
|
|
c46cc8d1a2 | ||
|
|
893fc4bad9 | ||
|
|
83e18391b7 |
@@ -122,10 +122,7 @@ bool fetch(Key &pressed) {
|
||||
|
||||
pressed = key_decoder.decode(out_buffer);
|
||||
|
||||
if (pressed.alt() || pressed.ctrl() || !pressed.valid())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void setRepeatRate(Speed speed, Delay delay) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* \ref TextWindow and only implements the method \ref TextStream::flush().
|
||||
* Further formatting or special effects are implemented in \ref TextWindow.
|
||||
*/
|
||||
class TextStream: public OutputStream, protected TextWindow {
|
||||
class TextStream: public OutputStream, public TextWindow {
|
||||
// Prevent copies and assignments
|
||||
TextStream(const TextStream&) = delete;
|
||||
TextStream& operator=(const TextStream&) = delete;
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#include "epilogues.h"
|
||||
|
||||
#include "../debug/output.h"
|
||||
#include "guard.h"
|
||||
|
||||
extern Key kout_key;
|
||||
extern TextStream kout;
|
||||
|
||||
namespace Epilogues {
|
||||
|
||||
void keyboard(Vault& g) {
|
||||
(void)g;
|
||||
kout << kout_key.ascii() << endl << flush ;
|
||||
g.kout.setPos(0,0);
|
||||
g.kout << kout_key.ascii() << flush ;
|
||||
|
||||
}
|
||||
|
||||
void timer(Vault& g) { (void)g; }
|
||||
|
||||
@@ -18,48 +18,55 @@ static BBuffer<Epilogue, 32> epilogue_queue[Core::MAX] = {};
|
||||
constinit Ticketlock global_lock;
|
||||
constinit bool epi_flag[Core::MAX] = {false};
|
||||
|
||||
Vault::Vault() {}
|
||||
Vault::Vault() {
|
||||
}
|
||||
|
||||
Guarded::~Guarded() { Guard::leave(); }
|
||||
|
||||
Guarded Guard::enter() {
|
||||
epi_flag FOR_CURRENT_CORE = true;
|
||||
Core::Interrupt::enable();
|
||||
//Core::Interrupt::enable();
|
||||
global_lock.lock();
|
||||
return Guarded(global_vault);
|
||||
}
|
||||
|
||||
void Guard::leave() {
|
||||
bool istate = Core::Interrupt::disable();
|
||||
|
||||
|
||||
Epilogue next;
|
||||
global_lock.unlock();
|
||||
while(epilogue_queue FOR_CURRENT_CORE.consume(next)){
|
||||
Core::Interrupt::enable();
|
||||
global_lock.lock();
|
||||
next(global_vault);
|
||||
global_lock.unlock();
|
||||
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(!epilogue_queue FOR_CURRENT_CORE.produce(handler))
|
||||
// return; // enqueue, but dont execute
|
||||
//if(!epi_flag FOR_CURRENT_CORE){
|
||||
// enter();
|
||||
// Core::Interrupt::enable();
|
||||
// handler(global_vault);
|
||||
// leave();
|
||||
//}
|
||||
|
||||
Core::Interrupt::enable(); // goto level 0.5
|
||||
if(epi_flag FOR_CURRENT_CORE){
|
||||
enter();
|
||||
Core::Interrupt::disable();
|
||||
epilogue_queue->produce(handler);
|
||||
}
|
||||
else{
|
||||
epi_flag FOR_CURRENT_CORE = true;
|
||||
global_lock.lock();
|
||||
handler(global_vault);
|
||||
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
|
||||
//}
|
||||
//epilogue_queue->consume(handler);
|
||||
|
||||
}
|
||||
|
||||
const Vault &Guard::unsafeConstAccess() { return global_vault; }
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
//! \brief The epilogue vault contains the protected data for the epilogue level
|
||||
struct Vault {
|
||||
Vault();
|
||||
TextStream kout = TextStream(0, 80, 0, 10, true);
|
||||
|
||||
// no copy
|
||||
//TextStream kout;
|
||||
Vault(const Vault&) = delete;
|
||||
Vault& operator=(const Vault&) = delete;
|
||||
};
|
||||
|
||||
@@ -73,22 +73,22 @@ enum PAGE_FAULT_ERROR {
|
||||
kernelpanic("Page fault!");
|
||||
}
|
||||
|
||||
extern TextStream kout;
|
||||
extern Ticketlock koutlock;
|
||||
extern Vault keyboard_vault;
|
||||
|
||||
void handle_keyboard() {
|
||||
//Key key = Key();
|
||||
if (PS2Controller::fetch(kout_key)) {
|
||||
Guard::relay(Epilogues::keyboard);
|
||||
LAPIC::endOfInterrupt();
|
||||
if (kout_key.ctrl() && kout_key.alt() && kout_key.scancode == Key::KEY_DEL)
|
||||
System::reboot();
|
||||
Guard::relay(Epilogues::keyboard);
|
||||
//koutlock.lock();
|
||||
//kout << key.ascii() << endl << flush ;
|
||||
//koutlock.unlock();
|
||||
}
|
||||
else if (kout_key.ctrl() && kout_key.alt() && kout_key.scancode == Key::KEY_DEL)
|
||||
System::reboot();
|
||||
|
||||
LAPIC::endOfInterrupt();
|
||||
else
|
||||
LAPIC::endOfInterrupt();
|
||||
}
|
||||
|
||||
[[gnu::interrupt]] void handle_panic(InterruptContext *context) {
|
||||
|
||||
23
main.cc
23
main.cc
@@ -16,7 +16,7 @@
|
||||
#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;
|
||||
|
||||
//TextStream dout[8] = {
|
||||
@@ -71,23 +71,6 @@ extern "C" int main() {
|
||||
CGA::setCursor(0, 0);
|
||||
|
||||
unsigned int numCPUs = Core::count();
|
||||
DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl;
|
||||
|
||||
kout << "Test <stream result> -> <expected>" << endl;
|
||||
kout << "bool: " << true << " -> true" << endl;
|
||||
kout << "zero: " << 0 << " -> 0" << endl;
|
||||
kout << "binary: " << bin << 42 << dec << " -> 0b101010" << endl;
|
||||
kout << "octal: " << oct << 42 << dec << " -> 052" << endl;
|
||||
kout << "hex: " << hex << 42 << dec << " -> 0x2a" << endl;
|
||||
kout << "uint64_t max: " << ~((uint64_t)0) << " -> 18446744073709551615" << endl;
|
||||
kout << "int64_t max: " << ~(1ll<<63) << " -> 9223372036854775807" << endl;
|
||||
kout << "int64_t min: " << (1ll<<63) << " -> -9223372036854775808" << endl;
|
||||
kout << "some int64_t: " << (-1234567890123456789) << " -> -1234567890123456789" << endl;
|
||||
kout << "some int64_t: " << (1234567890123456789) << " -> 1234567890123456789" << endl;
|
||||
kout << "pointer: " << reinterpret_cast<void*>(1994473406541717165ull)
|
||||
<< " -> 0x1badcafefee1dead" << endl;
|
||||
kout << "smiley: " << static_cast<char>(1) << endl;
|
||||
|
||||
/* Start application processors
|
||||
* To avoid unexpected behaviour, make sure that interrupts are not
|
||||
* enabled before the APs are booted. Otherwise it might interfere with the
|
||||
@@ -110,8 +93,8 @@ extern "C" int main() {
|
||||
|
||||
Application{}.action();
|
||||
while (true){
|
||||
DBG << "pos: " << testx << ", " << testy << endl << flush;
|
||||
Core::pause();
|
||||
//DBG << "pos: " << testx << ", " << testy << endl << flush;
|
||||
//Core::pause();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "sync/ticketlock.h"
|
||||
#include "debug/output.h"
|
||||
|
||||
void Ticketlock::lock() {
|
||||
uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_RELAXED);
|
||||
@@ -8,5 +9,7 @@ void Ticketlock::lock() {
|
||||
}
|
||||
|
||||
void Ticketlock::unlock() {
|
||||
__atomic_fetch_add(&ticket_current, 1, __ATOMIC_RELEASE);
|
||||
if(ticket_current != ticket_count){
|
||||
__atomic_fetch_add(&ticket_current, 1, __ATOMIC_RELEASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Test your system on real hardware
|
||||
|
||||
NETBOOT_LOCAL="/ibr/adm/user-boot/"
|
||||
NETBOOT_HOST="y0085044@x1.ibr.cs.tu-bs.de"
|
||||
NETBOOT_HOST="y0080589@x1.ibr.cs.tu-bs.de"
|
||||
|
||||
# The boot menu shows pairs of `vmlinuz-*` + `initrd-*.img` with owning user and timestamp.
|
||||
# We just need to choose a name that doesn't overlap with another user's.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../../sync/ticketlock.h"
|
||||
#include "../../arch/core.h"
|
||||
#include "../../interrupt/guard.h"
|
||||
|
||||
#include "../../debug/output.h"
|
||||
char text[] = "Ich mag\n\
|
||||
Saftige Pflaumen voller Aroma\n\
|
||||
Ich knuddel jede Oma ins Koma\n\
|
||||
@@ -21,7 +21,6 @@ Ich bin Großmuttersniffer\n\
|
||||
Und wacht sie aus'm Koma auf, kriegt sie von mir 'n Sticker\n\
|
||||
\n";
|
||||
|
||||
extern TextStream kout;
|
||||
extern Ticketlock koutlock;
|
||||
|
||||
void activeWaitDelay(uint64_t cycles) {
|
||||
@@ -37,16 +36,19 @@ void Application::action() { // NOLINT
|
||||
uint16_t cnt = 0;
|
||||
while (1) {
|
||||
//koutlock.lock();
|
||||
{
|
||||
Guarded g = Guard::enter();
|
||||
//g.vault();
|
||||
while(text[cnt++] != '\n'){
|
||||
kout << text[cnt-1];
|
||||
}
|
||||
kout << endl << flush;
|
||||
Guard::leave();
|
||||
g.vault().kout.setPos((unsigned)0,(unsigned)Core::getID()*2+1);
|
||||
|
||||
g.vault().kout << cnt++ << flush;
|
||||
|
||||
//g.vault().kout << endl << flush;
|
||||
//Guard::leave();
|
||||
//koutlock.unlock();
|
||||
|
||||
activeWaitDelay(1000000000);
|
||||
}
|
||||
Core::pause();
|
||||
//activeWaitDelay(1000000000);
|
||||
if(cnt >= sizeof(text)-1)
|
||||
cnt=0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user