55#include "printf.h"
66#include "clear.h"
77#include "string.h"
8+ #include "irq.h"
9+
810
911static const char * banner [] = {
1012 "========================================\r\n" ,
@@ -26,17 +28,47 @@ static void init_message(void)
2628 {
2729 puts (banner [i ]);
2830 }
31+
32+ printf ("AstraKernel is running...\r\n" );
33+ printf ("Press Ctrl-A and then X to exit QEMU.\r\n" );
34+ printf ("\r\n" );
35+ }
36+
37+ void irq_sanity_check (void )
38+ {
39+ irq_disable ();
40+ unsigned before = tick ;
41+
42+ irq_enable ();
43+ irq_disable ();
44+
45+ unsigned after = tick ;
46+
47+ if (before == after )
48+ {
49+ puts ("\r\nA1 Sanity PASS: no spurious IRQs\r\n" );
50+ }
51+ else
52+ {
53+ puts ("\r\nA1 Sanity FAIL: unexpected IRQs\r\n" );
54+ }
2955}
3056
57+ /* The following macros are for testing purposes. */
58+ #define SANITY_CHECK irq_sanity_check()
59+ #define CALL_SVC_0 __asm__ volatile ("svc #0")
60+
3161// Entry point for the kernel
3262void kernel_main (void )
3363{
3464 clear ();
3565
66+ /* TEST */
67+ SANITY_CHECK ;
68+ CALL_SVC_0 ;
69+
70+ /* Back to normal operations */
3671 init_message ();
37- printf ("AstraKernel is running...\r\n" );
38- printf ("Press Ctrl-A and then X to exit QEMU.\r\n" );
39- printf ("\r\n" );
4072
4173 char input_buffer [100 ];
4274
@@ -59,25 +91,25 @@ void kernel_main(void)
5991 break ;
6092 case 'e' :
6193 int result = strcmp ("abc" , "abc" ); // Expect 0
62- printf ("Expect 0 -> %d\n" , result );
94+ printf ("Expect 0 -> %d\r\ n" , result );
6395
6496 result = strcmp ("abc" , "abd" ); // Expect -1
65- printf ("Expect -1 -> %d\n" , result );
97+ printf ("Expect -1 -> %d\r\ n" , result );
6698
6799 result = strcmp ("abc" , "ABC" ); // Expect 1
68- printf ("Expect 1 -> %d\n" , result );
100+ printf ("Expect 1 -> %d\r\ n" , result );
69101
70102 result = strcmp ("ABC" , "abc" ); // Expect -1
71- printf ("Expect -1 -> %d\n" , result );
103+ printf ("Expect -1 -> %d\r\ n" , result );
72104
73105 result = strcmp ("\x01\x02\x03" , "\x01\x02\x03" ); // Expect 0
74- printf ("Expect 0 -> %d\n" , result );
106+ printf ("Expect 0 -> %d\r\ n" , result );
75107
76108 result = strcmp ("\x01\x02\x03" , "\x01\x02\x04" ); // Expect -1
77- printf ("Expect -1 -> %d\n" , result );
109+ printf ("Expect -1 -> %d\r\ n" , result );
78110
79111 result = strcmp ("\x01\x02\x04" , "\x01\x02\x03" ); // Expect 1
80- printf ("Expect 1 -> %d\n" , result );
112+ printf ("Expect 1 -> %d\r\ n" , result );
81113 break ;
82114 case 'q' : // Check for exit command
83115 printf ("Exiting...\r\n" );
@@ -89,11 +121,11 @@ void kernel_main(void)
89121
90122 case 't' : // Check for time command
91123 gettime (& time_struct );
92- printf ("Current time(GMT): %d:%d:%d\n" , time_struct .hrs , time_struct .mins , time_struct .secs );
124+ printf ("Current time(GMT): %d:%d:%d\r\ n" , time_struct .hrs , time_struct .mins , time_struct .secs );
93125 break ;
94126 case 'd' : // Check for date command
95127 getdate (& date_struct );
96- printf ("Current date(MM-DD-YYYY): %d-%d-%d\n" , date_struct .month , date_struct .day , date_struct .year );
128+ printf ("Current date(MM-DD-YYYY): %d-%d-%d\r\ n" , date_struct .month , date_struct .day , date_struct .year );
97129 break ;
98130 default :
99131 printf ("Unknown command. Type 'h' for help.\r\n" );
0 commit comments