expose peripheral iobase via getsystemattr for drivers to use. clean-up iobase code...
[AROS.git] / arch / arm-raspi / kernel / platform_init.c
blob7ddaecdb09181231381f2b1b7be78ddabd40f05e
1 /*
2 Copyright © 2013-2015, 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 "etask.h"
21 #include "kernel_intern.h"
22 #include "kernel_arch.h"
23 #include "kernel_romtags.h"
25 void *(*__AllocMem)();
27 #define ExecAllocMem(bytesize, requirements) \
28 AROS_CALL2(void *, __AllocMem, \
29 AROS_LCA(ULONG, byteSize, D0), \
30 AROS_LCA(ULONG, requirements, D1), \
31 struct ExecBase *, SysBase)
33 AROS_LH2(APTR, AllocMem,
34 AROS_LHA(ULONG, byteSize, D0),
35 AROS_LHA(ULONG, requirements, D1),
36 struct ExecBase *, SysBase, 33, Kernel)
38 AROS_LIBFUNC_INIT
40 if (requirements & MEMF_CHIP)
42 DALLOCMEM(bug("[Kernel] AllocMem: Ignoring MEMF_CHIP flag\n"));
43 requirements &= ~MEMF_CHIP;
45 return ExecAllocMem(bytesize, requirements);
47 AROS_LIBFUNC_EXIT
50 static int PlatformInit(struct KernelBase *KernelBase)
52 UBYTE *ptr;
53 D(bug("[Kernel] PlatformInit()\n"));
55 #if (1)
56 // TODO:
57 // How to identify broadcom IP's?
58 // Expose this as a seprate subsystem (like PCI?)
59 D(bug("[Kernel] Integrated Peripherals -:\n"));
60 for (ptr = ARM_PERIIOBASE; ptr < (ARM_PERIIOBASE + ARM_PERIIOSIZE); ptr += ARM_PRIMECELLPERISIZE)
62 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;
63 if (perihreg == ARM_PRIMECELLID)
65 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;
66 unsigned int manu = (perihreg & (0x7F << 12)) >> 12;
67 unsigned int prod = (perihreg & 0xFFF);
68 unsigned int rev = (perihreg & (0xF << 20)) >> 20;
69 unsigned int config = (perihreg & (0x7F << 24)) >> 24;
70 D(bug("[Kernel] 0x%p: manu %x, prod %x, rev %d, config %d\n", ptr, manu, prod, rev, config));
72 /* else
74 if (perihreg)
76 D(bug("[Kernel] PlatformInit: 0x%p: PrimeCellID != %08x\n", ptr, perihreg));
78 }*/
80 #endif
82 D(bug("[Kernel] PlatformInit: Patching in our AllocMem to ignore MEMF_CHIP..\n"));
84 __AllocMem = SetFunction(SysBase, -33*LIB_VECTSIZE, AROS_SLIB_ENTRY(AllocMem, Kernel, 33));
86 D(bug("[Kernel] PlatformInit: Registering Heartbeat timer..\n"));
88 KrnAddSysTimerHandler(KernelBase);
90 D(bug("[Kernel] PlatformInit: Done..\n"));
92 return TRUE;
95 ADD2INITLIB(PlatformInit, 0)
97 struct KernelBase *getKernelBase()
99 return (struct KernelBase *)KernelBase;