add vorgabe04
This commit is contained in:
4
c_os/Makefile
Executable file → Normal file
4
c_os/Makefile
Executable file → Normal file
@ -73,8 +73,8 @@ CXX ?= g++
|
|||||||
CFLAGS := $(CFLAGS) -m32 -march=i486 -Wall -fno-stack-protector -nostdlib -I. -g -ffreestanding -fno-pie -fno-pic -mpreferred-stack-boundary=2 -Wno-write-strings -mno-sse -mno-sse2 -mmanual-endbr
|
CFLAGS := $(CFLAGS) -m32 -march=i486 -Wall -fno-stack-protector -nostdlib -I. -g -ffreestanding -fno-pie -fno-pic -mpreferred-stack-boundary=2 -Wno-write-strings -mno-sse -mno-sse2 -mmanual-endbr
|
||||||
CXXFLAGS := $(CFLAGS) -Wno-non-virtual-dtor -fno-threadsafe-statics -fno-use-cxa-atexit -fno-rtti -fno-exceptions
|
CXXFLAGS := $(CFLAGS) -Wno-non-virtual-dtor -fno-threadsafe-statics -fno-use-cxa-atexit -fno-rtti -fno-exceptions
|
||||||
|
|
||||||
BOOT = ../c_boot
|
BOOT = ../boot
|
||||||
TOOLS = ../c_tools
|
TOOLS = ../tools
|
||||||
# BIOS-dev.code:total-tracks:-heads:-sectors:start-track:-head:-sector
|
# BIOS-dev.code:total-tracks:-heads:-sectors:start-track:-head:-sector
|
||||||
# Default-Werte fuer Boot von Floppy (USB/HD erkennt bootsect.asm selbst):
|
# Default-Werte fuer Boot von Floppy (USB/HD erkennt bootsect.asm selbst):
|
||||||
BOOTDEVICE = 0:80:2:18:0:0:1
|
BOOTDEVICE = 0:80:2:18:0:0:1
|
||||||
|
|||||||
@ -6,55 +6,50 @@
|
|||||||
* Beschreibung: Treiber für den Tastaturcontroller des PCs. *
|
* Beschreibung: Treiber für den Tastaturcontroller des PCs. *
|
||||||
* *
|
* *
|
||||||
* Autor: Olaf Spinczyk, TU Dortmund *
|
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||||
|
* Modifikationen, Michael Schoettner, 17.8.2016 *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#ifndef __Keyboard_include__
|
#ifndef __Keyboard_include__
|
||||||
#define __Keyboard_include__
|
#define __Keyboard_include__
|
||||||
|
|
||||||
#include "devices/Key.h"
|
#include "devices/Key.h"
|
||||||
#include "kernel/IOport.h"
|
#include "kernel/IOport.h"
|
||||||
|
#include "kernel/interrupts/ISR.h"
|
||||||
|
|
||||||
class Keyboard {
|
class Keyboard : public ISR {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Keyboard(const Keyboard& copy); // Verhindere Kopieren
|
Keyboard(const Keyboard ©); // Verhindere Kopieren
|
||||||
|
|
||||||
unsigned char code; // Byte von Tastatur
|
unsigned char code; // Byte von Tastatur
|
||||||
unsigned char prefix; // Prefix von Tastatur
|
unsigned char prefix; // Prefix von Tastatur
|
||||||
Key gather; // letzter dekodierter Key
|
Key gather; // letzter dekodierter Key
|
||||||
char leds; // Zustand LEDs
|
char leds; // Zustand LEDs
|
||||||
|
|
||||||
// Benutzte Ports des Tastaturcontrollers
|
// Benutzte Ports des Tastaturcontrollers
|
||||||
const IOport ctrl_port; // Status- (R) u. Steuerregister (W)
|
const IOport ctrl_port; // Status- (R) u. Steuerregister (W)
|
||||||
const IOport data_port; // Ausgabe- (R) u. Eingabepuffer (W)
|
const IOport data_port; // Ausgabe- (R) u. Eingabepuffer (W)
|
||||||
|
|
||||||
// Bits im Statusregister
|
// Bits im Statusregister
|
||||||
enum { outb = 0x01,
|
enum { outb = 0x01, inpb = 0x02, auxb = 0x20 };
|
||||||
inpb = 0x02,
|
|
||||||
auxb = 0x20 };
|
|
||||||
|
|
||||||
// Kommandos an die Tastatur
|
// Kommandos an die Tastatur
|
||||||
struct kbd_cmd {
|
struct kbd_cmd {
|
||||||
enum { set_led = 0xed,
|
enum { set_led = 0xed, set_speed = 0xf3 };
|
||||||
set_speed = 0xf3 };
|
|
||||||
};
|
};
|
||||||
enum { cpu_reset = 0xfe };
|
enum { cpu_reset = 0xfe };
|
||||||
|
|
||||||
// Namen der LEDs
|
// Namen der LEDs
|
||||||
struct led {
|
struct led {
|
||||||
enum { caps_lock = 4,
|
enum { caps_lock = 4, num_lock = 2, scroll_lock = 1 };
|
||||||
num_lock = 2,
|
};
|
||||||
scroll_lock = 1 };
|
|
||||||
};
|
|
||||||
|
|
||||||
// Antworten der Tastatur
|
// Antworten der Tastatur
|
||||||
struct kbd_reply {
|
struct kbd_reply {
|
||||||
enum { ack = 0xfa };
|
enum { ack = 0xfa };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Konstanten fuer die Tastaturdekodierung
|
// Konstanten fuer die Tastaturdekodierung
|
||||||
enum { break_bit = 0x80,
|
enum { break_bit = 0x80, prefix1 = 0xe0, prefix2 = 0xe1 };
|
||||||
prefix1 = 0xe0,
|
|
||||||
prefix2 = 0xe1 };
|
|
||||||
|
|
||||||
// Klassenvariablen
|
// Klassenvariablen
|
||||||
static unsigned char normal_tab[];
|
static unsigned char normal_tab[];
|
||||||
@ -64,26 +59,34 @@ private:
|
|||||||
static unsigned char scan_num_tab[];
|
static unsigned char scan_num_tab[];
|
||||||
|
|
||||||
// Interpretiert die Make und Break-Codes der Tastatur.
|
// Interpretiert die Make und Break-Codes der Tastatur.
|
||||||
bool key_decoded();
|
bool key_decoded ();
|
||||||
|
|
||||||
// Ermittelt anhand von Tabellen den ASCII-Code.
|
// Ermittelt anhand von Tabellen den ASCII-Code.
|
||||||
void get_ascii_code();
|
void get_ascii_code ();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Initialisierung der Tastatur.
|
|
||||||
Keyboard();
|
|
||||||
|
|
||||||
// Tastaturabfrage (vorerst Polling)
|
// Initialisierung der Tastatur.
|
||||||
Key key_hit();
|
Keyboard ();
|
||||||
|
|
||||||
// Fuehrt einen Neustart des Rechners durch.
|
// Tastaturabfrage (vorerst Polling)
|
||||||
void reboot();
|
Key key_hit ();
|
||||||
|
|
||||||
// Einstellen der Wiederholungsrate der Tastatur.
|
// Fuehrt einen Neustart des Rechners durch.
|
||||||
void set_repeat_rate(int speed, int delay);
|
void reboot ();
|
||||||
|
|
||||||
// Setzt oder loescht die angegebene Leuchtdiode.
|
// Einstellen der Wiederholungsrate der Tastatur.
|
||||||
void set_led(char led, bool on);
|
void set_repeat_rate (int speed, int delay);
|
||||||
|
|
||||||
|
// Setzt oder loescht die angegebene Leuchtdiode.
|
||||||
|
void set_led (char led, bool on);
|
||||||
|
|
||||||
|
// Aktivierung der Unterbrechungen fuer die Tastatur
|
||||||
|
void plugin ();
|
||||||
|
|
||||||
|
// Unterbrechnungsroutine der Tastatur.
|
||||||
|
void trigger ();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
* *
|
* *
|
||||||
*---------------------------------------------------------------------------*
|
*---------------------------------------------------------------------------*
|
||||||
* Beschreibung: Implementierung einer Abstraktion fuer den Prozessor. *
|
* Beschreibung: Implementierung einer Abstraktion fuer den Prozessor. *
|
||||||
|
* Derzeit wird nur angeboten, Interrupts zuzulassen, zu *
|
||||||
|
* verbieten oder den Prozessor anzuhalten. *
|
||||||
* *
|
* *
|
||||||
* Autor: Michael Schoettner, 30.7.16 *
|
* Autor: Michael Schoettner, 30.7.16 *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -19,12 +21,30 @@ private:
|
|||||||
public:
|
public:
|
||||||
CPU() {}
|
CPU() {}
|
||||||
|
|
||||||
|
// Erlauben von (Hardware-)Interrupts
|
||||||
|
inline void enable_int () {
|
||||||
|
asm volatile ( "sti" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interrupts werden ignoriert/verboten
|
||||||
|
inline void disable_int () {
|
||||||
|
asm volatile ( "cli" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prozessor bis zum naechsten Interrupt anhalten
|
||||||
|
inline void idle () {
|
||||||
|
asm volatile ( "sti;"
|
||||||
|
"hlt"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Prozessor anhalten
|
// Prozessor anhalten
|
||||||
inline void halt () {
|
inline void halt () {
|
||||||
asm volatile ( "cli;"
|
asm volatile ( "cli;"
|
||||||
"hlt"
|
"hlt"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
|
|||||||
6
c_os/kernel/Globals.cc
Executable file → Normal file
6
c_os/kernel/Globals.cc
Executable file → Normal file
@ -14,7 +14,9 @@ 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
|
||||||
Keyboard kb; // Tastatur
|
Keyboard kb; // Tastatur
|
||||||
|
IntDispatcher intdis; // Unterbrechungsverteilung
|
||||||
|
PIC pic; // Interrupt-Controller
|
||||||
unsigned int total_mem; // RAM total
|
unsigned int total_mem; // RAM total
|
||||||
// BumpAllocator allocator;
|
// BumpAllocator allocator;
|
||||||
// LinkedListAllocator allocator;
|
// LinkedListAllocator allocator;
|
||||||
TreeAllocator allocator;
|
TreeAllocator allocator;
|
||||||
|
|||||||
9
c_os/kernel/Globals.h
Executable file → Normal file
9
c_os/kernel/Globals.h
Executable file → Normal file
@ -15,16 +15,19 @@
|
|||||||
#include "devices/PCSPK.h"
|
#include "devices/PCSPK.h"
|
||||||
#include "kernel/allocator/BumpAllocator.h"
|
#include "kernel/allocator/BumpAllocator.h"
|
||||||
#include "kernel/allocator/LinkedListAllocator.h"
|
#include "kernel/allocator/LinkedListAllocator.h"
|
||||||
#include "kernel/allocator/TreeAllocator.h"
|
|
||||||
#include "kernel/CPU.h"
|
#include "kernel/CPU.h"
|
||||||
|
#include "kernel/interrupts/IntDispatcher.h"
|
||||||
|
#include "kernel/interrupts/PIC.h"
|
||||||
|
|
||||||
extern CPU cpu; // CPU-spezifische Funktionen
|
extern CPU cpu; // CPU-spezifische Funktionen
|
||||||
extern PCSPK pcspk; // PC-Lautsprecher
|
extern PCSPK pcspk; // PC-Lautsprecher
|
||||||
extern CGA_Stream kout; // Ausgabe-Strom fuer Kernel
|
extern CGA_Stream kout; // Ausgabe-Strom fuer Kernel
|
||||||
extern Keyboard kb; // Tastatur
|
extern Keyboard kb; // Tastatur
|
||||||
|
extern IntDispatcher intdis; // Unterbrechungsverteilung
|
||||||
|
extern PIC pic; // Interrupt-Controller
|
||||||
extern unsigned int total_mem; // RAM total
|
extern unsigned int total_mem; // RAM total
|
||||||
// extern BumpAllocator allocator;
|
// extern BumpAllocator allocator;
|
||||||
// extern LinkedListAllocator allocator;
|
// extern LinkedListAllocator allocator;
|
||||||
extern TreeAllocator allocator;
|
extern TreeAllocator allocator;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#define BASIC_ALIGN 8
|
#define BASIC_ALIGN 8
|
||||||
|
|
||||||
// NOTE: I added this file
|
// NOTE: I added this file
|
||||||
|
// NOTE: I can't imagine that this is very fast with all the tree logic?
|
||||||
|
|
||||||
typedef struct list_block {
|
typedef struct list_block {
|
||||||
// Doubly linked list for every block
|
// Doubly linked list for every block
|
||||||
@ -15,11 +16,10 @@ typedef struct list_block {
|
|||||||
struct list_block* previous;
|
struct list_block* previous;
|
||||||
} list_block_t;
|
} list_block_t;
|
||||||
|
|
||||||
// Format eines freien Blocks
|
|
||||||
// The free blocks are organized in a red-black tree to enable fast insertion with best-fit strategy.
|
// The free blocks are organized in a red-black tree to enable fast insertion with best-fit strategy.
|
||||||
// To allow fast merging of freed blocks every block is part of a doubly linked list.
|
// To allow fast merging of freed blocks every block is part of a doubly linked list.
|
||||||
// Because the red-black tree only contains the free blocks, the memory overhead comes
|
// Because the red-black tree only contains the free blocks, the memory overhead comes
|
||||||
// down to only 4 + 4 + 4 Bytes for the allocated flag, next and previous pointers.
|
// down to 4 + 4 + 4 Bytes for the allocated flag, next and previous pointers.
|
||||||
// The size can be calculated by using the next pointer so it doesn't have to be stored.
|
// The size can be calculated by using the next pointer so it doesn't have to be stored.
|
||||||
typedef struct tree_block {
|
typedef struct tree_block {
|
||||||
// Doubly linked list for every block
|
// Doubly linked list for every block
|
||||||
|
|||||||
27
c_os/kernel/interrupts/ISR.h
Executable file
27
c_os/kernel/interrupts/ISR.h
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* *
|
||||||
|
* I S R *
|
||||||
|
* *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Interrupt Service Routine. Jeweils ein Objekt pro ISR. *
|
||||||
|
* Erlaubt es einen Kontext mit Variablen fuer die Unter- *
|
||||||
|
* brechungsroutine bereitzustellen. *
|
||||||
|
* *
|
||||||
|
* Autor: Michael Schoettner, 06.04.20 *
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __ISR_include__
|
||||||
|
#define __ISR_include__
|
||||||
|
|
||||||
|
class ISR {
|
||||||
|
|
||||||
|
private:
|
||||||
|
ISR (const ISR ©); // Verhindere Kopieren
|
||||||
|
|
||||||
|
public:
|
||||||
|
ISR () {}
|
||||||
|
|
||||||
|
// Unterbrechungsbehandlungsroutine
|
||||||
|
virtual void trigger () = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -8,11 +8,78 @@
|
|||||||
* Interrupts an. Wenn eine Interrupt Service Routine *
|
* Interrupts an. Wenn eine Interrupt Service Routine *
|
||||||
* registriert ist, wird diese aufgerufen. *
|
* registriert ist, wird diese aufgerufen. *
|
||||||
* *
|
* *
|
||||||
* Autor: Michael Schoettner, 30.7.16 *
|
* Autor: Michael Schoettner, 31.8.2016 *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
#include "kernel/CPU.h"
|
||||||
|
#include "kernel/Globals.h"
|
||||||
|
#include "kernel/interrupts/IntDispatcher.h"
|
||||||
|
|
||||||
extern "C" void int_disp(unsigned int slot);
|
|
||||||
|
|
||||||
// Low-Level Interrupt-Behandlung. (Die Funktion wird spaeter noch erweitert)
|
extern "C" void int_disp (unsigned int slot);
|
||||||
void int_disp(unsigned int slot) {
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Prozedur: int_disp *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Low-Level Interrupt-Behandlung. *
|
||||||
|
* Diese Funktion ist in der IDT fuer alle Eintraege einge- *
|
||||||
|
* tragen. Dies geschieht bereits im Bootloader. *
|
||||||
|
* Sie wird also fuer alle Interrupts aufgerufen. Von hier *
|
||||||
|
* aus sollen die passenden ISR-Routinen der Treiber-Objekte*
|
||||||
|
* mithilfe von 'IntDispatcher::report' aufgerufen werden. *
|
||||||
|
* Parameter: *
|
||||||
|
* vector: Vektor-Nummer der Unterbrechung *
|
||||||
|
*****************************************************************************/
|
||||||
|
void int_disp (unsigned int vector) {
|
||||||
|
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
kout << "Ein Interrupt ist aufgetreten" << slot << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Konstruktor: IntDispatcher::IntDispatcher *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Initialisierung der ISR map mit einer Default-ISR. *
|
||||||
|
*****************************************************************************/
|
||||||
|
IntDispatcher::IntDispatcher () {
|
||||||
|
for (unsigned int slot=0; slot<size; slot++)
|
||||||
|
map[slot] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Methode: IntDispatcher::assign *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Registrierung einer ISR. *
|
||||||
|
* *
|
||||||
|
* Parameter: *
|
||||||
|
* vector: Vektor-Nummer der Unterbrechung *
|
||||||
|
* isr: ISR die registriert werden soll *
|
||||||
|
* *
|
||||||
|
* Rueckgabewert: 0 = Erfolg, -1 = Fehler *
|
||||||
|
*****************************************************************************/
|
||||||
|
int IntDispatcher::assign (unsigned int vector, ISR& isr) {
|
||||||
|
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Methode: IntDispatcher::report *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Eingetragene ISR ausfuehren. *
|
||||||
|
* *
|
||||||
|
* Parameter: *
|
||||||
|
* vector: Gesuchtes ISR-Objekt fuer diese Vektor-Nummer. *
|
||||||
|
* *
|
||||||
|
* Rueckgabewert: 0 = ISR wurde aufgerufen, -1 = unbekannte Vektor-Nummer *
|
||||||
|
*****************************************************************************/
|
||||||
|
int IntDispatcher::report (unsigned int vector) {
|
||||||
|
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
45
c_os/kernel/interrupts/IntDispatcher.h
Executable file
45
c_os/kernel/interrupts/IntDispatcher.h
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 (ISR) *
|
||||||
|
* in der Map registriert ist, so wird diese aufgerufen. *
|
||||||
|
* *
|
||||||
|
* Autor: Michael Schoettner, 30.7.16 *
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __IntDispatcher_include__
|
||||||
|
#define __IntDispatcher_include__
|
||||||
|
|
||||||
|
#include "kernel/ISR.h"
|
||||||
|
|
||||||
|
|
||||||
|
class IntDispatcher {
|
||||||
|
|
||||||
|
private:
|
||||||
|
IntDispatcher(const IntDispatcher ©); // Verhindere Kopieren
|
||||||
|
|
||||||
|
enum { size = 256 };
|
||||||
|
ISR* map[size];
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Vektor-Nummern
|
||||||
|
enum {
|
||||||
|
timer = 32,
|
||||||
|
keyboard = 33
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialisierung der ISR map mit einer Default-ISR.
|
||||||
|
IntDispatcher ();
|
||||||
|
|
||||||
|
// Registrierung einer ISR. (Rueckgabewert: 0 = Erfolg, -1 = Fehler)
|
||||||
|
int assign (unsigned int vector, ISR& gate);
|
||||||
|
|
||||||
|
// ISR fuer 'vector' ausfuehren
|
||||||
|
int report (unsigned int vector);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
73
c_os/kernel/interrupts/PIC.cc
Executable file
73
c_os/kernel/interrupts/PIC.cc
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* *
|
||||||
|
* P I C *
|
||||||
|
* *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Mit Hilfe des PICs koennen Hardware-Interrupts (IRQs) *
|
||||||
|
* einzeln zugelassen oder unterdrueckt werden. Auf diese *
|
||||||
|
* Weise wird also bestimmt, ob die Unterbrechung eines *
|
||||||
|
* Geraetes ueberhaupt an den Prozessor weitergegeben wird. *
|
||||||
|
* Selbst dann erfolgt eine Aktivierung der Unterbrechungs- *
|
||||||
|
* routine nur, wenn der Prozessor bereit ist, auf Unter- *
|
||||||
|
* brechungen zu reagieren. Dies kann mit Hilfe der Klasse *
|
||||||
|
* CPU festgelegt werden. *
|
||||||
|
* *
|
||||||
|
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "kernel/PIC.h"
|
||||||
|
#include "kernel/IOport.h"
|
||||||
|
|
||||||
|
|
||||||
|
static IOport IMR1 (0x21); // interrupt mask register von PIC 1
|
||||||
|
static IOport IMR2 (0xa1); // interrupt mask register von PIC 2
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Methode: PIC::allow *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Sorgt dafuer, dass der uebergebene IRQ ab sofort durch *
|
||||||
|
* den PIC an den Prozessor weitergereicht wird. Um eine *
|
||||||
|
* Unterbrechungsbehandlung zu ermoeglichen, muss *
|
||||||
|
* zusaetzlich CPU::enable_int() aufgerufen werden. *
|
||||||
|
* *
|
||||||
|
* Parameter: *
|
||||||
|
* irq: IRQ der erlaubt werden soll *
|
||||||
|
*****************************************************************************/
|
||||||
|
void PIC::allow (int irq) {
|
||||||
|
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Methode: PIC::forbid *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Unterdrueckt mit Hilfe des PICs einen bestimmten IRQ. *
|
||||||
|
* *
|
||||||
|
* Parameter: *
|
||||||
|
* interrupt: IRQ der maskiert werden soll *
|
||||||
|
*****************************************************************************/
|
||||||
|
void PIC::forbid (int irq) {
|
||||||
|
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Methode: PIC::status *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Liefert den aktuellen Zustand des Maskierbits eines *
|
||||||
|
* bestimmten IRQs. *
|
||||||
|
* *
|
||||||
|
* Parameter: *
|
||||||
|
* irq: IRQ dessen Status erfragt werden soll *
|
||||||
|
*****************************************************************************/
|
||||||
|
bool PIC::status (int irq) {
|
||||||
|
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
44
c_os/kernel/interrupts/PIC.h
Executable file
44
c_os/kernel/interrupts/PIC.h
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* *
|
||||||
|
* P I C *
|
||||||
|
* *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Mit Hilfe des PICs koennen Hardware-Interrupts (IRQs) *
|
||||||
|
* einzeln zugelassen oder unterdrueckt werden. Auf diese *
|
||||||
|
* Weise wird also bestimmt, ob die Unterbrechung eines *
|
||||||
|
* Geraetes ueberhaupt an den Prozessor weitergegeben wird. *
|
||||||
|
* Selbst dann erfolgt eine Aktivierung der Unterbrechungs- *
|
||||||
|
* routine nur, wenn der Prozessor bereit ist, auf Unter- *
|
||||||
|
* brechungen zu reagieren. Dies kann mit Hilfe der Klasse *
|
||||||
|
* CPU festgelegt werden. *
|
||||||
|
* *
|
||||||
|
* Autor: Olaf Spinczyk, TU Dortmund *
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef __PIC_include__
|
||||||
|
#define __PIC_include__
|
||||||
|
|
||||||
|
class PIC {
|
||||||
|
|
||||||
|
private:
|
||||||
|
PIC(const PIC ©); // Verhindere Kopieren
|
||||||
|
public:
|
||||||
|
PIC() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
// IRQ-Nummern von Geraeten
|
||||||
|
enum {
|
||||||
|
timer = 0, // Programmable Interrupt Timer (PIT)
|
||||||
|
keyboard = 1 // Tastatur
|
||||||
|
};
|
||||||
|
|
||||||
|
// Freischalten der Weiterleitung eines IRQs durch den PIC an die CPU
|
||||||
|
void allow (int irq);
|
||||||
|
|
||||||
|
// Unterdruecken der Weiterleitung eines IRQs durch den PIC an die CPU
|
||||||
|
void forbid (int irq);
|
||||||
|
|
||||||
|
// Abfragen, ob die Weiterleitung fuer einen bestimmten IRQ unterdrueckt ist
|
||||||
|
bool status (int interrupt_device);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
0
c_os/lib/MyStdLib.cc
Normal file → Executable file
0
c_os/lib/MyStdLib.cc
Normal file → Executable file
13
c_os/main.cc
13
c_os/main.cc
@ -47,9 +47,18 @@ int main() {
|
|||||||
// text_demo();
|
// text_demo();
|
||||||
// sound_demo();
|
// sound_demo();
|
||||||
// keyboard_demo();
|
// keyboard_demo();
|
||||||
heap_demo();
|
// heap_demo();
|
||||||
|
|
||||||
scroll_mode();
|
// Tastatur-Unterbrechungsroutine 'einstoepseln'
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
// Interrupts erlauben (Tastatur)
|
||||||
|
/* hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
key_irq_demo();
|
||||||
|
|
||||||
|
// TODO: Use interrupts
|
||||||
|
// scroll_mode();
|
||||||
|
|
||||||
while (1) {};
|
while (1) {};
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
18
c_os/user/KeyIRQDemo.cc
Normal file
18
c_os/user/KeyIRQDemo.cc
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* *
|
||||||
|
* K E Y I R Q D E M O *
|
||||||
|
* *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Demo zu Interrupts. *
|
||||||
|
* *
|
||||||
|
* Autor: Michael Schoettner, HHU, 26.10.2018 *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "kernel/Globals.h"
|
||||||
|
|
||||||
|
|
||||||
|
void key_irq_demo() {
|
||||||
|
|
||||||
|
/* Hier muss Code eingefuegt werden */
|
||||||
|
|
||||||
|
}
|
||||||
16
c_os/user/KeyIRQDemo.h
Normal file
16
c_os/user/KeyIRQDemo.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* *
|
||||||
|
* K E Y I R Q D E M O *
|
||||||
|
* *
|
||||||
|
*---------------------------------------------------------------------------*
|
||||||
|
* Beschreibung: Demo zu Interrupts. *
|
||||||
|
* *
|
||||||
|
* Autor: Michael Schoettner, HHU, 26.10.2018 *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __KeyIRQDemo_include__
|
||||||
|
#define __KeyIRQDemo_include__
|
||||||
|
|
||||||
|
void key_irq_demo();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user