Skip to content

Commit 0af32c0

Browse files
committed
Added timer interrupt testing to kernel_main
1 parent 96fb750 commit 0af32c0

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

kernel/kernel.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "clear.h"
77
#include "string.h"
88
#include "irq.h"
9+
#include "interrupt.h"
910

1011

1112
static const char *banner[] = {
@@ -54,7 +55,30 @@ void irq_sanity_check(void)
5455
}
5556
}
5657

58+
// This function is for testing purposes.
59+
// It test that the timer interrupt is firing as expected.
60+
void not_main(void)
61+
{
62+
puts("Time0 IRQ firing test!\r\n");
63+
64+
vic_enable_timer01_irq();
65+
timer0_start_periodic(10000);
66+
irq_enable();
67+
68+
unsigned last = 0;
69+
for (;;)
70+
{
71+
unsigned n = tick;
72+
if (n != last && (n % 100) == 0)
73+
{
74+
puts(".");
75+
last = n;
76+
}
77+
}
78+
}
79+
5780
/* The following macros are for testing purposes. */
81+
#define TIMER_TICK_TEST not_main()
5882
#define SANITY_CHECK irq_sanity_check()
5983
#define CALL_SVC_0 __asm__ volatile ("svc #0")
6084

@@ -63,9 +87,10 @@ void kernel_main(void)
6387
{
6488
clear();
6589

66-
/* TEST */
67-
SANITY_CHECK;
68-
CALL_SVC_0;
90+
/* TESTS */
91+
//SANITY_CHECK;
92+
//CALL_SVC_0;
93+
//TIMER_TICK_TEST;
6994

7095
/* Back to normal operations */
7196
init_message();

0 commit comments

Comments
 (0)