Vorgabe01 Aufgabe01
This commit is contained in:
121
devices/CGA.cc
Executable file
121
devices/CGA.cc
Executable file
@ -0,0 +1,121 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man auf den Bildschirm des *
|
||||
* PCs zugreifen. Der Zugriff erfolgt direkt auf der Hard- *
|
||||
* wareebene, d.h. ueber den Bildschirmspeicher und den *
|
||||
* I/O-Ports der Grafikkarte. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 21.8.2016 *
|
||||
*****************************************************************************/
|
||||
#include "devices/CGA.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::setpos *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Setzen des Cursors in Spalte x und Zeile y. *
|
||||
*****************************************************************************/
|
||||
void CGA::setpos (int x, int y) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::getpos *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Abfragem der Cursorposition *
|
||||
* *
|
||||
* Rückgabewerte: x und y *
|
||||
*****************************************************************************/
|
||||
void CGA::getpos (int &x, int &y) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::show *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Anzeige eines Zeichens mit Attribut an einer bestimmten *
|
||||
* Stelle auf dem Bildschirm. *
|
||||
* *
|
||||
* Parameter: *
|
||||
* x,y Position des Zeichens *
|
||||
* character Das auszugebende Zeichen *
|
||||
* attrib Attributbyte fuer das Zeichen *
|
||||
*****************************************************************************/
|
||||
void CGA::show (int x, int y, char character, unsigned char attrib) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::print *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Anzeige mehrerer Zeichen ab der aktuellen Cursorposition *
|
||||
* '\n' fuer Zeilenvorschub. *
|
||||
* *
|
||||
* Parameter: *
|
||||
* string Auszugebende Zeichenkette *
|
||||
* n Laenger der Zeichenkette *
|
||||
* attrib Attributbyte fuer alle Zeichen der Zeichenkette *
|
||||
*****************************************************************************/
|
||||
void CGA::print (char* string, int n, unsigned char attrib) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::scrollup *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Verschiebt den Bildschirminhalt um eine Zeile nach oben. *
|
||||
* Die neue Zeile am unteren Bildrand wird mit Leerzeichen *
|
||||
* gefuellt. *
|
||||
*****************************************************************************/
|
||||
void CGA::scrollup () {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::clear *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Lösche den Textbildschirm. *
|
||||
*****************************************************************************/
|
||||
void CGA::clear () {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA::attribute *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Hilfsfunktion zur Erzeugung eines Attribut-Bytes aus *
|
||||
* Hintergrund- und Vordergrundfarbe und der Angabe, ob das *
|
||||
* Zeichen blinkend darzustellen ist. *
|
||||
* *
|
||||
* Parameter: *
|
||||
* bg Background color *
|
||||
* fg Foreground color *
|
||||
* blink ywa/no *
|
||||
*****************************************************************************/
|
||||
unsigned char CGA::attribute (CGA::color bg, CGA::color fg, bool blink) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
73
devices/CGA.h
Executable file
73
devices/CGA.h
Executable file
@ -0,0 +1,73 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man auf den Bildschirm des *
|
||||
* PCs zugreifen. Der Zugriff erfolgt direkt auf der Hard- *
|
||||
* wareebene, d.h. ueber den Bildschirmspeicher und den *
|
||||
* I/O-Ports der Grafikkarte. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 21.8.2016 *
|
||||
*****************************************************************************/
|
||||
#ifndef __CGA_include__
|
||||
#define __CGA_include__
|
||||
|
||||
#include "kernel/IOport.h"
|
||||
|
||||
class CGA {
|
||||
|
||||
private:
|
||||
IOport index_port; // Auswahl eines Register der Grafikkarte
|
||||
IOport data_port; // Lese-/Schreib-Zugriff auf Register der Grafikk.
|
||||
|
||||
// Copy Konstrutkor unterbinden
|
||||
CGA(const CGA ©);
|
||||
|
||||
public:
|
||||
const char *CGA_START; // Startadresse des Buldschirmspeichers
|
||||
|
||||
// Konstruktur mit Initialisierung der Ports
|
||||
CGA () : index_port (0x3d4), data_port (0x3d5) {
|
||||
CGA_START = (const char*)0xb8000;
|
||||
}
|
||||
|
||||
// Konstanten fuer die moeglichen Farben im Attribut-Byte.
|
||||
typedef enum {
|
||||
BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHT_GREY,
|
||||
DARK_GREY, LIGHT_BLUE, LIGHT_GREEN, LIGHT_CYAN, LIGHT_RED,
|
||||
LIGHT_MAGENTA, YELLOW, WHITE
|
||||
} color;
|
||||
|
||||
// Standardzeichenfarbe
|
||||
enum { STD_ATTR = BLACK << 4 | LIGHT_GREY };
|
||||
|
||||
// Groesse des Bildschirms (25 Zeilen, 80 Spalten)
|
||||
enum { ROWS = 25, COLUMNS = 80 };
|
||||
|
||||
// Setzen des Cursors in Spalte x und Zeile y.
|
||||
void setpos (int x, int y);
|
||||
|
||||
// Abfragen der Cursorpostion
|
||||
void getpos (int& x, int& y);
|
||||
|
||||
// Anzeige eines Zeichens mit Attribut an einer bestimmten Stelle
|
||||
void show (int x, int y, char character, unsigned char attrib = STD_ATTR);
|
||||
|
||||
// Anzeige mehrerer Zeichen ab der aktuellen Cursorposition
|
||||
void print (char* string, int n, unsigned char attrib = STD_ATTR);
|
||||
|
||||
// Verschiebt den Bildschirminhalt um eine Zeile nach oben.
|
||||
// Neue Zeile am unteren Bildrand mit Leerzeichen fuellen
|
||||
void scrollup ();
|
||||
|
||||
// Lösche den Textbildschirm
|
||||
void clear ();
|
||||
|
||||
// Hilfsfunktion zur Erzeugung eines Attribut-Bytes
|
||||
unsigned char attribute (CGA::color bg, CGA::color fg, bool blink);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
31
devices/CGA_Stream.cc
Executable file
31
devices/CGA_Stream.cc
Executable file
@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A _ S T R E A M *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse CGA_Stream ermoeglicht die Ausgabe verschied. *
|
||||
* Datentypen als Zeichenketten auf dem CGA-Bildschirm eines*
|
||||
* PCs. Fuer weitergehende Formatierung oder spezielle *
|
||||
* Effekte stehen die Methoden der Klasse CGA_Stream zur *
|
||||
* Verfuegung. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 1.8.16 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "devices/CGA_Stream.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: CGA_Stream::flush *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Methode zur Ausgabe des Pufferinhalts der Basisklasse *
|
||||
* StringBuffer. Die Methode wird implizit aufgerufen, *
|
||||
* sobald der Puffer voll ist, kann aber auch explizit *
|
||||
* verwendet werden, um eine Ausgabe zu erzwingen. *
|
||||
*****************************************************************************/
|
||||
void CGA_Stream::flush () {
|
||||
print (buffer, pos);
|
||||
pos = 0;
|
||||
}
|
||||
|
33
devices/CGA_Stream.h
Executable file
33
devices/CGA_Stream.h
Executable file
@ -0,0 +1,33 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C G A _ S T R E A M *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse CGA_Stream ermoeglicht die Ausgabe verschied. *
|
||||
* Datentypen als Zeichenketten auf dem CGA-Bildschirm eines*
|
||||
* PCs. Fuer weitergehende Formatierung oder spezielle *
|
||||
* Effekte stehen die Methoden der Klasse CGA zur *
|
||||
* Verfuegung. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 06.04.20 *
|
||||
*****************************************************************************/
|
||||
#ifndef __CGA_Stream_include__
|
||||
#define __CGA_Stream_include__
|
||||
|
||||
#include "devices/CGA.h"
|
||||
#include "lib/OutStream.h"
|
||||
|
||||
class CGA_Stream : public OutStream, public CGA {
|
||||
|
||||
private:
|
||||
CGA_Stream(CGA_Stream ©); // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
CGA_Stream () : OutStream(), CGA () { flush(); }
|
||||
|
||||
// Methode zur Ausgabe des Pufferinhalts der Basisklasse StringBuffer.
|
||||
virtual void flush ();
|
||||
};
|
||||
|
||||
#endif
|
861
devices/PCSPK.cc
Executable file
861
devices/PCSPK.cc
Executable file
@ -0,0 +1,861 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* P C S P K *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man Toene auf dem *
|
||||
* PC-Lautsprecher ausgeben. *
|
||||
* *
|
||||
* Achtung: Qemu muss mit dem Parameter -soundhw pcspk aufgerufen *
|
||||
* werden. Ansonsten kann man nichts hoeren. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 22.9.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "devices/PCSPK.h"
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::play *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Ton abspielen. *
|
||||
* *
|
||||
* Rückgabewerte: f: Frequenz des Tons *
|
||||
* len: Laenge des Tons in ms *
|
||||
*****************************************************************************/
|
||||
void PCSPK::play (float f, int len) {
|
||||
int freq = (int)f;
|
||||
int cntStart = 1193180 / freq;
|
||||
int status;
|
||||
|
||||
|
||||
// Zaehler laden
|
||||
control.outb (0xB6); // Zaehler-2 konfigurieren
|
||||
data2.outb (cntStart%256); // Zaehler-2 laden (Lobyte)
|
||||
data2.outb (cntStart/256); // Zaehler-2 laden (Hibyte)
|
||||
|
||||
// Lautsprecher einschalten
|
||||
status = (int)ppi.inb (); // Status-Register des PPI auslesen
|
||||
ppi.outb ( status|3 ); // Lautpsrecher Einschalten
|
||||
|
||||
// Pause
|
||||
delay(len);
|
||||
|
||||
// Lautsprecher ausschalten
|
||||
off ();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::off *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Lautsprecher ausschalten. *
|
||||
*****************************************************************************/
|
||||
void PCSPK::off () {
|
||||
int status;
|
||||
|
||||
status = (int)ppi.inb (); // Status-Register des PPI auslesen
|
||||
ppi.outb ( (status>>2)<<2 ); // Lautsprecher ausschalten
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::readCounter *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Zaehler von PIT Channel 0 auslesen. *
|
||||
* (wird fuer delay benoetigt). *
|
||||
* *
|
||||
* Rückgabewerte: counter *
|
||||
*****************************************************************************/
|
||||
inline unsigned int PCSPK::readCounter() {
|
||||
unsigned char lo, hi;
|
||||
|
||||
control.outb (0x0); // Latch Command
|
||||
lo = data0.inb (); // Lobyte des Counters auslesen
|
||||
hi = data0.inb (); // Hibyte des Counters auslesen
|
||||
return (hi << 8) | lo;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::delay *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Verzoegerung um X ms (in 1ms Schritten; Min. 1ms). *
|
||||
* *
|
||||
* Parameter: time (delay in ms) *
|
||||
*****************************************************************************/
|
||||
inline void PCSPK::delay (int time) {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::tetris *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Tetris Sound, Kévin Rapaille, August 2013 *
|
||||
* https://gist.github.com/XeeX/6220067 *
|
||||
*****************************************************************************/
|
||||
void PCSPK::tetris () {
|
||||
play(658, 125);
|
||||
play(1320, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 250);
|
||||
play(1320, 125);
|
||||
play(1188, 125);
|
||||
play(1056, 250);
|
||||
play(990, 250);
|
||||
play(880, 500);
|
||||
play(880, 250);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 750);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(250);
|
||||
play(1188, 500);
|
||||
play(1408, 250);
|
||||
play(1760, 500);
|
||||
play(1584, 250);
|
||||
play(1408, 250);
|
||||
play(1320, 750);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(500);
|
||||
play(1320, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 250);
|
||||
play(1320, 125);
|
||||
play(1188, 125);
|
||||
play(1056, 250);
|
||||
play(990, 250);
|
||||
play(880, 500);
|
||||
play(880, 250);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 750);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(250);
|
||||
play(1188, 500);
|
||||
play(1408, 250);
|
||||
play(1760, 500);
|
||||
play(1584, 250);
|
||||
play(1408, 250);
|
||||
play(1320, 750);
|
||||
play(1056, 250);
|
||||
play(1320, 500);
|
||||
play(1188, 250);
|
||||
play(1056, 250);
|
||||
play(990, 500);
|
||||
play(990, 250);
|
||||
play(1056, 250);
|
||||
play(1188, 500);
|
||||
play(1320, 500);
|
||||
play(1056, 500);
|
||||
play(880, 500);
|
||||
play(880, 500);
|
||||
delay(500);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 1000);
|
||||
play(440, 1000);
|
||||
play(419, 1000);
|
||||
play(495, 1000);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 500);
|
||||
play(660, 500);
|
||||
play(880, 1000);
|
||||
play(838, 2000);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 1000);
|
||||
play(440, 1000);
|
||||
play(419, 1000);
|
||||
play(495, 1000);
|
||||
play(660, 1000);
|
||||
play(528, 1000);
|
||||
play(594, 1000);
|
||||
play(495, 1000);
|
||||
play(528, 500);
|
||||
play(660, 500);
|
||||
play(880, 1000);
|
||||
play(838, 2000);
|
||||
off ();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: PCSPK::tetris *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Clint, Part of Daft Punk’s Aerodynamic *
|
||||
* https://www.kirrus.co.uk/2010/09/linux-beep-music/ *
|
||||
*****************************************************************************/
|
||||
void PCSPK::aerodynamic() {
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(370.0, 122);
|
||||
play(493.9, 122);
|
||||
play(370.0, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(587.3, 122);
|
||||
play(415.3, 122);
|
||||
play(493.9, 122);
|
||||
play(415.3, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(784.0, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(493.9, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(440.0, 122);
|
||||
play(659.3, 122);
|
||||
play(440.0, 122);
|
||||
play(554.4, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(740.0, 122);
|
||||
play(987.8, 122);
|
||||
play(740.0, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1174.7, 122);
|
||||
play(830.6, 122);
|
||||
play(987.8, 122);
|
||||
play(830.6, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1568.0, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(987.8, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
play(1318.5, 122);
|
||||
play(880.0, 122);
|
||||
play(1108.7, 122);
|
||||
play(880.0, 122);
|
||||
off ();
|
||||
}
|
94
devices/PCSPK.h
Executable file
94
devices/PCSPK.h
Executable file
@ -0,0 +1,94 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* P C S P K *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Mit Hilfe dieser Klasse kann man Toene auf dem *
|
||||
* PC-Lautsprecher ausgeben. *
|
||||
* *
|
||||
* Achtung: Qemu muss mit dem Parameter -soundhw pcspk aufgerufen *
|
||||
* werden. Ansonsten kann man nichts hoeren. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 22.9.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __PCSPK_include__
|
||||
#define __PCSPK_include__
|
||||
|
||||
#include "kernel/IOport.h"
|
||||
|
||||
// Note, Frequenz
|
||||
#define C0 130.81
|
||||
#define C0X 138.59
|
||||
#define D0 146.83
|
||||
#define D0X 155.56
|
||||
#define E0 164.81
|
||||
#define F0 174.61
|
||||
#define F0X 185.00
|
||||
#define G0 196.00
|
||||
#define G0X 207.65
|
||||
#define A0 220.00
|
||||
#define A0X 233.08
|
||||
#define B0 246.94
|
||||
|
||||
#define C1 261.63
|
||||
#define C1X 277.18
|
||||
#define D1 293.66
|
||||
#define D1X 311.13
|
||||
#define E1 329.63
|
||||
#define F1 349.23
|
||||
#define F1X 369.99
|
||||
#define G1 391.00
|
||||
#define G1X 415.30
|
||||
#define A1 440.00
|
||||
#define A1X 466.16
|
||||
#define B1 493.88
|
||||
|
||||
#define C2 523.25
|
||||
#define C2X 554.37
|
||||
#define D2 587.33
|
||||
#define D2X 622.25
|
||||
#define E2 659.26
|
||||
#define F2 698.46
|
||||
#define F2X 739.99
|
||||
#define G2 783.99
|
||||
#define G2X 830.61
|
||||
#define A2 880.00
|
||||
#define A2X 923.33
|
||||
#define B2 987.77
|
||||
#define C3 1046.50
|
||||
|
||||
|
||||
class PCSPK {
|
||||
|
||||
private:
|
||||
IOport control; // Steuerregister (write only)
|
||||
IOport data0; // Zaehler-0 Datenregister (read/write)
|
||||
IOport data2; // Zaehler-2 Datenregister
|
||||
IOport ppi; // Status-Register des PPI
|
||||
|
||||
PCSPK (const PCSPK ©); // Verhindere Kopieren
|
||||
|
||||
// Verzoegerung um X ms (in 1ms Schritten; Min. 1ms)
|
||||
inline void delay (int time);
|
||||
|
||||
// Zaehler von PIT Channel 0 auslesen (wird fuer delay benoetigt)
|
||||
inline unsigned int readCounter ();
|
||||
|
||||
public:
|
||||
|
||||
// Konstruktor. Initialisieren der Ports.
|
||||
PCSPK () : control(0x43), data0(0x40), data2(0x42), ppi(0x61) {}
|
||||
|
||||
// Demo Sounds
|
||||
void tetris ();
|
||||
void aerodynamic ();
|
||||
|
||||
// Ton abspielen
|
||||
void play (float f, int len);
|
||||
|
||||
// Lautsprecher ausschalten
|
||||
void off ();
|
||||
};
|
||||
|
||||
#endif
|
30
kernel/CPU.h
Executable file
30
kernel/CPU.h
Executable file
@ -0,0 +1,30 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* C P U *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Implementierung einer Abstraktion fuer den Prozessor. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, 30.7.16 *
|
||||
*****************************************************************************/
|
||||
#ifndef __CPU_include__
|
||||
#define __CPU_include__
|
||||
|
||||
|
||||
class CPU {
|
||||
|
||||
private:
|
||||
CPU(const CPU ©); // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
CPU() {}
|
||||
|
||||
// Time-Stamp-Counter auslesen
|
||||
inline unsigned long long int rdtsc() {
|
||||
unsigned long long int ret;
|
||||
asm volatile ( "rdtsc" : "=A"(ret) );
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
17
kernel/Globals.cc
Executable file
17
kernel/Globals.cc
Executable file
@ -0,0 +1,17 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* G L O B A L S *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Globale Variablen des Systems. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, 30.7.16 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
|
||||
CPU cpu; // CPU-spezifische Funktionen
|
||||
PCSPK pcspk; // PC-Lautsprecher
|
||||
CGA_Stream kout; // Ausgabe-Strom fuer Kernel
|
||||
|
21
kernel/Globals.h
Executable file
21
kernel/Globals.h
Executable file
@ -0,0 +1,21 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* G L O B A L S *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Globale Variablen des Systems. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, 30.7.16 *
|
||||
*****************************************************************************/
|
||||
#ifndef __Globals_include__
|
||||
#define __Globals_include__
|
||||
|
||||
#include "kernel/CPU.h"
|
||||
#include "devices/PCSPK.h"
|
||||
#include "devices/CGA_Stream.h"
|
||||
|
||||
extern CPU cpu; // CPU-spezifische Funktionen
|
||||
extern PCSPK pcspk; // PC-Lautsprecher
|
||||
extern CGA_Stream kout; // Ausgabe-Strom fuer Kernel
|
||||
|
||||
#endif
|
76
kernel/IOport.h
Executable file
76
kernel/IOport.h
Executable file
@ -0,0 +1,76 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* I O P O R T *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Diese Klasse dient dem Zugriff auf die Ein-/Ausgabe *
|
||||
* Ports des PCs. Beim PC gibt es einen gesonderten I/O- *
|
||||
* Adressraum, der nur mittels der Maschineninstruktionen *
|
||||
* 'in' und 'out' angesprochen werden kann. Ein IOport- *
|
||||
* Objekt wird beim Erstellen an eine Adresse des I/O- *
|
||||
* Adressraums gebunden und kann dann fuer byte- oder *
|
||||
* wortweise Ein- oder Ausgaben verwendet werden. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, 28.8.2016 *
|
||||
*****************************************************************************/
|
||||
#ifndef __IOport_include__
|
||||
#define __IOport_include__
|
||||
|
||||
|
||||
class IOport {
|
||||
// Kopieren erlaubt!
|
||||
|
||||
// 16-Bit Adresse im I/O-Adressraum
|
||||
unsigned short address;
|
||||
|
||||
public:
|
||||
// Konstruktor, speichert Port-Adresse
|
||||
IOport (unsigned short a) : address (a) { };
|
||||
|
||||
// Byteweise Ausgabe eines Wertes ueber einen I/O-Port.
|
||||
void outb (unsigned char val) const {
|
||||
asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(address) );
|
||||
}
|
||||
|
||||
// Wortweise Ausgabe eines Wertes ueber einen I/O-Port.
|
||||
void outw (unsigned short val) const {
|
||||
asm volatile ( "outw %0, %1" : : "a"(val), "Nd"(address) );
|
||||
}
|
||||
|
||||
// 32-Bit Ausgabe eines Wertes ueber einen I/O-Port.
|
||||
void outdw (unsigned int val) const {
|
||||
asm volatile ( "outl %0, %1" : : "a"(val), "Nd"(address) );
|
||||
}
|
||||
|
||||
// Byteweises Einlesen eines Wertes ueber einen I/O-Port.
|
||||
unsigned char inb () const {
|
||||
unsigned char ret;
|
||||
|
||||
asm volatile ( "inb %1, %0"
|
||||
: "=a"(ret)
|
||||
: "Nd"(address) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Wortweises Einlesen eines Wertes ueber einen I/O-Port.
|
||||
unsigned short inw () const {
|
||||
unsigned short ret;
|
||||
|
||||
asm volatile ( "inw %1, %0"
|
||||
: "=a"(ret)
|
||||
: "Nd"(address) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 32-Bit Einlesen eines Wertes ueber einen I/O-Port.
|
||||
unsigned int indw () const {
|
||||
unsigned int ret;
|
||||
|
||||
asm volatile ( "inl %1, %0"
|
||||
: "=a"(ret)
|
||||
: "Nd"(address) );
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
21
kernel/interrupts/IntDispatcher.cc
Executable file
21
kernel/interrupts/IntDispatcher.cc
Executable file
@ -0,0 +1,21 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* I N T D I S P A T C H E R *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Zentrale Unterbrechungsbehandlungsroutine des Systems. *
|
||||
* Der Parameter gibt die Nummer des aufgetretenen *
|
||||
* Interrupts an. Wenn eine Interrupt Service Routine *
|
||||
* registriert ist, wird diese aufgerufen. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, 30.7.16 *
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
extern "C" void int_disp (unsigned int slot);
|
||||
|
||||
|
||||
// Low-Level Interrupt-Behandlung. (Die Funktion wird spaeter noch erweitert)
|
||||
void int_disp (unsigned int slot) {
|
||||
}
|
||||
|
160
lib/OutStream.cc
Executable file
160
lib/OutStream.cc
Executable file
@ -0,0 +1,160 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* O U T S T R E A M *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse OutStream enthaelt die Definition des *
|
||||
* << Operators fuer die wichtigsten der vordefinierten *
|
||||
* Datentypen und realisiert somit die bekannte Ausgabe- *
|
||||
* funktion der C++ iO_Stream Bibliothek. Zur Zeit wird *
|
||||
* die Darstellung von Zeichen, Zeichenketten und ganzen *
|
||||
* Zahlen unterstuetzt. Ein weiterer << Operator erlaubt *
|
||||
* die Verwendung von Manipulatoren. *
|
||||
* *
|
||||
* Neben der Klasse OutStream sind hier auch die *
|
||||
* Manipulatoren hex, dec, oct und bin fuer die Wahl der *
|
||||
* Basis bei der Zahlendarstellung, sowie endl fuer den *
|
||||
* Zeilenumbruch definiert. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 1.8.16 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "lib/OutStream.h"
|
||||
|
||||
|
||||
//
|
||||
// Zeichen und Zeichenketten in Stream ausgeben
|
||||
//
|
||||
OutStream& OutStream::operator << (char c) {
|
||||
put(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
OutStream& OutStream::operator << (unsigned char c) {
|
||||
return *this << (char) c;
|
||||
}
|
||||
|
||||
OutStream& OutStream::operator << (char* string) {
|
||||
char* pos = string;
|
||||
while (*pos) {
|
||||
put (*pos);
|
||||
pos++;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// Ganzer Zahlen im Zahlensystem zur Basis base in Stream ausgeveb
|
||||
// Alle vorzeichenbehafteten Datentypen werden als long dargestellt,
|
||||
// Alle vorzeichenlosen als unsigned long.
|
||||
OutStream& OutStream::operator << (short ival) {
|
||||
return *this << (long) ival;
|
||||
}
|
||||
|
||||
OutStream& OutStream::operator << (unsigned short ival) {
|
||||
return *this << (unsigned long) ival;
|
||||
}
|
||||
|
||||
OutStream& OutStream::operator << (int ival) {
|
||||
return *this << (long) ival;
|
||||
}
|
||||
|
||||
OutStream& OutStream::operator << (unsigned int ival) {
|
||||
return *this << (unsigned long) ival;
|
||||
}
|
||||
|
||||
// Darstellung eine vorzeichenbehafteten ganzen Zahl.
|
||||
OutStream& OutStream::operator << (long ival) {
|
||||
// Bei negativen Werten wird ein Minuszeichen ausgegeben.
|
||||
if (ival < 0) {
|
||||
put ('-');
|
||||
ival = -ival;
|
||||
}
|
||||
// Dann wird der Absolutwert als vorzeichenlose Zahl ausgegeben.
|
||||
return *this << (unsigned long) ival;
|
||||
}
|
||||
|
||||
// Darstellung einer vorzeichenlosen ganzen Zahl.
|
||||
OutStream& OutStream::operator << (unsigned long ival) {
|
||||
unsigned long div;
|
||||
char digit;
|
||||
|
||||
if (base == 8)
|
||||
put ('0'); // oktale Zahlen erhalten eine fuehrende Null
|
||||
else if (base == 16) {
|
||||
put ('0'); // hexadezimale Zahlen ein "0x"
|
||||
put ('x');
|
||||
}
|
||||
|
||||
// Bestimmung der groessten Potenz der gewaehlten Zahlenbasis, die
|
||||
// noch kleiner als die darzustellende Zahl ist.
|
||||
for (div = 1; ival/div >= (unsigned long) base; div *= base);
|
||||
|
||||
// ziffernweise Ausgabe der Zahl
|
||||
for (; div > 0; div /= (unsigned long) base) {
|
||||
digit = ival / div;
|
||||
if (digit < 10)
|
||||
put ('0' + digit);
|
||||
else
|
||||
put ('a' + digit - 10);
|
||||
ival %= div;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Darstellung eines Zeigers als hexadezimale ganze Zahl
|
||||
OutStream& OutStream::operator << (void* ptr) {
|
||||
int oldbase = base;
|
||||
base = 16;
|
||||
*this << (unsigned long) ptr;
|
||||
base = oldbase;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Aufruf einer Manipulatorfunktion
|
||||
OutStream& OutStream::operator << (OutStream& (*f) (OutStream&)) {
|
||||
return f(*this);
|
||||
}
|
||||
|
||||
//
|
||||
// Manipulatorfunktionen
|
||||
//
|
||||
// Die folgenden Funktionen erhalten und liefern jeweils eine Referenz auf
|
||||
// ein OutStream Objekt. Da die Klasse O_Stream einen Operator << fuer
|
||||
// derartige Funktionen definiert, koennen sie mit Hilfe dieses Operators
|
||||
// aufgerufen und sogar in weitere Eingaben eingebettet werden.
|
||||
// Aufgabe der Manipulatoren ist, die Darstellung der nachfolgenden Ausgaben
|
||||
// zu beeinflussen, z.B durch die Wahl des Zahlensystems.
|
||||
|
||||
// Fuege einen Zeilenumbruch in die Ausgabe ein.
|
||||
OutStream& endl (OutStream& os) {
|
||||
os << '\n';
|
||||
os.flush ();
|
||||
return os;
|
||||
}
|
||||
|
||||
// Waehlt das binaere Zahlensystem aus.
|
||||
OutStream& bin (OutStream& os) {
|
||||
os.base = 2;
|
||||
return os;
|
||||
}
|
||||
|
||||
// Waehlt das oktale Zahlensystem aus.
|
||||
OutStream& oct (OutStream& os) {
|
||||
os.base = 8;
|
||||
return os;
|
||||
}
|
||||
|
||||
// Waehlt das dezimale Zahlensystem aus.
|
||||
OutStream& dec (OutStream& os) {
|
||||
os.base = 10;
|
||||
return os;
|
||||
}
|
||||
|
||||
// Waehlt das hexadezimale Zahlensystem aus.
|
||||
OutStream& hex (OutStream& os) {
|
||||
os.base = 16;
|
||||
return os;
|
||||
}
|
||||
|
92
lib/OutStream.h
Executable file
92
lib/OutStream.h
Executable file
@ -0,0 +1,92 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* O U T S T R E A M *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse OutStream enthaelt die Definition des *
|
||||
* << Operators fuer die wichtigsten der vordefinierten *
|
||||
* Datentypen und realisiert somit die bekannte Ausgabe- *
|
||||
* funktion der C++ iO_Stream Bibliothek. Zur Zeit wird *
|
||||
* die Darstellung von Zeichen, Zeichenketten und ganzen *
|
||||
* Zahlen unterstuetzt. Ein weiterer << Operator erlaubt *
|
||||
* die Verwendung von Manipulatoren. *
|
||||
* *
|
||||
* Neben der Klasse OutStream sind hier auch die *
|
||||
* Manipulatoren hex, dec, oct und bin fuer die Wahl der *
|
||||
* Basis bei der Zahlendarstellung, sowie endl fuer den *
|
||||
* Zeilenumbruch definiert. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 06.04.20 *
|
||||
*****************************************************************************/
|
||||
#ifndef __OutStream_include__
|
||||
#define __OutStream_include__
|
||||
|
||||
#include "lib/StringBuffer.h"
|
||||
|
||||
class OutStream : public StringBuffer {
|
||||
|
||||
private:
|
||||
OutStream(const OutStream ©); // Verhindere Kopieren
|
||||
|
||||
public:
|
||||
int base; // Basis des Zahlensystems: z.B. 2, 8, 10 oder 16
|
||||
|
||||
OutStream () : StringBuffer () { base = 10; } // initial Dezimalsystem
|
||||
|
||||
virtual void flush () = 0; // weiterhin undefiniert
|
||||
|
||||
// OPERATOR << : Umwandlung des angegebenen Datentypes in eine
|
||||
// Zeichenkette.
|
||||
|
||||
// Darstellung eines Zeichens (trivial)
|
||||
OutStream& operator << (char c);
|
||||
OutStream& operator << (unsigned char c);
|
||||
|
||||
// Darstellung einer nullterminierten Zeichenkette
|
||||
OutStream& operator << (char* string);
|
||||
|
||||
// Darstellung ganzer Zahlen im Zahlensystem zur Basis base
|
||||
OutStream& operator << (short ival);
|
||||
OutStream& operator << (unsigned short ival);
|
||||
OutStream& operator << (int ival);
|
||||
OutStream& operator << (unsigned int ival);
|
||||
OutStream& operator << (long ival);
|
||||
OutStream& operator << (unsigned long ival);
|
||||
|
||||
// Darstellung eines Zeigers als hexadezimale ganze Zahl
|
||||
OutStream& operator << (void* ptr);
|
||||
|
||||
// Aufruf einer Manipulatorfunktion
|
||||
OutStream& operator << (OutStream& (*f) (OutStream&));
|
||||
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Manipulatorfunktionen
|
||||
//
|
||||
// Die folgenden Funktionen erhalten und liefern jeweils eine Referenz auf
|
||||
// ein OutStream Objekt. Da die Klasse OutStream einen Operator << fuer
|
||||
// derartige Funktionen definiert, koennen sie mit Hilfe dieses Operators
|
||||
// aufgerufen und sogar in weitere Eingaben eingebettet werden.
|
||||
// Aufgabe der Manipulatoren ist, die Darstellung der nachfolgenden Ausgaben
|
||||
// zu beeinflussen, z.B durch die Wahl des Zahlensystems.
|
||||
|
||||
// Zeilenumbruch in Ausgabe einfuegen.
|
||||
OutStream& endl (OutStream& os);
|
||||
|
||||
// Waehle binaeres Zahlensystem aus.
|
||||
OutStream& bin (OutStream& os);
|
||||
|
||||
// Waehle oktales Zahlensystem aus.
|
||||
OutStream& oct (OutStream& os);
|
||||
|
||||
// Waehle dezimales Zahlensystem aus.
|
||||
OutStream& dec (OutStream& os);
|
||||
|
||||
// Waehle hexadezimales Zahlensystem aus.
|
||||
OutStream& hex (OutStream& os);
|
||||
|
||||
#endif
|
||||
|
38
lib/StringBuffer.cc
Executable file
38
lib/StringBuffer.cc
Executable file
@ -0,0 +1,38 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* S T R I N G B U F F E R *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse StringBuffer stellt einen Puffer fuer die *
|
||||
* Sammlung von Zeichen zur Darstellung auf dem Bildschirm *
|
||||
* oder anderen Ausgabegeraeten bereit. Die Ausgabe der *
|
||||
* Zeichen erfolgt, sobald der Puffer voll ist oder wenn *
|
||||
* explizit die Methode flush() aufgerufen wird. *
|
||||
* Da StringBuffer geraeteunabhaengig sein soll, ist *
|
||||
* flush() eine virtuelle Methode, die von den abgeleiteten *
|
||||
* Klassen definiert werden muss. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 1.8.16 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "lib/StringBuffer.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: StringBuffer::put *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Fuegt ein Zeichen in den Puffer ein. Wenn der Puffer *
|
||||
* daraufhin voll ist, wird er durch Aufruf der Methode *
|
||||
* flush geleert. *
|
||||
* *
|
||||
* Parameter: *
|
||||
* c: Einzufuegendes Zeichen. *
|
||||
*****************************************************************************/
|
||||
void StringBuffer::put (char c) {
|
||||
buffer[pos] = c;
|
||||
pos++;
|
||||
if (pos == sizeof (buffer))
|
||||
flush ();
|
||||
}
|
||||
|
47
lib/StringBuffer.h
Executable file
47
lib/StringBuffer.h
Executable file
@ -0,0 +1,47 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* S T R I N G B U F F E R *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Die Klasse StringBuffer stellt einen Puffer fuer die *
|
||||
* Sammlung von Zeichen zur Darstellung auf dem Bildschirm *
|
||||
* oder anderen Ausgabegeraeten bereit. Die Ausgabe der *
|
||||
* Zeichen erfolgt, sobald der Puffer voll ist oder wenn *
|
||||
* explizit die Methode flush() aufgerufen wird. *
|
||||
* Da StringBuffer geraeteunabhaengig sein soll, ist *
|
||||
* flush() eine virtuelle Methode, die von den abgeleiteten *
|
||||
* Klassen definiert werden muss. *
|
||||
* *
|
||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||
* Aenderungen von Michael Schoettner, HHU, 06.04.20 *
|
||||
*****************************************************************************/
|
||||
#ifndef __StringBuffer_include__
|
||||
#define __StringBuffer_include__
|
||||
|
||||
class StringBuffer {
|
||||
|
||||
private:
|
||||
StringBuffer(const StringBuffer ©); // Verhindere Kopieren
|
||||
|
||||
// Alle Variablen und Methoden dieser Klasse sind "protected",
|
||||
// da die abgeleiteten Klassen einen direkten Zugriff auf den
|
||||
// Puffer, den Konstruktor, den Destruktor und die Methode put
|
||||
// benoetigen. Die Methode flush() muss sowieso neu definiert
|
||||
// werden und kann dann auch public werden.
|
||||
|
||||
protected:
|
||||
char buffer[80];
|
||||
int pos;
|
||||
|
||||
// StringBuffer: Im Konstruktor wird der Puffer als leer markiert.
|
||||
StringBuffer () : pos(0) {}
|
||||
|
||||
// Fuegt ein Zeichen in den Puffer ein. Wenn der Puffer
|
||||
void put (char c);
|
||||
|
||||
// Methode zur Ausgabe des Pufferinhalts
|
||||
virtual void flush () = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
31
main.cc
Executable file
31
main.cc
Executable file
@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* M A I N *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Startroutine, wird direkt vom Bootlader angesprungen, *
|
||||
* nachdem dieser in den Protected Mode geschaltet hat und *
|
||||
* die GDT und IDT initalisiert hat. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 15.8.2016 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
#include "user/TextDemo.h"
|
||||
#include "user/SoundDemo.h"
|
||||
|
||||
|
||||
int main() {
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
// Bildschirm loeschen.
|
||||
|
||||
// Startmeldung ausgeben
|
||||
|
||||
text_demo();
|
||||
|
||||
sound_demo();
|
||||
|
||||
while (1);
|
||||
return 0;
|
||||
}
|
17
user/SoundDemo.cc
Executable file
17
user/SoundDemo.cc
Executable file
@ -0,0 +1,17 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* S O U N D D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Test für den PC-Lautsprecher-Treiber. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 26.10.2018 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
void sound_demo() {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
16
user/SoundDemo.h
Executable file
16
user/SoundDemo.h
Executable file
@ -0,0 +1,16 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* S O U N D D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Test für den PC-Lautsprecher-Treiber. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 26.10.2018 *
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __SoundDemo_include__
|
||||
#define __SondDemo_include__
|
||||
|
||||
void sound_demo();
|
||||
|
||||
#endif
|
18
user/TextDemo.cc
Executable file
18
user/TextDemo.cc
Executable file
@ -0,0 +1,18 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* T E X T D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Testausgaben für den CGA-Treiber. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 26.10.2018 *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "kernel/Globals.h"
|
||||
|
||||
|
||||
void text_demo() {
|
||||
|
||||
/* Hier muess Code eingefuegt werden */
|
||||
|
||||
}
|
16
user/TextDemo.h
Executable file
16
user/TextDemo.h
Executable file
@ -0,0 +1,16 @@
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* T E X T D E M O *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Testausgaben für den CGA-Treiber. *
|
||||
* *
|
||||
* Autor: Michael Schoettner, HHU, 26.10.2018 *
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __TextDemo_include__
|
||||
#define __TextDemo_include__
|
||||
|
||||
void text_demo();
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user