Fixing Tegra2 build
authorJohn Hodge <[email protected]>
Sat, 7 Jan 2012 10:07:52 +0000 (18:07 +0800)
committerJohn Hodge <[email protected]>
Sat, 7 Jan 2012 10:07:52 +0000 (18:07 +0800)
Kernel/arch/armv7/Makefile
Kernel/arch/armv7/debug.c
Kernel/arch/armv7/include/lock.h
Kernel/arch/armv7/link.ld
Kernel/arch/armv7/main.c
Kernel/arch/armv7/mm_phys.c
Kernel/arch/armv7/start.S
Kernel/debug.c
Kernel/lib.c
Modules/Input/PS2KbMouse/pl050.c

index 4e36774..fad1b55 100644 (file)
@@ -15,4 +15,6 @@ A_OBJ += mm_phys.o mm_virt.o proc.o proc.ao
 
 #main.c: Makefile.BuildNum.$(ARCH)
 
-POSTBUILD = arm-elf-objcopy $(BIN) -O binary $(BIN)
+ifeq ($(PLATFORM),tegra2)
+       POSTBUILD = arm-elf-objcopy $(BIN) -O binary $(BIN)
+endif
index d75048e..7b9e55d 100644 (file)
@@ -23,8 +23,14 @@ void StartupPrint(const char *str);
 // === CODE ===
 void Debug_PutCharDebug(char ch)
 {
-//     while( *(volatile Uint32*)(SERIAL_BASE + SERIAL_REG_FLAG) & SERIAL_FLAG_FULL )
+       if(ch == '\n')
+               Debug_PutCharDebug('\r');
+
+       #if PLATFORM_is_tegra2
+       // Tegra2
+       while( !(*(volatile Uint32*)(UART0_BASE + 0x14) & (1 << 5)) )
                ;
+       #endif
        
 //     *(volatile Uint32*)(SERIAL_BASE + SERIAL_REG_DATA) = ch;
        *(volatile Uint32*)(UART0_BASE) = ch;
index 627726b..6688af4 100644 (file)
@@ -26,7 +26,7 @@ static inline int CPU_HAS_LOCK(struct sShortSpinlock *Lock)
 
 static inline int SHORTLOCK(struct sShortSpinlock *Lock)
 {
-       #if 1
+       #if 0
        // Coped from linux, yes, but I know what it does now :)
        Uint    tmp;
        __asm__ __volatile__ (
@@ -39,11 +39,14 @@ static inline int SHORTLOCK(struct sShortSpinlock *Lock)
                : "r" (&Lock->Lock), "r" (1)
                : "cc"  // Condition codes clobbered
                );
+       #elif 1
+       while( *(volatile int*)&Lock->Lock )    ;
+       Lock->Lock = 1;
        #else
         int    v = 1;
        while( v )
                __asm__ __volatile__ (
-                       "swp %0, [%1]"
+                       "swp %0, %0, [%1]"
                        : "=r" (v) : "r" (&Lock->Lock)
                        : "cc"
                        );
index bf07b4c..d10dcc4 100644 (file)
@@ -44,10 +44,12 @@ SECTIONS
        }
        .bss : AT( ADDR(.bss) - _kernel_base )
        {
+               bss_start = .;
                *(.bss*)
                *(COMMON*)
                . = ALIGN(0x1000);
                *(.pabss)
+               bss_end = .;
        }
        gKernelEnd = .;
 }
index 20d65d1..eb9f1a6 100644 (file)
@@ -24,8 +24,8 @@ Uint32        ARMv7_int_HandleSyscalls(Uint32 Num, Uint32 *Args);
 int kmain(void)
 {
        LogF("Acess2 ARMv7 v"EXPAND_STR(KERNEL_VERSION)"\n");
-       LogF(" Build %i, Git Hash %s\n", BUILD_NUM, gsGitHash);
-//     Interrupts_Setup();
+       LogF(" Git Hash %s\n", gsGitHash);
+       LogF(" Build %i\n", BUILD_NUM);
        
        MM_SetupPhys();
 
index 53c5731..5e4a242 100644 (file)
@@ -32,6 +32,7 @@ extern char   gKernelEnd[];
 
 void MM_SetupPhys(void)
 {
+       LogF("MM_SetupPhys: ()\n");
        MM_Tpl_InitPhys( REALVIEW_LOWRAM_SIZE/0x1000, NULL );
 }
 
index 7c1be8c..3f53cc2 100644 (file)
@@ -87,13 +87,27 @@ _start:
        str r1, [r2]    
        mov r1, #'m'
        str r1, [r2]    
+       mov r1, #13
+       str r1, [r2]    
+       mov r1, #10
+       str r1, [r2]    
 
-       ldr sp, =0x80000000-4   @ Set up stack (top of user range)
+.extern bss_start
+.extern bss_size_div_4
+.zero_bss:
+       ldr r0, =bss_start
+       ldr r1, =bss_end
+       mov r3, #0
+.zero_bss_loop:
+       str r3, [r0],#4
+       cmp r0, r1
+       bls .zero_bss_loop
+
+.goto_c:
+       ldr sp, =0x80000000-8   @ Set up stack (top of user range)
        ldr r0, =kmain
        mov pc, r0
 1:     b 1b    @ Infinite loop
-_ptr_kmain:
-       .long kmain
 
 .comm irqstack, 0x1000 @ ; 4KiB Stack
 .comm abortstack, 0x1000       @ ; 4KiB Stack
index 379f676..25ffda1 100644 (file)
@@ -9,7 +9,7 @@
 
 #define        DEBUG_MAX_LINE_LEN      256
 
-#define        LOCK_DEBUG_OUTPUT       1
+#define        LOCK_DEBUG_OUTPUT       0
 
 #define TRACE_TO_KTERM 0
 
@@ -37,7 +37,7 @@ tShortSpinlock        glDebug_Lock;
 
 // === CODE ===
 static void Debug_Putchar(char ch)
-{      
+{
        Debug_PutCharDebug(ch);
        if( !gbDebug_IsKPanic )
        {
index 2b786ec..953264b 100644 (file)
@@ -191,11 +191,7 @@ void itoa(char *buf, Uint64 num, int base, int minLength, char pad)
 /**
  * \brief Append a character the the vsnprintf output
  */
-#define PUTCH(c)       do{\
-       char ch=(c);\
-       if(pos==__maxlen){return pos;}\
-       if(__s){__s[pos++]=ch;}else{pos++;}\
-       }while(0)
+#define PUTCH(c)       _putch(c)
 #define GETVAL()       do {\
        if(isLongLong)  val = va_arg(args, Uint64);\
        else    val = va_arg(args, unsigned int);\
@@ -214,16 +210,23 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args)
        size_t  pos = 0;
        // Flags
         int    bPadLeft = 0;
-       
-       //Log("vsnprintf: (__s=%p, __maxlen=%i, __format='%s', ...)", __s, __maxlen, __format);
-       
+
+       inline void _putch(char ch)
+       {
+               if(pos < __maxlen)
+               {
+                       if(__s) __s[pos] = ch;
+                       pos ++;
+               }
+       }
+
        while((c = *__format++) != 0)
        {
                // Non control character
                if(c != '%') { PUTCH(c); continue; }
-               
+
                c = *__format++;
-               //Log("pos = %i", pos);
+               if(c == '\0')   break;
                
                // Literal %
                if(c == '%') { PUTCH('%'); continue; }
@@ -232,9 +235,9 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args)
                if(c == 'p') {
                        Uint    ptr = va_arg(args, Uint);
                        PUTCH('*');     PUTCH('0');     PUTCH('x');
-                       itoa(tmpBuf, ptr, 16, BITS/4, '0');
-                       p = tmpBuf;
-                       goto printString;
+                       for( len = BITS/4; len --; )
+                               PUTCH( cUCDIGITS[ (ptr>>(len*4))&15 ] );
+                       continue ;
                }
                
                // - Padding Side Flag
index 5a0a32a..839c0bd 100644 (file)
@@ -86,7 +86,7 @@ static inline void PL050_WriteMouseData(Uint8 Data)
 
        ENTER("xData", Data);
 
-       while( --timeout && gpPL050_MouseBase[1] & PL050_TXBUSY );
+       while( --timeout && (gpPL050_MouseBase[1] & PL050_TXBUSY) );
        if(timeout)
                gpPL050_MouseBase[2] = Data;
        else

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