7 /* These macros are defined in both UNIX and AROS headers. Get rid of warnings. */
13 #include <aros/kernel.h>
16 #include "kickstart.h"
22 * This is the UNIX-hosted kicker. Theory of operation:
23 * We want to run the loaded code multiple times, every time as a new process (in order
24 * to drop all open file descriptors etc).
25 * We have already loaded our kickstart and allocated RAM. Now we use fork() to mark
26 * the point where we are started.
27 * AROS is executed inside child process. The parent just sits and waits for the return
29 * When AROS shuts down, it sets exit status in order to indicate a reason. There are
34 * We pick up this code and see what we need to do. Warm reboot means just creating a
35 * new AROS process using the same kickstart and RAM image. When the RAM is made shared,
36 * this will effectively keep KickTags etc.
37 * Cold reboot is the same as before, re-running everything from scratch.
38 * Shutdown is just plain exit.
40 int kick(int (*addr
)(), struct TagItem
*msg
)
51 DisplayError("Failed to run kickstart!");
55 fprintf(stderr
, "[Bootstrap] entering kernel at %p...\n", addr
);
56 i
= addr(msg
, AROS_BOOT_MAGIC
);
60 /* Wait until AROS process exits */
61 waitpid(child
, &i
, 0);
65 D(fprintf(stderr
, "AROS process died with error\n"));
69 D(fprintf(stderr
, "AROS exited with status 0x%08X\n", WEXITSTATUS(i
)));
71 /* ColdReboot() returns 0x8F */
72 } while (WEXITSTATUS(i
) == 0x8F);
74 if (WEXITSTATUS(i
) == 0x81)
77 * Perform cold boot if requested.
78 * Before rebooting, we clean up. Otherwise execvp()'ed process will
79 * inherit what we allocated here, then again... This will cause memory leak.
85 return WEXITSTATUS(i
);