2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: Code that loads and initializes necessary HIDDs.
9 #include <exec/memory.h>
10 #include <exec/resident.h>
11 #include <exec/alerts.h>
13 #include <exec/lists.h>
14 #include <dos/filesystem.h>
15 #include <utility/tagitem.h>
16 #include <utility/hooks.h>
17 #include <hidd/hidd.h>
18 #include <aros/bootloader.h>
20 #include <proto/exec.h>
21 #include <proto/oop.h>
22 #include <proto/utility.h>
23 #include <proto/dos.h>
24 #include <proto/bootloader.h>
25 #include <proto/intuition.h>
29 #warning Fix this in a better way. It will break if things move around.
30 #include "../../rom/devs/devs_private.h"
32 #include <aros/asmcall.h>
35 #include <aros/debug.h>
37 #warning This is just a temporary and hackish way to get the HIDDs up and working
41 struct ExecBase
*sysbase
;
42 struct DosLibrary
*dosbase
;
43 struct Library
*oopbase
;
46 #define SysBase (base->sysbase)
47 #define DOSBase (base->dosbase)
48 #define OOPBase (base->oopbase)
51 static BOOL
init_gfx ( STRPTR gfxclassname
, struct initbase
*base
);
52 static BOOL
init_device( STRPTR hiddclassname
, STRPTR devicename
, struct initbase
*base
);
54 /************************************************************************/
58 /* We don't link with c library so I must implement this separately */
60 (c == '\t' || c == ' ')
62 (c == '\t' || c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\v')
65 #include <proto/graphics.h>
67 BOOL
init_hidds(struct ExecBase
*sysBase
, struct DosLibrary
*dosBase
)
69 /* This is the initialisation code for InitHIDDs module */
72 struct initbase stack_b
, *base
= &stack_b
;
73 BOOL success
= TRUE
, vga
= FALSE
;
74 STRPTR defvhidd
= "hidd.gfx.vga";
75 STRPTR defvlib
= "vgah.hidd";
76 UBYTE gfxname
[BUFSIZE
];
77 struct BootLoaderBase
*BootLoaderBase
;
79 base
->sysbase
= sysBase
;
80 base
->dosbase
= dosBase
;
82 EnterFunc(bug("init_hidds\n"));
84 OOPBase
= OpenLibrary(AROSOOP_NAME
, 0);
91 /* Initialize these HIDDs by default */
92 if (!(OpenLibrary("mouse.hidd",0L)))
95 bug("[DOS] InitHidds: Failed to open mouse.hidd\n");
98 if (!(OpenLibrary("kbd.hidd",0L)))
101 bug("[DOS] InitHidds: Failed to open kbd.hidd\n");
103 if (!(OpenLibrary("graphics.hidd",0L)))
106 bug("[DOS] InitHidds: Failed to open graphics.hidd\n");
109 /* Prepare the VGA hidd as a fallback */
110 strncpy(gfxname
,defvhidd
,BUFSIZE
-1);
111 if ((BootLoaderBase
= OpenResource("bootloader.resource")))
117 /* See if VESA mode specified. If so, we will use vesagfx.hidd instead
118 * of vgah.hid by default */
119 if ((vi
= GetBootInfo(BL_Video
)))
121 if (vi
->ModeNumber
!= 3)
123 /* Bootloader set vesa mode */
124 defvhidd
= "hidd.gfx.vesa";
125 defvlib
= "vesagfx.hidd";
126 strcpy(gfxname
,defvhidd
);
127 bug("[DOS] InitHidds: VESA graphics requested\n");
130 list
= (struct List
*)GetBootInfo(BL_Args
);
133 ForeachNode(list
,node
)
135 if (0 == strncmp(node
->ln_Name
,"gfx=",4))
137 bug("[DOS] InitHidds: Using %s as graphics driver\n",&node
->ln_Name
[4]);
138 strncpy(gfxname
,&(node
->ln_Name
[4]),BUFSIZE
-1);
140 if (0 == strncmp(node
->ln_Name
,"lib=",4))
142 bug("[DOS] InitHidds: Opening library %s\n",&node
->ln_Name
[4]);
143 if (!(OpenLibrary(&node
->ln_Name
[4],0L)))
144 bug("[DOS] InitHidds: Failed to open %s\n",&node
->ln_Name
[4]);
145 if (0 == strcmp(&node
->ln_Name
[4],defvlib
))
152 /* If we got no gfx hidd on the commandline, and did not load default hidd,
153 * we will do that now. */
154 if (0 == strcmp(gfxname
,defvhidd
) && vga
== FALSE
)
156 OpenLibrary(defvlib
,0L);
159 /* Set up the graphics HIDD system */
160 if (!init_gfx(gfxname
, base
))
162 bug("[DOS] InitHidds: Could not init gfx hidd %s\n", gfxname
);
166 /* And finally keyboard and mouse */
167 if (!init_device("hidd.kbd.hw", "keyboard.device", base
))
169 bug("[DOS] InitHidds: Could not init keyboard hidd\n");
173 if (!init_device("hidd.bus.mouse", "gameport.device", base
))
175 bug("[DOS] InitHidds: Could not init mouse hidd\n");
178 CloseLibrary(OOPBase
);
181 ReturnBool("init_hidds", success
);
188 static BOOL
init_gfx(STRPTR gfxclassname
, struct initbase
*base
)
190 struct GfxBase
*GfxBase
;
191 BOOL success
= FALSE
;
193 EnterFunc(bug("init_gfx(hiddbase=%s)\n", gfxclassname
));
195 GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 37);
198 D(bug("gfx.library opened\n"));
200 /* Call private gfx.library call to init the HIDD.
201 Gfx library is responsable for closing the HIDD
202 library (although it will probably not be neccesary).
205 D(bug("calling private gfx LateGfxInit()\n"));
206 if (LateGfxInit(gfxclassname
))
208 struct IntuitionBase
*IntuitionBase
;
211 /* Now that gfx. is guaranteed to be up & working, let intuition open WB screen */
212 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 37);
215 if (LateIntuiInit(NULL
))
219 CloseLibrary((struct Library
*)IntuitionBase
);
222 D(bug("Closing gfx\n"));
224 CloseLibrary((struct Library
*)GfxBase
);
226 ReturnBool ("init_gfxhidd", success
);
230 static BOOL
init_device( STRPTR hiddclassname
, STRPTR devicename
, struct initbase
*base
)
232 BOOL success
= FALSE
;
236 EnterFunc(bug("init_device(classname=%s)\n", hiddclassname
));
238 mp
= CreateMsgPort();
241 struct IORequest
*io
;
242 io
= CreateIORequest(mp
, sizeof ( struct IOStdReq
));
244 if (0 == OpenDevice(devicename
, 0, io
, 0))
248 /* Allocate message data */
249 data
= AllocMem(BUFSIZE
, MEMF_PUBLIC
);
252 #define ioStd(x) ((struct IOStdReq *)x)
253 strcpy(data
, hiddclassname
);
254 ioStd(io
)->io_Command
= CMD_HIDDINIT
;
255 ioStd(io
)->io_Data
= data
;
256 ioStd(io
)->io_Length
= strlen(data
);
258 /* Let the device init the HIDD */
260 if (0 == io
->io_Error
)
265 FreeMem(data
, BUFSIZE
);
278 ReturnBool("init_device", success
);