Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / ppc-chrp / dosboot / inithidds.c
blob58c08e05f11ea03c37293aa781adf04331541582
1 /*
2 Copyright � 1995-2006, The AROS Development Team. All rights reserved.
3 $Id: inithidds.c 28503 2008-04-28 09:32:13Z schulz $
5 Desc: Code that loads and initializes necessary HIDDs.
6 Lang: english
7 */
9 #include <exec/memory.h>
10 #include <exec/resident.h>
11 #include <exec/alerts.h>
12 #include <exec/io.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>
26 #include <oop/oop.h>
27 #include <string.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>
34 #define DEBUG 1
35 #include <aros/debug.h>
37 #warning This is just a temporary and hackish way to get the HIDDs up and working
39 struct initbase
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 __dosboot_InitGfx ( STRPTR gfxclassname, struct initbase *base);
52 static BOOL __dosboot_InitDevice( STRPTR hiddclassname, STRPTR devicename, struct initbase *base);
54 /************************************************************************/
56 #define BUFSIZE 100
58 /* We don't link with c library so I must implement this separately */
59 #define isblank(c) \
60 (c == '\t' || c == ' ')
61 #define isspace(c) \
62 (c == '\t' || c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\v')
65 #include <proto/graphics.h>
67 BOOL __dosboot_InitHidds(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 = "RadeonDriver";
75 STRPTR defvlib = "radeon.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);
85 if (!OOPBase)
87 success = FALSE;
89 else
91 if (!(OpenLibrary("graphics.hidd",0L)))
93 success = FALSE;
94 bug("[DOS] InitHidds: Failed to open graphics.hidd\n");
97 /* Prepare the VGA hidd as a fallback */
98 strncpy(gfxname,defvhidd,BUFSIZE-1);
99 if ((BootLoaderBase = OpenResource("bootloader.resource")))
101 struct List *list;
102 struct Node *node;
103 struct VesaInfo *vi;
105 /* See if VESA mode specified. If so, we will use vesagfx.hidd instead
106 * of vgah.hid by default */
107 if ((vi = GetBootInfo(BL_Video)))
109 if (vi->ModeNumber != 3)
111 /* Bootloader set vesa mode */
112 defvhidd = "RadeonDriver";
113 defvlib = "radeon.hidd";
114 strcpy(gfxname,defvhidd);
115 bug("[DOS] InitHidds: VESA graphics requested\n");
118 list = (struct List *)GetBootInfo(BL_Args);
119 if (list)
121 ForeachNode(list,node)
123 if (0 == strncmp(node->ln_Name,"gfx=",4))
125 bug("[DOS] InitHidds: Using %s as graphics driver\n",&node->ln_Name[4]);
126 strncpy(gfxname,&(node->ln_Name[4]),BUFSIZE-1);
128 if (0 == strncmp(node->ln_Name,"lib=",4))
130 bug("[DOS] InitHidds: Opening library %s\n",&node->ln_Name[4]);
131 if (!(OpenLibrary(&node->ln_Name[4],0L)))
132 bug("[DOS] InitHidds: Failed to open %s\n",&node->ln_Name[4]);
133 if (0 == strcmp(&node->ln_Name[4],defvlib))
134 vga = TRUE;
140 /* If we got no gfx hidd on the commandline, and did not load default hidd,
141 * we will do that now. */
142 if (0 == strcmp(gfxname,defvhidd) && vga == FALSE)
144 OpenLibrary(defvlib,0L);
147 /* Set up the graphics HIDD system */
148 if (!__dosboot_InitGfx(gfxname, base))
150 bug("[DOS] InitHidds: Could not init gfx hidd %s\n", gfxname);
151 success = FALSE;
153 #if 0
154 /* And finally keyboard and mouse */
155 if (!init_device("hidd.kbd.hw", "keyboard.device", base))
157 bug("[DOS] InitHidds: Could not init keyboard hidd\n");
158 success = FALSE;
161 if (!init_device("hidd.bus.mouse", "gameport.device", base))
163 bug("[DOS] InitHidds: Could not init mouse hidd\n");
164 success = FALSE;
166 #endif
167 CloseLibrary(OOPBase);
170 ReturnBool("init_hidds", success);
173 /*****************
174 ** init_gfx() **
175 *****************/
177 static BOOL __dosboot_InitGfx(STRPTR gfxclassname, struct initbase *base)
179 struct GfxBase *GfxBase;
180 BOOL success = FALSE;
182 EnterFunc(bug("init_gfx(hiddbase=%s)\n", gfxclassname));
184 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37);
185 if (GfxBase)
187 D(bug("gfx.library opened\n"));
189 /* Call private gfx.library call to init the HIDD.
190 Gfx library is responsable for closing the HIDD
191 library (although it will probably not be neccesary).
194 D(bug("calling private gfx LateGfxInit()\n"));
195 if (LateGfxInit(gfxclassname))
197 struct IntuitionBase *IntuitionBase;
198 D(bug("success\n"));
200 /* Now that gfx. is guaranteed to be up & working, let intuition open WB screen */
201 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
202 if (IntuitionBase)
204 if (LateIntuiInit(NULL))
206 success = TRUE;
208 CloseLibrary((struct Library *)IntuitionBase);
211 D(bug("Closing gfx\n"));
213 CloseLibrary((struct Library *)GfxBase);
215 ReturnBool ("init_gfxhidd", success);
219 static BOOL __dosboot_InitDevice( STRPTR hiddclassname, STRPTR devicename, struct initbase *base)
221 BOOL success = FALSE;
222 struct MsgPort *mp;
225 EnterFunc(bug("init_device(classname=%s)\n", hiddclassname));
227 mp = CreateMsgPort();
228 if (mp)
230 struct IORequest *io;
231 io = CreateIORequest(mp, sizeof ( struct IOStdReq));
233 if (0 == OpenDevice(devicename, 0, io, 0))
235 UBYTE *data;
237 /* Allocate message data */
238 data = AllocMem(BUFSIZE, MEMF_PUBLIC);
239 if (data)
241 #define ioStd(x) ((struct IOStdReq *)x)
242 strcpy(data, hiddclassname);
243 ioStd(io)->io_Command = CMD_HIDDINIT;
244 ioStd(io)->io_Data = data;
245 ioStd(io)->io_Length = strlen(data);
247 /* Let the device init the HIDD */
248 DoIO(io);
249 if (0 == io->io_Error)
251 success = TRUE;
254 FreeMem(data, BUFSIZE);
256 CloseDevice(io);
259 DeleteIORequest(io);
263 DeleteMsgPort(mp);
267 ReturnBool("init_device", success);