implement exercise 04 interrupts
This commit is contained in:
@ -10,13 +10,11 @@
|
||||
* *
|
||||
* Autor: Michael Schoettner, 31.8.2016 *
|
||||
*****************************************************************************/
|
||||
#include "kernel/interrupts/IntDispatcher.h"
|
||||
#include "kernel/CPU.h"
|
||||
#include "kernel/Globals.h"
|
||||
#include "kernel/interrupts/IntDispatcher.h"
|
||||
|
||||
|
||||
extern "C" void int_disp (unsigned int slot);
|
||||
|
||||
extern "C" void int_disp(unsigned int slot);
|
||||
|
||||
/*****************************************************************************
|
||||
* Prozedur: int_disp *
|
||||
@ -30,26 +28,25 @@ extern "C" void int_disp (unsigned int slot);
|
||||
* Parameter: *
|
||||
* vector: Vektor-Nummer der Unterbrechung *
|
||||
*****************************************************************************/
|
||||
void int_disp (unsigned int vector) {
|
||||
void int_disp(unsigned int vector) {
|
||||
|
||||
/* hier muss Code eingefuegt werden */
|
||||
|
||||
kout << "Ein Interrupt ist aufgetreten" << slot << endl;
|
||||
|
||||
// kout << "Ein Interrupt ist aufgetreten (vector: " << vector << ")" << endl;
|
||||
intdis.report(vector);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Konstruktor: IntDispatcher::IntDispatcher *
|
||||
*---------------------------------------------------------------------------*
|
||||
* Beschreibung: Initialisierung der ISR map mit einer Default-ISR. *
|
||||
*****************************************************************************/
|
||||
IntDispatcher::IntDispatcher () {
|
||||
for (unsigned int slot=0; slot<size; slot++)
|
||||
IntDispatcher::IntDispatcher() {
|
||||
for (unsigned int slot = 0; slot < size; slot++) {
|
||||
map[slot] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: IntDispatcher::assign *
|
||||
*---------------------------------------------------------------------------*
|
||||
@ -61,12 +58,20 @@ IntDispatcher::IntDispatcher () {
|
||||
* *
|
||||
* Rueckgabewert: 0 = Erfolg, -1 = Fehler *
|
||||
*****************************************************************************/
|
||||
int IntDispatcher::assign (unsigned int vector, ISR& isr) {
|
||||
int IntDispatcher::assign(unsigned int vector, ISR& isr) {
|
||||
|
||||
/* hier muss Code eingefuegt werden */
|
||||
|
||||
}
|
||||
if (vector >= this->size) {
|
||||
kout << "Invalid vector number when assigning" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
this->map[vector] = &isr;
|
||||
kout << "Registered ISR for vector " << dec << vector << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Methode: IntDispatcher::report *
|
||||
@ -78,8 +83,22 @@ int IntDispatcher::assign (unsigned int vector, ISR& isr) {
|
||||
* *
|
||||
* Rueckgabewert: 0 = ISR wurde aufgerufen, -1 = unbekannte Vektor-Nummer *
|
||||
*****************************************************************************/
|
||||
int IntDispatcher::report (unsigned int vector) {
|
||||
int IntDispatcher::report(unsigned int vector) {
|
||||
|
||||
/* hier muss Code eingefuegt werden */
|
||||
|
||||
if (vector >= this->size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ISR* isr = this->map[vector];
|
||||
|
||||
if (isr == 0) {
|
||||
kout << "No ISR registered for vector " << vector << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
isr->trigger();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user