2 Copyright © 2009-2014, The AROS Development Team. All rights reserved.
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
)
18 void *OpenFirmwareBase
;
21 D(bug("[SDMA] BestComm Init.\n"));
23 OpenFirmwareBase
= OpenResource("openfirmware.resource");
25 /* Get some addresses from OF tree */
28 key
= OF_OpenKey("/builtin");
31 prop
= OF_FindProperty(key
, "reg");
34 reg_t
*reg
= OF_GetPropValue(prop
);
35 BestCommBase
->bc_MBAR
= (uint8_t *)reg
->addr
;
39 key
= OF_OpenKey("/builtin/sram");
42 prop
= OF_FindProperty(key
, "reg");
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");
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");
75 void *prop
= OF_FindProperty(key
, "reg");
78 BestCommBase
->bc_BestComm
= *(void **)OF_GetPropValue(prop
);
80 D(bug("[SDMA] bestcomm at %08x\n", BestCommBase
->bc_BestComm
));
92 ADD2INITLIB(bestcomm_init
, 0)