Hint added.
[AROS.git] / workbench / c / Shell / shell_init.c
blobe71c03a678f55d9d6052588b62bd345629b1b3f2
1 /*
2 Copyright © 2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Shell Resource
6 Lang: english
7 */
9 #define DEBUG 0
10 #include <aros/debug.h>
12 #include <exec/resident.h>
13 #include <proto/exec.h>
14 #include <proto/dos.h>
16 #include <aros/symbolsets.h>
17 #include <aros/shcommands.h>
19 THIS_PROGRAM_HANDLES_SYMBOLSET(SHCOMMANDS)
20 DEFINESET(SHCOMMANDS)
22 #include LC_LIBDEFS_FILE
24 #undef DOSBase
26 extern void ShellStart(void);
28 #ifdef __mc68000
29 /* Under AOS, the "CLI" segment has a BCPL entry,
30 * while the "Shell" segment has a C entry point.
32 * This small stub 'thunks' from BCPL to C,
33 * and back again.
35 extern void Shell_CLISeg(void);
36 asm (
37 " .balign 4\n"
38 " .global Shell_CLISeg\n"
39 " .long ((Shell_CLI_end - Shell_CLI_start) / 4)+1\n"
40 "Shell_CLISeg:\n"
41 " .long 0\n" /* No next BCPL segment */
42 " .long ((Shell_CLI_end - Shell_CLI_start) / 4)+1\n"
43 "Shell_CLI_start:\n"
44 " movem.l %a0-%a1/%a6, %sp@-\n"
45 " lsl.l #2, %d1\n"
46 " move.l %d1, %a0\n"
47 " jsr ShellStart\n"
48 " movem.l %sp@+,%a0-%a1/%a6\n"
49 " move.l %d0, %d1\n"
50 " jmp %a6@\n"
51 " .balign 4\n"
52 " .long 0\n" /* End of setup data */
53 " .long 1\n" /* Update BCPL Entry (GV #1) */
54 " .long 4\n" /* Offset of CLI start */
55 " .long 2\n" /* Need a minimum of 2 GV slots */
56 "Shell_CLI_end:\n"
58 #endif
60 static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR LIBBASE)
62 APTR DOSBase;
63 BPTR seg;
65 D(bug("[Shell] Init\n"));
67 DOSBase = OpenLibrary("dos.library", 0);
68 if ( DOSBase == NULL ) {
69 D(bug("[Shell] What? No dos.library?\n"));
70 return FALSE;
73 seg = CreateSegList(ShellStart);
74 if (seg != BNULL) {
75 AddSegment("shell", seg, CMD_SYSTEM);
76 #ifdef __mc68000
77 AddSegment("CLI", MKBADDR(Shell_CLISeg), CMD_SYSTEM);
78 #else
79 AddSegment("CLI", seg, CMD_SYSTEM);
80 #endif
83 CloseLibrary(DOSBase);
85 return TRUE;
88 ADD2INITLIB(GM_UNIQUENAME(Init), 0);