Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / .unmaintained / m68k-pp-native / dos / boot.c
blob019702060b2b3738f616922da4e1466886e9ab9b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Boot your operating system.
6 Lang: english
7 */
9 #include <exec/types.h>
10 #include <exec/alerts.h>
11 #include <exec/libraries.h>
12 #include <exec/devices.h>
13 #include <exec/execbase.h>
14 #include <aros/libcall.h>
15 #include <aros/asmcall.h>
16 #include <dos/dosextens.h>
17 #include <utility/tagitem.h>
18 #include <aros/arossupportbase.h>
19 #include <aros/debug.h>
21 #include <proto/exec.h>
22 #include <proto/dos.h>
24 /* Require this for the stdout defn */
25 #include <stdio.h>
27 extern void AROSSupportBase_SetStdOut (void *);
28 extern int submain(struct ExecBase *, struct DosLibrary *);
30 struct emulbase
32 struct Device eb_device;
33 struct Unit *eb_stdin;
34 struct Unit *eb_stdout;
35 struct Unit *eb_stderr;
38 AROS_UFH3(void, boot,
39 AROS_UFHA(STRPTR, argString, A0),
40 AROS_UFHA(ULONG, argSize, D0),
41 AROS_UFHA(struct ExecBase *, SysBase, A6)
44 /* We have been created as a process by DOS, we should now
45 try and boot the system. We do this by calling the submain()
46 function in arosshell.c
48 DOS has created our process, but it has not given us
49 the correct I/O Streams yet. What we have to do is
50 to (conditionally) close the old streams, and set
51 our own, which we get from emul.handler.
53 This is really only necessary if
54 a) We want to use the XTerm as our boot shell
55 b) Don't have a working console.device/CON: handler.
58 AROS_USERFUNC_INIT
60 struct DosLibrary *DOSBase;
61 // struct emulbase *emulbase;
62 // struct TagItem fhtags[]= { { TAG_END, 0 } };
63 // struct FileHandle *fh_stdin, *fh_stdout;
65 DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 0);
66 if( DOSBase == NULL )
68 /* BootStrap couldn't open dos.library */
69 Alert(AT_DeadEnd | AN_BootStrap | AG_OpenLib | AO_DOSLib );
73 This is quite naughty, but I know what I'm doing here, since
74 emul.handler ALWAYS exists under Unix, and it won't go away.
78 Forbid();
79 emulbase = (struct emulbase *)FindName(&SysBase->DeviceList, "emul.handler");
80 Permit();
82 if( emulbase == NULL )
85 /* BootStrap couldn't open unknown */
87 Alert(AT_DeadEnd | AN_BootStrap | AG_OpenDev | AO_Unknown );
90 fh_stdin = AllocDosObject(DOS_FILEHANDLE, fhtags);
91 fh_stdout = AllocDosObject(DOS_FILEHANDLE, fhtags);
93 if(fh_stdin == NULL || fh_stdout == NULL)
96 /* We have got some problems here. */
97 /* Alert(AT_DeadEnd | AN_BootStrap | AG_NoMemory);
100 fh_stdin->fh_Device =&emulbase->eb_device;
101 fh_stdin->fh_Unit =emulbase->eb_stdin;
102 fh_stdout->fh_Device =&emulbase->eb_device;
103 fh_stdout->fh_Unit =emulbase->eb_stdout;
105 if(Input())
106 Close(Input());
107 if(Output())
108 Close(Output());
110 SelectInput(MKBADDR(fh_stdin));
111 SelectOutput(MKBADDR(fh_stdout));
112 ((struct Process *)FindTask(NULL))->pr_CES = MKBADDR(fh_stdout);
114 AROSSupportBase_SetStdOut (stderr);
116 submain(SysBase, DOSBase);
118 /* submain() returns, when the Boot Shell Window is left with EndShell/EndCli */
120 /* To avoid that the input/output/error handles of emul.handler
121 are closed when the Boot Process dies, we set the in/out/err
122 handles of this process to 0.
126 SelectInput(0);
127 SelectOutput(0);
128 ((struct Process *)FindTask(NULL))->pr_CES = 0;
131 /* No RemTask() here, otherwise the process cleanup routines
132 are not called. And that would for example mean, that the
133 Boot Process (having a CLI) is not removed from the rootnode.
134 --> Dead stuff in there -> Crash
136 AROS_USERFUNC_EXIT