Compare commits

...

5 Commits

Author SHA1 Message Date
Simon 7c1f380184 fixed really all bugs, for real 5 months ago
Simon 0a150eb84b fixed really all bugs 5 months ago
Simon c46cc8d1a2 fixed all bugs 5 months ago
Simon 893fc4bad9 added kout to vault 5 months ago
Eggert Jung 83e18391b7 rum 5 months ago

@ -122,10 +122,7 @@ bool fetch(Key &pressed) {
pressed = key_decoder.decode(out_buffer); pressed = key_decoder.decode(out_buffer);
if (pressed.alt() || pressed.ctrl() || !pressed.valid()) return true;
return false;
else
return true;
} }
void setRepeatRate(Speed speed, Delay delay) { void setRepeatRate(Speed speed, Delay delay) {

@ -20,7 +20,7 @@
* \ref TextWindow and only implements the method \ref TextStream::flush(). * \ref TextWindow and only implements the method \ref TextStream::flush().
* Further formatting or special effects are implemented in \ref TextWindow. * 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 // Prevent copies and assignments
TextStream(const TextStream&) = delete; TextStream(const TextStream&) = delete;
TextStream& operator=(const TextStream&) = delete; TextStream& operator=(const TextStream&) = delete;

@ -1,15 +1,16 @@
#include "epilogues.h" #include "epilogues.h"
#include "../debug/output.h"
#include "guard.h" #include "guard.h"
extern Key kout_key; extern Key kout_key;
extern TextStream kout;
namespace Epilogues { namespace Epilogues {
void keyboard(Vault& g) { void keyboard(Vault& g) {
(void)g; g.kout.setPos(0,0);
kout << kout_key.ascii() << endl << flush ; g.kout << kout_key.ascii() << flush ;
} }
void timer(Vault& g) { (void)g; } void timer(Vault& g) { (void)g; }

@ -18,48 +18,55 @@ static BBuffer<Epilogue, 32> epilogue_queue[Core::MAX] = {};
constinit Ticketlock global_lock; constinit Ticketlock global_lock;
constinit bool epi_flag[Core::MAX] = {false}; constinit bool epi_flag[Core::MAX] = {false};
Vault::Vault() {} Vault::Vault() {
}
Guarded::~Guarded() { Guard::leave(); } Guarded::~Guarded() { Guard::leave(); }
Guarded Guard::enter() { Guarded Guard::enter() {
epi_flag FOR_CURRENT_CORE = true; epi_flag FOR_CURRENT_CORE = true;
Core::Interrupt::enable(); //Core::Interrupt::enable();
global_lock.lock(); global_lock.lock();
return Guarded(global_vault); return Guarded(global_vault);
} }
void Guard::leave() { void Guard::leave() {
bool istate = Core::Interrupt::disable(); bool istate = Core::Interrupt::disable();
Epilogue next; Epilogue next;
global_lock.unlock();
while(epilogue_queue FOR_CURRENT_CORE.consume(next)){ while(epilogue_queue FOR_CURRENT_CORE.consume(next)){
Core::Interrupt::enable(); Core::Interrupt::enable();
global_lock.lock();
next(global_vault); next(global_vault);
global_lock.unlock();
Core::Interrupt::disable(); Core::Interrupt::disable();
} }
epi_flag FOR_CURRENT_CORE = false; epi_flag FOR_CURRENT_CORE = false;
global_lock.unlock();
Core::Interrupt::restore(istate); Core::Interrupt::restore(istate);
} }
void Guard::relay(Epilogue handler) { void Guard::relay(Epilogue handler) {
if(!epilogue_queue FOR_CURRENT_CORE.consume(handler)) //if(!epilogue_queue FOR_CURRENT_CORE.produce(handler))
return; // enqueue, but dont execute // 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){ if(epi_flag FOR_CURRENT_CORE){
enter(); epilogue_queue->produce(handler);
Core::Interrupt::disable(); }
else{
epi_flag FOR_CURRENT_CORE = true;
global_lock.lock();
handler(global_vault);
leave(); leave();
} }
//Core::Interrupt::enable(); // goto level 0.5 //epilogue_queue->consume(handler);
//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; }

@ -12,8 +12,9 @@
//! \brief The epilogue vault contains the protected data for the epilogue level //! \brief The epilogue vault contains the protected data for the epilogue level
struct Vault { struct Vault {
Vault(); Vault();
TextStream kout = TextStream(0, 80, 0, 10, true);
// no copy // no copy
//TextStream kout;
Vault(const Vault&) = delete; Vault(const Vault&) = delete;
Vault& operator=(const Vault&) = delete; Vault& operator=(const Vault&) = delete;
}; };

@ -73,22 +73,22 @@ enum PAGE_FAULT_ERROR {
kernelpanic("Page fault!"); kernelpanic("Page fault!");
} }
extern TextStream kout;
extern Ticketlock koutlock; extern Ticketlock koutlock;
extern Vault keyboard_vault; extern Vault keyboard_vault;
void handle_keyboard() { void handle_keyboard() {
//Key key = Key(); //Key key = Key();
if (PS2Controller::fetch(kout_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(); //koutlock.lock();
//kout << key.ascii() << endl << flush ; //kout << key.ascii() << endl << flush ;
//koutlock.unlock(); //koutlock.unlock();
} }
else if (kout_key.ctrl() && kout_key.alt() && kout_key.scancode == Key::KEY_DEL) else
System::reboot(); LAPIC::endOfInterrupt();
LAPIC::endOfInterrupt();
} }
[[gnu::interrupt]] void handle_panic(InterruptContext *context) { [[gnu::interrupt]] void handle_panic(InterruptContext *context) {

@ -16,7 +16,7 @@
#include "sync/ticketlock.h" #include "sync/ticketlock.h"
#include "interrupt/guard.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;
//TextStream dout[8] = { //TextStream dout[8] = {
@ -71,23 +71,6 @@ extern "C" int main() {
CGA::setCursor(0, 0); CGA::setCursor(0, 0);
unsigned int numCPUs = Core::count(); 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 /* Start application processors
* To avoid unexpected behaviour, make sure that interrupts are not * To avoid unexpected behaviour, make sure that interrupts are not
* enabled before the APs are booted. Otherwise it might interfere with the * enabled before the APs are booted. Otherwise it might interfere with the
@ -110,8 +93,8 @@ extern "C" int main() {
Application{}.action(); Application{}.action();
while (true){ while (true){
DBG << "pos: " << testx << ", " << testy << endl << flush; //DBG << "pos: " << testx << ", " << testy << endl << flush;
Core::pause(); //Core::pause();
} }
return 0; return 0;

@ -1,4 +1,5 @@
#include "sync/ticketlock.h" #include "sync/ticketlock.h"
#include "debug/output.h"
void Ticketlock::lock() { void Ticketlock::lock() {
uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_RELAXED); uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_RELAXED);
@ -8,5 +9,7 @@ void Ticketlock::lock() {
} }
void Ticketlock::unlock() { 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 # Test your system on real hardware
NETBOOT_LOCAL="/ibr/adm/user-boot/" 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. # 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. # We just need to choose a name that doesn't overlap with another user's.

@ -7,7 +7,7 @@
#include "../../sync/ticketlock.h" #include "../../sync/ticketlock.h"
#include "../../arch/core.h" #include "../../arch/core.h"
#include "../../interrupt/guard.h" #include "../../interrupt/guard.h"
#include "../../debug/output.h"
char text[] = "Ich mag\n\ char text[] = "Ich mag\n\
Saftige Pflaumen voller Aroma\n\ Saftige Pflaumen voller Aroma\n\
Ich knuddel jede Oma ins Koma\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\ Und wacht sie aus'm Koma auf, kriegt sie von mir 'n Sticker\n\
\n"; \n";
extern TextStream kout;
extern Ticketlock koutlock; extern Ticketlock koutlock;
void activeWaitDelay(uint64_t cycles) { void activeWaitDelay(uint64_t cycles) {
@ -37,16 +36,19 @@ void Application::action() { // NOLINT
uint16_t cnt = 0; uint16_t cnt = 0;
while (1) { while (1) {
//koutlock.lock(); //koutlock.lock();
{
Guarded g = Guard::enter(); Guarded g = Guard::enter();
//g.vault(); //g.vault();
while(text[cnt++] != '\n'){ g.vault().kout.setPos((unsigned)0,(unsigned)Core::getID()*2+1);
kout << text[cnt-1];
} g.vault().kout << cnt++ << flush;
kout << endl << flush;
Guard::leave(); //g.vault().kout << endl << flush;
//Guard::leave();
//koutlock.unlock(); //koutlock.unlock();
}
activeWaitDelay(1000000000); Core::pause();
//activeWaitDelay(1000000000);
if(cnt >= sizeof(text)-1) if(cnt >= sizeof(text)-1)
cnt=0; cnt=0;

Loading…
Cancel
Save