2 Copyright © 2011-2015, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
7 #include <dos/dosextens.h>
8 #include <hidd/graphics.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 "intelG45_intern.h"
22 #include "compositing_intern.h"
23 #include "gallium_intern.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 HiddCompositingAttrBase
;
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_Compositing
, &HiddCompositingAttrBase
},
72 const TEXT version_string
[] = "$VER: IntelGMA 3.12 (18.8.2015)\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
);
178 struct TagItem INTELG45_tags
[] =
180 {aMeta_SuperID
, (IPTR
)CLID_Hidd_Gfx
},
181 {aMeta_InterfaceDescr
, (IPTR
)INTELG45_ifdescr
},
182 {aMeta_InstSize
, sizeof(struct g45data
) },
183 {aMeta_ID
, (IPTR
)CLID_Hidd_Gfx_IntelGMA
},
188 sd
.IntelG45Class
= OOP_NewObject(NULL
, CLID_HiddMeta
, INTELG45_tags
);
189 if (sd
.IntelG45Class
)
191 struct TagItem GMABM_tags
[] =
193 {aMeta_SuperID
, (IPTR
)CLID_Hidd_BitMap
},
194 {aMeta_InterfaceDescr
, (IPTR
)GMABM_ifdescr
},
195 {aMeta_InstSize
, sizeof(GMABitMap_t
) },
196 {aMeta_ID
, (IPTR
)CLID_Hidd_BitMap_IntelGMA
},
200 /* According to a tradition, we store a pointer to static data in class' UserData */
201 sd
.IntelG45Class
->UserData
= &sd
;
203 sd
.BMClass
= OOP_NewObject(NULL
, CLID_HiddMeta
, GMABM_tags
);
206 struct TagItem INTELI2C_tags
[] =
208 {aMeta_SuperID
, (IPTR
)CLID_Hidd_I2C
},
209 {aMeta_InterfaceDescr
, (IPTR
)INTELI2C_ifdescr
},
210 {aMeta_InstSize
, sizeof(struct i2cdata
)},
214 sd
.BMClass
->UserData
= &sd
;
216 sd
.IntelI2C
= OOP_NewObject(NULL
, CLID_HiddMeta
, INTELI2C_tags
);
219 struct TagItem Compositing_tags
[] =
221 {aMeta_SuperID
, (IPTR
)CLID_Hidd
},
222 {aMeta_InterfaceDescr
, (IPTR
)Compositing_ifdescr
},
223 {aMeta_InstSize
, sizeof(struct HIDDCompositingData
)},
227 sd
.IntelI2C
->UserData
= &sd
;
229 sd
.compositingclass
= OOP_NewObject(NULL
, CLID_HiddMeta
, Compositing_tags
);
230 if (sd
.compositingclass
)
233 #ifndef GALLIUM_SIMULATION
234 /* Init internal stuff */
238 struct Process
*me
= (struct Process
*)FindTask(NULL
);
240 #ifndef GALLIUM_SIMULATION
242 * Register our gfx class as public, we use it as a
243 * protection against double start
245 OOP_AddClass(sd
.IntelG45Class
);
248 /* Init Galliumclass */
251 /* Everything is okay, stay resident and exit */
253 D(bug("[SDL] Staying resident, process 0x%p\n", me
));
256 struct CommandLineInterface
*cli
= BADDR(me
->pr_CLI
);
258 cli
->cli_Module
= BNULL
;
261 me
->pr_SegList
= BNULL
;
264 * Note also that we don't close needed libraries and
265 * don't free attribute bases
269 OOP_DisposeObject((OOP_Object
*)sd
.compositingclass
);
271 OOP_DisposeObject((OOP_Object
*)sd
.IntelI2C
);
273 OOP_DisposeObject((OOP_Object
*)sd
.BMClass
);
275 OOP_DisposeObject((OOP_Object
*)sd
.IntelG45Class
);
277 OOP_ReleaseAttrBases(attrbases
);
280 if (StdCIOBase
!= NULL
)
281 CloseLibrary(StdCIOBase
);
282 if (StdCBase
!= NULL
)
283 CloseLibrary(StdCBase
);
284 if (UtilityBase
!= NULL
)
285 CloseLibrary(UtilityBase
);
287 CloseLibrary(OOPBase
);