Copyright clean-up (part 1):
[AROS.git] / arch / ppc-chrp / efika / bestcomm / bestcomm_init.c
blobea3c43d3ae45f945d5d614d6c38dc49a1a1c5832
1 /*
2 Copyright © 2009-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 1
8 #include <aros/debug.h>
9 #include <aros/symbolsets.h>
10 #include <proto/openfirmware.h>
11 #include <proto/kernel.h>
13 #include "bestcomm_private.h"
15 static int bestcomm_init(struct BestCommBase *BestCommBase)
17 int retval = TRUE;
18 void *OpenFirmwareBase;
19 void *key, *prop;
21 D(bug("[SDMA] BestComm Init.\n"));
23 OpenFirmwareBase = OpenResource("openfirmware.resource");
25 /* Get some addresses from OF tree */
26 if (OpenFirmwareBase)
28 key = OF_OpenKey("/builtin");
29 if (key)
31 prop = OF_FindProperty(key, "reg");
32 if (prop)
34 reg_t *reg = OF_GetPropValue(prop);
35 BestCommBase->bc_MBAR = (uint8_t *)reg->addr;
39 key = OF_OpenKey("/builtin/sram");
40 if (key)
42 prop = OF_FindProperty(key, "reg");
43 if (prop)
45 reg_t *reg = OF_GetPropValue(prop);
46 BestCommBase->bc_SRAM = reg->addr;
47 BestCommBase->bc_SRAMSize = reg->size;
49 D(bug("[SDMA] %d bytes SRAM at %08x\n", BestCommBase->bc_SRAMSize, BestCommBase->bc_SRAM));
50 if (BestCommBase->bc_SRAMSize)
52 /* Get memory for Free bitmap. Here, 1=free and 0=in use */
53 BestCommBase->bc_SRAMFree = AllocMem((BestCommBase->bc_SRAMSize >> 4) / (8*sizeof(uint32_t)), MEMF_CLEAR|MEMF_PUBLIC);
55 prop = OF_FindProperty(key, "available");
56 if (prop)
58 int i;
59 const int regs = OF_GetPropLen(prop) / sizeof(reg_t);
60 reg_t *reg = OF_GetPropValue(prop);
62 for (i=0; i < regs; i++)
64 D(bug("[SDMA] addr=%08x len=%d\n", reg[i].addr, reg[i].size));
72 key = OF_OpenKey("/builtin/bestcomm");
73 if (key)
75 void *prop = OF_FindProperty(key, "reg");
76 if (prop)
78 BestCommBase->bc_BestComm = *(void **)OF_GetPropValue(prop);
80 D(bug("[SDMA] bestcomm at %08x\n", BestCommBase->bc_BestComm));
83 else
84 retval = FALSE;
88 return retval;
92 ADD2INITLIB(bestcomm_init, 0)