1 |
2 |
fukuchi |
/* This file is part of test microkernel for OpenRISC 1000. */
|
2 |
|
|
/* (C) 2001 Simon Srot, srot@opencores.org */
|
3 |
|
|
|
4 |
|
|
#include "support.h"
|
5 |
|
|
#include "spr_defs.h"
|
6 |
|
|
#include "debug.h"
|
7 |
|
|
|
8 |
|
|
#include "int.h"
|
9 |
|
|
|
10 |
|
|
static IHND int_handlers[MAX_INT_HANDLERS] __attribute__ ((section(".bss")));
|
11 |
|
|
|
12 |
|
|
//void (*vector_0x000)(void) = dummy_main;
|
13 |
|
|
//void (*vector_0x100)(void) = dummy_main;
|
14 |
|
|
//void (*vector_0x200)(void) = dummy_main;
|
15 |
|
|
//void (*vector_0x300)(void) = dummy_main;
|
16 |
|
|
//void (*vector_0x400)(void) = dummy_main;
|
17 |
|
|
//void (*vector_0x500)(void) = tick_main; // tick.c
|
18 |
|
|
//void (*vector_0x600)(void) = dummy_main;
|
19 |
|
|
//void (*vector_0x700)(void) = dummy_main;
|
20 |
|
|
//void (*vector_0x800)(void) = int_main; // int.c
|
21 |
|
|
//void (*vector_0x900)(void) = dummy_main;
|
22 |
|
|
//void (*vector_0xa00)(void) = dummy_main;
|
23 |
|
|
//void (*vector_0xb00)(void) = dummy_main;
|
24 |
|
|
//void (*vector_0xc00)(void) = dummy_main;
|
25 |
|
|
//void (*vector_0xd00)(void) = dummy_main;
|
26 |
|
|
//void (*vector_0xe00)(void) = dummy_main;
|
27 |
|
|
//void (*vector_0xf00)(void) = dummy_main;
|
28 |
|
|
|
29 |
|
|
//
|
30 |
|
|
// dummy excption
|
31 |
|
|
//
|
32 |
|
|
void dummy0x000_main(){
|
33 |
|
|
unsigned long int epcr,eear,esr;
|
34 |
|
|
epcr = mfspr(SPR_EPCR_BASE);
|
35 |
|
|
eear = mfspr(SPR_EEAR_BASE);
|
36 |
|
|
esr = mfspr(SPR_ESR_BASE);
|
37 |
|
|
DEBUG_INTEGER(epcr,8);
|
38 |
|
|
DEBUG_PRINT("\n");
|
39 |
|
|
DEBUG_INTEGER(eear,8);
|
40 |
|
|
DEBUG_PRINT("\n");
|
41 |
|
|
DEBUG_INTEGER(esr,8);
|
42 |
|
|
DEBUG_PRINT("\n");
|
43 |
|
|
return;
|
44 |
|
|
}
|
45 |
|
|
void dummy0x100_main(){ DEBUG_PRINT("1"); return; }
|
46 |
|
|
void dummy0x200_main(){ DEBUG_PRINT("2"); return; }
|
47 |
|
|
void dummy0x300_main(){ DEBUG_PRINT("3"); return; }
|
48 |
|
|
void dummy0x400_main(){ DEBUG_PRINT("4"); return; }
|
49 |
|
|
void dummy0x500_main(){ DEBUG_PRINT("5"); return; }
|
50 |
|
|
void dummy0x600_main(){ DEBUG_PRINT("6"); return; }
|
51 |
|
|
void dummy0x700_main(){ DEBUG_PRINT("7"); return; }
|
52 |
|
|
void dummy0x800_main(){ DEBUG_PRINT("8"); return; }
|
53 |
|
|
void dummy0x900_main(){ DEBUG_PRINT("9"); return; }
|
54 |
|
|
void dummy0xa00_main(){ DEBUG_PRINT("a"); return; }
|
55 |
|
|
void dummy0xb00_main(){ DEBUG_PRINT("b"); return; }
|
56 |
|
|
void dummy0xc00_main(){ DEBUG_PRINT("c"); return; }
|
57 |
|
|
void dummy0xd00_main(){ DEBUG_PRINT("d"); return; }
|
58 |
|
|
void dummy0xe00_main(){ DEBUG_PRINT("e"); return; }
|
59 |
|
|
void dummy0xf00_main(){ DEBUG_PRINT("f"); return; }
|
60 |
|
|
void dummy_main(){
|
61 |
|
|
unsigned long int epcr,eear,esr;
|
62 |
|
|
epcr = mfspr(SPR_EPCR_BASE);
|
63 |
|
|
eear = mfspr(SPR_EEAR_BASE);
|
64 |
|
|
esr = mfspr(SPR_ESR_BASE);
|
65 |
|
|
DEBUG_INTEGER(epcr,8);
|
66 |
|
|
DEBUG_PRINT("\n");
|
67 |
|
|
DEBUG_INTEGER(eear,8);
|
68 |
|
|
DEBUG_PRINT("\n");
|
69 |
|
|
DEBUG_INTEGER(esr,8);
|
70 |
|
|
DEBUG_PRINT("\n");
|
71 |
|
|
return;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
int int_init(){
|
75 |
|
|
unsigned long int i;
|
76 |
|
|
// external interrupt
|
77 |
|
|
for(i = 0; i < MAX_INT_HANDLERS; i++) {
|
78 |
|
|
int_handlers[i].handler = 0;
|
79 |
|
|
int_handlers[i].arg = 0;
|
80 |
|
|
}
|
81 |
|
|
return 0;
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
int int_add(unsigned long vect, void (* handler)(void *), void *arg){
|
85 |
|
|
if(vect >= MAX_INT_HANDLERS) return -1;
|
86 |
|
|
int_handlers[vect].handler = handler;
|
87 |
|
|
int_handlers[vect].arg = arg;
|
88 |
|
|
mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
|
89 |
|
|
return 0;
|
90 |
|
|
}
|
91 |
|
|
int int_disable(unsigned long vect){
|
92 |
|
|
if(vect >= MAX_INT_HANDLERS) return -1;
|
93 |
|
|
mtspr(SPR_PICMR, mfspr(SPR_PICMR) & ~(0x00000001L << vect));
|
94 |
|
|
return 0;
|
95 |
|
|
}
|
96 |
|
|
int int_enable(unsigned long vect){
|
97 |
|
|
if(vect >= MAX_INT_HANDLERS) return -1;
|
98 |
|
|
mtspr(SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << vect));
|
99 |
|
|
return 0;
|
100 |
|
|
}
|
101 |
|
|
void int_main(void){
|
102 |
|
|
{ // external interrupt from exception 0x800
|
103 |
|
|
unsigned long picsr = mfspr(SPR_PICSR);
|
104 |
|
|
unsigned long i = 0;
|
105 |
|
|
mtspr(SPR_PICSR, 0); // need?
|
106 |
|
|
while(i < MAX_INT_HANDLERS) {
|
107 |
|
|
if((picsr & (0x01L << i)) && (int_handlers[i].handler != 0)) {
|
108 |
|
|
(*int_handlers[i].handler)(int_handlers[i].arg);
|
109 |
|
|
mtspr(SPR_PICSR, mfspr(SPR_PICSR) & ~(0x00000001L << i));
|
110 |
|
|
}
|
111 |
|
|
i++;
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
|
|
|