Support dynamic ARM_PERIIOBASE as requred by rpi2
[AROS.git] / arch / arm-raspi / kernel / platform_init.c
blobd4a43a08a388c227cdaba96672d03f8d9a328046
1 /*
2 Copyright � 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
8 #include <aros/kernel.h>
9 #include <aros/symbolsets.h>
10 #include <exec/memory.h>
11 #include <exec/tasks.h>
12 #include <exec/alerts.h>
13 #include <exec/execbase.h>
14 #include <asm/io.h>
15 #include <proto/kernel.h>
16 #include <proto/exec.h>
17 #include <strings.h>
19 #include <hardware/bcm283x.h>
21 #include "etask.h"
23 #include "kernel_intern.h"
24 #include "kernel_arch.h"
25 #include "kernel_romtags.h"
27 #undef ARM_PERIIOBASE
28 extern uint32_t __arm_periiobase;
29 #define ARM_PERIIOBASE (__arm_periiobase)
31 void *(*__AllocMem)();
33 #define ExecAllocMem(bytesize, requirements) \
34 AROS_CALL2(void *, __AllocMem, \
35 AROS_LCA(ULONG, byteSize, D0), \
36 AROS_LCA(ULONG, requirements, D1), \
37 struct ExecBase *, SysBase)
39 AROS_LH2(APTR, AllocMem,
40 AROS_LHA(ULONG, byteSize, D0),
41 AROS_LHA(ULONG, requirements, D1),
42 struct ExecBase *, SysBase, 33, Kernel)
44 AROS_LIBFUNC_INIT
46 if (requirements & MEMF_CHIP)
48 DALLOCMEM(bug("[Kernel] AllocMem: Ignoring MEMF_CHIP flag\n"));
49 requirements &= ~MEMF_CHIP;
51 return ExecAllocMem(bytesize, requirements);
53 AROS_LIBFUNC_EXIT
56 static int PlatformInit(struct KernelBase *KernelBase)
58 UBYTE *ptr;
59 D(bug("[Kernel] PlatformInit()\n"));
61 #if (1)
62 // TODO:
63 // How to identify broadcom IP's?
64 // Expose this as a seprate subsystem (like PCI?)
65 D(bug("[Kernel] Integrated Peripherals -:\n"));
66 for (ptr = ARM_PERIIOBASE; ptr < (ARM_PERIIOBASE + ARM_PERIIOSIZE); ptr += ARM_PRIMECELLPERISIZE)
68 unsigned int perihreg = (*(volatile unsigned int *)(ptr + 0xFF0) & 0xFF) | (*(volatile unsigned int *)(ptr + 0xFF4) & 0xFF) << 8 | (*(volatile unsigned int *)(ptr + 0xFF8) & 0xFF) << 16 | (*(volatile unsigned int *)(ptr + 0xFFC) & 0xFF) << 24;
69 if (perihreg == ARM_PRIMECELLID)
71 perihreg = (*(volatile unsigned int *)(ptr + 0xFE0) & 0xFF) | (*(volatile unsigned int *)(ptr + 0xFE4) & 0xFF) << 8 | (*(volatile unsigned int *)(ptr + 0xFE8) & 0xFF) << 16 | (*(volatile unsigned int *)(ptr + 0xFEC) & 0xFF) << 24;
72 unsigned int manu = (perihreg & (0x7F << 12)) >> 12;
73 unsigned int prod = (perihreg & 0xFFF);
74 unsigned int rev = (perihreg & (0xF << 20)) >> 20;
75 unsigned int config = (perihreg & (0x7F << 24)) >> 24;
76 D(bug("[Kernel] 0x%p: manu %x, prod %x, rev %d, config %d\n", ptr, manu, prod, rev, config));
78 /* else
80 if (perihreg)
82 D(bug("[Kernel] PlatformInit: 0x%p: PrimeCellID != %08x\n", ptr, perihreg));
84 }*/
86 #endif
88 D(bug("[Kernel] PlatformInit: Patching in our AllocMem to ignore MEMF_CHIP..\n"));
90 __AllocMem = SetFunction(SysBase, -33*LIB_VECTSIZE, AROS_SLIB_ENTRY(AllocMem, Kernel, 33));
92 D(bug("[Kernel] PlatformInit: Registering Heartbeat timer..\n"));
94 KrnAddSysTimerHandler(KernelBase);
96 D(bug("[Kernel] PlatformInit: Done..\n"));
98 return TRUE;
101 ADD2INITLIB(PlatformInit, 0)
103 struct KernelBase *getKernelBase()
105 return (struct KernelBase *)KernelBase;