Merge branch 'x86/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
[pandora-kernel.git] / arch / x86 / boot / main.c
index 1f95750..2296164 100644 (file)
@@ -9,8 +9,6 @@
  * ----------------------------------------------------------------------- */
 
 /*
- * arch/i386/boot/main.c
- *
  * Main module for the real-mode kernel code
  */
 
@@ -100,20 +98,32 @@ static void set_bios_mode(void)
 #endif
 }
 
-void main(void)
+static void init_heap(void)
 {
-       /* First, copy the boot header into the "zeropage" */
-       copy_boot_params();
+       char *stack_end;
 
-       /* End of heap check */
        if (boot_params.hdr.loadflags & CAN_USE_HEAP) {
-               heap_end = (char *)(boot_params.hdr.heap_end_ptr
-                                   +0x200-STACK_SIZE);
+               asm("leal %P1(%%esp),%0"
+                   : "=r" (stack_end) : "i" (-STACK_SIZE));
+
+               heap_end = (char *)
+                       ((size_t)boot_params.hdr.heap_end_ptr + 0x200);
+               if (heap_end > stack_end)
+                       heap_end = stack_end;
        } else {
                /* Boot protocol 2.00 only, no heap available */
                puts("WARNING: Ancient bootloader, some functionality "
                     "may be limited!\n");
        }
+}
+
+void main(void)
+{
+       /* First, copy the boot header into the "zeropage" */
+       copy_boot_params();
+
+       /* End of heap check */
+       init_heap();
 
        /* Make sure we have all the proper CPU support */
        if (validate_cpu()) {
@@ -131,9 +141,6 @@ void main(void)
        /* Set keyboard repeat rate (why?) */
        keyboard_set_repeat();
 
-       /* Set the video mode */
-       set_video();
-
        /* Query MCA information */
        query_mca();
 
@@ -154,6 +161,14 @@ void main(void)
 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
        query_edd();
 #endif
+
+       /* Set the video mode */
+       set_video();
+
+       /* Parse command line for 'quiet' and pass it to decompressor. */
+       if (cmdline_find_option_bool("quiet"))
+               boot_params.hdr.loadflags |= QUIET_FLAG;
+
        /* Do the last things and invoke protected mode */
        go_to_protected_mode();
 }