2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
5 Desc: Implements AROS's generic/amiga-like boot sequence.
9 #include <aros/debug.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 <dos/cliinit.h>
18 #include <dos/stdio.h>
19 #include <utility/tagitem.h>
20 #include <libraries/expansionbase.h>
21 #include <proto/exec.h>
22 #include <proto/dos.h>
24 #include "dos_intern.h"
25 #include "../dosboot/bootflags.h"
29 * Load DEVS:system-configuration only on m68k.
30 * Setup pre-2.0 boot disk colors and mouse cursors (for example)
32 #define USE_SYSTEM_CONFIGURATION
36 #ifdef USE_SYSTEM_CONFIGURATION
38 #include <proto/intuition.h>
40 static void load_system_configuration(struct DosLibrary
*DOSBase
)
44 struct Preferences prefs
;
45 struct Library
*IntuitionBase
;
47 fh
= Open("DEVS:system-configuration", MODE_OLDFILE
);
50 len
= Read(fh
, &prefs
, sizeof prefs
);
52 if (len
!= sizeof prefs
)
54 IntuitionBase
= TaggedOpenLibrary(TAGGEDOPEN_INTUITION
);
56 SetPrefs(&prefs
, len
, FALSE
);
57 CloseLibrary(IntuitionBase
);
62 #define load_system_configuration(DOSBase) do { } while (0)
66 extern void BCPL_cliInit(void);
68 void __dos_Boot(struct DosLibrary
*DOSBase
, ULONG BootFlags
, UBYTE Flags
)
72 /* We have been created as a process by DOS, we should now
73 try and boot the system. */
76 bug("[DOS] %s: ** starting generic boot sequence\n", __func__
);
77 bug("[DOS] %s: BootFlags 0x%08X Flags 0x%02X\n", __func__
, BootFlags
, Flags
);
78 bug("[DOS] %s: DOSBase @ 0x%p\n", __func__
, DOSBase
);
81 /* m68000 uses this to get the default colors and
82 * cursors for Workbench
84 load_system_configuration(DOSBase
);
86 D(bug("[DOS] %s: system config loaded\n", __func__
);)
89 * If needed, run the display drivers loader.
90 * In fact the system must have at least one resident driver,
91 * which will be used for bootmenu etc. However, it we somehow happen
92 * not to have it, this will be our last chance.
94 if ((BootFlags
& (BF_NO_DISPLAY_DRIVERS
| BF_NO_COMPOSITION
)) != (BF_NO_DISPLAY_DRIVERS
| BF_NO_COMPOSITION
))
96 /* Check that it exists first... */
99 D(bug("[DOS] %s: initialising displays\n", __func__
);)
101 if ((seg
= LoadSeg("C:AROSMonDrvs")) != BNULL
)
107 * Argument strings MUST contain terminating LF because of ReadItem() bugs.
108 * Their absence causes ReadArgs() crash.
110 if (BootFlags
& BF_NO_COMPOSITION
)
111 args
= "NOCOMPOSITION\n";
112 else if (BootFlags
& BF_NO_DISPLAY_DRIVERS
)
113 args
= "ONLYCOMPOSITION\n";
115 D(bug("[DOS] %s: Running AROSMonDrvs %s\n", __func__
, args
);)
117 /* RunCommand needs a valid Input() handle
118 * for passing in its arguments.
120 oldin
= SelectInput(Open("NIL:", MODE_OLDFILE
));
121 oldout
= SelectOutput(Open("NIL:", MODE_NEWFILE
));
122 RunCommand(seg
, AROS_STACKSIZE
, args
, strlen(args
));
124 SelectOutput(oldout
);
126 /* We don't care about the return code */
131 D(bug("[DOS] %s: preparing console\n", __func__
);)
133 if (BootFlags
& BF_EMERGENCY_CONSOLE
) {
134 D(bug("[DOS] %s: (emergency console)\n", __func__
);)
135 BootFlags
|= BF_NO_STARTUP_SEQUENCE
;
136 cis
= Open("ECON:", MODE_OLDFILE
);
140 cis
= Open("CON:////AROS/AUTO/CLOSE/SMART/BOOT", MODE_OLDFILE
);
143 BPTR cos
= OpenFromLock(DupLockFromFH(cis
));
144 BYTE
const C
[] = "Copyright © 1995-2016, The AROS Development Team.\n"
145 "Licensed under the AROS Public License.\n"
146 "Version SVN" SVNREV
", built on " ISODATE
".\n";
148 D(bug("[DOS] %s: handle @ 0x%p (0x%p)\n", __func__
, cis
, cos
);)
153 if (!(BootFlags
& BF_NO_STARTUP_SEQUENCE
))
154 cas
= Open("S:Startup-Sequence", MODE_OLDFILE
);
156 /* Inject the banner */
157 if (Flags
& EBF_SILENTSTART
) {
158 if (SetVBuf(cos
, NULL
, BUF_FULL
, sizeof(C
)) == 0) {
160 SetVBuf(cos
, NULL
, BUF_LINE
, -1);
166 D(bug("[DOS] %s: initialising CLI\n", __func__
);)
169 NP_Name
, "Initial CLI",
170 SYS_Background
, FALSE
,
174 SYS_ScriptInput
, cas
,
176 D(bug("[DOS] %s: .. failed!\n", __func__
);)
177 Alert(AT_DeadEnd
| AN_BootStrap
);
182 /* Do not flush cos (show banner) if we got this far, we don't want to
183 * see shell window quickly opening and then immediately closing at
184 * the end of startup-sequence.
186 * There has to be less hacky way..
188 struct FileHandle
*fh
= ((struct FileHandle
*)BADDR(cos
));
189 fh
->fh_Flags
&= ~0x80000000;
192 /* NOTE: 'cas' will already have been closed by the Shell */
195 D(bug("[DOS] %s: .. failed!\n", __func__
);)