-
Notifications
You must be signed in to change notification settings - Fork 0
/
IVTEntry.cpp
58 lines (52 loc) · 1.42 KB
/
IVTEntry.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "IVTEntry.h"
#include "KerEv.h"
#include "Thread.h"
#include "Timer.h"
#include <dos.h>
#include <iostream.h>//test
unsigned IVTEntry::usedTable[256]={0};//Nebitno, ne koristi se
IVTEntry* IVTEntry::ivtTable[256]={0};//Tabela ulaza
IVTEntry::IVTEntry(unsigned char ivtNumber,
Handler newHandler,
int callOldHandlerFlag)
{
asm cli;
myKernelEvent=0;
this->callOldHandlerFlag=callOldHandlerFlag;//flag iz PREPAREENTRY makroa
this->ivtNumber=ivtNumber;
this->newHandler=newHandler;
oldHandler=getvect(ivtNumber);//Nabavljamo staru rutinu
setvect(ivtNumber,newHandler);//Postavljamo novu rutinu
ivtTable[ivtNumber]=this;//Postavljamo ovaj ulaz u tabelu
asm sti;
}
IVTEntry::~IVTEntry()
{
asm cli;
setvect(ivtNumber, oldHandler);//Vracamo staru rutinu
ivtTable[ivtNumber]=0;//Brisemo ulaz iz tabele
if(ivtNumber==9)//Vidio sam negdje da ovako treba, nije radilo bez ovoga
{
asm{
mov al,20h
out 20h,al
}
}
oldHandler=0;
newHandler=0;
asm sti;
}
void IVTEntry::signal()
{
if(myKernelEvent)//Ako postoji myKernelEvent
myKernelEvent->signal();//Pozivamo njegov signal
if(callOldHandlerFlag)//Ako treba pozvati i staru rutinu
{
for(int i=0;i<30000;++i)//Ovo je mali workaround, posto negdje
for(int j=0;j<30000;j++);//nisam dobro ispratio lock i unlock
asm cli;
(*oldHandler)();//Pozivamo staru rutinu
asm sti;
}
dispatch();//Preotimanje
}