#include <libpayload.h>
-/*
- * This structure seeds the stack. We provide the return address of our main
- * function, and further down, the address of the function that we call when
- * we leave and try to restore the original stack. At the very bottom of the
- * stack we store the orignal stack pointer from the calling application.
- */
-
-static void start_main(void);
-extern void _leave(void);
+unsigned long loader_eax; /**< The value of EAX passed from the loader */
+unsigned long loader_ebx; /**< The value of EBX passed from the loader */
-static struct {
- uint32_t eip[2];
- uint32_t raddr[2];
- uint32_t esp;
-} initial_stack __attribute__ ((section(".istack"))) = {
- { (uint32_t) start_main, 0 },
- { (uint32_t) _leave, 0 },
- (uint32_t) & initial_stack,
-};
+unsigned int main_argc; /**< The argc value to pass to main() */
-void *_istack = &initial_stack;
+/** The argv value to pass to main() */
+char *main_argv[MAX_ARGC_COUNT];
/**
* This is our C entry function - set up the system
* and jump into the payload entry point.
*/
-static void start_main(void)
+void start_main(void)
{
- extern int main(void);
+ extern int main(int argc, char **argv);
/* Set up the consoles. */
console_init();
* user gets control goes here.
*/
- /* Go to the entry point. */
+ /*
+ * Go to the entry point.
+ * In the future we may care about the return value.
+ */
- /* In the future we may care about the return value. */
- (void) main();
+ (void) main(main_argc, (main_argc != 0) ? main_argv : NULL);
/*
* Returning here will go to the _leave function to return