From 3733a77bb073c6c22e674bebe22a6f4f9a2b5225 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 23 Sep 2011 11:26:49 +0800 Subject: [PATCH] Kernel/arm7 - Serial works (realview-pb-a8) --- Kernel/arch/arm7/debug.c | 11 +++++------ Kernel/arch/arm7/include/lock.h | 10 ++++++++++ Kernel/arch/arm7/proc.c | 2 +- Kernel/arch/arm7/start.s | 22 +++++++++++++--------- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Kernel/arch/arm7/debug.c b/Kernel/arch/arm7/debug.c index ba64ba0f..02a17be1 100644 --- a/Kernel/arch/arm7/debug.c +++ b/Kernel/arch/arm7/debug.c @@ -3,10 +3,8 @@ #include // === CONSTANTS === -#define SERIAL_BASE 0x16000000 -#define SERIAL_REG_DATA 0x0 -#define SERIAL_REG_FLAG 0x18 -#define SERIAL_FLAG_FULL 0x20 +//#define UART0_BASE 0x10009000 +#define UART0_BASE 0xF0000000 // === PROTOTYPES === void KernelPanic_SetMode(void); @@ -19,10 +17,11 @@ void StartupPrint(const char *str); // === CODE === void Debug_PutCharDebug(char ch) { - while( *(volatile Uint32*)(SERIAL_BASE + SERIAL_REG_FLAG) & SERIAL_FLAG_FULL ) +// while( *(volatile Uint32*)(SERIAL_BASE + SERIAL_REG_FLAG) & SERIAL_FLAG_FULL ) ; - *(volatile Uint32*)(SERIAL_BASE + SERIAL_REG_DATA) = ch; +// *(volatile Uint32*)(SERIAL_BASE + SERIAL_REG_DATA) = ch; + *(volatile Uint32*)(UART0_BASE) = ch; } void Debug_PutStringDebug(const char *str) diff --git a/Kernel/arch/arm7/include/lock.h b/Kernel/arch/arm7/include/lock.h index 5a670862..627726b5 100644 --- a/Kernel/arch/arm7/include/lock.h +++ b/Kernel/arch/arm7/include/lock.h @@ -26,6 +26,7 @@ static inline int CPU_HAS_LOCK(struct sShortSpinlock *Lock) static inline int SHORTLOCK(struct sShortSpinlock *Lock) { + #if 1 // Coped from linux, yes, but I know what it does now :) Uint tmp; __asm__ __volatile__ ( @@ -38,6 +39,15 @@ static inline int SHORTLOCK(struct sShortSpinlock *Lock) : "r" (&Lock->Lock), "r" (1) : "cc" // Condition codes clobbered ); + #else + int v = 1; + while( v ) + __asm__ __volatile__ ( + "swp %0, [%1]" + : "=r" (v) : "r" (&Lock->Lock) + : "cc" + ); + #endif return 1; } diff --git a/Kernel/arch/arm7/proc.c b/Kernel/arch/arm7/proc.c index 07c823eb..9b4dc183 100644 --- a/Kernel/arch/arm7/proc.c +++ b/Kernel/arch/arm7/proc.c @@ -42,7 +42,7 @@ void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char ** { } -tTID Proc_SpawnWorker(void) +tTID Proc_SpawnWorker( void (*Fnc)(void*), void *Ptr ) { return 0; } diff --git a/Kernel/arch/arm7/start.s b/Kernel/arch/arm7/start.s index fb28d33b..abfbb59b 100644 --- a/Kernel/arch/arm7/start.s +++ b/Kernel/arch/arm7/start.s @@ -3,7 +3,7 @@ KERNEL_BASE = 0x80000000 .section .init interrupt_vector_table: b _start @ Reset - b . + b . @ ? b SyscallHandler @ SWI instruction b . b . @@ -17,13 +17,16 @@ _start: mcr p15, 0, r0, c2, c0, 1 @ Set TTBR1 to r0 mcr p15, 0, r0, c2, c0, 0 @ Set TTBR0 to r0 too (for identity) -@ mov r0, #1 -@ mcr p15, 0, r0, c2, c0, 2 @ Set TTCR to 1 (50/50 split) + mov r0, #1 + mcr p15, 0, r0, c2, c0, 2 @ Set TTCR to 1 (50/50 split) + + mov r0, #3 + mcr p15, 0, r0, c3, c0, 0 @ Set Domain 0 to Manager -@ mrc p15, 0, r0, c1, c0, 0 + mrc p15, 0, r0, c1, c0, 0 orr r0, r0, #1 -@ orr r0, r0, #1 << 23 -@ mcr p15, 0, r0, c1, c0, 0 + orr r0, r0, #1 << 23 + mcr p15, 0, r0, c1, c0, 0 ldr sp, =stack+0x10000 @ Set up stack ldr r0, =kmain @@ -41,10 +44,10 @@ SyscallHandler: kernel_table0: .long 0x00000002 @ Identity map the first 4 MiB - .rept 0x801 + .rept 0x800 - 1 .long 0 .endr - .long 0x00000002 @ Identity map the first 4 MiB + .long 0x00000002 @ Map first 4 MiB to 2GiB .long 0x00100002 @ .long 0x00200002 @ .long 0x00300002 @ @@ -79,9 +82,10 @@ kernel_table1_map: .long kernel_table1_map - KERNEL_BASE + (1 << 4) + 3 .long 0 +@ Hardware mappings .globl hwmap_table_0 hwmap_table_0: - .long 0x16000000 + (1 << 4) + 3 @ Serial Port + .long 0x10009000 + (1 << 4) + 3 @ UART0 .rept 1024 - 1 .long 0 .endr -- 2.20.1