1

initial reformat, still has misformats

This commit is contained in:
churl
2022-04-25 14:24:56 +02:00
parent 67fce9ff2d
commit 263563c105
20 changed files with 295 additions and 317 deletions

View File

@ -13,7 +13,6 @@
*****************************************************************************/ *****************************************************************************/
#include "devices/CGA.h" #include "devices/CGA.h"
/***************************************************************************** /*****************************************************************************
* Methode: CGA::setpos * * Methode: CGA::setpos *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -33,10 +32,8 @@ void CGA::setpos (int x, int y) {
index_port.outb(0xE); // Cursor(high) index_port.outb(0xE); // Cursor(high)
data_port.outb(cursor_high); data_port.outb(cursor_high);
} }
/***************************************************************************** /*****************************************************************************
* Methode: CGA::getpos * * Methode: CGA::getpos *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -55,15 +52,12 @@ void CGA::getpos (int &x, int &y) {
unsigned char cursor_high = data_port.inb(); unsigned char cursor_high = data_port.inb();
unsigned short cursor = unsigned short cursor =
(cursor_low & 0xFF) (cursor_low & 0xFF) | ((cursor_high << 8) & 0xFF00);
| ((cursor_high << 8) & 0xFF00);
x = cursor % 80; x = cursor % 80;
y = (int)(cursor / 80); y = (int)(cursor / 80);
} }
/***************************************************************************** /*****************************************************************************
* Methode: CGA::show * * Methode: CGA::show *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -84,10 +78,8 @@ void CGA::show (int x, int y, char character, unsigned char attrib) {
*(pos + 1) = attrib; *(pos + 1) = attrib;
// TODO: screen border check // TODO: screen border check
} }
/***************************************************************************** /*****************************************************************************
* Methode: CGA::print * * Methode: CGA::print *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -126,10 +118,8 @@ void CGA::print (char* string, int n, unsigned char attrib) {
// TODO: automatic line breaking, automatic scrolling // TODO: automatic line breaking, automatic scrolling
// TODO: printing doesn't work after first newline character // TODO: printing doesn't work after first newline character
} }
/***************************************************************************** /*****************************************************************************
* Methode: CGA::scrollup * * Methode: CGA::scrollup *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -150,10 +140,8 @@ void CGA::scrollup () {
for (unsigned short byte = 2 * 80 * 24; byte < 2 * 80 * 25; ++byte) { for (unsigned short byte = 2 * 80 * 24; byte < 2 * 80 * 25; ++byte) {
*((char*)(CGA_START + byte)) = '\0'; *((char*)(CGA_START + byte)) = '\0';
} }
} }
/***************************************************************************** /*****************************************************************************
* Methode: CGA::clear * * Methode: CGA::clear *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -168,10 +156,8 @@ void CGA::clear () {
} }
this->setpos(0, 0); this->setpos(0, 0);
} }
/***************************************************************************** /*****************************************************************************
* Methode: CGA::attribute * * Methode: CGA::attribute *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -187,5 +173,4 @@ void CGA::clear () {
unsigned char CGA::attribute(CGA::color bg, CGA::color fg, bool blink) { unsigned char CGA::attribute(CGA::color bg, CGA::color fg, bool blink) {
/* Hier muess Code eingefuegt werden */ /* Hier muess Code eingefuegt werden */
} }

View File

@ -38,16 +38,30 @@ public:
// Konstanten fuer die moeglichen Farben im Attribut-Byte. // Konstanten fuer die moeglichen Farben im Attribut-Byte.
typedef enum { typedef enum {
BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHT_GREY, BLACK,
DARK_GREY, LIGHT_BLUE, LIGHT_GREEN, LIGHT_CYAN, LIGHT_RED, BLUE,
LIGHT_MAGENTA, YELLOW, WHITE GREEN,
CYAN,
RED,
MAGENTA,
BROWN,
LIGHT_GREY,
DARK_GREY,
LIGHT_BLUE,
LIGHT_GREEN,
LIGHT_CYAN,
LIGHT_RED,
LIGHT_MAGENTA,
YELLOW,
WHITE
} color; } color;
// Standardzeichenfarbe // Standardzeichenfarbe
enum { STD_ATTR = BLACK << 4 | LIGHT_GREY }; enum { STD_ATTR = BLACK << 4 | LIGHT_GREY };
// Groesse des Bildschirms (25 Zeilen, 80 Spalten) // Groesse des Bildschirms (25 Zeilen, 80 Spalten)
enum { ROWS = 25, COLUMNS = 80 }; enum { ROWS = 25,
COLUMNS = 80 };
// Setzen des Cursors in Spalte x und Zeile y. // Setzen des Cursors in Spalte x und Zeile y.
void setpos(int x, int y); void setpos(int x, int y);
@ -73,4 +87,3 @@ public:
}; };
#endif #endif

View File

@ -15,7 +15,6 @@
#include "devices/CGA_Stream.h" #include "devices/CGA_Stream.h"
/***************************************************************************** /*****************************************************************************
* Methode: CGA_Stream::flush * * Methode: CGA_Stream::flush *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -28,4 +27,3 @@ void CGA_Stream::flush () {
print(buffer, pos); print(buffer, pos);
pos = 0; pos = 0;
} }

View File

@ -15,7 +15,6 @@
#include "devices/PCSPK.h" #include "devices/PCSPK.h"
#include "kernel/Globals.h" #include "kernel/Globals.h"
/***************************************************************************** /*****************************************************************************
* Methode: PCSPK::play * * Methode: PCSPK::play *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -29,7 +28,6 @@ void PCSPK::play (float f, int len) {
int cntStart = 1193180 / freq; int cntStart = 1193180 / freq;
int status; int status;
// Zaehler laden // Zaehler laden
control.outb(0xB6); // Zaehler-2 konfigurieren control.outb(0xB6); // Zaehler-2 konfigurieren
data2.outb(cntStart % 256); // Zaehler-2 laden (Lobyte) data2.outb(cntStart % 256); // Zaehler-2 laden (Lobyte)
@ -46,7 +44,6 @@ void PCSPK::play (float f, int len) {
off(); off();
} }
/***************************************************************************** /*****************************************************************************
* Methode: PCSPK::off * * Methode: PCSPK::off *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -59,7 +56,6 @@ void PCSPK::off () {
ppi.outb((status >> 2) << 2); // Lautsprecher ausschalten ppi.outb((status >> 2) << 2); // Lautsprecher ausschalten
} }
/***************************************************************************** /*****************************************************************************
* Methode: PCSPK::readCounter * * Methode: PCSPK::readCounter *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -77,7 +73,6 @@ inline unsigned int PCSPK::readCounter() {
return (hi << 8) | lo; return (hi << 8) | lo;
} }
/***************************************************************************** /*****************************************************************************
* Methode: PCSPK::delay * * Methode: PCSPK::delay *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -110,12 +105,9 @@ inline void PCSPK::delay (int time) {
initial_count = current_count; initial_count = current_count;
} }
} }
} }
/***************************************************************************** /*****************************************************************************
* Methode: PCSPK::tetris * * Methode: PCSPK::tetris *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -241,7 +233,6 @@ void PCSPK::tetris () {
off(); off();
} }
/***************************************************************************** /*****************************************************************************
* Methode: PCSPK::tetris * * Methode: PCSPK::tetris *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*

View File

@ -58,7 +58,6 @@
#define B2 987.77 #define B2 987.77
#define C3 1046.50 #define C3 1046.50
class PCSPK { class PCSPK {
private: private:
@ -76,7 +75,6 @@ private:
inline unsigned int readCounter(); inline unsigned int readCounter();
public: public:
// Konstruktor. Initialisieren der Ports. // Konstruktor. Initialisieren der Ports.
PCSPK() : control(0x43), data0(0x40), data2(0x42), ppi(0x61) {} PCSPK() : control(0x43), data0(0x40), data2(0x42), ppi(0x61) {}

View File

@ -10,7 +10,6 @@
#ifndef __CPU_include__ #ifndef __CPU_include__
#define __CPU_include__ #define __CPU_include__
class CPU { class CPU {
private: private:
@ -22,7 +21,8 @@ public:
// Time-Stamp-Counter auslesen // Time-Stamp-Counter auslesen
inline unsigned long long int rdtsc() { inline unsigned long long int rdtsc() {
unsigned long long int ret; unsigned long long int ret;
asm volatile ( "rdtsc" : "=A"(ret) ); asm volatile("rdtsc"
: "=A"(ret));
return ret; return ret;
} }
}; };

View File

@ -10,8 +10,6 @@
#include "kernel/Globals.h" #include "kernel/Globals.h"
CPU cpu; // CPU-spezifische Funktionen CPU cpu; // CPU-spezifische Funktionen
PCSPK pcspk; // PC-Lautsprecher PCSPK pcspk; // PC-Lautsprecher
CGA_Stream kout; // Ausgabe-Strom fuer Kernel CGA_Stream kout; // Ausgabe-Strom fuer Kernel

View File

@ -10,9 +10,9 @@
#ifndef __Globals_include__ #ifndef __Globals_include__
#define __Globals_include__ #define __Globals_include__
#include "kernel/CPU.h"
#include "devices/PCSPK.h"
#include "devices/CGA_Stream.h" #include "devices/CGA_Stream.h"
#include "devices/PCSPK.h"
#include "kernel/CPU.h"
extern CPU cpu; // CPU-spezifische Funktionen extern CPU cpu; // CPU-spezifische Funktionen
extern PCSPK pcspk; // PC-Lautsprecher extern PCSPK pcspk; // PC-Lautsprecher

View File

@ -16,7 +16,6 @@
#ifndef __IOport_include__ #ifndef __IOport_include__
#define __IOport_include__ #define __IOport_include__
class IOport { class IOport {
// Kopieren erlaubt! // Kopieren erlaubt!
@ -29,17 +28,23 @@ public:
// Byteweise Ausgabe eines Wertes ueber einen I/O-Port. // Byteweise Ausgabe eines Wertes ueber einen I/O-Port.
void outb(unsigned char val) const { void outb(unsigned char val) const {
asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(address) ); asm volatile("outb %0, %1"
:
: "a"(val), "Nd"(address));
} }
// Wortweise Ausgabe eines Wertes ueber einen I/O-Port. // Wortweise Ausgabe eines Wertes ueber einen I/O-Port.
void outw(unsigned short val) const { void outw(unsigned short val) const {
asm volatile ( "outw %0, %1" : : "a"(val), "Nd"(address) ); asm volatile("outw %0, %1"
:
: "a"(val), "Nd"(address));
} }
// 32-Bit Ausgabe eines Wertes ueber einen I/O-Port. // 32-Bit Ausgabe eines Wertes ueber einen I/O-Port.
void outdw(unsigned int val) const { void outdw(unsigned int val) const {
asm volatile ( "outl %0, %1" : : "a"(val), "Nd"(address) ); asm volatile("outl %0, %1"
:
: "a"(val), "Nd"(address));
} }
// Byteweises Einlesen eines Wertes ueber einen I/O-Port. // Byteweises Einlesen eines Wertes ueber einen I/O-Port.

View File

@ -11,11 +11,8 @@
* Autor: Michael Schoettner, 30.7.16 * * Autor: Michael Schoettner, 30.7.16 *
*****************************************************************************/ *****************************************************************************/
extern "C" void int_disp(unsigned int slot); extern "C" void int_disp(unsigned int slot);
// Low-Level Interrupt-Behandlung. (Die Funktion wird spaeter noch erweitert) // Low-Level Interrupt-Behandlung. (Die Funktion wird spaeter noch erweitert)
void int_disp(unsigned int slot) { void int_disp(unsigned int slot) {
} }

View File

@ -139,7 +139,8 @@ OutStream& OutStream::operator << (unsigned long ival) {
// Bestimmung der groessten Potenz der gewaehlten Zahlenbasis, die // Bestimmung der groessten Potenz der gewaehlten Zahlenbasis, die
// noch kleiner als die darzustellende Zahl ist. // noch kleiner als die darzustellende Zahl ist.
for (div = 1; ival/div >= (unsigned long) base; div *= base); for (div = 1; ival / div >= (unsigned long)base; div *= base)
;
// ziffernweise Ausgabe der Zahl // ziffernweise Ausgabe der Zahl
for (; div > 0; div /= (unsigned long)base) { for (; div > 0; div /= (unsigned long)base) {
@ -209,4 +210,3 @@ OutStream& hex (OutStream& os) {
os.base = 16; os.base = 16;
return os; return os;
} }

View File

@ -40,7 +40,6 @@ public:
char c; char c;
}; };
class OutStream : public StringBuffer { class OutStream : public StringBuffer {
private: private:
@ -99,7 +98,6 @@ public:
OutStream& operator<<(OutStream& (*f)(OutStream&)); OutStream& operator<<(OutStream& (*f)(OutStream&));
}; };
// //
// Manipulatorfunktionen // Manipulatorfunktionen
// //

View File

@ -18,7 +18,6 @@
#include "lib/StringBuffer.h" #include "lib/StringBuffer.h"
/***************************************************************************** /*****************************************************************************
* Methode: StringBuffer::put * * Methode: StringBuffer::put *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
@ -35,4 +34,3 @@ void StringBuffer::put (char c) {
if (pos == sizeof(buffer)) if (pos == sizeof(buffer))
flush(); flush();
} }

View File

@ -42,7 +42,6 @@ protected:
// Methode zur Ausgabe des Pufferinhalts // Methode zur Ausgabe des Pufferinhalts
virtual void flush() = 0; virtual void flush() = 0;
}; };
#endif #endif

View File

@ -11,9 +11,8 @@
*****************************************************************************/ *****************************************************************************/
#include "kernel/Globals.h" #include "kernel/Globals.h"
#include "user/TextDemo.h"
#include "user/SoundDemo.h" #include "user/SoundDemo.h"
#include "user/TextDemo.h"
int main() { int main() {
/* Hier muess Code eingefuegt werden */ /* Hier muess Code eingefuegt werden */
@ -23,10 +22,10 @@ int main() {
// TODO: Startmeldung ausgeben // TODO: Startmeldung ausgeben
text_demo(); text_demo();
// sound_demo(); // sound_demo();
while (1); while (1)
;
return 0; return 0;
} }

View File

@ -15,5 +15,4 @@ void sound_demo() {
/* Hier muess Code eingefuegt werden */ /* Hier muess Code eingefuegt werden */
pcspk.tetris(); pcspk.tetris();
// pcspk.play(440, 1000); // pcspk.play(440, 1000);
} }

View File

@ -10,11 +10,11 @@
#include "kernel/Globals.h" #include "kernel/Globals.h"
void text_demo() { void text_demo() {
/* Hier muess Code eingefuegt werden */ /* Hier muess Code eingefuegt werden */
kout << "Test der Zahlenausgabefunktion:" << endl << endl; kout << "Test der Zahlenausgabefunktion:" << endl;
kout << endl;
kout << "| dec | hex | bin |" << endl; kout << "| dec | hex | bin |" << endl;
kout << "+-------+-------+-------+" << endl; kout << "+-------+-------+-------+" << endl;