From: John Hodge Date: Sat, 7 Jan 2012 10:07:52 +0000 (+0800) Subject: Fixing Tegra2 build X-Git-Tag: rel0.14~19 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=72e1657f992d917aee5c0b5ca17bf730537629d1;p=tpg%2Facess2.git Fixing Tegra2 build --- diff --git a/Kernel/arch/armv7/Makefile b/Kernel/arch/armv7/Makefile index 4e36774c..fad1b55d 100644 --- a/Kernel/arch/armv7/Makefile +++ b/Kernel/arch/armv7/Makefile @@ -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 diff --git a/Kernel/arch/armv7/debug.c b/Kernel/arch/armv7/debug.c index d75048ed..7b9e55dd 100644 --- a/Kernel/arch/armv7/debug.c +++ b/Kernel/arch/armv7/debug.c @@ -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; diff --git a/Kernel/arch/armv7/include/lock.h b/Kernel/arch/armv7/include/lock.h index 627726b5..6688af48 100644 --- a/Kernel/arch/armv7/include/lock.h +++ b/Kernel/arch/armv7/include/lock.h @@ -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" ); diff --git a/Kernel/arch/armv7/link.ld b/Kernel/arch/armv7/link.ld index bf07b4cb..d10dcc46 100644 --- a/Kernel/arch/armv7/link.ld +++ b/Kernel/arch/armv7/link.ld @@ -44,10 +44,12 @@ SECTIONS } .bss : AT( ADDR(.bss) - _kernel_base ) { + bss_start = .; *(.bss*) *(COMMON*) . = ALIGN(0x1000); *(.pabss) + bss_end = .; } gKernelEnd = .; } diff --git a/Kernel/arch/armv7/main.c b/Kernel/arch/armv7/main.c index 20d65d13..eb9f1a63 100644 --- a/Kernel/arch/armv7/main.c +++ b/Kernel/arch/armv7/main.c @@ -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(); diff --git a/Kernel/arch/armv7/mm_phys.c b/Kernel/arch/armv7/mm_phys.c index 53c57315..5e4a2428 100644 --- a/Kernel/arch/armv7/mm_phys.c +++ b/Kernel/arch/armv7/mm_phys.c @@ -32,6 +32,7 @@ extern char gKernelEnd[]; void MM_SetupPhys(void) { + LogF("MM_SetupPhys: ()\n"); MM_Tpl_InitPhys( REALVIEW_LOWRAM_SIZE/0x1000, NULL ); } diff --git a/Kernel/arch/armv7/start.S b/Kernel/arch/armv7/start.S index 7c1be8c5..3f53cc2c 100644 --- a/Kernel/arch/armv7/start.S +++ b/Kernel/arch/armv7/start.S @@ -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 diff --git a/Kernel/debug.c b/Kernel/debug.c index 379f6767..25ffda19 100644 --- a/Kernel/debug.c +++ b/Kernel/debug.c @@ -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 ) { diff --git a/Kernel/lib.c b/Kernel/lib.c index 2b786ece..953264b7 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -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 diff --git a/Modules/Input/PS2KbMouse/pl050.c b/Modules/Input/PS2KbMouse/pl050.c index 5a0a32a6..839c0bda 100644 --- a/Modules/Input/PS2KbMouse/pl050.c +++ b/Modules/Input/PS2KbMouse/pl050.c @@ -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