optional icu diff.
[AROS.git] / rom / dos / boot.c
blobfefebb28f3002ac43abf0bafc74fdacd82526068
1 /*
2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Implements AROS's generic/amiga-like boot sequence.
6 Lang: english
7 */
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"
27 #ifdef __mc68000
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
34 #endif
36 #ifdef USE_SYSTEM_CONFIGURATION
38 #include <proto/intuition.h>
40 static void load_system_configuration(struct DosLibrary *DOSBase)
42 BPTR fh;
43 ULONG len;
44 struct Preferences prefs;
45 struct Library *IntuitionBase;
47 fh = Open("DEVS:system-configuration", MODE_OLDFILE);
48 if (!fh)
49 return;
50 len = Read(fh, &prefs, sizeof prefs);
51 Close(fh);
52 if (len != sizeof prefs)
53 return;
54 IntuitionBase = TaggedOpenLibrary(TAGGEDOPEN_INTUITION);
55 if (IntuitionBase)
56 SetPrefs(&prefs, len, FALSE);
57 CloseLibrary(IntuitionBase);
60 #else
62 #define load_system_configuration(DOSBase) do { } while (0)
64 #endif
66 extern void BCPL_cliInit(void);
68 void __dos_Boot(struct DosLibrary *DOSBase, ULONG BootFlags, UBYTE Flags)
70 BPTR cis = BNULL;
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... */
97 BPTR seg;
99 D(bug("[DOS] %s: initialising displays\n", __func__);)
101 if ((seg = LoadSeg("C:AROSMonDrvs")) != BNULL)
103 STRPTR args = "";
104 BPTR oldin, oldout;
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));
123 SelectInput(oldin);
124 SelectOutput(oldout);
126 /* We don't care about the return code */
127 UnLoadSeg(seg);
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);
139 if (cis == BNULL)
140 cis = Open("CON:////AROS/AUTO/CLOSE/SMART/BOOT", MODE_OLDFILE);
142 if (cis) {
143 BPTR cos = OpenFromLock(DupLockFromFH(cis));
144 BYTE const C[] = "Copyright © 1995-2019, 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);)
150 if (cos) {
151 BPTR cas = BNULL;
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) {
159 FPuts(cos, C);
160 SetVBuf(cos, NULL, BUF_LINE, -1);
162 } else {
163 FPuts(cos, C);
166 D(bug("[DOS] %s: initialising CLI\n", __func__);)
168 if (SystemTags(NULL,
169 NP_Name, "Initial CLI",
170 SYS_Background, FALSE,
171 SYS_Asynch, FALSE,
172 SYS_Input, cis,
173 SYS_Output, cos,
174 SYS_ScriptInput, cas,
175 TAG_END) == -1) {
176 D(bug("[DOS] %s: .. failed!\n", __func__);)
177 Alert(AT_DeadEnd | AN_BootStrap);
180 Close(cis);
181 #if (1)
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;
190 #endif
191 Close(cos);
192 /* NOTE: 'cas' will already have been closed by the Shell */
194 } else {
195 D(bug("[DOS] %s: .. failed!\n", __func__);)
196 Alert(AN_NoWindow);