2 Copyright © 2013-2017, The AROS Development Team. All rights reserved.
5 Desc: BCM VideoCore4 Gfx Hidd initialisation code
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/mbox.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>
27 #include <utility/utility.h>
28 #include <aros/symbolsets.h>
30 #include "vc4gfx_hidd.h"
31 #include "vc4gfx_hardware.h"
33 #include LC_LIBDEFS_FILE
39 #define MBoxBase xsd->vcsd_MBoxBase
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
)
48 for (i
= 0; i
< num
; i
++)
52 OOP_ReleaseAttrBase(iftable
[i
]);
53 bases
[i
] = (OOP_AttrBase
)0;
58 static BOOL
FNAME_SUPPORT(GetAttrBases
)(const STRPTR
*iftable
, OOP_AttrBase
*bases
, ULONG num
)
62 for (i
= 0; i
< num
; i
++)
64 bases
[i
] = OOP_ObtainAttrBase(iftable
[i
]);
67 FNAME_SUPPORT(FreeAttrBases
)(iftable
, bases
, i
);
75 static const STRPTR interfaces
[] =
77 IID_Hidd_Gfx_VideoCore4
,
78 IID_Hidd_BitMap_VideoCore4
,
87 static int FNAME_SUPPORT(Init
)(LIBBASETYPEPTR LIBBASE
)
89 struct VideoCoreGfx_staticdata
*xsd
= &LIBBASE
->vsd
;
92 KernelBase
= OpenResource("kernel.resource");
93 __arm_periiobase
= KrnGetSystemAttr(KATTR_PeripheralBase
);
95 if (!FNAME_SUPPORT(GetAttrBases
)(interfaces
, xsd
->vcsd_attrBases
, ATTRBASES_NUM
))
98 if (!(MBoxBase
= OpenResource("mbox.resource")))
101 if (!(xsd
->vcsd_MBoxBuff
= (IPTR
)AllocVec(16 + (sizeof(IPTR
) * 2 * MAX_TAGS
), MEMF_CLEAR
)))
104 xsd
->vcsd_MBoxMessage
=
105 (unsigned int *)((xsd
->vcsd_MBoxBuff
+ 0xF) & ~0x0000000F);
107 D(bug("[VideoCoreGfx] %s: VideoCore Mailbox resource @ 0x%p\n", __PRETTY_FUNCTION__
, MBoxBase
));
108 D(bug("[VideoCoreGfx] %s: VideoCore message buffer @ 0x%p\n", __PRETTY_FUNCTION__
, xsd
->vcsd_MBoxMessage
));
111 xsd
->vcsd_MBoxMessage
[0] = AROS_LE2LONG(8 * 4);
112 xsd
->vcsd_MBoxMessage
[1] = AROS_LE2LONG(VCTAG_REQ
);
113 xsd
->vcsd_MBoxMessage
[2] = AROS_LE2LONG(VCTAG_GETVCRAM
);
114 xsd
->vcsd_MBoxMessage
[3] = AROS_LE2LONG(8);
115 xsd
->vcsd_MBoxMessage
[4] = 0;
117 xsd
->vcsd_MBoxMessage
[5] = 0;
118 xsd
->vcsd_MBoxMessage
[6] = 0;
120 xsd
->vcsd_MBoxMessage
[7] = 0; // terminate tag
122 MBoxWrite((void*)VCMB_BASE
, VCMB_PROPCHAN
, xsd
->vcsd_MBoxMessage
);
123 if (MBoxRead((void*)VCMB_BASE
, VCMB_PROPCHAN
) == xsd
->vcsd_MBoxMessage
)
125 if (FNAME_SUPPORT(InitMem
)((void*)AROS_LE2LONG(xsd
->vcsd_MBoxMessage
[5]), AROS_LE2LONG(xsd
->vcsd_MBoxMessage
[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 LIBBASE
->vsd
.vcsd_basebm
= OOP_FindClass(CLID_Hidd_BitMap
);
134 if (AddDisplayDriver(LIBBASE
->vsd
.vcsd_VideoCoreGfxClass
, NULL
, DDRV_BootMode
, TRUE
, TAG_DONE
) == DD_OK
)
136 bug("[VideoCoreGfx] BootMode Display Driver Registered\n");
138 LIBBASE
->library
.lib_OpenCnt
++;
141 CloseLibrary(&GfxBase
->LibNode
);
149 bug("[VideoCoreGfx] No VideoCore GPU Found\n");
151 FreeVec((APTR
)xsd
->vcsd_MBoxBuff
);
153 FNAME_SUPPORT(FreeAttrBases
)(interfaces
, xsd
->vcsd_attrBases
, ATTRBASES_NUM
);
159 ADD2INITLIB(FNAME_SUPPORT(Init
), 0)