1

final cleanup

This commit is contained in:
2022-07-24 23:13:12 +02:00
parent f711e41216
commit d04f4495ae
10 changed files with 26 additions and 10 deletions

View File

@ -58,6 +58,8 @@ public:
pos = 0; pos = 0;
} }
// CAn't make singleton because atexit
// ~CGA_Stream() override = default; // ~CGA_Stream() override = default;
void lock() { sem.p(); } void lock() { sem.p(); }

View File

@ -73,9 +73,11 @@ public:
// Konstruktor. Initialisieren der Ports. // Konstruktor. Initialisieren der Ports.
PCSPK() = default; PCSPK() = default;
// Can't make singleton because atexit
// Demo Sounds // Demo Sounds
void tetris(); static void tetris();
void aerodynamic(); static void aerodynamic();
// Ton abspielen // Ton abspielen
static void play(float f, int len); static void play(float f, int len);

View File

@ -32,6 +32,8 @@ public:
VESA() : log("VESA") {} VESA() : log("VESA") {}
// Can't make singleton because atexit
// Bestimmten Grafikmodus einschalten // Bestimmten Grafikmodus einschalten
bool initGraphicMode(unsigned short mode); bool initGraphicMode(unsigned short mode);
static void initTextMode(); static void initTextMode();

View File

@ -34,11 +34,17 @@ struct BIOScall_params {
extern BIOScall_params* BC_params; extern BIOScall_params* BC_params;
class BIOS { class BIOS {
private:
// Initialisierung: manuelles Anlegen einer Funktion
BIOS();
public: public:
BIOS(const BIOS& copy) = delete; // Verhindere Kopieren BIOS(const BIOS& copy) = delete; // Verhindere Kopieren
// Initialisierung: manuelles Anlegen einer Funktion static BIOS& instance() {
BIOS(); static BIOS bios;
return bios;
}
// BIOS-Aufruf, per Software-Interrupt // BIOS-Aufruf, per Software-Interrupt
static void Int(int inter); static void Int(int inter);

View File

@ -11,7 +11,7 @@
#include "kernel/Globals.h" #include "kernel/Globals.h"
CGA_Stream kout; // Ausgabe-Strom fuer Kernel 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 VESA vesa; // VESA-Treiber
PIC pic; // Interrupt-Controller PIC pic; // Interrupt-Controller

View File

@ -30,7 +30,7 @@
// I wanted to make more of these singletons but there were problems with atexit missing because of nostdlib I guess // 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 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 VESA vesa; // VESA-Treiber
extern PIC pic; // Interrupt-Controller extern PIC pic; // Interrupt-Controller

View File

@ -29,6 +29,8 @@ public:
PIC() = default; PIC() = default;
// Can't make static because atexit
// IRQ-Nummern von Geraeten // IRQ-Nummern von Geraeten
enum { enum {
timer = 0, // Programmable Interrupt Timer (PIT) timer = 0, // Programmable Interrupt Timer (PIT)

View File

@ -6,7 +6,7 @@ void PCSPKdemo::run() {
kout << "Playing..." << endl; kout << "Playing..." << endl;
kout.unlock(); kout.unlock();
(pcspk.*melody)(); // This syntax is confusing as hell (*melody)(); // This syntax is confusing as hell
kout.lock(); kout.lock();
kout << "Finished" << endl; kout << "Finished" << endl;

View File

@ -6,12 +6,12 @@
class PCSPKdemo : public Thread { class PCSPKdemo : public Thread {
private: 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: public:
PCSPKdemo(const PCSPKdemo& copy) = delete; PCSPKdemo(const PCSPKdemo& copy) = delete;
explicit PCSPKdemo(void (PCSPK::*melody)()) : Thread("PCSPKdemo"), melody(melody) {} PCSPKdemo(void (*melody)()) : Thread("PCSPKdemo"), melody(melody) {}
~PCSPKdemo() override { ~PCSPKdemo() override {
PCSPK::off(); PCSPK::off();

View File

@ -14,8 +14,10 @@ private:
static int is_transmit_empty(); static int is_transmit_empty();
public: public:
SerialOut(const SerialOut& copy) = delete;
SerialOut(); SerialOut();
SerialOut(const SerialOut& copy) = delete;
// Can't make singleton because atexit
static char read(); static char read();
static void write(char a); static void write(char a);