vserver 1.9.3
[linux-2.6.git] / init / main.c
index cafeaeb..0c0135a 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/tty.h>
 #include <linux/gfp.h>
 #include <linux/percpu.h>
+#include <linux/kmod.h>
 #include <linux/kernel_stat.h>
 #include <linux/security.h>
 #include <linux/workqueue.h>
@@ -93,6 +94,11 @@ extern void free_initmem(void);
 extern void populate_rootfs(void);
 extern void driver_init(void);
 extern void prepare_namespace(void);
+#ifdef CONFIG_ACPI
+extern void acpi_early_init(void);
+#else
+static inline void acpi_early_init(void) { }
+#endif
 
 #ifdef CONFIG_TC
 extern void tc_init(void);
@@ -104,8 +110,8 @@ EXPORT_SYMBOL(system_state);
 /*
  * Boot command-line arguments
  */
-#define MAX_INIT_ARGS 8
-#define MAX_INIT_ENVS 8
+#define MAX_INIT_ARGS 32
+#define MAX_INIT_ENVS 32
 
 extern void time_init(void);
 /* Default late time init is NULL. archs can override this later. */
@@ -150,8 +156,6 @@ static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
 char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
 static const char *panic_later, *panic_param;
 
-__setup("profile=", profile_setup);
-
 static int __init obsolete_checksetup(char *line)
 {
        struct obs_kernel_param *p;
@@ -178,15 +182,28 @@ static int __init obsolete_checksetup(char *line)
        return 0;
 }
 
-/* this should be approx 2 Bo*oMips to start (note initial shift), and will
-   still work even if initially too large, it will just take slightly longer */
+static unsigned long preset_lpj;
+static int __init lpj_setup(char *str)
+{
+       preset_lpj = simple_strtoul(str,NULL,0);
+       return 1;
+}
+
+__setup("lpj=", lpj_setup);
+
+/*
+ * This should be approx 2 Bo*oMips to start (note initial shift), and will
+ * still work even if initially too large, it will just take slightly longer
+ */
 unsigned long loops_per_jiffy = (1<<12);
 
 EXPORT_SYMBOL(loops_per_jiffy);
 
-/* This is the number of bits of precision for the loops_per_jiffy.  Each
-   bit takes on average 1.5/HZ seconds.  This (like the original) is a little
-   better than 1% */
+/*
+ * This is the number of bits of precision for the loops_per_jiffy.  Each
+ * bit takes on average 1.5/HZ seconds.  This (like the original) is a little
+ * better than 1%
+ */
 #define LPS_PREC 8
 
 void __devinit calibrate_delay(void)
@@ -194,40 +211,53 @@ void __devinit calibrate_delay(void)
        unsigned long ticks, loopbit;
        int lps_precision = LPS_PREC;
 
-       loops_per_jiffy = (1<<12);
-
-       printk("Calibrating delay loop... ");
-       while ((loops_per_jiffy <<= 1) != 0) {
-               /* wait for "start of" clock tick */
-               ticks = jiffies;
-               while (ticks == jiffies)
-                       /* nothing */;
-               /* Go .. */
-               ticks = jiffies;
-               __delay(loops_per_jiffy);
-               ticks = jiffies - ticks;
-               if (ticks)
-                       break;
-       }
+       if (preset_lpj) {
+               loops_per_jiffy = preset_lpj;
+               printk("Calibrating delay loop (skipped)... "
+                       "%lu.%02lu BogoMIPS preset\n",
+                       loops_per_jiffy/(500000/HZ),
+                       (loops_per_jiffy/(5000/HZ)) % 100);
+       } else {
+               loops_per_jiffy = (1<<12);
+
+               printk(KERN_DEBUG "Calibrating delay loop... ");
+               while ((loops_per_jiffy <<= 1) != 0) {
+                       /* wait for "start of" clock tick */
+                       ticks = jiffies;
+                       while (ticks == jiffies)
+                               /* nothing */;
+                       /* Go .. */
+                       ticks = jiffies;
+                       __delay(loops_per_jiffy);
+                       ticks = jiffies - ticks;
+                       if (ticks)
+                               break;
+               }
+
+               /*
+                * Do a binary approximation to get loops_per_jiffy set to
+                * equal one clock (up to lps_precision bits)
+                */
+               loops_per_jiffy >>= 1;
+               loopbit = loops_per_jiffy;
+               while (lps_precision-- && (loopbit >>= 1)) {
+                       loops_per_jiffy |= loopbit;
+                       ticks = jiffies;
+                       while (ticks == jiffies)
+                               /* nothing */;
+                       ticks = jiffies;
+                       __delay(loops_per_jiffy);
+                       if (jiffies != ticks)   /* longer than 1 tick */
+                               loops_per_jiffy &= ~loopbit;
+               }
 
-/* Do a binary approximation to get loops_per_jiffy set to equal one clock
-   (up to lps_precision bits) */
-       loops_per_jiffy >>= 1;
-       loopbit = loops_per_jiffy;
-       while ( lps_precision-- && (loopbit >>= 1) ) {
-               loops_per_jiffy |= loopbit;
-               ticks = jiffies;
-               while (ticks == jiffies);
-               ticks = jiffies;
-               __delay(loops_per_jiffy);
-               if (jiffies != ticks)   /* longer than 1 tick */
-                       loops_per_jiffy &= ~loopbit;
+               /* Round the value and print it */
+               printk("%lu.%02lu BogoMIPS (lpj=%lu)\n",
+                       loops_per_jiffy/(500000/HZ),
+                       (loops_per_jiffy/(5000/HZ)) % 100,
+                       loops_per_jiffy);
        }
 
-/* Round the value and print it */     
-       printk("%lu.%02lu BogoMIPS\n",
-               loops_per_jiffy/(500000/HZ),
-               (loops_per_jiffy/(5000/HZ)) % 100);
 }
 
 static int __init debug_kernel(char *str)
@@ -249,20 +279,26 @@ static int __init quiet_kernel(char *str)
 __setup("debug", debug_kernel);
 __setup("quiet", quiet_kernel);
 
-/* Unknown boot options get handed to init, unless they look like
-   failed parameters */
+/*
+ * Unknown boot options get handed to init, unless they look like
+ * failed parameters
+ */
 static int __init unknown_bootoption(char *param, char *val)
 {
        /* Change NUL term back to "=", to make "param" the whole string. */
-       if (val)
-               val[-1] = '=';
+       if (val) {
+               if (val[-1] == '"') val[-2] = '=';
+               else val[-1] = '=';
+       }
 
        /* Handle obsolete-style parameters */
        if (obsolete_checksetup(param))
                return 0;
 
-       /* Preemptive maintenance for "why didn't my mispelled command
-           line work?" */
+       /*
+        * Preemptive maintenance for "why didn't my mispelled command
+        * line work?"
+        */
        if (strchr(param, '.') && (!val || strchr(param, '.') < val)) {
                printk(KERN_ERR "Unknown boot option `%s': ignoring\n", param);
                return 0;
@@ -302,7 +338,8 @@ static int __init init_setup(char *str)
        unsigned int i;
 
        execute_command = str;
-       /* In case LILO is going to boot us with default command line,
+       /*
+        * In case LILO is going to boot us with default command line,
         * it prepends "auto" before the whole cmdline which makes
         * the shell think it should execute a script with such name.
         * So we ignore all arguments entered _before_ init=... [MJ]
@@ -465,7 +502,6 @@ asmlinkage void __init start_kernel(void)
         * time - but meanwhile we still have a functioning scheduler.
         */
        sched_init();
-
        build_all_zonelists();
        page_alloc_init();
        printk("Kernel command line: %s\n", saved_command_line);
@@ -530,12 +566,7 @@ asmlinkage void __init start_kernel(void)
 #endif
        check_bugs();
 
-       /* 
-        *      We count on the initial thread going ok 
-        *      Like idlers init is an unlocked kernel thread, which will
-        *      make syscalls (and thus be locked).
-        */
-       init_idle(current, smp_processor_id());
+       acpi_early_init(); /* before LAPIC and SMP init */
 
        /* Do the rest non-__init'ed, we're now alive */
        rest_init();
@@ -598,6 +629,10 @@ static void __init do_initcalls(void)
  */
 static void __init do_basic_setup(void)
 {
+       /* drivers will send hotplug events */
+       init_workqueues();
+       usermodehelper_init();
+
        driver_init();
 
 #ifdef CONFIG_SYSCTL
@@ -607,7 +642,6 @@ static void __init do_basic_setup(void)
        /* Networking initialization needs a process context */ 
        sock_init();
 
-       init_workqueues();
        do_initcalls();
 }