#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
// === 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;
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__ (
: "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"
);
}
.bss : AT( ADDR(.bss) - _kernel_base )
{
+ bss_start = .;
*(.bss*)
*(COMMON*)
. = ALIGN(0x1000);
*(.pabss)
+ bss_end = .;
}
gKernelEnd = .;
}
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();
void MM_SetupPhys(void)
{
+ LogF("MM_SetupPhys: ()\n");
MM_Tpl_InitPhys( REALVIEW_LOWRAM_SIZE/0x1000, NULL );
}
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
#define DEBUG_MAX_LINE_LEN 256
-#define LOCK_DEBUG_OUTPUT 1
+#define LOCK_DEBUG_OUTPUT 0
#define TRACE_TO_KTERM 0
// === CODE ===
static void Debug_Putchar(char ch)
-{
+{
Debug_PutCharDebug(ch);
if( !gbDebug_IsKPanic )
{
/**
* \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);\
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; }
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
ENTER("xData", Data);
- while( --timeout && gpPL050_MouseBase[1] & PL050_TXBUSY );
+ while( --timeout && (gpPL050_MouseBase[1] & PL050_TXBUSY) );
if(timeout)
gpPL050_MouseBase[2] = Data;
else