OOStuBS - Technische Informatik II (TI-II)  2.4
interruptstorage.cc
gehe zur Dokumentation dieser Datei
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2  * Technische Informatik II *
3  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * *
5  * I N T E R R U P T _ S T O R A G E *
6  * *
7 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8 
9 /* * * * * * * * * * * * * * * * * * * * * * * * *\
10 # INCLUDES #
11 \* * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 
15 /* * * * * * * * * * * * * * * * * * * * * * * * *\
16 # METHODS #
17 \* * * * * * * * * * * * * * * * * * * * * * * * */
18 
19 bool InterruptStorage::iNum2Index(int iNum, unsigned int& index){
20  int temp = iNum-mMinINum;
21  if(temp >= 0 && temp < mMaxINum-mMinINum){
22  index=temp;
23  return true;
24  }else
25  return false;
26 }
27 
29  for(unsigned int i=0;i<mMaxINum-mMinINum;i++)
30  mHandler[i] = &panic;
31 }
32 
33 void InterruptStorage::assign(int iNum, InterruptHandler& handler){
34  unsigned int index;
35  if(iNum2Index(iNum, index))
36  mHandler[index] = &handler;
37 }
38 
39 void InterruptStorage::handle(int iNum){
40  unsigned int index;
41 
42  panic.currentInterrupt(iNum);
43 
44  if(iNum2Index(iNum, index))
45  mHandler[index]->trigger();
46  else
47  panic.trigger();
48 }