2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
5 Desc: VMWare SVGA Hidd initialisation code
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>
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
},
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
))
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
)
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
;
78 STATIC BOOL
findCard(struct VMWareSVGA_staticdata
*xsd
)
80 struct Hook findHook
= {
81 h_Entry
: (IPTR (*)())VMWSVGAEnumerator
,
85 struct TagItem Requirements
[] =
87 {tHidd_PCI_VendorID
, VENDOR_VMWARE
},
88 {tHidd_PCI_Class
, 3 }, /* Display */
89 {tHidd_PCI_Interface
, 0 },
93 HIDD_PCI_EnumDevices(xsd
->pcihidd
, &findHook
, (struct TagItem
*)&Requirements
);
97 if (!initVMWareSVGAHW(&xsd
->data
, xsd
->card
))
99 bug("[VMWareSVGA] findCard: Unsupported VMWare SVGA device found - skipping\n");
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
)
114 if (!OOP_ObtainAttrBases(abd
))
117 xsd
->basebm
= OOP_FindClass(CLID_Hidd_BitMap
);
119 xsd
->pcihidd
= OOP_NewObject(NULL
, CLID_Hidd_PCI
, NULL
);
120 if (xsd
->pcihidd
== NULL
)
123 HiddPCIDeviceAttrBase
= OOP_ObtainAttrBase(IID_Hidd_PCIDevice
);
124 if (HiddPCIDeviceAttrBase
== 0)
127 xsd
->hiddGalliumAB
= OOP_ObtainAttrBase((STRPTR
)IID_Hidd_Gallium
);
128 if (xsd
->hiddGalliumAB
== 0)
134 D(bug("[VMWareSVGA] Init: VMWare SVGA Adaptor Found\n"));
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
);
158 OOP_ReleaseAttrBases(abd
);
163 ADD2INITLIB(VMWareSVGA_Init
, 0)
165 ADD2LIBS((STRPTR
)"gallium.hidd", 7, static struct Library
*, GalliumHiddBase
);