4 * Created on: Mar 15, 2009
10 #include <aros/debug.h>
11 #include <aros/symbolsets.h>
12 #include <proto/openfirmware.h>
13 #include <proto/kernel.h>
15 #include "bestcomm_private.h"
17 static int bestcomm_init(struct BestCommBase
*BestCommBase
)
20 void *OpenFirmwareBase
;
23 D(bug("[SDMA] BestComm Init.\n"));
25 OpenFirmwareBase
= OpenResource("openfirmware.resource");
27 /* Get some addresses from OF tree */
30 key
= OF_OpenKey("/builtin");
33 prop
= OF_FindProperty(key
, "reg");
36 reg_t
*reg
= OF_GetPropValue(prop
);
37 BestCommBase
->bc_MBAR
= (uint8_t *)reg
->addr
;
41 key
= OF_OpenKey("/builtin/sram");
44 prop
= OF_FindProperty(key
, "reg");
47 reg_t
*reg
= OF_GetPropValue(prop
);
48 BestCommBase
->bc_SRAM
= reg
->addr
;
49 BestCommBase
->bc_SRAMSize
= reg
->size
;
51 D(bug("[SDMA] %d bytes SRAM at %08x\n", BestCommBase
->bc_SRAMSize
, BestCommBase
->bc_SRAM
));
52 if (BestCommBase
->bc_SRAMSize
)
54 /* Get memory for Free bitmap. Here, 1=free and 0=in use */
55 BestCommBase
->bc_SRAMFree
= AllocMem((BestCommBase
->bc_SRAMSize
>> 4) / (8*sizeof(uint32_t)), MEMF_CLEAR
|MEMF_PUBLIC
);
57 prop
= OF_FindProperty(key
, "available");
61 const int regs
= OF_GetPropLen(prop
) / sizeof(reg_t
);
62 reg_t
*reg
= OF_GetPropValue(prop
);
64 for (i
=0; i
< regs
; i
++)
66 D(bug("[SDMA] addr=%08x len=%d\n", reg
[i
].addr
, reg
[i
].size
));
74 key
= OF_OpenKey("/builtin/bestcomm");
77 void *prop
= OF_FindProperty(key
, "reg");
80 BestCommBase
->bc_BestComm
= *(void **)OF_GetPropValue(prop
);
82 D(bug("[SDMA] bestcomm at %08x\n", BestCommBase
->bc_BestComm
));
94 ADD2INITLIB(bestcomm_init
, 0)