From 5155733afe0b96a2b5c0395668318f6c694ccab3 Mon Sep 17 00:00:00 2001 From: NicJA Date: Mon, 13 Apr 2015 23:32:03 +0000 Subject: [PATCH] wip. move remaining bcm2708 specific code out of kernel and into platform specific file. enable more debug in the videocore gfx driver git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50368 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/arm-all/exec/preparecontext.c | 8 + arch/arm-all/processor/processor_init.c | 19 ++- arch/arm-native/exec/platform_init.c | 6 +- arch/arm-native/kernel/getcpunumber.c | 14 ++ arch/arm-native/kernel/getsystemattr.c | 2 +- arch/arm-native/kernel/intr.c | 162 +++++--------------- arch/arm-native/kernel/kernel_arm.h | 21 ++- arch/arm-native/kernel/kernel_cpu.c | 14 +- arch/arm-native/kernel/kernel_debug.c | 74 +++------ arch/arm-native/kernel/kernel_fb.h | 2 - arch/arm-native/kernel/kernel_intern.h | 4 - arch/arm-native/kernel/kernel_startup.c | 45 +++--- arch/arm-native/kernel/kernel_systimer.c | 6 +- arch/arm-native/kernel/maygetchar.c | 5 +- arch/arm-native/kernel/platform_bcm2708.c | 170 ++++++++++++++++++++- .../2708/hidd/videocoregfx/videocoregfx_class.c | 2 +- .../2708/hidd/videocoregfx/videocoregfx_hardware.c | 2 +- .../2708/hidd/videocoregfx/videocoregfx_hdmi.c | 2 +- .../2708/hidd/videocoregfx/videocoregfx_init.c | 2 +- .../2708/hidd/videocoregfx/videocoregfx_memory.c | 2 +- .../2708/hidd/videocoregfx/videocoregfx_onbitmap.c | 2 +- .../2708/hidd/videocoregfx/videocoregfx_pixfmts.c | 2 +- .../2708/hidd/videocoregfx/videocoregfx_sdtv.c | 2 +- .../soc/broadcom/2708/include/hardware/bcm2708.h | 4 - 24 files changed, 332 insertions(+), 240 deletions(-) rewrite arch/arm-native/kernel/kernel_debug.c (62%) diff --git a/arch/arm-all/exec/preparecontext.c b/arch/arm-all/exec/preparecontext.c index d9dd045b6d..93cf46832b 100644 --- a/arch/arm-all/exec/preparecontext.c +++ b/arch/arm-all/exec/preparecontext.c @@ -15,6 +15,9 @@ #include "exec_intern.h" #include "exec_util.h" +#if defined(__AROSEXEC_SMP__) +#include "etask.h" +#endif BOOL PrepareContext(struct Task *task, APTR entryPoint, APTR fallBack, const struct TagItem *tagList, struct ExecBase *SysBase) @@ -38,6 +41,11 @@ BOOL PrepareContext(struct Task *task, APTR entryPoint, APTR fallBack, { switch(t->ti_Tag) { +#if defined(__AROSEXEC_SMP__) + case TASKTAG_AFFINITY: + IntETask(task->tc_UnionETask.tc_ETask)->iet_CpuAffinity = t->ti_Data; + break; +#endif #define REGARG(x) \ case TASKTAG_ARG ## x: \ ctx->r[x - 1] = t->ti_Data; \ diff --git a/arch/arm-all/processor/processor_init.c b/arch/arm-all/processor/processor_init.c index 937c8fd5b6..0454b87d7f 100644 --- a/arch/arm-all/processor/processor_init.c +++ b/arch/arm-all/processor/processor_init.c @@ -1,5 +1,5 @@ /* - Copyright © 2013, The AROS Development Team. All rights reserved. + Copyright © 2013-2015, The AROS Development Team. All rights reserved. $Id$ */ @@ -25,7 +25,7 @@ LONG Processor_Init(struct ProcessorBase * ProcessorBase) D(bug("[processor.ARM] :%s()\n", __PRETTY_FUNCTION__)); sysprocs = AllocVec(ProcessorBase->cpucount * sizeof(APTR), MEMF_ANY | MEMF_CLEAR); - if (sysprocs == NULL) + if ((ProcessorBase->Private1 = sysprocs) == NULL) return FALSE; for (i = 0; i < ProcessorBase->cpucount; i++) @@ -33,10 +33,21 @@ LONG Processor_Init(struct ProcessorBase * ProcessorBase) sysprocs[i] = AllocMem(sizeof(struct ARMProcessorInformation), MEMF_CLEAR); if (!sysprocs[i]) return FALSE; +#if defined(__AROSEXEC_SMP__) + if (i > 0) + { + struct TagItem coreTags[] = + { + {NP_Entry , ReadProcessorInformation }, + {TASKTAG_AFFINITY , (1<Private1 = sysprocs; - /* Boot CPU is number 0. Fill in its data. */ ReadProcessorInformation(sysprocs[0]); diff --git a/arch/arm-native/exec/platform_init.c b/arch/arm-native/exec/platform_init.c index 37767330a5..e7d3019865 100644 --- a/arch/arm-native/exec/platform_init.c +++ b/arch/arm-native/exec/platform_init.c @@ -6,6 +6,7 @@ #define DEBUG 0 #include +#include #include #include #include @@ -16,8 +17,6 @@ #include #include -#include - /* Linked from kernel.resource, * need to retrieve in a cleaner fashion .. */ extern IPTR stack[]; @@ -35,9 +34,10 @@ static int PlatformInit(struct ExecBase *SysBase) /* for our sanity we will tell exec about the correct stack for the boot task */ BootTask->tc_SPLower = stack; - BootTask->tc_SPUpper = stack + STACK_SIZE; + BootTask->tc_SPUpper = stack + AROS_STACKSIZE; sysIdleTask = NewCreateTask(TASKTAG_NAME , "System Idle", + TASKTAG_AFFINITY , ~0, TASKTAG_PRI , -127, TASKTAG_PC , IdleTask, TASKTAG_ARG1 , SysBase, diff --git a/arch/arm-native/kernel/getcpunumber.c b/arch/arm-native/kernel/getcpunumber.c index 4edf4d81e0..a37b3acd2c 100644 --- a/arch/arm-native/kernel/getcpunumber.c +++ b/arch/arm-native/kernel/getcpunumber.c @@ -28,3 +28,17 @@ AROS_LH0(unsigned int, KrnGetCPUNumber, AROS_LIBFUNC_EXIT } + +AROS_LH1(unsigned int, KrnGetCPUMask, + AROS_LHA(uint32_t, id, D0), + struct KernelBase *, KernelBase, 37, Kernel) +{ + AROS_LIBFUNC_INIT + + int shift = 0; + + + return (1 << shift); + + AROS_LIBFUNC_EXIT +} diff --git a/arch/arm-native/kernel/getsystemattr.c b/arch/arm-native/kernel/getsystemattr.c index 2d3cfc20a2..e0ba006ebb 100644 --- a/arch/arm-native/kernel/getsystemattr.c +++ b/arch/arm-native/kernel/getsystemattr.c @@ -58,7 +58,7 @@ return (intptr_t)"arm-raspi"; case KATTR_PeripheralBase: - return (intptr_t)__arm_periiobase; + return (intptr_t)__arm_arosintern.ARMI_PeripheralBase; default: return -1; diff --git a/arch/arm-native/kernel/intr.c b/arch/arm-native/kernel/intr.c index 235fb8e74d..75b1736de4 100644 --- a/arch/arm-native/kernel/intr.c +++ b/arch/arm-native/kernel/intr.c @@ -22,49 +22,32 @@ #define BOOT_STACK_SIZE (256 << 2) #define BOOT_TAGS_SIZE (128 << 3) -#define IRQBANK_POINTER(bank) ((bank == 0) ? GPUIRQ_ENBL0 : (bank == 1) ? GPUIRQ_ENBL1 : ARMIRQ_ENBL) - #define DREGS(x) #define DIRQ(x) #define D(x) +/* linker exports */ +extern void *__intvecs_start, *__intvecs_end; +extern void __arm_halt(void); + void ictl_enable_irq(uint8_t irq, struct KernelBase *KernelBase) { - int bank = IRQ_BANK(irq); - unsigned int val, reg; - - reg = IRQBANK_POINTER(bank); - - DIRQ(bug("[KRN] Enabling irq %d [bank %d, reg 0x%p]\n", irq, bank, reg)); - - val = *((volatile unsigned int *)reg); - val |= IRQ_MASK(irq); - *((volatile unsigned int *)reg) = val; + if (__arm_arosintern.ARMI_IRQEnable) + __arm_arosintern.ARMI_IRQEnable(irq); } void ictl_disable_irq(uint8_t irq, struct KernelBase *KernelBase) { - int bank = IRQ_BANK(irq); - unsigned int val, reg; - - reg = IRQBANK_POINTER(bank); - - DIRQ(bug("[KRN] Dissabling irq %d [bank %d, reg 0x%p]\n", irq, bank, reg)); - - val = *((volatile unsigned int *)reg); - val |= IRQ_MASK(irq); - *((volatile unsigned int *)reg) = val; + if (__arm_arosintern.ARMI_IRQDisable) + __arm_arosintern.ARMI_IRQDisable(irq); } -static void arm_halt(void) -{ - bug("[Kernel] halting cpu\n"); - - __asm__ __volatile__( - "haltloop: \n" - " b haltloop \n" +asm ( + ".globl __arm_halt \n" + ".type __arm_halt,%function \n" + "__arm_halt: \n" + " b __arm_halt \n" ); -} /* ** UNDEF INSTRUCTION EXCEPTION @@ -87,7 +70,7 @@ asm ( " bl handle_undef \n" VECTCOMMON_END -); + ); void handle_undef(regs_t *regs) { @@ -110,7 +93,7 @@ void handle_undef(regs_t *regs) cpu_DumpRegs(regs); - arm_halt(); + __arm_halt(); } /* @@ -132,8 +115,7 @@ asm ( " ldr pc, 2f \n" // jump into kernel resource "1: b 1b \n" "2: .word kernel_cstart \n" - -); + ); /* ** SWI HANDLER ** */ @@ -174,74 +156,16 @@ asm ( " bl core_ExitInterrupt \n" "1: \n" VECTCOMMON_END -); - -#define IRQ_BANK1 0x00000100 -#define IRQ_BANK2 0x00000200 + ); void handle_irq(regs_t *regs) { - unsigned int pending, processed, irq; - DIRQ(bug("[KRN] ## IRQ ##\n")); DREGS(cpu_DumpRegs(regs)); - pending = *((volatile unsigned int *)(ARMIRQ_PEND)); - DIRQ(bug("[KRN] PendingARM %08x\n", pending)); - if (!(pending & IRQ_BANK1)) - { - processed = 0; - for (irq = (2 << 5); irq < ((2 << 5) + 32); irq++) - { - if (pending & (1 << (irq - (2 << 5)))) - { - DIRQ(bug("[KRN] Handling IRQ %d ..\n", irq)); - krnRunIRQHandlers(KernelBase, irq); - processed |= (1 << (irq - (2 << 5))); - } - } - } - else - { - processed = IRQ_BANK1; - } - if (processed) *((volatile unsigned int *)(ARMIRQ_PEND)) = (pending & ~processed); - - pending = *((volatile unsigned int *)(GPUIRQ_PEND0)); - DIRQ(bug("[KRN] Pending0 %08x\n", pending)); - if (!(pending & IRQ_BANK2)) - { - processed = 0; - for (irq = (0 << 5); irq < ((0 << 5) + 32); irq++) - { - if (pending & (1 << (irq - (0 << 5)))) - { - DIRQ(bug("[KRN] Handling IRQ %d ..\n", irq)); - krnRunIRQHandlers(KernelBase, irq); - processed |= (1 << (irq - (0 << 5))); - } - } - } - else - { - processed = IRQ_BANK2; - } - if (processed) *((volatile unsigned int *)(GPUIRQ_PEND0)) = (pending & ~processed); - - pending = *((volatile unsigned int *)(GPUIRQ_PEND1)); - DIRQ(bug("[KRN] Pending1 %08x\n", pending)); - processed = 0; - for (irq = (1 << 5); irq < ((1 << 5) + 32); irq++) - { - if (pending & (1 << (irq - (1 << 5)))) - { - DIRQ(bug("[KRN] Handling IRQ %d ..\n", irq)); - krnRunIRQHandlers(KernelBase, irq); - processed |= (1 << (irq - (1 << 5))); - } - } - if (processed) *((volatile unsigned int *)(GPUIRQ_PEND1)) = (pending & ~processed); + if (__arm_arosintern.ARMI_IRQProcess) + __arm_arosintern.ARMI_IRQProcess(); DIRQ(bug("[KRN] IRQ processing finished\n")); @@ -258,10 +182,11 @@ __attribute__ ((interrupt ("FIQ"))) void __vectorhand_fiq(void) { DIRQ(bug("[KRN] ## FIQ ##\n")); + DIRQ(bug("[KRN] FIQ processing finished\n")); + return; } - /* ** DATA ABORT EXCEPTION return address = lr - 8 @@ -284,7 +209,7 @@ asm ( " bl handle_dataabort \n" VECTCOMMON_END -); + ); void handle_dataabort(regs_t *regs) { @@ -312,7 +237,7 @@ void handle_dataabort(regs_t *regs) cpu_DumpRegs(regs); - arm_halt(); + __arm_halt(); } /* @@ -337,7 +262,7 @@ asm ( " bl handle_prefetchabort \n" VECTCOMMON_END -); + ); void handle_prefetchabort(regs_t *regs) { @@ -360,35 +285,32 @@ void handle_prefetchabort(regs_t *regs) cpu_DumpRegs(regs); - arm_halt(); + __arm_halt(); } /* ** SETUP ** */ -/* linker exports */ -extern void *__intvecs_start, *__intvecs_end; - void arm_flush_cache(uint32_t addr, uint32_t length) { - while (length) - { - __asm__ __volatile__("mcr p15, 0, %0, c7, c14, 1"::"r"(addr)); - addr += 32; - length -= 32; - } - __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4"::"r"(addr)); + while (length) + { + __asm__ __volatile__("mcr p15, 0, %0, c7, c14, 1"::"r"(addr)); + addr += 32; + length -= 32; + } + __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4"::"r"(addr)); } void arm_icache_invalidate(uint32_t addr, uint32_t length) { - while (length) - { - __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 1"::"r"(addr)); - addr += 32; - length -= 32; - } - __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4"::"r"(addr)); + while (length) + { + __asm__ __volatile__("mcr p15, 0, %0, c7, c5, 1"::"r"(addr)); + addr += 32; + length -= 32; + } + __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 4"::"r"(addr)); } void core_SetupIntr(void) @@ -419,8 +341,6 @@ void core_SetupIntr(void) bug("\n"); ) - D(bug("[KRN] Disabling IRQs\n")); - *(volatile unsigned int *)ARMIRQ_DIBL = ~0; - *(volatile unsigned int *)GPUIRQ_DIBL0 = ~0; - *(volatile unsigned int *)GPUIRQ_DIBL1 = ~0; + if (__arm_arosintern.ARMI_IRQInit) + __arm_arosintern.ARMI_IRQInit(); } diff --git a/arch/arm-native/kernel/kernel_arm.h b/arch/arm-native/kernel/kernel_arm.h index f76569fd51..adae705a4f 100644 --- a/arch/arm-native/kernel/kernel_arm.h +++ b/arch/arm-native/kernel/kernel_arm.h @@ -5,13 +5,24 @@ struct ARM_Implementation { - IPTR ARMI_Family; - IPTR ARMI_Platform; - APTR (*ARMI_InitTimer) (APTR); // takes a pointer to KernelBase as input, and returns struct IntrNode - void (*ARMI_Delay) (int); - void (*ARMI_LED_Toggle) (int, int); + IPTR ARMI_Family; + IPTR ARMI_Platform; + APTR ARMI_PeripheralBase; + APTR (*ARMI_InitTimer) (APTR); // takes a pointer to KernelBase as input, and returns struct IntrNode + void (*ARMI_Delay) (int); + unsigned int (*ARMI_GetTime) (void); + void (*ARMI_PutChar) (int); + void (*ARMI_SerPutChar) (int); + int (*ARMI_SerGetChar) (void); + void (*ARMI_IRQInit) (); + void (*ARMI_IRQEnable) (int); + void (*ARMI_IRQDisable) (int); + void (*ARMI_IRQProcess) (void); + void (*ARMI_LED_Toggle) (int, int); }; +extern struct ARM_Implementation __arm_arosintern; + // values for arm_toggle_led #define ARM_LED_ON 1 diff --git a/arch/arm-native/kernel/kernel_cpu.c b/arch/arm-native/kernel/kernel_cpu.c index 01ce8adb69..1b055d2403 100644 --- a/arch/arm-native/kernel/kernel_cpu.c +++ b/arch/arm-native/kernel/kernel_cpu.c @@ -107,8 +107,11 @@ void cpu_Switch(regs_t *regs) /* Restore the task's state */ STORE_TASKSTATE(task, regs) - /* Update the taks CPU time .. */ - GetIntETask(task)->iet_CpuTime += *((volatile unsigned int *)(SYSTIMER_CLO)) - GetIntETask(task)->iet_private1; + if (__arm_arosintern.ARMI_GetTime) + { + /* Update the taks CPU time .. */ + GetIntETask(task)->iet_CpuTime += __arm_arosintern.ARMI_GetTime() - GetIntETask(task)->iet_private1; + } core_Switch(); } @@ -139,8 +142,11 @@ void cpu_Dispatch(regs_t *regs) if (task->tc_Flags & TF_EXCEPT) Exception(); - /* Store the launch time */ - GetIntETask(task)->iet_private1 = *((volatile unsigned int *)(SYSTIMER_CLO)); + if (__arm_arosintern.ARMI_GetTime) + { + /* Store the launch time */ + GetIntETask(task)->iet_private1 = __arm_arosintern.ARMI_GetTime(); + } if (task->tc_Flags & TF_LAUNCH) { diff --git a/arch/arm-native/kernel/kernel_debug.c b/arch/arm-native/kernel/kernel_debug.c dissimilarity index 62% index 065c2548d9..f2f02f496e 100644 --- a/arch/arm-native/kernel/kernel_debug.c +++ b/arch/arm-native/kernel/kernel_debug.c @@ -1,49 +1,25 @@ -/* - Copyright © 2013-2015, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include - -#include -#include -#include "kernel_intern.h" -#include - -void (*_KrnPutC)(char) = NULL; - -inline void krnWaitSerOut() -{ - while(1) - { - if ((*(volatile uint32_t *)(PL011_0_BASE + PL011_FR) & PL011_FR_TXFF) == 0) break; - } -} - - -inline void krnSerPutC(uint8_t chr) -{ - krnWaitSerOut(); - - if (chr == '\n') - { - *(volatile uint32_t *)(PL011_0_BASE + PL011_DR) = '\r'; - krnWaitSerOut(); - } - *(volatile uint32_t *)(PL011_0_BASE + PL011_DR) = chr; -} - -int krnPutC(int chr, struct KernelBase *KernelBase) -{ - if (chr == 0x03) - _KrnPutC = NULL; - else - { - if (_KrnPutC) - _KrnPutC(chr); - - krnSerPutC(chr); - } - return 1; -} +/* + Copyright © 2013-2015, The AROS Development Team. All rights reserved. + $Id$ +*/ + +#include +#include + +#include +#include +#include "kernel_intern.h" + +int krnPutC(int chr, struct KernelBase *KernelBase) +{ + if (chr == 0x03) + __arm_arosintern.ARMI_PutChar = NULL; + else + { + if (__arm_arosintern.ARMI_PutChar) + __arm_arosintern.ARMI_PutChar(chr); + if (__arm_arosintern.ARMI_SerPutChar) + __arm_arosintern.ARMI_SerPutChar(chr); + } + return 1; +} diff --git a/arch/arm-native/kernel/kernel_fb.h b/arch/arm-native/kernel/kernel_fb.h index d04bf10918..00d9f0db70 100644 --- a/arch/arm-native/kernel/kernel_fb.h +++ b/arch/arm-native/kernel/kernel_fb.h @@ -9,5 +9,3 @@ #if !defined(KRN_FuncPutC) #define KRN_FuncPutC (KRN_Dummy + 99) /* RAW FrameBuffer descriptor */ #endif - -extern void (*_KrnPutC)(char); diff --git a/arch/arm-native/kernel/kernel_intern.h b/arch/arm-native/kernel/kernel_intern.h index 130bbc46ae..cf9b20574e 100644 --- a/arch/arm-native/kernel/kernel_intern.h +++ b/arch/arm-native/kernel/kernel_intern.h @@ -17,10 +17,6 @@ #include "kernel_arm.h" -extern uint32_t __arm_periiobase; -#define ARM_PERIIOBASE (__arm_periiobase) -#include - #undef KernelBase struct KernelBase; diff --git a/arch/arm-native/kernel/kernel_startup.c b/arch/arm-native/kernel/kernel_startup.c index 06f7b31310..d669ffaf9f 100644 --- a/arch/arm-native/kernel/kernel_startup.c +++ b/arch/arm-native/kernel/kernel_startup.c @@ -10,6 +10,8 @@ #include +#include + #include #include #include @@ -27,17 +29,16 @@ #include "kernel_intern.h" #include "kernel_debug.h" -#include "kernel_fb.h" #include "kernel_romtags.h" extern struct TagItem *BootMsg; void __attribute__((used)) kernel_cstart(struct TagItem *msg); -uint32_t stack[STACK_SIZE] __attribute__((used,aligned(16))); -static uint32_t stack_super[STACK_SIZE] __attribute__((used,aligned(16))); -static uint32_t stack_abort[STACK_SIZE] __attribute__((used,aligned(16))); -static uint32_t stack_irq[STACK_SIZE] __attribute__((used,aligned(16))); +uint32_t stack[AROS_STACKSIZE] __attribute__((used,aligned(16))); +static uint32_t stack_super[AROS_STACKSIZE] __attribute__((used,aligned(16))); +static uint32_t stack_abort[AROS_STACKSIZE] __attribute__((used,aligned(16))); +static uint32_t stack_irq[AROS_STACKSIZE] __attribute__((used,aligned(16))); asm ( ".section .aros.init,\"ax\"\n\t" @@ -60,12 +61,12 @@ asm ( ".string \"Native/CORE v3 (" __DATE__ ")\"" "\n\t\n\t" ); -static uint32_t * const stack_end __attribute__((used, section(".aros.init"))) = &stack[STACK_SIZE - sizeof(IPTR)]; -static uint32_t * const stack_super_end __attribute__((used, section(".aros.init"))) = &stack_super[STACK_SIZE - sizeof(IPTR)]; -static uint32_t * const stack_abort_end __attribute__((used, section(".aros.init"))) = &stack_abort[STACK_SIZE - sizeof(IPTR)]; -static uint32_t * const stack_irq_end __attribute__((used, section(".aros.init"))) = &stack_irq[STACK_SIZE - sizeof(IPTR)]; +static uint32_t * const stack_end __attribute__((used, section(".aros.init"))) = &stack[AROS_STACKSIZE - sizeof(IPTR)]; +static uint32_t * const stack_super_end __attribute__((used, section(".aros.init"))) = &stack_super[AROS_STACKSIZE - sizeof(IPTR)]; +static uint32_t * const stack_abort_end __attribute__((used, section(".aros.init"))) = &stack_abort[AROS_STACKSIZE - sizeof(IPTR)]; +static uint32_t * const stack_irq_end __attribute__((used, section(".aros.init"))) = &stack_irq[AROS_STACKSIZE - sizeof(IPTR)]; -struct ARM_Implementation krnARMImpl __attribute__((aligned(4), section(".data"))) = {0,0,NULL,NULL}; +struct ARM_Implementation __arm_arosintern __attribute__((aligned(4), section(".data"))) = {0,0,NULL,NULL}; struct ExecBase *SysBase __attribute__((section(".data"))) = NULL; static void __attribute__((used)) __clear_bss(struct TagItem *msg) @@ -120,9 +121,9 @@ void __attribute__((used)) kernel_cstart(struct TagItem *msg) long unsigned int memlower = 0, memupper = 0, protlower = 0, protupper = 0; BootMsg = msg; - cpu_Probe(&krnARMImpl); - platform_Init(&krnARMImpl, msg); - cpu_Init(&krnARMImpl, msg); + cpu_Probe(&__arm_arosintern); + platform_Init(&__arm_arosintern, msg); + cpu_Init(&__arm_arosintern, msg); /* NB: the bootstrap has conveniently setup the framebuffer and initialised the serial port and led for us */ @@ -131,10 +132,6 @@ void __attribute__((used)) kernel_cstart(struct TagItem *msg) { switch (msg->ti_Tag) { - case KRN_FuncPutC: - _KrnPutC = (void *)msg->ti_Data; - _KrnPutC(0xFF); // Clear the display - break; case KRN_MEMLower: memlower = msg->ti_Data; break; @@ -167,20 +164,20 @@ void __attribute__((used)) kernel_cstart(struct TagItem *msg) D(bug("[KRN] Entered kernel_cstart @ 0x%p, BootMsg @ %p\n", kernel_cstart, BootMsg)); D( - if (_KrnPutC) + if (__arm_arosintern.ARMI_PutChar) { - bug("[KRN] Using boostrap PutC implementation @ %p\n", _KrnPutC); + bug("[KRN] Using PutChar implementation @ %p\n", __arm_arosintern.ARMI_PutChar); } ) core_SetupIntr(); - if (krnARMImpl.ARMI_LED_Toggle) + if (__arm_arosintern.ARMI_LED_Toggle) { - krnARMImpl.ARMI_LED_Toggle(ARM_LED_POWER, ARM_LED_OFF); - if (krnARMImpl.ARMI_Delay) - krnARMImpl.ARMI_Delay(1500); - krnARMImpl.ARMI_LED_Toggle(ARM_LED_POWER, ARM_LED_ON); + __arm_arosintern.ARMI_LED_Toggle(ARM_LED_POWER, ARM_LED_OFF); + if (__arm_arosintern.ARMI_Delay) + __arm_arosintern.ARMI_Delay(1500); + __arm_arosintern.ARMI_LED_Toggle(ARM_LED_POWER, ARM_LED_ON); } NEWLIST(&memList); diff --git a/arch/arm-native/kernel/kernel_systimer.c b/arch/arm-native/kernel/kernel_systimer.c index 8d852b13bf..484b1750b8 100644 --- a/arch/arm-native/kernel/kernel_systimer.c +++ b/arch/arm-native/kernel/kernel_systimer.c @@ -21,16 +21,14 @@ #define DIRQ(x) #define D(x) -extern struct ARM_Implementation krnARMImpl; - void *KrnAddSysTimerHandler(struct KernelBase *KernelBase) { struct IntrNode *SysTimerHandle = NULL; D(bug("[KRN] KrnAddSysTimerHandler(%012p)\n", KernelBase)); - if (krnARMImpl.ARMI_InitTimer) - SysTimerHandle = krnARMImpl.ARMI_InitTimer(KernelBase); + if (__arm_arosintern.ARMI_InitTimer) + SysTimerHandle = __arm_arosintern.ARMI_InitTimer(KernelBase); D(bug("[KRN] KrnAddSysTimerHandler: returning handle @ 0x%p \n", SysTimerHandle)); diff --git a/arch/arm-native/kernel/maygetchar.c b/arch/arm-native/kernel/maygetchar.c index 011b7596ea..4ae67e3457 100644 --- a/arch/arm-native/kernel/maygetchar.c +++ b/arch/arm-native/kernel/maygetchar.c @@ -8,7 +8,6 @@ #include #include #include "kernel_intern.h" -#include #include #include @@ -20,8 +19,8 @@ AROS_LH0(int, KrnMayGetChar, { AROS_LIBFUNC_INIT - if ((*(volatile uint32_t *)(PL011_0_BASE + PL011_FR) & PL011_FR_RXFE) == 0) - return (int)*(volatile uint32_t *)(PL011_0_BASE + PL011_DR); + if (__arm_arosintern.ARMI_SerGetChar) + return __arm_arosintern.ARMI_SerGetChar(); return -1; diff --git a/arch/arm-native/kernel/platform_bcm2708.c b/arch/arm-native/kernel/platform_bcm2708.c index 8b2d27d46b..7f88008fca 100644 --- a/arch/arm-native/kernel/platform_bcm2708.c +++ b/arch/arm-native/kernel/platform_bcm2708.c @@ -16,6 +16,17 @@ #include "kernel_cpu.h" #include "kernel_interrupts.h" #include "kernel_intr.h" +#include "kernel_fb.h" + +#define ARM_PERIIOBASE __arm_arosintern.ARMI_PeripheralBase +#include +#include + +#define IRQBANK_POINTER(bank) ((bank == 0) ? GPUIRQ_ENBL0 : (bank == 1) ? GPUIRQ_ENBL1 : ARMIRQ_ENBL) +#define IRQ_BANK1 0x00000100 +#define IRQ_BANK2 0x00000200 + +#define DIRQ(x) extern void cpu_Register(void); @@ -24,9 +35,112 @@ static void bcm2708_init(void) } +static unsigned int bcm2807_get_time(void) +{ + return *((volatile unsigned int *)(SYSTIMER_CLO)); +} + +static void bcm2807_irq_init(void) +{ + // disable IRQ's + *(volatile unsigned int *)ARMIRQ_DIBL = ~0; + *(volatile unsigned int *)GPUIRQ_DIBL0 = ~0; + *(volatile unsigned int *)GPUIRQ_DIBL1 = ~0; +} + +static void bcm2807_irq_enable(int irq) +{ + int bank = IRQ_BANK(irq); + unsigned int val, reg; + + reg = IRQBANK_POINTER(bank); + + DIRQ(bug("[KRN:BCM2708] Enabling irq %d [bank %d, reg 0x%p]\n", irq, bank, reg)); + + val = *((volatile unsigned int *)reg); + val |= IRQ_MASK(irq); + *((volatile unsigned int *)reg) = val; +} + +static void bcm2807_irq_disable(int irq) +{ + int bank = IRQ_BANK(irq); + unsigned int val, reg; + + reg = IRQBANK_POINTER(bank); + + DIRQ(bug("[KRN:BCM2708] Dissabling irq %d [bank %d, reg 0x%p]\n", irq, bank, reg)); + + val = *((volatile unsigned int *)reg); + val |= IRQ_MASK(irq); + *((volatile unsigned int *)reg) = val; +} + +static void bcm2807_irq_process() +{ + unsigned int pending, processed, irq; + + pending = *((volatile unsigned int *)(ARMIRQ_PEND)); + DIRQ(bug("[KRN] PendingARM %08x\n", pending)); + if (!(pending & IRQ_BANK1)) + { + processed = 0; + for (irq = (2 << 5); irq < ((2 << 5) + 32); irq++) + { + if (pending & (1 << (irq - (2 << 5)))) + { + DIRQ(bug("[KRN] Handling IRQ %d ..\n", irq)); + krnRunIRQHandlers(KernelBase, irq); + processed |= (1 << (irq - (2 << 5))); + } + } + } + else + { + processed = IRQ_BANK1; + } + if (processed) *((volatile unsigned int *)(ARMIRQ_PEND)) = (pending & ~processed); + + pending = *((volatile unsigned int *)(GPUIRQ_PEND0)); + DIRQ(bug("[KRN] Pending0 %08x\n", pending)); + if (!(pending & IRQ_BANK2)) + { + processed = 0; + for (irq = (0 << 5); irq < ((0 << 5) + 32); irq++) + { + if (pending & (1 << (irq - (0 << 5)))) + { + DIRQ(bug("[KRN] Handling IRQ %d ..\n", irq)); + krnRunIRQHandlers(KernelBase, irq); + processed |= (1 << (irq - (0 << 5))); + } + } + } + else + { + processed = IRQ_BANK2; + } + if (processed) *((volatile unsigned int *)(GPUIRQ_PEND0)) = (pending & ~processed); + + pending = *((volatile unsigned int *)(GPUIRQ_PEND1)); + DIRQ(bug("[KRN] Pending1 %08x\n", pending)); + processed = 0; + for (irq = (1 << 5); irq < ((1 << 5) + 32); irq++) + { + if (pending & (1 << (irq - (1 << 5)))) + { + DIRQ(bug("[KRN] Handling IRQ %d ..\n", irq)); + krnRunIRQHandlers(KernelBase, irq); + processed |= (1 << (irq - (1 << 5))); + } + } + if (processed) *((volatile unsigned int *)(GPUIRQ_PEND1)) = (pending & ~processed); +} + + static void bcm2708_toggle_led(int LED, int state) { - if (__arm_periiobase == BCM2836_PERIPHYSBASE) + if (__arm_arosintern.ARMI_PeripheralBase == BCM2836_PERIPHYSBASE) { int pin = 35; IPTR gpiofunc = GPCLR1; @@ -109,19 +223,67 @@ static bcm2708_init_gputimer(struct KernelBase *KernelBase) return GPUTimerHandle; } +static inline void bcm2708_ser_waitout() +{ + while(1) + { + if ((*(volatile uint32_t *)(PL011_0_BASE + PL011_FR) & PL011_FR_TXFF) == 0) break; + } +} + +static void bcm2708_ser_putc(uint8_t chr) +{ + bcm2708_ser_waitout(); + + if (chr == '\n') + { + *(volatile uint32_t *)(PL011_0_BASE + PL011_DR) = '\r'; + bcm2708_ser_waitout(); + } + *(volatile uint32_t *)(PL011_0_BASE + PL011_DR) = chr; +} + +static int bcm2708_ser_getc(void) +{ + if ((*(volatile uint32_t *)(PL011_0_BASE + PL011_FR) & PL011_FR_RXFE) == 0) + return (int)*(volatile uint32_t *)(PL011_0_BASE + PL011_DR); + + return -1; +} static IPTR bcm2708_probe(struct ARM_Implementation *krnARMImpl, struct TagItem *msg) { //TODO: really detect if we are running on a broadcom 2835/2836 if (krnARMImpl->ARMI_Family == 7) /* bcm2836 uses armv7 */ - __arm_periiobase = BCM2836_PERIPHYSBASE; + krnARMImpl->ARMI_PeripheralBase = BCM2836_PERIPHYSBASE; else - __arm_periiobase = BCM2835_PERIPHYSBASE; + krnARMImpl->ARMI_PeripheralBase = BCM2835_PERIPHYSBASE; + krnARMImpl->ARMI_GetTime = &bcm2807_get_time; krnARMImpl->ARMI_InitTimer = &bcm2708_init_gputimer; krnARMImpl->ARMI_LED_Toggle = &bcm2708_toggle_led; - if (__arm_periiobase == BCM2836_PERIPHYSBASE) + krnARMImpl->ARMI_SerPutChar = &bcm2708_ser_putc; + krnARMImpl->ARMI_SerGetChar = &bcm2708_ser_getc; + + while(msg->ti_Tag != TAG_DONE) + { + switch (msg->ti_Tag) + { + case KRN_FuncPutC: + krnARMImpl->ARMI_PutChar = (void *)msg->ti_Data; + krnARMImpl->ARMI_PutChar(0xFF); // Clear the display + break; + } + msg++; + } + + krnARMImpl->ARMI_IRQInit = &bcm2807_irq_init; + krnARMImpl->ARMI_IRQEnable = &bcm2807_irq_enable; + krnARMImpl->ARMI_IRQDisable = &bcm2807_irq_disable; + krnARMImpl->ARMI_IRQProcess = &bcm2807_irq_process; + + if (krnARMImpl->ARMI_PeripheralBase == BCM2836_PERIPHYSBASE) { int core; for (core = 1; core < 3; core ++) diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_class.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_class.c index 7ea49556de..e0d04c1db3 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_class.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_class.c @@ -6,7 +6,7 @@ Lang: English. */ -#define DEBUG 0 +#define DEBUG 1 #include #define __OOP_NOATTRBASES__ diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hardware.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hardware.c index b21cb7649b..e00d10263c 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hardware.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hardware.c @@ -6,7 +6,7 @@ Lang: English */ -#define DEBUG 0 +#define DEBUG 1 #include #include diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hdmi.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hdmi.c index cfd32eda4e..9a5498315f 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hdmi.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_hdmi.c @@ -3,7 +3,7 @@ $Id$ */ -#define DEBUG 0 +#define DEBUG 1 #include #include #include diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_init.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_init.c index 139123eb8b..f9f8c70312 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_init.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_init.c @@ -6,7 +6,7 @@ Lang: english */ -#define DEBUG 0 +#define DEBUG 1 #include #define __OOP_NOATTRBASES__ diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_memory.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_memory.c index d7401ad0a3..9bf01dc2d1 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_memory.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_memory.c @@ -3,7 +3,7 @@ $Id$ */ -#define DEBUG 0 +#define DEBUG 1 #include #define __OOP_NOATTRBASES__ diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_onbitmap.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_onbitmap.c index 440b0277ab..1452f884a1 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_onbitmap.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_onbitmap.c @@ -6,7 +6,7 @@ Lang: English. */ -#define DEBUG 0 +#define DEBUG 1 #include #define __OOP_NOATTRBASES__ diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_pixfmts.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_pixfmts.c index a247f356bd..1ec508846b 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_pixfmts.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_pixfmts.c @@ -3,7 +3,7 @@ $Id$ */ -#define DEBUG 0 +#define DEBUG 1 #include #define __OOP_NOATTRBASES__ diff --git a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_sdtv.c b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_sdtv.c index db8feaf80a..30b8ca1dc1 100644 --- a/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_sdtv.c +++ b/arch/arm-native/soc/broadcom/2708/hidd/videocoregfx/videocoregfx_sdtv.c @@ -3,7 +3,7 @@ $Id$ */ -#define DEBUG 0 +#define DEBUG 1 #include #include "videocoregfx_class.h" diff --git a/arch/arm-native/soc/broadcom/2708/include/hardware/bcm2708.h b/arch/arm-native/soc/broadcom/2708/include/hardware/bcm2708.h index 60dc570bbc..ea4dcbf7cf 100644 --- a/arch/arm-native/soc/broadcom/2708/include/hardware/bcm2708.h +++ b/arch/arm-native/soc/broadcom/2708/include/hardware/bcm2708.h @@ -18,14 +18,10 @@ #if (1) // TODO: Move to a more generic ARM header.. -#define ARM_STACK_DEF 4096 #define ARM_VIRTBASE 0xF0000000 #define ARM_PRIMECELLID 0xB105F00D #define ARM_PRIMECELLPERISIZE 0x1000 -#define STACK_SIZE ARM_STACK_DEF - - /* caller must provide ARM_PERIIOBASE */ -- 2.11.4.GIT