Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / hidds / vmwaresvga / vmwaresvga_init.c
blob79c56ac14c9e15dcffc88446c87888cbb9a8f68e
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: VMWare SVGA 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/oop.h>
16 #include <exec/types.h>
17 #include <exec/lists.h>
18 #include <hidd/graphics.h>
19 #include <hidd/pci.h>
20 #include <oop/oop.h>
21 #include <utility/utility.h>
22 #include <aros/symbolsets.h>
24 #include "vmwaresvgahardware.h"
25 #include "vmwaresvgaclass.h"
26 #include "svga_reg.h"
28 #include LC_LIBDEFS_FILE
30 static OOP_AttrBase HiddPixFmtAttrBase; // = 0;
31 static OOP_AttrBase HiddPCIDeviceAttrBase;
33 static struct OOP_ABDescr abd[] =
35 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
36 { NULL, NULL }
39 AROS_UFH3(void, VMWSVGAEnumerator,
40 AROS_UFHA(struct Hook *, hook, A0),
41 AROS_UFHA(OOP_Object *, pciDevice, A2),
42 AROS_UFHA(APTR, message, A1))
44 AROS_USERFUNC_INIT
46 struct VMWareSVGA_staticdata *xsd = (struct VMWareSVGA_staticdata *)hook->h_Data;
48 IPTR ProductID, VendorID, SubClass;
50 OOP_GetAttr(pciDevice, aHidd_PCIDevice_ProductID, &ProductID);
51 OOP_GetAttr(pciDevice, aHidd_PCIDevice_VendorID, &VendorID);
52 OOP_GetAttr(pciDevice, aHidd_PCIDevice_SubClass, &SubClass);
54 bug("[VMWareSVGA] VMWSVGAEnumerator: VMWare SVGA device %04x\n", ProductID);
56 if (ProductID == DEVICE_VMWARE0710)
58 xsd->data.indexReg = SVGA_LEGACY_BASE_PORT + SVGA_INDEX_PORT * sizeof(ULONG);
59 xsd->data.valueReg = SVGA_LEGACY_BASE_PORT + SVGA_VALUE_PORT * sizeof(ULONG);
61 bug("[VMWareSVGA] VMWSVGAEnumerator: Found VMWare SVGA 0710 device\n");
62 xsd->card = pciDevice;
64 else if (ProductID == DEVICE_VMWARE0405)
66 IPTR mmio;
68 OOP_GetAttr(pciDevice, aHidd_PCIDevice_Base0, &mmio);
70 xsd->data.indexReg = mmio + SVGA_INDEX_PORT;
71 xsd->data.valueReg = mmio + SVGA_VALUE_PORT;
73 bug("[VMWareSVGA] VMWSVGAEnumerator: Found VMWare SVGA 0405 device\n");
74 xsd->card = pciDevice;
77 AROS_USERFUNC_EXIT
80 STATIC BOOL findCard(struct VMWareSVGA_staticdata *xsd)
82 struct Hook findHook = {
83 h_Entry: (IPTR (*)())VMWSVGAEnumerator,
84 h_Data: xsd,
87 struct TagItem Requirements[] =
89 {tHidd_PCI_VendorID, VENDOR_VMWARE },
90 {tHidd_PCI_Class, 3 }, /* Display */
91 {tHidd_PCI_Interface, 0 },
92 {TAG_DONE, 0UL }
95 HIDD_PCI_EnumDevices(xsd->pcihidd, &findHook, (struct TagItem *)&Requirements);
97 if (xsd->card)
99 if (!initVMWareSVGAHW(&xsd->data, xsd->card))
101 bug("[VMWareSVGA] findCard: Unsupported VMWare SVGA device found - skipping\n");
102 xsd->card = NULL;
105 return (xsd->card) ? TRUE : FALSE;
108 static int VMWareSVGA_Init(LIBBASETYPEPTR LIBBASE)
110 struct VMWareSVGA_staticdata *xsd = &LIBBASE->vsd;
112 if (!OOP_ObtainAttrBases(abd))
113 goto failure;
115 xsd->basebm = OOP_FindClass(CLID_Hidd_BitMap);
117 xsd->pcihidd = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
118 if (xsd->pcihidd == NULL)
119 goto failure;
121 HiddPCIDeviceAttrBase = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);
122 if (HiddPCIDeviceAttrBase == 0)
123 goto failure;
125 if (!findCard(xsd))
126 goto failure;
128 D(bug("[VMWareSVGA] Init: VMWare SVGA Adaptor Found\n"));
129 return TRUE;
131 failure:
132 D(bug("[VMWareSVGA] Init: No VMWare SVGA Adaptor Found\n"));
133 if (HiddPCIDeviceAttrBase != 0)
135 OOP_ReleaseAttrBase(IID_Hidd_PCIDevice);
136 HiddPCIDeviceAttrBase = 0;
139 if (xsd->pcihidd != NULL)
141 OOP_DisposeObject(xsd->pcihidd);
142 xsd->pcihidd = NULL;
145 OOP_ReleaseAttrBases(abd);
147 return FALSE;
150 ADD2INITLIB(VMWareSVGA_Init, 0)