blob: ff26eba3d49cac3716a8d0dce77936b1ea5cfcd6 (
plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#include "uart.h"
#include "interrupts.h"
#include "io.h"
#include "svc_interface.h"
#include "armclock.h"
/**
@brief The undefined instruction interrupt handler
*/
void __attribute__((noreturn)) setup(void);
// from what I've heard, reset is never used on the Pi;
// in our case it should run once - when stage1 of the kernel
// jumps to stage2
void reset_handler(void)
{
setup();
}
void undefined_instruction_vector(void)
{
puts("Undefined instruction occured");
while( 1 )
{
/* Do Nothing! */
}
}
uint32_t supervisor_call_handler(enum svc_type request, uint32_t arg1,
uint32_t arg2, uint32_t arg3)
{
(void) arg2; (void) arg3; // unused for now
switch(request) {
case UART_PUTCHAR:
putchar(arg1);
break;
case UART_GETCHAR:
return getchar();
case UART_WRITE:
puts("UART_WRITE not implemented!!!!!");
break;
default:
// perhaps we should kill the process now?
puts("unknown supervisor call type!!!!!");
}
return 0; // a dummy value
}
void abort_handler(void)
{
puts("re-entered system");
while(1);
}
void generic_handler(void)
{
puts("something weird happened");
while(1);
}
void irq_handler(void)
{
// uart_puts("nwm\r\n");
// system_reentry_point();
if (armclk_irq_pending())
{
puts("<<irq from timer>>");
armclk_irq_settimeout(0x00100000);
}
else
{
puts("unknown irq");
while(1);
}
}
void fiq_handler(void)
{
puts("fiq happened");
while(1);
}
/* Here is your interrupt function */
void
__attribute__((interrupt("IRQ")))
__attribute__((section(".interrupt_vectors.text")))
irq_handler2(void) {
/* You code goes here */
// uart_puts("GOT INTERRUPT!\r\n");
local_timer_clr_reload_reg_t temp = { .IntClear = 1, .Reload = 1 };
QA7->TimerClearReload = temp; // Clear interrupt & reload
}
/* here is your main */
int enable_timer(void) {
QA7->TimerRouting.Routing = LOCALTIMER_TO_CORE0_IRQ; // Route local timer IRQ to Core0
QA7->TimerControlStatus.ReloadValue = 100; // Timer period set
QA7->TimerControlStatus.TimerEnable = 1; // Timer enabled
QA7->TimerControlStatus.IntEnable = 1; // Timer IRQ enabled
QA7->TimerClearReload.IntClear = 1; // Clear interrupt
QA7->TimerClearReload.Reload = 1; // Reload now
QA7->Core0TimerIntControl.nCNTPNSIRQ_IRQ = 1; // We are in NS EL1 so enable IRQ to core0 that level
QA7->Core0TimerIntControl.nCNTPNSIRQ_FIQ = 0; // Make sure FIQ is zero
// uart_puts("Enabled Timer\r\n");
return(0);
}
|