more rendering corrections
[AROS.git] / workbench / hidds / hidd.vmwaresvga / vmwaresvga_init.c
blob300ef3a0a166bc4ff68c726cca9c8af66301871c
1 /*
2 Copyright © 1995-2008, 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->pcihidd = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
116 if (xsd->pcihidd == NULL)
117 goto failure;
119 HiddPCIDeviceAttrBase = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);
120 if (HiddPCIDeviceAttrBase == 0)
121 goto failure;
123 if (!findCard(xsd))
124 goto failure;
126 D(bug("[VMWareSVGA] Init: VMWare SVGA Adaptor Found\n"));
127 return TRUE;
129 failure:
130 D(bug("[VMWareSVGA] Init: No VMWare SVGA Adaptor Found\n"));
131 if (HiddPCIDeviceAttrBase != 0)
133 OOP_ReleaseAttrBase(HiddPCIDeviceAttrBase);
134 HiddPCIDeviceAttrBase = 0;
137 if (xsd->pcihidd != NULL)
139 OOP_DisposeObject(xsd->pcihidd);
140 xsd->pcihidd;
143 OOP_ReleaseAttrBases(abd);
145 return FALSE;
148 ADD2INITLIB(VMWareSVGA_Init, 0)