disable debug
[AROS.git] / workbench / hidds / vmwaresvga / vmwaresvga_init.c
blob26b7ed2e7792338b31645853b3331e2cc87fdaff
1 /*
2 Copyright © 1995-2019, 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/gfx.h>
19 #include <hidd/pci.h>
20 #include <oop/oop.h>
21 #include <utility/utility.h>
22 #include <aros/symbolsets.h>
24 #include "vmwaresvga_intern.h"
26 #include LC_LIBDEFS_FILE
28 static OOP_AttrBase HiddPixFmtAttrBase; // = 0;
29 static OOP_AttrBase HiddPCIDeviceAttrBase;
31 static struct OOP_ABDescr abd[] =
33 { IID_Hidd_PixFmt, &HiddPixFmtAttrBase },
34 { NULL, NULL }
37 AROS_UFH3(void, VMWSVGAEnumerator,
38 AROS_UFHA(struct Hook *, hook, A0),
39 AROS_UFHA(OOP_Object *, pciDevice, A2),
40 AROS_UFHA(APTR, message, A1))
42 AROS_USERFUNC_INIT
44 struct VMWareSVGA_staticdata *xsd = (struct VMWareSVGA_staticdata *)hook->h_Data;
46 IPTR ProductID, VendorID, SubClass;
48 OOP_GetAttr(pciDevice, aHidd_PCIDevice_ProductID, &ProductID);
49 OOP_GetAttr(pciDevice, aHidd_PCIDevice_VendorID, &VendorID);
50 OOP_GetAttr(pciDevice, aHidd_PCIDevice_SubClass, &SubClass);
52 bug("[VMWareSVGA] VMWSVGAEnumerator: VMWare SVGA device %04x\n", ProductID);
54 if (ProductID == DEVICE_VMWARE0710)
56 xsd->data.indexReg = SVGA_LEGACY_BASE_PORT + SVGA_INDEX_PORT * sizeof(ULONG);
57 xsd->data.valueReg = SVGA_LEGACY_BASE_PORT + SVGA_VALUE_PORT * sizeof(ULONG);
59 bug("[VMWareSVGA] VMWSVGAEnumerator: Found VMWare SVGA 0710 device\n");
60 xsd->card = pciDevice;
62 else if (ProductID == DEVICE_VMWARE0405)
64 IPTR mmio;
66 OOP_GetAttr(pciDevice, aHidd_PCIDevice_Base0, &mmio);
68 xsd->data.indexReg = mmio + SVGA_INDEX_PORT;
69 xsd->data.valueReg = mmio + SVGA_VALUE_PORT;
71 bug("[VMWareSVGA] VMWSVGAEnumerator: Found VMWare SVGA 0405 device\n");
72 xsd->card = pciDevice;
75 AROS_USERFUNC_EXIT
78 STATIC BOOL findCard(struct VMWareSVGA_staticdata *xsd)
80 struct Hook findHook = {
81 h_Entry: (IPTR (*)())VMWSVGAEnumerator,
82 h_Data: xsd,
85 struct TagItem Requirements[] =
87 {tHidd_PCI_VendorID, VENDOR_VMWARE },
88 {tHidd_PCI_Class, 3 }, /* Display */
89 {tHidd_PCI_Interface, 0 },
90 {TAG_DONE, 0UL }
93 HIDD_PCI_EnumDevices(xsd->pcihidd, &findHook, (struct TagItem *)&Requirements);
95 if (xsd->card)
97 if (!initVMWareSVGAHW(&xsd->data, xsd->card))
99 bug("[VMWareSVGA] findCard: Unsupported VMWare SVGA device found - skipping\n");
100 xsd->card = NULL;
103 return (xsd->card) ? TRUE : FALSE;
106 static int VMWareSVGA_Init(LIBBASETYPEPTR LIBBASE)
108 struct VMWareSVGA_staticdata *xsd = &LIBBASE->vsd;
110 xsd->VMWareSVGACyberGfxBase = OpenLibrary((STRPTR)"cybergraphics.library",0);
111 if (xsd->VMWareSVGACyberGfxBase == NULL)
112 goto failure;
114 if (!OOP_ObtainAttrBases(abd))
115 goto failure;
117 xsd->basebm = OOP_FindClass(CLID_Hidd_BitMap);
119 xsd->pcihidd = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
120 if (xsd->pcihidd == NULL)
121 goto failure;
123 HiddPCIDeviceAttrBase = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);
124 if (HiddPCIDeviceAttrBase == 0)
125 goto failure;
127 xsd->hiddGalliumAB = OOP_ObtainAttrBase((STRPTR)IID_Hidd_Gallium);
128 if (xsd->hiddGalliumAB == 0)
129 goto failure;
131 if (!findCard(xsd))
132 goto failure;
134 D(bug("[VMWareSVGA] Init: VMWare SVGA Adaptor Found\n"));
135 return TRUE;
137 failure:
138 D(bug("[VMWareSVGA] Init: No VMWare SVGA Adaptor Found\n"));
140 if (xsd->VMWareSVGACyberGfxBase)
141 CloseLibrary(xsd->VMWareSVGACyberGfxBase);
143 if (xsd->hiddGalliumAB)
144 OOP_ReleaseAttrBase((STRPTR)IID_Hidd_Gallium);
146 if (HiddPCIDeviceAttrBase != 0)
148 OOP_ReleaseAttrBase(IID_Hidd_PCIDevice);
149 HiddPCIDeviceAttrBase = 0;
152 if (xsd->pcihidd != NULL)
154 OOP_DisposeObject(xsd->pcihidd);
155 xsd->pcihidd = NULL;
158 OOP_ReleaseAttrBases(abd);
160 return FALSE;
163 ADD2INITLIB(VMWareSVGA_Init, 0)
165 ADD2LIBS((STRPTR)"gallium.hidd", 7, static struct Library *, GalliumHiddBase);