[PATCH] libpayload: Add multiboot support
[coreboot.git] / payloads / libpayload / i386 / main.c
index c880937e9837fd63f31bfea432653e9b57d61604..48d6ef54952aa8105ade915b6e36b359c98bc717 100644 (file)
 
 #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();
@@ -70,10 +56,12 @@ static void start_main(void)
         * 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