Bumped project copyright year.
[AROS.git] / rom / dos / boot.c
blobc094fddd12023cecef71f7f0f24f4fd05d53d635
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Boot your operating system.
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. */
75 D(bug("[__dos_Boot] generic boot sequence, BootFlags 0x%08X Flags 0x%02X\n", BootFlags, Flags));
77 /* m68000 uses this to get the default colors and
78 * cursors for Workbench
80 load_system_configuration(DOSBase);
83 * If needed, run the display drivers loader.
84 * In fact the system must have at least one resident driver,
85 * which will be used for bootmenu etc. However, it we somehow happen
86 * not to have it, this will be our last chance.
88 if ((BootFlags & (BF_NO_DISPLAY_DRIVERS | BF_NO_COMPOSITION)) != (BF_NO_DISPLAY_DRIVERS | BF_NO_COMPOSITION))
90 /* Check that it exists first... */
91 BPTR seg = LoadSeg("C:AROSMonDrvs");
93 if (seg != BNULL)
95 STRPTR args = "";
96 BPTR oldin, oldout;
99 * Argument strings MUST contain terminating LF because of ReadItem() bugs.
100 * Their absence causes ReadArgs() crash.
102 if (BootFlags & BF_NO_COMPOSITION)
103 args = "NOCOMPOSITION\n";
104 else if (BootFlags & BF_NO_DISPLAY_DRIVERS)
105 args = "ONLYCOMPOSITION\n";
107 D(bug("[__dos_Boot] Running AROSMonDrvs %s\n", args));
109 /* RunCommand needs a valid Input() handle
110 * for passing in its arguments.
112 oldin = SelectInput(Open("NIL:", MODE_OLDFILE));
113 oldout= SelectOutput(Open("NIL:", MODE_NEWFILE));
114 RunCommand(seg, AROS_STACKSIZE, args, strlen(args));
115 SelectInput(oldin);
116 SelectOutput(oldout);
118 /* We don't care about the return code */
119 UnLoadSeg(seg);
123 if (BootFlags & BF_EMERGENCY_CONSOLE) {
124 BootFlags |= BF_NO_STARTUP_SEQUENCE;
125 cis = Open("ECON:", MODE_OLDFILE);
128 if (cis == BNULL)
129 cis = Open("CON:////AROS/AUTO/CLOSE/SMART/BOOT", MODE_OLDFILE);
131 if (cis) {
132 BPTR cos = OpenFromLock(DupLockFromFH(cis));
133 BYTE const C[] = "Copyright © 1995-2015, The AROS Development Team.\n"
134 "Licensed under the AROS Public License.\n"
135 "Version SVN" SVNREV ", built on " ISODATE ".\n";
137 if (cos) {
138 BPTR cas = BNULL;
140 if (!(BootFlags & BF_NO_STARTUP_SEQUENCE))
141 cas = Open("S:Startup-Sequence", MODE_OLDFILE);
143 /* Inject the banner */
144 if (Flags & EBF_SILENTSTART) {
145 if (SetVBuf(cos, NULL, BUF_FULL, sizeof(C)) == 0) {
146 FPuts(cos, C);
147 SetVBuf(cos, NULL, BUF_LINE, -1);
149 } else {
150 FPuts(cos, C);
153 if (SystemTags(NULL,
154 NP_Name, "Initial CLI",
155 SYS_Background, FALSE,
156 SYS_Asynch, FALSE,
157 SYS_Input, cis,
158 SYS_Output, cos,
159 SYS_ScriptInput, cas,
160 TAG_END) == -1) {
161 Alert(AT_DeadEnd | AN_BootStrap);
163 Close(cis);
164 { /* Do not flush cos (show banner) if we got this far, we don't want to
165 * see shell window quickly opening and then immediately closing at
166 * the end of startup-sequence.
168 * There has to be less hacky way..
170 struct FileHandle *fh = ((struct FileHandle*)BADDR(cos));
171 fh->fh_Flags &= ~0x80000000;
173 Close(cos);
174 /* NOTE: 'cas' will already have been closed by the Shell */
176 } else
177 Alert(AN_NoWindow);