2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
12 /* These macros are defined in both UNIX and AROS headers. Get rid of warnings. */
18 #include <aros/kernel.h>
21 #include "kickstart.h"
27 * This is the UNIX-hosted kicker. Theory of operation:
28 * We want to run the loaded code multiple times, every time as a new process (in order
29 * to drop all open file descriptors etc).
30 * We have already loaded our kickstart and allocated RAM. Now we use fork() to mark
31 * the point where we are started.
32 * AROS is executed inside child process. The parent just sits and waits for the return
34 * When AROS shuts down, it sets exit status in order to indicate a reason. There are
39 * We pick up this code and see what we need to do. Warm reboot means just creating a
40 * new AROS process using the same kickstart and RAM image. When the RAM is made shared,
41 * this will effectively keep KickTags etc.
42 * Cold reboot is the same as before, re-running everything from scratch.
43 * Shutdown is just plain exit.
45 int kick(int (*addr
)(), struct TagItem
*msg
)
56 DisplayError("Failed to run kickstart!");
60 fprintf(stderr
, "[Bootstrap] Entering kernel at %p...\n", addr
);
62 i
= addr(msg
, AROS_BOOT_MAGIC
);
66 /* Wait until AROS process exits */
67 waitpid(child
, &i
, 0);
71 D(fprintf(stderr
, "AROS process died with error\n"));
75 D(fprintf(stderr
, "AROS exited with status 0x%08X\n", WEXITSTATUS(i
)));
77 /* ColdReboot() returns 0x8F */
78 } while (WEXITSTATUS(i
) == 0x8F);
80 if (WEXITSTATUS(i
) == 0x81)
83 * Perform cold boot if requested.
84 * Before rebooting, we clean up. Otherwise execvp()'ed process will
85 * inherit what we allocated here, then again... This will cause memory leak.
91 return WEXITSTATUS(i
);