Kernel - Fix compilation on x86_64 and armv7 (for MM changes)
[tpg/acess2.git] / KernelLand / Kernel / arch / armv7 / debug.c
1 /**
2  * Acess2
3  * - By John Hodge (thePowersGang)
4  *
5  * arch/arm7/debug.c
6  * - ARM7 Debug output
7  * NOTE: Currently designed for the realview-pb-a8 emulated by Qemu
8  * - PL011
9  */
10 #include <acess.h>
11 #include <drv_serial.h>
12 #include <debug_hooks.h>
13
14 // === CONSTANTS ===
15 //#define UART0_BASE    0x10009000
16 #define UART0_BASE      0xF1000000      // Boot time mapped
17
18 // === PROTOTYPES ===
19 void    Debug_int_SerialIRQHandler(int IRQ, void *unused);
20 void    KernelPanic_SetMode(void);
21 void    KernelPanic_PutChar(char Ch);
22 void    StartupPrint(const char *str);
23
24 // === GLOBALS ===
25  int    giDebug_SerialInitialised = 0;
26
27 // === CODE ===
28 void Debug_int_SerialIRQHandler(int IRQ, void *unused)
29 {
30         volatile Uint32 *regs = (void*)UART0_BASE;
31         #if PLATFORM_is_realview_pb
32         if( !(regs[15] & 0x10) ) {
33         #else
34         if( !(regs[5] & 1) ) {
35         #endif
36                 // RX Int hadn't fired
37                 Debug("No IRQ %x %x", regs[15], regs[0]);
38                 return ;
39         }
40         char ch = regs[0];
41         Serial_ByteReceived(gSerial_KernelDebugPort, ch);
42 }
43
44 void Debug_PutCharDebug(char ch)
45 {
46         if(ch == '\n')
47                 Debug_PutCharDebug('\r');
48         
49         volatile Uint32 *regs = (void*)UART0_BASE;
50         
51         if( !giDebug_SerialInitialised ) {
52                 #if PLATFORM_is_tegra2
53                 // 16550 (i.e. PC) compatible
54                 regs[1] = 5;    // Enable RX interrupt
55                 #else
56                 regs[14] = 0x10;        // Enable RX interrupt
57                 regs[13] = (1<<1);      // Set RX trigger to 1 byte
58                 #endif
59                 giDebug_SerialInitialised = 1;
60         }
61
62         #if PLATFORM_is_tegra2
63         // Tegra2
64         while( !(regs[5] & (1 << 5)) )
65                 ;
66         #endif
67         
68         regs[0] = ch;
69 }
70
71 void Debug_PutStringDebug(const char *str)
72 {
73         for( ; *str; str++ )
74                 Debug_PutCharDebug( *str );
75 }
76
77 void KernelPanic_SetMode(void)
78 {
79 }
80
81 void KernelPanic_PutChar(char ch)
82 {
83 //      Debug_PutCharDebug(ch);
84 }
85
86 void StartupPrint(const char *str)
87 {
88 }
89
90 void Proc_PrintBacktrace(void)
91 {
92         // TODO: Print backtrace
93 }
94

UCC git Repository :: git.ucc.asn.au