dd87e7ee435df083b4baabee8ae1205a4b0c7daa
[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
13 // === CONSTANTS ===
14 //#define UART0_BASE    0x10009000
15 #define UART0_BASE      0xF1000000      // Boot time mapped
16
17 // === PROTOTYPES ===
18 void    Debug_int_SerialIRQHandler(int IRQ, void *unused);
19 void    KernelPanic_SetMode(void);
20 void    KernelPanic_PutChar(char Ch);
21 void    StartupPrint(const char *str);
22
23 // === GLOBALS ===
24  int    giDebug_SerialInitialised = 0;
25
26 // === CODE ===
27 void Debug_int_SerialIRQHandler(int IRQ, void *unused)
28 {
29         volatile Uint32 *regs = (void*)UART0_BASE;
30         if( !(regs[15] & 0x10) ) {
31                 // RX Int hadn't fired
32                 Debug("No IRQ %x %x", regs[15], regs[0]);
33                 return ;
34         }
35         char ch = regs[0];
36         Serial_ByteReceived(gSerial_KernelDebugPort, ch);
37 }
38
39 void Debug_PutCharDebug(char ch)
40 {
41         if(ch == '\n')
42                 Debug_PutCharDebug('\r');
43         
44         volatile Uint32 *regs = (void*)UART0_BASE;
45         
46         if( !giDebug_SerialInitialised ) {
47                 regs[14] = 0x10;        // Enable RX interrupt
48                 regs[13] = (1<<1);      // Set RX trigger to 1 byte
49                 giDebug_SerialInitialised = 1;
50         }
51
52         #if PLATFORM_is_tegra2
53         // Tegra2
54         while( !(regs[5] & (1 << 5)) )
55                 ;
56         #endif
57         
58 //      *(volatile Uint32*)(SERIAL_BASE + SERIAL_REG_DATA) = ch;
59         regs[0] = ch;
60 }
61
62 void Debug_PutStringDebug(const char *str)
63 {
64         for( ; *str; str++ )
65                 Debug_PutCharDebug( *str );
66 }
67
68 void KernelPanic_SetMode(void)
69 {
70 }
71
72 void KernelPanic_PutChar(char ch)
73 {
74 //      Debug_PutCharDebug(ch);
75 }
76
77 void StartupPrint(const char *str)
78 {
79 }
80

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