make sure the arm implementation struct is aligned
[AROS.git] / arch / arm-native / soc / broadcom / 283x / hidd / videocoregfx / videocoregfx_init.c
blobb79cd2a3a7d59a80200aaaf7277f291d1dbcbf42
1 /*
2 Copyright © 2013-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: VideoCore Hidd initialisation code
6 Lang: english
7 */
9 #define DEBUG 0
10 #include <aros/debug.h>
12 #define __OOP_NOATTRBASES__
14 #include <proto/exec.h>
15 #include <proto/graphics.h>
16 #include <proto/oop.h>
17 #include <proto/vcmbox.h>
18 #include <proto/kernel.h>
19 #include <proto/utility.h>
21 #include <exec/types.h>
22 #include <exec/lists.h>
23 #include <graphics/driver.h>
24 #include <graphics/gfxbase.h>
25 #include <hidd/graphics.h>
26 #include <oop/oop.h>
27 #include <utility/utility.h>
28 #include <aros/symbolsets.h>
30 #include "videocoregfx_class.h"
31 #include "videocoregfx_hardware.h"
33 #include LC_LIBDEFS_FILE
35 #ifdef VCMBoxBase
36 #undef VCMBoxBase
37 #endif
39 #define VCMBoxBase xsd->vcsd_VCMBoxBase
41 IPTR __arm_periiobase __attribute__((used)) = 0 ;
42 APTR KernelBase __attribute__((used)) = NULL;
44 static void FNAME_SUPPORT(FreeAttrBases)(const STRPTR *iftable, OOP_AttrBase *bases, ULONG num)
46 ULONG i;
48 for (i = 0; i < num; i++)
50 if (bases[i])
52 OOP_ReleaseAttrBase(iftable[i]);
53 bases[i] = NULL;
58 static BOOL FNAME_SUPPORT(GetAttrBases)(const STRPTR *iftable, OOP_AttrBase *bases, ULONG num)
60 ULONG i;
62 for (i = 0; i < num; i++)
64 bases[i] = OOP_ObtainAttrBase(iftable[i]);
65 if (!bases[i])
67 FNAME_SUPPORT(FreeAttrBases)(iftable, bases, i);
68 return FALSE;
72 return TRUE;
75 static const STRPTR interfaces[] =
77 IID_Hidd_VideoCoreGfx,
78 IID_Hidd_VideoCoreGfxBitMap,
79 IID_Hidd_ChunkyBM,
80 IID_Hidd_BitMap,
81 IID_Hidd_PixFmt,
82 IID_Hidd_Sync,
83 IID_Hidd_Gfx,
84 IID_Hidd
87 static int FNAME_SUPPORT(Init)(LIBBASETYPEPTR LIBBASE)
89 struct VideoCoreGfx_staticdata *xsd = &LIBBASE->vsd;
90 int retval = FALSE;
92 KernelBase = OpenResource("kernel.resource");
93 __arm_periiobase = KrnGetSystemAttr(KATTR_PeripheralBase);
95 if (!FNAME_SUPPORT(GetAttrBases)(interfaces, xsd->vcsd_attrBases, ATTRBASES_NUM))
96 goto failure;
98 if (!(VCMBoxBase = OpenResource("vcmbox.resource")))
99 goto failure;
101 if (!(xsd->vcsd_VCMBoxBuff = AllocVec(16 + (sizeof(IPTR) * 2 * MAX_TAGS), MEMF_CLEAR)))
102 goto failure;
104 xsd->vcsd_VCMBoxMessage =
105 (unsigned int *)((xsd->vcsd_VCMBoxBuff + 0xF) & ~0x0000000F);
107 D(bug("[VideoCoreGfx] %s: VideoCore Mailbox resource @ 0x%p\n", __PRETTY_FUNCTION__, VCMBoxBase));
108 D(bug("[VideoCoreGfx] %s: VideoCore message buffer @ 0x%p\n", __PRETTY_FUNCTION__, xsd->vcsd_VCMBoxMessage));
111 xsd->vcsd_VCMBoxMessage[0] = 8 * 4;
112 xsd->vcsd_VCMBoxMessage[1] = VCTAG_REQ;
113 xsd->vcsd_VCMBoxMessage[2] = VCTAG_GETVCRAM;
114 xsd->vcsd_VCMBoxMessage[3] = 8;
115 xsd->vcsd_VCMBoxMessage[4] = 0;
117 xsd->vcsd_VCMBoxMessage[5] = 0;
118 xsd->vcsd_VCMBoxMessage[6] = 0;
120 xsd->vcsd_VCMBoxMessage[7] = 0; // terminate tag
122 VCMBoxWrite(VCMB_BASE, VCMB_PROPCHAN, xsd->vcsd_VCMBoxMessage);
123 if (VCMBoxRead(VCMB_BASE, VCMB_PROPCHAN) == xsd->vcsd_VCMBoxMessage)
125 if (FNAME_SUPPORT(InitMem)(xsd->vcsd_VCMBoxMessage[5], xsd->vcsd_VCMBoxMessage[6], LIBBASE))
127 bug("[VideoCoreGfx] VideoCore GPU Found\n");
129 FNAME_HW(InitGfxHW)((APTR)xsd);
131 if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 41)) != NULL)
133 if (AddDisplayDriver(LIBBASE->vsd.vcsd_VideoCoreGfxClass, NULL, DDRV_BootMode, TRUE, TAG_DONE) == DD_OK)
135 bug("[VideoCoreGfx] BootMode Display Driver Registered\n");
137 LIBBASE->library.lib_OpenCnt++;
138 retval = TRUE;
140 CloseLibrary(&GfxBase->LibNode);
145 failure:
146 if (!(retval))
148 bug("[VideoCoreGfx] No VideoCore GPU Found\n");
150 FreeVec((APTR)xsd->vcsd_VCMBoxBuff);
152 FNAME_SUPPORT(FreeAttrBases)(interfaces, xsd->vcsd_attrBases, ATTRBASES_NUM);
155 return retval;
158 ADD2INITLIB(FNAME_SUPPORT(Init), 0)