1

add pit indicator

This commit is contained in:
2022-07-04 17:07:09 +02:00
parent 42a1d719ee
commit 16f814bfcf
4 changed files with 33 additions and 2 deletions

View File

@ -25,6 +25,16 @@
void PIT::interval (int us) {
/* hier muss Code eingefuegt werden */
IOport control(0x43);
control.outb(0x36); // Zähler 0 Mode 3
unsigned int cntStart = (1193180.0 / 1000000.0) * us; // 1.19Mhz PIT
IOport data0(0x40);
data0.outb(cntStart & 0xFF); // Zaehler-0 laden (Lobyte)
data0.outb(cntStart >> 8); // Zaehler-0 laden (Hibyte)
}
@ -40,6 +50,8 @@ void PIT::plugin () {
/* hier muss Code eingefuegt werden */
intdis.assign(IntDispatcher::timer, *this);
pic.allow(PIC::timer);
}
@ -63,6 +75,20 @@ void PIT::trigger () {
// und ein weiterer Thread rechnen moechte
/* hier muss Code eingefuegt werden */
// Indicator
if (systime - this->last_indicator_refresh >= 10) {
this->indicator_pos = (this->indicator_pos + 1) % 4;
kout.show(79, 0, this->indicator[this->indicator_pos]);
this->last_indicator_refresh = systime;
}
// Preemption
if (scheduler.isInitialized()) {
}
}

View File

@ -16,12 +16,15 @@
class PIT : public ISR {
private:
PIT(const PIT &copy); // Verhindere Kopieren
PIT(const PIT &copy) = delete; // Verhindere Kopieren
private:
enum { time_base = 838 }; /* ns */
int timer_interval;
char indicator[4] = {'|', '/', '-', '\\'};
unsigned int indicator_pos = 0;
unsigned long last_indicator_refresh = 0;
public:
// Zeitgeber initialisieren.
PIT (int us) {

View File

@ -32,6 +32,7 @@ extern "C" void int_disp(unsigned int slot);
void int_disp(unsigned int vector) {
/* hier muss Code eingefuegt werden */
if (vector < 32) {
bs_dump(vector);
cpu.halt();

View File

@ -45,6 +45,7 @@ int main() {
// Tastatur-Unterbrechungsroutine 'einstoepseln'
/* hier muss Code eingefuegt werden */
kb.plugin();
pit.plugin();
// Interrupts erlauben (Tastatur)
/* hier muss Code eingefuegt werden */