2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Boot your operating system.
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"
28 * Load DEVS:system-configuration only on m68k.
29 * Setup pre-2.0 boot disk colors and mouse cursors (for example)
31 #define USE_SYSTEM_CONFIGURATION
35 #ifdef USE_SYSTEM_CONFIGURATION
37 #include <proto/intuition.h>
39 static void load_system_configuration(struct DosLibrary
*DOSBase
)
43 struct Preferences prefs
;
44 struct Library
*IntuitionBase
;
46 fh
= Open("DEVS:system-configuration", MODE_OLDFILE
);
49 len
= Read(fh
, &prefs
, sizeof prefs
);
51 if (len
!= sizeof prefs
)
53 IntuitionBase
= TaggedOpenLibrary(TAGGEDOPEN_INTUITION
);
55 SetPrefs(&prefs
, len
, FALSE
);
56 CloseLibrary(IntuitionBase
);
61 #define load_system_configuration(DOSBase) do { } while (0)
65 extern void BCPL_cliInit(void);
67 void __dos_Boot(struct DosLibrary
*DOSBase
, ULONG BootFlags
, UBYTE Flags
)
71 /* We have been created as a process by DOS, we should now
72 try and boot the system. */
74 D(bug("[__dos_Boot] generic boot sequence, BootFlags 0x%08X Flags 0x%02X\n", BootFlags
, Flags
));
76 /* m68000 uses this to get the default colors and
77 * cursors for Workbench
79 load_system_configuration(DOSBase
);
82 * If needed, run the display drivers loader.
83 * In fact the system must have at least one resident driver,
84 * which will be used for bootmenu etc. However, it we somehow happen
85 * not to have it, this will be our last chance.
87 if ((BootFlags
& (BF_NO_DISPLAY_DRIVERS
| BF_NO_COMPOSITION
)) != (BF_NO_DISPLAY_DRIVERS
| BF_NO_COMPOSITION
))
89 /* Check that it exists first... */
90 BPTR seg
= LoadSeg("C:AROSMonDrvs");
98 * Argument strings MUST contain terminating LF because of ReadItem() bugs.
99 * Their absence causes ReadArgs() crash.
101 if (BootFlags
& BF_NO_COMPOSITION
)
102 args
= "NOCOMPOSITION\n";
103 else if (BootFlags
& BF_NO_DISPLAY_DRIVERS
)
104 args
= "ONLYCOMPOSITION\n";
106 D(bug("[__dos_Boot] Running AROSMonDrvs %s\n", args
));
108 /* RunCommand needs a valid Input() handle
109 * for passing in its arguments.
111 oldin
= SelectInput(Open("NIL:", MODE_OLDFILE
));
112 oldout
= SelectOutput(Open("NIL:", MODE_NEWFILE
));
113 RunCommand(seg
, AROS_STACKSIZE
, args
, strlen(args
));
115 SelectOutput(oldout
);
117 /* We don't care about the return code */
122 if (BootFlags
& BF_EMERGENCY_CONSOLE
) {
123 BootFlags
|= BF_NO_STARTUP_SEQUENCE
;
124 cis
= Open("ECON:", MODE_OLDFILE
);
128 cis
= Open("CON:////AROS/AUTO/CLOSE/SMART/BOOT", MODE_OLDFILE
);
131 BPTR cos
= OpenFromLock(DupLockFromFH(cis
));
132 BYTE
const C
[] = "Copyright © 1995-2013, The AROS Development Team.\n"
133 "Licensed under the AROS Public License.\n"
134 "Version SVN" SVNREV
", built on " ISODATE
".\n";
139 if (!(BootFlags
& BF_NO_STARTUP_SEQUENCE
))
140 cas
= Open("S:Startup-Sequence", MODE_OLDFILE
);
142 /* Inject the banner */
143 if (Flags
& EBF_SILENTSTART
) {
144 if (SetVBuf(cos
, NULL
, BUF_FULL
, sizeof(C
)) == 0) {
146 SetVBuf(cos
, NULL
, BUF_LINE
, -1);
153 NP_Name
, "Initial CLI",
154 SYS_Background
, FALSE
,
158 SYS_ScriptInput
, cas
,
160 Alert(AT_DeadEnd
| AN_BootStrap
);
163 { /* Do not flush cos (show banner) if we got this far, we don't want to
164 * see shell window quickly opening and then immediately closing at
165 * the end of startup-sequence.
167 * There has to be less hacky way..
169 struct FileHandle
*fh
= ((struct FileHandle
*)BADDR(cos
));
170 fh
->fh_Flags
&= ~0x80000000;
173 /* NOTE: 'cas' will already have been closed by the Shell */