1
This commit is contained in:
2022-07-16 01:01:44 +02:00
parent 156e49c7f4
commit b66bfac5d7

37
c_os/devices/PIT.cc Normal file → Executable file
View File

@ -9,9 +9,8 @@
*****************************************************************************/
#include "devices/PIT.h"
#include "kernel/IOport.h"
#include "kernel/Globals.h"
#include "kernel/IOport.h"
/*****************************************************************************
* Methode: PIT::interval *
@ -22,23 +21,21 @@
* us: Zeitintervall in Mikrosekunden, nachdem periodisch ein *
* Interrupt erzeugt werden soll. *
*****************************************************************************/
void PIT::interval (int us) {
void PIT::interval(int us) {
/* hier muss Code eingefuegt werden */
IOport control(0x43);
control.outb(0x36); // Zähler 0 Mode 3
control.outb(0x36); // Zähler 0 Mode 3
unsigned int cntStart = (1193180.0 / 1000000.0) * us; // 1.19Mhz PIT
unsigned int cntStart = (1193180.0 / 1000000.0) * us; // 1.19Mhz PIT
// kout << "PIT cntStart: " << dec << cntStart << endl;
IOport data0(0x40);
data0.outb(cntStart & 0xFF); // Zaehler-0 laden (Lobyte)
data0.outb(cntStart >> 8); // Zaehler-0 laden (Hibyte)
}
/*****************************************************************************
* Methode: PIT::plugin *
*---------------------------------------------------------------------------*
@ -46,7 +43,7 @@ void PIT::interval (int us) {
* wird bei Ablauf des definierten Zeitintervalls die *
* Methode 'trigger' aufgerufen. *
*****************************************************************************/
void PIT::plugin () {
void PIT::plugin() {
/* hier muss Code eingefuegt werden */
@ -54,7 +51,6 @@ void PIT::plugin () {
pic.allow(PIC::timer);
}
/*****************************************************************************
* Methode: PIT::trigger *
*---------------------------------------------------------------------------*
@ -63,10 +59,10 @@ void PIT::plugin () {
* aktualisieren und Thread wechseln durch Setzen der *
* Variable 'forceSwitch', wird in 'int_disp' behandelt. *
*****************************************************************************/
void PIT::trigger () {
void PIT::trigger() {
/* hier muss Code eingefuegt werden */
// alle 10ms, Systemzeit weitersetzen
systime++;
@ -77,18 +73,15 @@ void PIT::trigger () {
/* hier muss Code eingefuegt werden */
// Indicator
if (systime - this->last_indicator_refresh >= 10) {
if (systime - this->last_indicator_refresh >= 100) {
this->indicator_pos = (this->indicator_pos + 1) % 4;
kout.show(79, 0, this->indicator[this->indicator_pos]);
this->last_indicator_refresh = systime;
// TODO: Move this out again
// Preemption
if (scheduler.preemption_enabled()) {
scheduler.preempt();
}
}
// Preemption
if (scheduler.isInitialized()) {
scheduler.preempt();
}
}