diff --git a/c_os/devices/CGA_Stream.h b/c_os/devices/CGA_Stream.h index faebb28..21b7264 100755 --- a/c_os/devices/CGA_Stream.h +++ b/c_os/devices/CGA_Stream.h @@ -58,6 +58,8 @@ public: pos = 0; } + // CAn't make singleton because atexit + // ~CGA_Stream() override = default; void lock() { sem.p(); } diff --git a/c_os/devices/PCSPK.h b/c_os/devices/PCSPK.h index d71e220..cf49085 100755 --- a/c_os/devices/PCSPK.h +++ b/c_os/devices/PCSPK.h @@ -73,9 +73,11 @@ public: // Konstruktor. Initialisieren der Ports. PCSPK() = default; + // Can't make singleton because atexit + // Demo Sounds - void tetris(); - void aerodynamic(); + static void tetris(); + static void aerodynamic(); // Ton abspielen static void play(float f, int len); diff --git a/c_os/devices/VESA.h b/c_os/devices/VESA.h index e0bbebf..4272bf5 100644 --- a/c_os/devices/VESA.h +++ b/c_os/devices/VESA.h @@ -32,6 +32,8 @@ public: VESA() : log("VESA") {} + // Can't make singleton because atexit + // Bestimmten Grafikmodus einschalten bool initGraphicMode(unsigned short mode); static void initTextMode(); diff --git a/c_os/kernel/BIOS.h b/c_os/kernel/BIOS.h index 6d9e4e4..608df36 100644 --- a/c_os/kernel/BIOS.h +++ b/c_os/kernel/BIOS.h @@ -34,11 +34,17 @@ struct BIOScall_params { extern BIOScall_params* BC_params; class BIOS { +private: + // Initialisierung: manuelles Anlegen einer Funktion + BIOS(); + public: BIOS(const BIOS& copy) = delete; // Verhindere Kopieren - // Initialisierung: manuelles Anlegen einer Funktion - BIOS(); + static BIOS& instance() { + static BIOS bios; + return bios; + } // BIOS-Aufruf, per Software-Interrupt static void Int(int inter); diff --git a/c_os/kernel/Globals.cc b/c_os/kernel/Globals.cc index 68e3de8..9071279 100755 --- a/c_os/kernel/Globals.cc +++ b/c_os/kernel/Globals.cc @@ -11,7 +11,7 @@ #include "kernel/Globals.h" CGA_Stream kout; // Ausgabe-Strom fuer Kernel -BIOS bios; // Schnittstelle zum 16-Bit BIOS +const BIOS& bios = BIOS::instance(); // Schnittstelle zum 16-Bit BIOS VESA vesa; // VESA-Treiber PIC pic; // Interrupt-Controller diff --git a/c_os/kernel/Globals.h b/c_os/kernel/Globals.h index b13374d..77fa40e 100755 --- a/c_os/kernel/Globals.h +++ b/c_os/kernel/Globals.h @@ -30,7 +30,7 @@ // I wanted to make more of these singletons but there were problems with atexit missing because of nostdlib I guess extern CGA_Stream kout; // Ausgabe-Strom fuer Kernel -extern BIOS bios; // Schnittstelle zum 16-Bit BIOS +extern const BIOS& bios; // Schnittstelle zum 16-Bit BIOS extern VESA vesa; // VESA-Treiber extern PIC pic; // Interrupt-Controller diff --git a/c_os/kernel/interrupts/PIC.h b/c_os/kernel/interrupts/PIC.h index af96c88..9838e5d 100755 --- a/c_os/kernel/interrupts/PIC.h +++ b/c_os/kernel/interrupts/PIC.h @@ -29,6 +29,8 @@ public: PIC() = default; + // Can't make static because atexit + // IRQ-Nummern von Geraeten enum { timer = 0, // Programmable Interrupt Timer (PIT) diff --git a/c_os/user/demo/PCSPKdemo.cc b/c_os/user/demo/PCSPKdemo.cc index 6c2eb22..4792008 100644 --- a/c_os/user/demo/PCSPKdemo.cc +++ b/c_os/user/demo/PCSPKdemo.cc @@ -6,7 +6,7 @@ void PCSPKdemo::run() { kout << "Playing..." << endl; kout.unlock(); - (pcspk.*melody)(); // This syntax is confusing as hell + (*melody)(); // This syntax is confusing as hell kout.lock(); kout << "Finished" << endl; diff --git a/c_os/user/demo/PCSPKdemo.h b/c_os/user/demo/PCSPKdemo.h index 9635e00..7c4da26 100644 --- a/c_os/user/demo/PCSPKdemo.h +++ b/c_os/user/demo/PCSPKdemo.h @@ -6,12 +6,12 @@ class PCSPKdemo : public Thread { private: - void (PCSPK::*melody)(); // Allow to pass a melody to play when initializing the demo + void (*melody)(); // Allow to pass a melody to play when initializing the demo public: PCSPKdemo(const PCSPKdemo& copy) = delete; - explicit PCSPKdemo(void (PCSPK::*melody)()) : Thread("PCSPKdemo"), melody(melody) {} + PCSPKdemo(void (*melody)()) : Thread("PCSPKdemo"), melody(melody) {} ~PCSPKdemo() override { PCSPK::off(); diff --git a/c_os/user/devices/SerialOut.h b/c_os/user/devices/SerialOut.h index f71e785..822a296 100644 --- a/c_os/user/devices/SerialOut.h +++ b/c_os/user/devices/SerialOut.h @@ -14,8 +14,10 @@ private: static int is_transmit_empty(); public: - SerialOut(const SerialOut& copy) = delete; SerialOut(); + SerialOut(const SerialOut& copy) = delete; + + // Can't make singleton because atexit static char read(); static void write(char a);