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

View File

@ -38,16 +38,30 @@ public:
// 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
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 };
enum { ROWS = 25,
COLUMNS = 80 };
// Setzen des Cursors in Spalte x und Zeile y.
void setpos(int x, int y);
@ -73,4 +87,3 @@ public:
};
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@
#ifndef __IOport_include__
#define __IOport_include__
class IOport {
// Kopieren erlaubt!
@ -29,17 +28,23 @@ public:
// Byteweise Ausgabe eines Wertes ueber einen I/O-Port.
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.
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.
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.

View File

@ -11,11 +11,8 @@
* 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) {
}

View File

@ -139,7 +139,8 @@ OutStream& OutStream::operator << (unsigned long ival) {
// 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);
for (div = 1; ival / div >= (unsigned long)base; div *= base)
;
// ziffernweise Ausgabe der Zahl
for (; div > 0; div /= (unsigned long)base) {
@ -209,4 +210,3 @@ OutStream& hex (OutStream& os) {
os.base = 16;
return os;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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