2 Copyright © 2011-2019, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
7 #include <dos/dosextens.h>
10 #include <workbench/startup.h>
11 #include <workbench/workbench.h>
12 #include <proto/dos.h>
13 #include <proto/exec.h>
14 #include <proto/graphics.h>
15 #include <proto/icon.h>
16 #include <proto/oop.h>
21 #include "intelgma_hidd.h"
22 #include "intelgma_compositor.h"
23 #include "intelgma_gallium.h"
25 struct Library
*OOPBase
;
26 struct Library
*UtilityBase
;
27 struct Library
*StdCBase
;
28 struct Library
*StdCIOBase
;
30 OOP_AttrBase HiddPCIDeviceAttrBase
;
31 OOP_AttrBase HiddGMABitMapAttrBase
;
32 OOP_AttrBase HiddI2CAttrBase
;
33 OOP_AttrBase HiddI2CDeviceAttrBase
;
34 OOP_AttrBase HiddGCAttrBase
;
35 OOP_AttrBase HiddCompositorAttrBase
;
36 OOP_AttrBase MetaAttrBase
;
37 OOP_AttrBase HiddAttrBase
;
38 OOP_AttrBase HiddPCIDeviceAttrBase
;
39 OOP_AttrBase HiddGMABitMapAttrBase
;
40 OOP_AttrBase HiddPixFmtAttrBase
;
41 OOP_AttrBase HiddBitMapAttrBase
;
42 OOP_AttrBase HiddColorMapAttrBase
;
43 OOP_AttrBase HiddSyncAttrBase
;
44 OOP_AttrBase HiddGfxAttrBase
;
45 OOP_AttrBase __IHidd_PlanarBM
;
48 * Class static data is really static now. :)
49 * If the driver would be compiled as a ROM resident, this structure
50 * needs to be allocated using AllocMem()
52 struct g45staticdata sd
;
54 static const struct OOP_ABDescr attrbases
[] =
56 {IID_Meta
, &MetaAttrBase
},
57 {IID_Hidd
, &HiddAttrBase
},
58 {IID_Hidd_PCIDevice
, &HiddPCIDeviceAttrBase
},
59 {IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
60 {IID_Hidd_PixFmt
, &HiddPixFmtAttrBase
},
61 {IID_Hidd_Sync
, &HiddSyncAttrBase
},
62 {IID_Hidd_Gfx
, &HiddGfxAttrBase
},
63 {IID_Hidd_BitMap_IntelGMA
, &HiddGMABitMapAttrBase
},
64 {IID_Hidd_I2C
, &HiddI2CAttrBase
},
65 {IID_Hidd_I2CDevice
, &HiddI2CDeviceAttrBase
},
66 {IID_Hidd_PlanarBM
, &__IHidd_PlanarBM
},
67 {IID_Hidd_GC
, &HiddGCAttrBase
},
68 {IID_Hidd_Compositor
, &HiddCompositorAttrBase
},
72 const TEXT version_string
[] = "$VER: IntelGMA 3.13 (17.10.2016)\n";
74 extern struct WBStartup
*WBenchMsg
;
75 int __nocommandline
= 1;
81 struct DiskObject
*icon
;
82 struct RDArgs
*rdargs
= NULL
;
84 int ret
= RETURN_FAIL
;
88 * Open libraries manually, otherwise they will be closed
89 * when this subroutine exits. Driver needs them.
91 OOPBase
= OpenLibrary("oop.library", 42);
96 * If our class is already registered, the user attempts to run us twice.
101 if (OOP_FindClass(CLID_Hidd_Gfx_IntelGMA
))
108 UtilityBase
= OpenLibrary("utility.library", 36);
109 StdCBase
= OpenLibrary("stdc.library", 0);
110 StdCIOBase
= OpenLibrary("stdcio.library", 0);
111 if (UtilityBase
== NULL
|| StdCBase
== NULL
|| StdCIOBase
== NULL
)
116 memset(&sd
, 0, sizeof(sd
));
118 /* We don't open dos.library and icon.library manually because only startup code
119 needs them and these libraries can be closed even upon successful exit */
122 olddir
= CurrentDir(WBenchMsg
->sm_ArgList
[0].wa_Lock
);
123 myname
= WBenchMsg
->sm_ArgList
[0].wa_Name
;
127 struct Process
*me
= (struct Process
*)FindTask(NULL
);
131 struct CommandLineInterface
*cli
= BADDR(me
->pr_CLI
);
133 myname
= AROS_BSTR_ADDR(cli
->cli_CommandName
);
136 myname
= me
->pr_Task
.tc_Node
.ln_Name
;
139 icon
= GetDiskObject(myname
);
145 str
= FindToolType(icon
->do_ToolTypes
, "FORCEGMA");
146 args
[0] = str
? TRUE
: FALSE
;
148 str
= FindToolType(icon
->do_ToolTypes
, "FORCEGALLIUM");
149 args
[1] = str
? TRUE
: FALSE
;
153 rdargs
= ReadArgs("FORCEGMA/S,FORCEGALLIUM/S", args
, NULL
);
156 sd
.force_gallium
= args
[1];
161 FreeDiskObject(icon
);
166 /* Obtain attribute bases first */
169 if (!OOP_ObtainAttrBases(attrbases
))
173 sd
.basegc
= OOP_FindClass(CLID_Hidd_GC
);
174 sd
.basebm
= OOP_FindClass(CLID_Hidd_BitMap
);
175 sd
.basei2c
= OOP_FindClass(CLID_Hidd_I2C
);
179 struct TagItem INTELG45_tags
[] =
181 {aMeta_SuperID
, (IPTR
)CLID_Hidd_Gfx
},
182 {aMeta_InterfaceDescr
, (IPTR
)INTELG45_ifdescr
},
183 {aMeta_InstSize
, sizeof(struct g45data
) },
184 {aMeta_ID
, (IPTR
)CLID_Hidd_Gfx_IntelGMA
},
189 sd
.IntelG45Class
= OOP_NewObject(NULL
, CLID_HiddMeta
, INTELG45_tags
);
190 if (sd
.IntelG45Class
)
192 struct TagItem GMABM_tags
[] =
194 {aMeta_SuperID
, (IPTR
)CLID_Hidd_BitMap
},
195 {aMeta_InterfaceDescr
, (IPTR
)GMABM_ifdescr
},
196 {aMeta_InstSize
, sizeof(GMABitMap_t
) },
197 {aMeta_ID
, (IPTR
)CLID_Hidd_BitMap_IntelGMA
},
201 /* According to a tradition, we store a pointer to static data in class' UserData */
202 sd
.IntelG45Class
->UserData
= &sd
;
204 sd
.BMClass
= OOP_NewObject(NULL
, CLID_HiddMeta
, GMABM_tags
);
207 struct TagItem INTELI2C_tags
[] =
209 {aMeta_SuperID
, (IPTR
)CLID_Hidd_I2C
},
210 {aMeta_InterfaceDescr
, (IPTR
)INTELI2C_ifdescr
},
211 {aMeta_InstSize
, sizeof(struct i2cdata
)},
215 sd
.BMClass
->UserData
= &sd
;
217 sd
.IntelI2C
= OOP_NewObject(NULL
, CLID_HiddMeta
, INTELI2C_tags
);
220 struct TagItem Compositor_tags
[] =
222 {aMeta_SuperID
, (IPTR
)CLID_Hidd
},
223 {aMeta_InterfaceDescr
, (IPTR
)Compositor_ifdescr
},
224 {aMeta_InstSize
, sizeof(struct HIDDCompositorData
)},
228 sd
.IntelI2C
->UserData
= &sd
;
230 sd
.compositorclass
= OOP_NewObject(NULL
, CLID_HiddMeta
, Compositor_tags
);
231 if (sd
.compositorclass
)
234 #ifndef GALLIUM_SIMULATION
235 /* Init internal stuff */
239 struct Process
*me
= (struct Process
*)FindTask(NULL
);
241 #ifndef GALLIUM_SIMULATION
243 * Register our gfx class as public, we use it as a
244 * protection against double start
246 OOP_AddClass(sd
.IntelG45Class
);
249 /* Init Galliumclass */
252 /* Everything is okay, stay resident and exit */
254 D(bug("[SDL] Staying resident, process 0x%p\n", me
));
257 struct CommandLineInterface
*cli
= BADDR(me
->pr_CLI
);
259 cli
->cli_Module
= BNULL
;
262 me
->pr_SegList
= BNULL
;
265 * Note also that we don't close needed libraries and
266 * don't free attribute bases
270 OOP_DisposeObject((OOP_Object
*)sd
.compositorclass
);
272 OOP_DisposeObject((OOP_Object
*)sd
.IntelI2C
);
274 OOP_DisposeObject((OOP_Object
*)sd
.BMClass
);
276 OOP_DisposeObject((OOP_Object
*)sd
.IntelG45Class
);
278 OOP_ReleaseAttrBases(attrbases
);
281 if (StdCIOBase
!= NULL
)
282 CloseLibrary(StdCIOBase
);
283 if (StdCBase
!= NULL
)
284 CloseLibrary(StdCBase
);
285 if (UtilityBase
!= NULL
)
286 CloseLibrary(UtilityBase
);
288 CloseLibrary(OOPBase
);