init/main.c
18683 /*
18684 * linux/init/main.c
18685 *
18686 * Copyright (C) 1991, 1992 Linus Torvalds
18687 *
18688 * GK 2/5/95 - Changed to support mounting root fs via
18689 * NFS
18690 * Added initrd & change_root: Werner Almesberger & Hans
18691 * Lermen, Feb '96
18692 * Moan early if gcc is old, avoiding bogus kernels -
18693 * Paul Gortmaker, May '96
18694 * Simplified starting of init: Michael A. Griffith
18695 * <grif@acm.org> */
18696
18697 #define __KERNEL_SYSCALLS__
18698
18699 #include <linux/config.h>
18700 #include <linux/proc_fs.h>
18701 #include <linux/unistd.h>
18702 #include <linux/ctype.h>
18703 #include <linux/delay.h>
18704 #include <linux/utsname.h>
18705 #include <linux/ioport.h>
18706 #include <linux/init.h>
18707 #include <linux/smp_lock.h>
18708 #include <linux/blk.h>
18709 #include <linux/hdreg.h>
18710
18711 #include <asm/io.h>
18712 #include <asm/bugs.h>
18713
18714 #ifdef CONFIG_PCI
18715 #include <linux/pci.h>
18716 #endif
18717
18718 #ifdef CONFIG_DIO
18719 #include <linux/dio.h>
18720 #endif
18721
18722 #ifdef CONFIG_ZORRO
18723 #include <linux/zorro.h>
18724 #endif
18725
18726 #ifdef CONFIG_MTRR
18727 # include <asm/mtrr.h>
18728 #endif
18729
18730 #ifdef CONFIG_APM
18731 #include <linux/apm_bios.h>
18732 #endif
18733
18734 /* Versions of gcc older than that listed below may
18735 * actually compile and link okay, but the end product
18736 * can have subtle run time bugs. To avoid associated
18737 * bogus bug reports, we flatly refuse to compile with a
18738 * gcc that is known to be too old from the very
18739 * beginning. */
18740 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
18741 #error sorry, your GCC is too old. \
18742 It builds incorrect kernels.
18743 #endif
18744
18745 extern char _stext, _etext;
18746 extern char *linux_banner;
18747
18748 extern int console_loglevel;
18749
18750 static int init(void *);
18751 extern int bdflush(void *);
18752 extern int kswapd(void *);
18753 extern int kpiod(void *);
18754 extern void kswapd_setup(void);
18755
18756 extern void init_IRQ(void);
18757 extern void init_modules(void);
18758 extern long console_init(long, long);
18759 extern void sock_init(void);
18760 extern void uidcache_init(void);
18761 extern void mca_init(void);
18762 extern void sbus_init(void);
18763 extern void powermac_init(void);
18764 extern void sysctl_init(void);
18765 extern void filescache_init(void);
18766 extern void signals_init(void);
18767
18768 extern void device_setup(void);
18769 extern void binfmt_setup(void);
18770 extern void free_initmem(void);
18771 extern void filesystem_setup(void);
18772
18773 #ifdef CONFIG_ARCH_ACORN
18774 extern void ecard_init(void);
18775 #endif
18776
18777 extern void smp_setup(char *str, int *ints);
18778 #ifdef __i386__
18779 extern void ioapic_pirq_setup(char *str, int *ints);
18780 extern void ioapic_setup(char *str, int *ints);
18781 #endif
18782 extern void no_scroll(char *str, int *ints);
18783 extern void kbd_reset_setup(char *str, int *ints);
18784 extern void panic_setup(char *str, int *ints);
18785 extern void bmouse_setup(char *str, int *ints);
18786 extern void msmouse_setup(char *str, int *ints);
18787 extern void console_setup(char *str, int *ints);
18788 #ifdef CONFIG_PRINTER
18789 extern void lp_setup(char *str, int *ints);
18790 #endif
18791 #ifdef CONFIG_JOY_AMIGA
18792 extern void js_am_setup(char *str, int *ints);
18793 #endif
18794 #ifdef CONFIG_JOY_ANALOG
18795 extern void js_an_setup(char *str, int *ints);
18796 #endif
18797 #ifdef CONFIG_JOY_ASSASIN
18798 extern void js_as_setup(char *str, int *ints);
18799 #endif
18800 #ifdef CONFIG_JOY_CONSOLE
18801 extern void js_console_setup(char *str, int *ints);
18802 #endif
18803 #ifdef CONFIG_JOY_DB9
18804 extern void js_db9_setup(char *str, int *ints);
18805 #endif
18806 #ifdef CONFIG_JOY_TURBOGRAFX
18807 extern void js_tg_setup(char *str, int *ints);
18808 #endif
18809 #ifdef CONFIG_JOY_LIGHTNING
18810 extern void js_l4_setup(char *str, int *ints);
18811 #endif
18812 extern void eth_setup(char *str, int *ints);
18813 #ifdef CONFIG_ARCNET_COM20020
18814 extern void com20020_setup(char *str, int *ints);
18815 #endif
18816 #ifdef CONFIG_ARCNET_RIM_I
18817 extern void arcrimi_setup(char *str, int *ints);
18818 #endif
18819 #ifdef CONFIG_ARCNET_COM90xxIO
18820 extern void com90io_setup(char *str, int *ints);
18821 #endif
18822 #ifdef CONFIG_ARCNET_COM90xx
18823 extern void com90xx_setup(char *str, int *ints);
18824 #endif
18825 #ifdef CONFIG_DECNET
18826 extern void decnet_setup(char *str, int *ints);
18827 #endif
18828 #ifdef CONFIG_BLK_DEV_XD
18829 extern void xd_setup(char *str, int *ints);
18830 extern void xd_manual_geo_init(char *str, int *ints);
18831 #endif
18832 #ifdef CONFIG_BLK_DEV_IDE
18833 extern void ide_setup(char *);
18834 #endif
18835 #ifdef CONFIG_PARIDE_PD
18836 extern void pd_setup(char *str, int *ints);
18837 #endif
18838 #ifdef CONFIG_PARIDE_PF
18839 extern void pf_setup(char *str, int *ints);
18840 #endif
18841 #ifdef CONFIG_PARIDE_PT
18842 extern void pt_setup(char *str, int *ints);
18843 #endif
18844 #ifdef CONFIG_PARIDE_PG
18845 extern void pg_setup(char *str, int *ints);
18846 #endif
18847 #ifdef CONFIG_PARIDE_PCD
18848 extern void pcd_setup(char *str, int *ints);
18849 #endif
18850 extern void floppy_setup(char *str, int *ints);
18851 extern void st_setup(char *str, int *ints);
18852 extern void st0x_setup(char *str, int *ints);
18853 extern void advansys_setup(char *str, int *ints);
18854 extern void tmc8xx_setup(char *str, int *ints);
18855 extern void t128_setup(char *str, int *ints);
18856 extern void pas16_setup(char *str, int *ints);
18857 extern void generic_NCR5380_setup(char *str, int *intr);
18858 extern void generic_NCR53C400_setup(char *str,int *intr);
18859 extern void generic_NCR53C400A_setup(char *str,
18860 int *intr);
18861 extern void generic_DTC3181E_setup(char *str, int *intr);
18862 extern void aha152x_setup(char *str, int *ints);
18863 extern void aha1542_setup(char *str, int *ints);
18864 extern void gdth_setup(char *str, int *ints);
18865 extern void aic7xxx_setup(char *str, int *ints);
18866 extern void AM53C974_setup(char *str, int *ints);
18867 extern void BusLogic_Setup(char *str, int *ints);
18868 extern void ncr53c8xx_setup(char *str, int *ints);
18869 extern void eata2x_setup(char *str, int *ints);
18870 extern void u14_34f_setup(char *str, int *ints);
18871 extern void fdomain_setup(char *str, int *ints);
18872 extern void ibmmca_scsi_setup(char *str, int *ints);
18873 extern void in2000_setup(char *str, int *ints);
18874 extern void NCR53c406a_setup(char *str, int *ints);
18875 extern void sym53c416_setup(char *str, int *ints);
18876 extern void wd7000_setup(char *str, int *ints);
18877 extern void dc390_setup(char* str, int *ints);
18878 extern void scsi_luns_setup(char *str, int *ints);
18879 extern void scsi_logging_setup(char *str, int *ints);
18880 extern void sound_setup(char *str, int *ints);
18881 extern void reboot_setup(char *str, int *ints);
18882 extern void video_setup(char *str, int *ints);
18883 #ifdef CONFIG_CDU31A
18884 extern void cdu31a_setup(char *str, int *ints);
18885 #endif CONFIG_CDU31A
18886 #ifdef CONFIG_BLK_DEV_PS2
18887 extern void ed_setup(char *str, int *ints);
18888 extern void tp720_setup(char *str, int *ints);
18889 #endif CONFIG_BLK_DEV_PS2
18890 #ifdef CONFIG_MCD
18891 extern void mcd_setup(char *str, int *ints);
18892 #endif CONFIG_MCD
18893 #ifdef CONFIG_MCDX
18894 extern void mcdx_setup(char *str, int *ints);
18895 #endif CONFIG_MCDX
18896 #ifdef CONFIG_SBPCD
18897 extern void sbpcd_setup(char *str, int *ints);
18898 #endif CONFIG_SBPCD
18899 #ifdef CONFIG_AZTCD
18900 extern void aztcd_setup(char *str, int *ints);
18901 #endif CONFIG_AZTCD
18902 #ifdef CONFIG_CDU535
18903 extern void sonycd535_setup(char *str, int *ints);
18904 #endif CONFIG_CDU535
18905 #ifdef CONFIG_GSCD
18906 extern void gscd_setup(char *str, int *ints);
18907 #endif CONFIG_GSCD
18908 #ifdef CONFIG_CM206
18909 extern void cm206_setup(char *str, int *ints);
18910 #endif CONFIG_CM206
18911 #ifdef CONFIG_OPTCD
18912 extern void optcd_setup(char *str, int *ints);
18913 #endif CONFIG_OPTCD
18914 #ifdef CONFIG_SJCD
18915 extern void sjcd_setup(char *str, int *ints);
18916 #endif CONFIG_SJCD
18917 #ifdef CONFIG_ISP16_CDI
18918 extern void isp16_setup(char *str, int *ints);
18919 #endif CONFIG_ISP16_CDI
18920 #ifdef CONFIG_BLK_DEV_RAM
18921 static void ramdisk_start_setup(char *str, int *ints);
18922 static void load_ramdisk(char *str, int *ints);
18923 static void prompt_ramdisk(char *str, int *ints);
18924 static void ramdisk_size(char *str, int *ints);
18925 #ifdef CONFIG_BLK_DEV_INITRD
18926 static void no_initrd(char *s,int *ints);
18927 #endif
18928 #endif CONFIG_BLK_DEV_RAM
18929 #ifdef CONFIG_ISDN_DRV_ICN
18930 extern void icn_setup(char *str, int *ints);
18931 #endif
18932 #ifdef CONFIG_ISDN_DRV_HISAX
18933 extern void HiSax_setup(char *str, int *ints);
18934 #endif
18935 #ifdef CONFIG_DIGIEPCA
18936 extern void epca_setup(char *str, int *ints);
18937 #endif
18938 #ifdef CONFIG_ISDN_DRV_PCBIT
18939 extern void pcbit_setup(char *str, int *ints);
18940 #endif
18941
18942 #ifdef CONFIG_ATARIMOUSE
18943 extern void atari_mouse_setup (char *str, int *ints);
18944 #endif
18945 #ifdef CONFIG_DMASOUND
18946 extern void dmasound_setup (char *str, int *ints);
18947 #endif
18948 #ifdef CONFIG_ATARI_SCSI
18949 extern void atari_scsi_setup (char *str, int *ints);
18950 #endif
18951 extern void stram_swap_setup (char *str, int *ints);
18952 extern void wd33c93_setup (char *str, int *ints);
18953 extern void gvp11_setup (char *str, int *ints);
18954 extern void ncr53c7xx_setup (char *str, int *ints);
18955 #ifdef CONFIG_MAC_SCSI
18956 extern void mac_scsi_setup (char *str, int *ints);
18957 #endif
18958
18959 #ifdef CONFIG_CYCLADES
18960 extern void cy_setup(char *str, int *ints);
18961 #endif
18962 #ifdef CONFIG_DIGI
18963 extern void pcxx_setup(char *str, int *ints);
18964 #endif
18965 #ifdef CONFIG_RISCOM8
18966 extern void riscom8_setup(char *str, int *ints);
18967 #endif
18968 #ifdef CONFIG_SPECIALIX
18969 extern void specialix_setup(char *str, int *ints);
18970 #endif
18971 #ifdef CONFIG_DMASCC
18972 extern void dmascc_setup(char *str, int *ints);
18973 #endif
18974 #ifdef CONFIG_BAYCOM_PAR
18975 extern void baycom_par_setup(char *str, int *ints);
18976 #endif
18977 #ifdef CONFIG_BAYCOM_SER_FDX
18978 extern void baycom_ser_fdx_setup(char *str, int *ints);
18979 #endif
18980 #ifdef CONFIG_BAYCOM_SER_HDX
18981 extern void baycom_ser_hdx_setup(char *str, int *ints);
18982 #endif
18983 #ifdef CONFIG_SOUNDMODEM
18984 extern void sm_setup(char *str, int *ints);
18985 #endif
18986 #ifdef CONFIG_ADBMOUSE
18987 extern void adb_mouse_setup(char *str, int *ints);
18988 #endif
18989 #ifdef CONFIG_WDT
18990 extern void wdt_setup(char *str, int *ints);
18991 #endif
18992 #ifdef CONFIG_PARPORT
18993 extern void parport_setup(char *str, int *ints);
18994 #endif
18995 #ifdef CONFIG_PLIP
18996 extern void plip_setup(char *str, int *ints);
18997 #endif
18998 #ifdef CONFIG_HFMODEM
18999 extern void hfmodem_setup(char *str, int *ints);
19000 #endif
19001 #ifdef CONFIG_IP_PNP
19002 extern void ip_auto_config_setup(char *str, int *ints);
19003 #endif
19004 #ifdef CONFIG_ROOT_NFS
19005 extern void nfs_root_setup(char *str, int *ints);
19006 #endif
19007 #ifdef CONFIG_FTAPE
19008 extern void ftape_setup(char *str, int *ints);
19009 #endif
19010 #ifdef CONFIG_MDA_CONSOLE
19011 extern void mdacon_setup(char *str, int *ints);
19012 #endif
19013 #ifdef CONFIG_LTPC
19014 extern void ltpc_setup(char *str, int *ints);
19015 #endif
19016
19017 #if defined(CONFIG_SYSVIPC)
19018 extern void ipc_init(void);
19019 #endif
19020 #if defined(CONFIG_QUOTA)
19021 extern void dquot_init_hash(void);
19022 #endif
19023
19024 #ifdef CONFIG_MD_BOOT
19025 extern void md_setup(char *str,int *ints) __init;
19026 #endif
19027
19028 /* Boot command-line arguments */
19029 #define MAX_INIT_ARGS 8
19030 #define MAX_INIT_ENVS 8
19031
19032 extern void time_init(void);
19033
19034 static unsigned long memory_start = 0;
19035 static unsigned long memory_end = 0;
19036
19037 int rows, cols;
19038
19039 #ifdef CONFIG_BLK_DEV_RAM
19040 /* 1 = load ramdisk, 0 = don't load */
19041 extern int rd_doload;
19042 /* 1 = prompt for ramdisk, 0 = don't prompt */
19043 extern int rd_prompt;
19044 /* Size of the ramdisk(s) */
19045 extern int rd_size;
19046 /* starting block # of image */
19047 extern int rd_image_start;
19048
19049 #ifdef CONFIG_BLK_DEV_INITRD
19050 kdev_t real_root_dev;
19051 #endif
19052 #endif
19053
19054 int root_mountflags = MS_RDONLY;
19055 char *execute_command = NULL;
19056
19057 static char * argv_init[MAX_INIT_ARGS+2] =
19058 { "init", NULL, };
19059 static char * envp_init[MAX_INIT_ENVS+2] =
19060 { "HOME=/", "TERM=linux", NULL, };
19061
19062 char *get_options(char *str, int *ints)
19063 {
19064 char *cur = str;
19065 int i=1;
19066
19067 while (cur && (*cur=='-' || isdigit(*cur)) && i <= 10){
19068 ints[i++] = simple_strtol(cur,NULL,0);
19069 if ((cur = strchr(cur,',')) != NULL)
19070 cur++;
19071 }
19072 ints[0] = i-1;
19073 return(cur);
19074 }
19075
19076 static void __init profile_setup(char *str, int *ints)
19077 {
19078 if (ints[0] > 0)
19079 prof_shift = (unsigned long) ints[1];
19080 else
19081 prof_shift = 2;
19082 }
19083
19084
19085 static struct dev_name_struct {
19086 const char *name;
19087 const int num;
19088 } root_dev_names[] __initdata = {
19089 #ifdef CONFIG_ROOT_NFS
19090 { "nfs", 0x00ff },
19091 #endif
19092 #ifdef CONFIG_BLK_DEV_IDE
19093 { "hda", 0x0300 },
19094 { "hdb", 0x0340 },
19095 { "hdc", 0x1600 },
19096 { "hdd", 0x1640 },
19097 { "hde", 0x2100 },
19098 { "hdf", 0x2140 },
19099 { "hdg", 0x2200 },
19100 { "hdh", 0x2240 },
19101 { "hdi", 0x3800 },
19102 { "hdj", 0x3840 },
19103 { "hdk", 0x3900 },
19104 { "hdl", 0x3940 },
19105 #endif
19106 #ifdef CONFIG_BLK_DEV_SD
19107 { "sda", 0x0800 },
19108 { "sdb", 0x0810 },
19109 { "sdc", 0x0820 },
19110 { "sdd", 0x0830 },
19111 { "sde", 0x0840 },
19112 { "sdf", 0x0850 },
19113 { "sdg", 0x0860 },
19114 { "sdh", 0x0870 },
19115 { "sdi", 0x0880 },
19116 { "sdj", 0x0890 },
19117 { "sdk", 0x08a0 },
19118 { "sdl", 0x08b0 },
19119 { "sdm", 0x08c0 },
19120 { "sdn", 0x08d0 },
19121 { "sdo", 0x08e0 },
19122 { "sdp", 0x08f0 },
19123 #endif
19124 #ifdef CONFIG_ATARI_ACSI
19125 { "ada", 0x1c00 },
19126 { "adb", 0x1c10 },
19127 { "adc", 0x1c20 },
19128 { "add", 0x1c30 },
19129 { "ade", 0x1c40 },
19130 #endif
19131 #ifdef CONFIG_BLK_DEV_FD
19132 { "fd", 0x0200 },
19133 #endif
19134 #ifdef CONFIG_MD_BOOT
19135 { "md", 0x0900 },
19136 #endif
19137 #ifdef CONFIG_BLK_DEV_XD
19138 { "xda", 0x0d00 },
19139 { "xdb", 0x0d40 },
19140 #endif
19141 #ifdef CONFIG_BLK_DEV_RAM
19142 { "ram", 0x0100 },
19143 #endif
19144 #ifdef CONFIG_BLK_DEV_SR
19145 { "scd", 0x0b00 },
19146 #endif
19147 #ifdef CONFIG_MCD
19148 { "mcd", 0x1700 },
19149 #endif
19150 #ifdef CONFIG_CDU535
19151 { "cdu535", 0x1800 },
19152 { "sonycd", 0x1800 },
19153 #endif
19154 #ifdef CONFIG_AZTCD
19155 { "aztcd", 0x1d00 },
19156 #endif
19157 #ifdef CONFIG_CM206
19158 { "cm206cd", 0x2000 },
19159 #endif
19160 #ifdef CONFIG_GSCD
19161 { "gscd", 0x1000 },
19162 #endif
19163 #ifdef CONFIG_SBPCD
19164 { "sbpcd", 0x1900 },
19165 #endif
19166 #ifdef CONFIG_BLK_DEV_PS2
19167 { "eda", 0x2400 },
19168 { "edb", 0x2440 },
19169 #endif
19170 #ifdef CONFIG_PARIDE_PD
19171 { "pda", 0x2d00 },
19172 { "pdb", 0x2d10 },
19173 { "pdc", 0x2d20 },
19174 { "pdd", 0x2d30 },
19175 #endif
19176 #ifdef CONFIG_PARIDE_PCD
19177 { "pcd", 0x2e00 },
19178 #endif
19179 #ifdef CONFIG_PARIDE_PF
19180 { "pf", 0x2f00 },
19181 #endif
19182 #if CONFIG_APBLOCK
19183 { "apblock", APBLOCK_MAJOR << 8},
19184 #endif
19185 #if CONFIG_DDV
19186 { "ddv", DDV_MAJOR << 8},
19187 #endif
19188 { NULL, 0 }
19189 };
19190
19191 kdev_t __init name_to_kdev_t(char *line)
19192 {
19193 int base = 0;
19194 if (strncmp(line,"/dev/",5) == 0) {
19195 struct dev_name_struct *dev = root_dev_names;
19196 line += 5;
19197 do {
19198 int len = strlen(dev->name);
19199 if (strncmp(line,dev->name,len) == 0) {
19200 line += len;
19201 base = dev->num;
19202 break;
19203 }
19204 dev++;
19205 } while (dev->name);
19206 }
19207 return to_kdev_t(base + simple_strtoul(line,NULL,
19208 base ? 10 : 16));
19209 }
19210
19211 static void __init root_dev_setup(char *line, int *num)
19212 {
19213 ROOT_DEV = name_to_kdev_t(line);
19214 }
19215
19216 /* List of kernel command line parameters. The first
19217 * table lists parameters which are subject to values
19218 * parsing (leading numbers are converted to an array of
19219 * ints and chopped off the string), the second table
19220 * contains the few exceptions which obey their own
19221 * syntax rules. */
19222
19223 struct kernel_param {
19224 const char *str;
19225 void (*setup_func)(char *, int *);
19226 };
19227
19228 static struct kernel_param cooked_params[] __initdata = {
19229 /* FIXME: make PNP just become reserve_setup */
19230 #ifndef CONFIG_KERNEL_PNP_RESOURCE
19231 { "reserve=", reserve_setup },
19232 #else
19233 { "reserve=", pnp_reserve_setup },
19234 #endif
19235 { "profile=", profile_setup },
19236 #ifdef __SMP__
19237 { "nosmp", smp_setup },
19238 { "maxcpus=", smp_setup },
19239 #ifdef CONFIG_X86_IO_APIC
19240 { "noapic", ioapic_setup },
19241 { "pirq=", ioapic_pirq_setup },
19242 #endif
19243 #endif
19244 #ifdef CONFIG_BLK_DEV_RAM
19245 { "ramdisk_start=", ramdisk_start_setup },
19246 { "load_ramdisk=", load_ramdisk },
19247 { "prompt_ramdisk=", prompt_ramdisk },
19248 { "ramdisk=", ramdisk_size },
19249 { "ramdisk_size=", ramdisk_size },
19250 #ifdef CONFIG_BLK_DEV_INITRD
19251 { "noinitrd", no_initrd },
19252 #endif
19253 #endif
19254 #ifdef CONFIG_FB
19255 { "video=", video_setup },
19256 #endif
19257 { "panic=", panic_setup },
19258 { "console=", console_setup },
19259 #ifdef CONFIG_VGA_CONSOLE
19260 { "no-scroll", no_scroll },
19261 #endif
19262 #ifdef CONFIG_MDA_CONSOLE
19263 { "mdacon=", mdacon_setup },
19264 #endif
19265 #ifdef CONFIG_VT
19266 { "kbd-reset", kbd_reset_setup },
19267 #endif
19268 #ifdef CONFIG_BUGi386
19269 { "no-hlt", no_halt },
19270 { "no387", no_387 },
19271 { "reboot=", reboot_setup },
19272 #endif
19273 #ifdef CONFIG_INET
19274 { "ether=", eth_setup },
19275 #endif
19276 #ifdef CONFIG_ARCNET_COM20020
19277 { "com20020=", com20020_setup },
19278 #endif
19279 #ifdef CONFIG_ARCNET_RIM_I
19280 { "arcrimi=", arcrimi_setup },
19281 #endif
19282 #ifdef CONFIG_ARCNET_COM90xxIO
19283 { "com90io=", com90io_setup },
19284 #endif
19285 #ifdef CONFIG_ARCNET_COM90xx
19286 { "com90xx=", com90xx_setup },
19287 #endif
19288 #ifdef CONFIG_DECNET
19289 { "decnet=", decnet_setup },
19290 #endif
19291 #ifdef CONFIG_PRINTER
19292 { "lp=", lp_setup },
19293 #endif
19294 #ifdef CONFIG_JOY_AMIGA
19295 { "js_am=", js_am_setup },
19296 #endif
19297 #ifdef CONFIG_JOY_ANALOG
19298 { "js_an=", js_an_setup },
19299 #endif
19300 #ifdef CONFIG_JOY_ASSASIN
19301 { "js_as=", js_as_setup },
19302 #endif
19303 #ifdef CONFIG_JOY_CONSOLE
19304 { "js_console=", js_console_setup },
19305 { "js_console2=", js_console_setup },
19306 { "js_console3=", js_console_setup },
19307 #endif
19308 #ifdef CONFIG_JOY_DB9
19309 { "js_db9=", js_db9_setup },
19310 { "js_db9_2=", js_db9_setup },
19311 { "js_db9_3=", js_db9_setup },
19312 #endif
19313 #ifdef CONFIG_JOY_TURBOGRAFX
19314 { "js_tg=", js_tg_setup },
19315 { "js_tg_2=", js_tg_setup },
19316 { "js_tg_3=", js_tg_setup },
19317 #endif
19318 #ifdef CONFIG_SCSI
19319 { "max_scsi_luns=", scsi_luns_setup },
19320 { "scsi_logging=", scsi_logging_setup },
19321 #endif
19322 #ifdef CONFIG_JOY_LIGHTNING
19323 { "js_l4=", js_l4_setup },
19324 #endif
19325 #ifdef CONFIG_SCSI_ADVANSYS
19326 { "advansys=", advansys_setup },
19327 #endif
19328 #if defined(CONFIG_BLK_DEV_HD)
19329 { "hd=", hd_setup },
19330 #endif
19331 #ifdef CONFIG_CHR_DEV_ST
19332 { "st=", st_setup },
19333 #endif
19334 #ifdef CONFIG_BUSMOUSE
19335 { "bmouse=", bmouse_setup },
19336 #endif
19337 #ifdef CONFIG_MS_BUSMOUSE
19338 { "msmouse=", msmouse_setup },
19339 #endif
19340 #ifdef CONFIG_SCSI_SEAGATE
19341 { "st0x=", st0x_setup },
19342 { "tmc8xx=", tmc8xx_setup },
19343 #endif
19344 #ifdef CONFIG_SCSI_T128
19345 { "t128=", t128_setup },
19346 #endif
19347 #ifdef CONFIG_SCSI_PAS16
19348 { "pas16=", pas16_setup },
19349 #endif
19350 #ifdef CONFIG_SCSI_GENERIC_NCR5380
19351 { "ncr5380=", generic_NCR5380_setup },
19352 { "ncr53c400=", generic_NCR53C400_setup },
19353 { "ncr53c400a=", generic_NCR53C400A_setup },
19354 { "dtc3181e=", generic_DTC3181E_setup },
19355 #endif
19356 #ifdef CONFIG_SCSI_AHA152X
19357 { "aha152x=", aha152x_setup},
19358 #endif
19359 #ifdef CONFIG_SCSI_AHA1542
19360 { "aha1542=", aha1542_setup},
19361 #endif
19362 #ifdef CONFIG_SCSI_GDTH
19363 { "gdth=", gdth_setup},
19364 #endif
19365 #ifdef CONFIG_SCSI_AIC7XXX
19366 { "aic7xxx=", aic7xxx_setup},
19367 #endif
19368 #ifdef CONFIG_SCSI_BUSLOGIC
19369 { "BusLogic=", BusLogic_Setup},
19370 #endif
19371 #ifdef CONFIG_SCSI_NCR53C8XX
19372 { "ncr53c8xx=", ncr53c8xx_setup},
19373 #endif
19374 #ifdef CONFIG_SCSI_EATA
19375 { "eata=", eata2x_setup},
19376 #endif
19377 #ifdef CONFIG_SCSI_U14_34F
19378 { "u14-34f=", u14_34f_setup},
19379 #endif
19380 #ifdef CONFIG_SCSI_AM53C974
19381 { "AM53C974=", AM53C974_setup},
19382 #endif
19383 #ifdef CONFIG_SCSI_NCR53C406A
19384 { "ncr53c406a=", NCR53c406a_setup},
19385 #endif
19386 #ifdef CONFIG_SCSI_SYM53C416
19387 { "sym53c416=", sym53c416_setup},
19388 #endif
19389 #ifdef CONFIG_SCSI_FUTURE_DOMAIN
19390 { "fdomain=", fdomain_setup},
19391 #endif
19392 #ifdef CONFIG_SCSI_IN2000
19393 { "in2000=", in2000_setup},
19394 #endif
19395 #ifdef CONFIG_SCSI_7000FASST
19396 { "wd7000=", wd7000_setup},
19397 #endif
19398 #ifdef CONFIG_SCSI_IBMMCA
19399 { "ibmmcascsi=", ibmmca_scsi_setup },
19400 #endif
19401 #if defined(CONFIG_SCSI_DC390T) && \
19402 !defined(CONFIG_SCSI_DC390T_NOGENSUPP)
19403 { "tmscsim=", dc390_setup },
19404 #endif
19405 #ifdef CONFIG_BLK_DEV_XD
19406 { "xd=", xd_setup },
19407 { "xd_geo=", xd_manual_geo_init },
19408 #endif
19409 #if defined(CONFIG_BLK_DEV_FD) || \
19410 defined(CONFIG_AMIGA_FLOPPY) || \
19411 defined(CONFIG_ATARI_FLOPPY)
19412 { "floppy=", floppy_setup },
19413 #endif
19414 #ifdef CONFIG_BLK_DEV_PS2
19415 { "eda=", ed_setup },
19416 { "edb=", ed_setup },
19417 { "tp720=", tp720_setup },
19418 #endif
19419 #ifdef CONFIG_CDU31A
19420 { "cdu31a=", cdu31a_setup },
19421 #endif CONFIG_CDU31A
19422 #ifdef CONFIG_MCD
19423 { "mcd=", mcd_setup },
19424 #endif CONFIG_MCD
19425 #ifdef CONFIG_MCDX
19426 { "mcdx=", mcdx_setup },
19427 #endif CONFIG_MCDX
19428 #ifdef CONFIG_SBPCD
19429 { "sbpcd=", sbpcd_setup },
19430 #endif CONFIG_SBPCD
19431 #ifdef CONFIG_AZTCD
19432 { "aztcd=", aztcd_setup },
19433 #endif CONFIG_AZTCD
19434 #ifdef CONFIG_CDU535
19435 { "sonycd535=", sonycd535_setup },
19436 #endif CONFIG_CDU535
19437 #ifdef CONFIG_GSCD
19438 { "gscd=", gscd_setup },
19439 #endif CONFIG_GSCD
19440 #ifdef CONFIG_CM206
19441 { "cm206=", cm206_setup },
19442 #endif CONFIG_CM206
19443 #ifdef CONFIG_OPTCD
19444 { "optcd=", optcd_setup },
19445 #endif CONFIG_OPTCD
19446 #ifdef CONFIG_SJCD
19447 { "sjcd=", sjcd_setup },
19448 #endif CONFIG_SJCD
19449 #ifdef CONFIG_ISP16_CDI
19450 { "isp16=", isp16_setup },
19451 #endif CONFIG_ISP16_CDI
19452 #ifdef CONFIG_SOUND_OSS
19453 { "sound=", sound_setup },
19454 #endif
19455 #ifdef CONFIG_ISDN_DRV_ICN
19456 { "icn=", icn_setup },
19457 #endif
19458 #ifdef CONFIG_ISDN_DRV_HISAX
19459 { "hisax=", HiSax_setup },
19460 { "HiSax=", HiSax_setup },
19461 #endif
19462 #ifdef CONFIG_ISDN_DRV_PCBIT
19463 { "pcbit=", pcbit_setup },
19464 #endif
19465 #ifdef CONFIG_ATARIMOUSE
19466 { "atamouse=", atari_mouse_setup },
19467 #endif
19468 #ifdef CONFIG_DMASOUND
19469 { "dmasound=", dmasound_setup },
19470 #endif
19471 #ifdef CONFIG_ATARI_SCSI
19472 { "atascsi=", atari_scsi_setup },
19473 #endif
19474 #ifdef CONFIG_STRAM_SWAP
19475 { "stram_swap=", stram_swap_setup },
19476 #endif
19477 #if defined(CONFIG_A4000T_SCSI) || \
19478 defined(CONFIG_WARPENGINE_SCSI) || \
19479 defined(CONFIG_A4091_SCSI) || \
19480 defined(CONFIG_MVME16x_SCSI) || \
19481 defined(CONFIG_BVME6000_SCSI)
19482 { "53c7xx=", ncr53c7xx_setup },
19483 #endif
19484 #if defined(CONFIG_A3000_SCSI) || \
19485 defined(CONFIG_A2091_SCSI) || \
19486 defined(CONFIG_GVP11_SCSI)
19487 { "wd33c93=", wd33c93_setup },
19488 #endif
19489 #if defined(CONFIG_GVP11_SCSI)
19490 { "gvp11=", gvp11_setup },
19491 #endif
19492 #ifdef CONFIG_MAC_SCSI
19493 { "mac5380=", mac_scsi_setup },
19494 #endif
19495 #ifdef CONFIG_CYCLADES
19496 { "cyclades=", cy_setup },
19497 #endif
19498 #ifdef CONFIG_DIGI
19499 { "digi=", pcxx_setup },
19500 #endif
19501 #ifdef CONFIG_DIGIEPCA
19502 { "digiepca=", epca_setup },
19503 #endif
19504 #ifdef CONFIG_RISCOM8
19505 { "riscom8=", riscom8_setup },
19506 #endif
19507 #ifdef CONFIG_DMASCC
19508 { "dmascc=", dmascc_setup },
19509 #endif
19510 #ifdef CONFIG_SPECIALIX
19511 { "specialix=", specialix_setup },
19512 #endif
19513 #ifdef CONFIG_BAYCOM_PAR
19514 { "baycom_par=", baycom_par_setup },
19515 #endif
19516 #ifdef CONFIG_BAYCOM_SER_FDX
19517 { "baycom_ser_fdx=", baycom_ser_fdx_setup },
19518 #endif
19519 #ifdef CONFIG_BAYCOM_SER_HDX
19520 { "baycom_ser_hdx=", baycom_ser_hdx_setup },
19521 #endif
19522 #ifdef CONFIG_SOUNDMODEM
19523 { "soundmodem=", sm_setup },
19524 #endif
19525 #ifdef CONFIG_WDT
19526 { "wdt=", wdt_setup },
19527 #endif
19528 #ifdef CONFIG_PARPORT
19529 { "parport=", parport_setup },
19530 #endif
19531 #ifdef CONFIG_PLIP
19532 { "plip=", plip_setup },
19533 #endif
19534 #ifdef CONFIG_HFMODEM
19535 { "hfmodem=", hfmodem_setup },
19536 #endif
19537 #ifdef CONFIG_FTAPE
19538 { "ftape=", ftape_setup},
19539 #endif
19540 #ifdef CONFIG_MD_BOOT
19541 { "md=", md_setup},
19542 #endif
19543 #ifdef CONFIG_ADBMOUSE
19544 { "adb_buttons=", adb_mouse_setup },
19545 #endif
19546 #ifdef CONFIG_LTPC
19547 { "ltpc=", ltpc_setup },
19548 #endif
19549 { 0, 0 }
19550 };
19551
19552 static struct kernel_param raw_params[] __initdata = {
19553 { "root=", root_dev_setup },
19554 #ifdef CONFIG_ROOT_NFS
19555 { "nfsroot=", nfs_root_setup },
19556 { "nfsaddrs=", ip_auto_config_setup },
19557 #endif
19558 #ifdef CONFIG_IP_PNP
19559 { "ip=", ip_auto_config_setup },
19560 #endif
19561 #ifdef CONFIG_PCI
19562 { "pci=", pci_setup },
19563 #endif
19564 #ifdef CONFIG_PARIDE_PD
19565 { "pd.", pd_setup },
19566 #endif
19567 #ifdef CONFIG_PARIDE_PCD
19568 { "pcd.", pcd_setup },
19569 #endif
19570 #ifdef CONFIG_PARIDE_PF
19571 { "pf.", pf_setup },
19572 #endif
19573 #ifdef CONFIG_PARIDE_PT
19574 { "pt.", pt_setup },
19575 #endif
19576 #ifdef CONFIG_PARIDE_PG
19577 { "pg.", pg_setup },
19578 #endif
19579 #ifdef CONFIG_APM
19580 { "apm=", apm_setup },
19581 #endif
19582 { 0, 0 }
19583 };
19584
19585 #ifdef CONFIG_BLK_DEV_RAM
19586 static void __init ramdisk_start_setup(char *str,
19587 int *ints)
19588 {
19589 if (ints[0] > 0 && ints[1] >= 0)
19590 rd_image_start = ints[1];
19591 }
19592
19593 static void __init load_ramdisk(char *str, int *ints)
19594 {
19595 if (ints[0] > 0 && ints[1] >= 0)
19596 rd_doload = ints[1] & 1;
19597 }
19598
19599 static void __init prompt_ramdisk(char *str, int *ints)
19600 {
19601 if (ints[0] > 0 && ints[1] >= 0)
19602 rd_prompt = ints[1] & 1;
19603 }
19604
19605 static void __init ramdisk_size(char *str, int *ints)
19606 {
19607 if (ints[0] > 0 && ints[1] >= 0)
19608 rd_size = ints[1];
19609 }
19610 #endif
19611
19612 static int __init checksetup(char *line)
19613 {
19614 int i, ints[11];
19615
19616 #ifdef CONFIG_BLK_DEV_IDE
19617 /* ide driver needs the basic string, rather than
19618 * pre-processed values */
19619 if (!strncmp(line,"ide",3) ||
19620 (!strncmp(line,"hd",2) && line[2] != '=')) {
19621 ide_setup(line);
19622 return 1;
19623 }
19624 #endif
19625 for (i=0; raw_params[i].str; i++) {
19626 int n = strlen(raw_params[i].str);
19627 if (!strncmp(line,raw_params[i].str,n)) {
19628 raw_params[i].setup_func(line+n, NULL);
19629 return 1;
19630 }
19631 }
19632 for (i=0; cooked_params[i].str; i++) {
19633 int n = strlen(cooked_params[i].str);
19634 if (!strncmp(line,cooked_params[i].str,n)) {
19635 cooked_params[i].setup_func(get_options(line+n,
19636 ints), ints);
19637 return 1;
19638 }
19639 }
19640 return 0;
19641 }
19642
19643 /* this should be approx 2 Bo*oMips to start (note
19644 * initial shift), and will still work even if initially
19645 * too large, it will just take slightly longer */
19646 unsigned long loops_per_sec = (1<<12);
19647
19648 /* This is the number of bits of precision for the
19649 * loops_per_second. Each bit takes on average 1.5/HZ
19650 * seconds. This (like the original) is a little better
19651 * than 1% */
19652 #define LPS_PREC 8
19653
19654 void __init calibrate_delay(void)
19655 {
19656 unsigned long ticks, loopbit;
19657 int lps_precision = LPS_PREC;
19658
19659 loops_per_sec = (1<<12);
19660
19661 printk("Calibrating delay loop... ");
19662 while (loops_per_sec <<= 1) {
19663 /* wait for "start of" clock tick */
19664 ticks = jiffies;
19665 while (ticks == jiffies)
19666 /* nothing */;
19667 /* Go .. */
19668 ticks = jiffies;
19669 __delay(loops_per_sec);
19670 ticks = jiffies - ticks;
19671 if (ticks)
19672 break;
19673 }
19674
19675 /* Do a binary approximation to get loops_per_second set
19676 * to equal one clock (up to lps_precision bits) */
19677 loops_per_sec >>= 1;
19678 loopbit = loops_per_sec;
19679 while ( lps_precision-- && (loopbit >>= 1) ) {
19680 loops_per_sec |= loopbit;
19681 ticks = jiffies;
19682 while (ticks == jiffies);
19683 ticks = jiffies;
19684 __delay(loops_per_sec);
19685 if (jiffies != ticks) /* longer than 1 tick */
19686 loops_per_sec &= ~loopbit;
19687 }
19688
19689 /* finally, adjust loops per second in terms of seconds
19690 * instead of clocks */
19691 loops_per_sec *= HZ;
19692 /* Round the value and print it */
19693 printk("%lu.%02lu BogoMIPS\n",
19694 (loops_per_sec+2500)/500000,
19695 ((loops_per_sec+2500)/5000) % 100);
19696 }
19697
19698 /* This is a simple kernel command line parsing function:
19699 * it parses the command line, and fills in the
19700 * arguments/environment to init as appropriate. Any
19701 * cmd-line option is taken to be an environment variable
19702 * if it contains the character '='.
19703 *
19704 * This routine also checks for options meant for the
19705 * kernel. These options are not given to init - they
19706 * are for internal kernel use only. */
19707 static void __init parse_options(char *line)
19708 {
19709 char *next;
19710 int args, envs;
19711
19712 if (!*line)
19713 return;
19714 args = 0;
19715 envs = 1; /* TERM is set to 'linux' by default */
19716 next = line;
19717 while ((line = next) != NULL) {
19718 if ((next = strchr(line,' ')) != NULL)
19719 *next++ = 0;
19720 /* check for kernel options first.. */
19721 if (!strcmp(line,"ro")) {
19722 root_mountflags |= MS_RDONLY;
19723 continue;
19724 }
19725 if (!strcmp(line,"rw")) {
19726 root_mountflags &= ~MS_RDONLY;
19727 continue;
19728 }
19729 if (!strcmp(line,"debug")) {
19730 console_loglevel = 10;
19731 continue;
19732 }
19733 if (!strncmp(line,"init=",5)) {
19734 line += 5;
19735 execute_command = line;
19736 /* In case LILO is going to boot us with default
19737 * command line, it prepends "auto" before the
19738 * whole cmdline which makes the shell think it
19739 * should execute a script with such name. So we
19740 * ignore all arguments entered _before_
19741 * init=... [MJ] */
19742 args = 0;
19743 continue;
19744 }
19745 if (checksetup(line))
19746 continue;
19747
19748 /* Then check if it's an environment variable or an
19749 * option. */
19750 if (strchr(line,'=')) {
19751 if (envs >= MAX_INIT_ENVS)
19752 break;
19753 envp_init[++envs] = line;
19754 } else {
19755 if (args >= MAX_INIT_ARGS)
19756 break;
19757 argv_init[++args] = line;
19758 }
19759 }
19760 argv_init[args+1] = NULL;
19761 envp_init[envs+1] = NULL;
19762 }
19763
19764
19765 extern void setup_arch(char **, unsigned long *,
19766 unsigned long *);
19767
19768 #ifndef __SMP__
19769
19770 /* Uniprocessor idle thread */
19771
19772 int cpu_idle(void *unused)
19773 {
19774 for(;;)
19775 idle();
19776 }
19777
19778 #define smp_init() do { } while (0)
19779
19780 #else
19781
19782 /* Multiprocessor idle thread is in arch/... */
19783
19784 extern int cpu_idle(void * unused);
19785
19786 /* Called by boot processor to activate the rest. */
19787 static void __init smp_init(void)
19788 {
19789 /* Get other processors into their bootup holding
19790 * patterns. */
19791 smp_boot_cpus();
19792 smp_threads_ready=1;
19793 smp_commence();
19794 }
19795
19796 #endif
19797
19798 extern void initialize_secondary(void);
19799
19800 /* Activate the first processor. */
19801
19802 asmlinkage void __init start_kernel(void)
19803 {
19804 char * command_line;
19805
19806 #ifdef __SMP__
19807 static int boot_cpu = 1;
19808 /* "current" has been set up, we need to load it now */
19809 if (!boot_cpu)
19810 initialize_secondary();
19811 boot_cpu = 0;
19812 #endif
19813
19814 /* Interrupts are still disabled. Do necessary setups,
19815 * then enable them */
19816 printk(linux_banner);
19817 setup_arch(&command_line, &memory_start, &memory_end);
19818 memory_start = paging_init(memory_start,memory_end);
19819 trap_init();
19820 init_IRQ();
19821 sched_init();
19822 time_init();
19823 parse_options(command_line);
19824
19825 /* HACK ALERT! This is early. We're enabling the
19826 * console before we've done PCI setups etc, and
19827 * console_init() must be aware of this. But we do want
19828 * output early, in case something goes wrong. */
19829 memory_start = console_init(memory_start,memory_end);
19830 #ifdef CONFIG_MODULES
19831 init_modules();
19832 #endif
19833 if (prof_shift) {
19834 prof_buffer = (unsigned int *) memory_start;
19835 /* only text is profiled */
19836 prof_len = (unsigned long) &_etext -
19837 (unsigned long) &_stext;
19838 prof_len >>= prof_shift;
19839 memory_start += prof_len * sizeof(unsigned int);
19840 memset(prof_buffer, 0,
19841 prof_len * sizeof(unsigned int));
19842 }
19843
19844 memory_start = kmem_cache_init(memory_start,
19845 memory_end);
19846 sti();
19847 calibrate_delay();
19848 #ifdef CONFIG_BLK_DEV_INITRD
19849 if (initrd_start && !initrd_below_start_ok &&
19850 initrd_start < memory_start) {
19851 printk(KERN_CRIT
19852 "initrd overwritten (0x%08lx < 0x%08lx) - "
19853 "disabling it.\n", initrd_start,memory_start);
19854 initrd_start = 0;
19855 }
19856 #endif
19857 mem_init(memory_start,memory_end);
19858 kmem_cache_sizes_init();
19859 #ifdef CONFIG_PROC_FS
19860 proc_root_init();
19861 #endif
19862 uidcache_init();
19863 filescache_init();
19864 dcache_init();
19865 vma_init();
19866 buffer_init();
19867 signals_init();
19868 inode_init();
19869 file_table_init();
19870 #if defined(CONFIG_SYSVIPC)
19871 ipc_init();
19872 #endif
19873 #if defined(CONFIG_QUOTA)
19874 dquot_init_hash();
19875 #endif
19876 check_bugs();
19877 printk("POSIX conformance testing by UNIFIX\n");
19878
19879 /* We count on the initial thread going ok Like idlers
19880 * init is an unlocked kernel thread, which will make
19881 * syscalls (and thus be locked). */
19882 smp_init();
19883 kernel_thread(init, NULL,
19884 CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
19885 current->need_resched = 1;
19886 cpu_idle(NULL);
19887 }
19888
19889 #ifdef CONFIG_BLK_DEV_INITRD
19890 static int do_linuxrc(void * shell)
19891 {
19892 static char *argv[] = { "linuxrc", NULL, };
19893
19894 close(0);close(1);close(2);
19895 setsid();
19896 (void) open("/dev/console",O_RDWR,0);
19897 (void) dup(0);
19898 (void) dup(0);
19899 return execve(shell, argv, envp_init);
19900 }
19901
19902 static void __init no_initrd(char *s,int *ints)
19903 {
19904 mount_initrd = 0;
19905 }
19906 #endif
19907
19908 struct task_struct *child_reaper = &init_task;
19909
19910 /* Ok, the machine is now initialized. None of the
19911 * devices have been touched yet, but the CPU subsystem
19912 * is up and running, and memory and process management
19913 * works.
19914 *
19915 * Now we can finally start doing some real work.. */
19916 static void __init do_basic_setup(void)
19917 {
19918 #ifdef CONFIG_BLK_DEV_INITRD
19919 int real_root_mountflags;
19920 #endif
19921
19922 /* Tell the world that we're going to be the grim
19923 * reaper of innocent orphaned children.
19924 *
19925 * We don't want people to have to make incorrect
19926 * assumptions about where in the task array this can
19927 * be found. */
19928 child_reaper = current;
19929
19930 #if defined(CONFIG_MTRR) /* After SMP initialization */
19931 /* We should probably create some architecture-dependent
19932 * "fixup after everything is up" style function where
19933 * this would belong better than in init/main.c.. */
19934 mtrr_init();
19935 #endif
19936
19937 #ifdef CONFIG_SYSCTL
19938 sysctl_init();
19939 #endif
19940
19941 /* Ok, at this point all CPU's should be initialized,
19942 * so we can start looking into devices.. */
19943 #ifdef CONFIG_PCI
19944 pci_init();
19945 #endif
19946 #ifdef CONFIG_SBUS
19947 sbus_init();
19948 #endif
19949 #if defined(CONFIG_PPC)
19950 powermac_init();
19951 #endif
19952 #ifdef CONFIG_MCA
19953 mca_init();
19954 #endif
19955 #ifdef CONFIG_ARCH_ACORN
19956 ecard_init();
19957 #endif
19958 #ifdef CONFIG_ZORRO
19959 zorro_init();
19960 #endif
19961 #ifdef CONFIG_DIO
19962 dio_init();
19963 #endif
19964
19965 /* Net initialization needs a process context */
19966 sock_init();
19967
19968 /* Launch bdflush from here, instead of the old syscall
19969 * way. */
19970 kernel_thread(bdflush, NULL,
19971 CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
19972 /* Start the background pageout daemon. */
19973 kswapd_setup();
19974 kernel_thread(kpiod, NULL,
19975 CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
19976 kernel_thread(kswapd, NULL,
19977 CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
19978
19979 #if CONFIG_AP1000
19980 /* Start the async paging daemon. */
19981 {
19982 extern int asyncd(void *);
19983 kernel_thread(asyncd, NULL,
19984 CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
19985 }
19986 #endif
19987
19988 #ifdef CONFIG_BLK_DEV_INITRD
19989
19990 real_root_dev = ROOT_DEV;
19991 real_root_mountflags = root_mountflags;
19992 if (initrd_start && mount_initrd)
19993 root_mountflags &= ~MS_RDONLY;
19994 else mount_initrd =0;
19995 #endif
19996
19997 /* Set up devices .. */
19998 device_setup();
19999
20000 /* .. executable formats .. */
20001 binfmt_setup();
20002
20003 /* .. filesystems .. */
20004 filesystem_setup();
20005
20006 /* Mount the root filesystem.. */
20007 mount_root();
20008
20009 #ifdef CONFIG_UMSDOS_FS
20010 {
20011 /* When mounting a umsdos fs as root, we detect the
20012 * pseudo_root (/linux) and initialise it here.
20013 * pseudo_root is defined in fs/umsdos/inode.c */
20014 extern struct inode *pseudo_root;
20015 if (pseudo_root != NULL){
20016 current->fs->root = pseudo_root->i_sb->s_root;
20017 current->fs->pwd = pseudo_root->i_sb->s_root;
20018 }
20019 }
20020 #endif
20021
20022 #ifdef CONFIG_BLK_DEV_INITRD
20023 root_mountflags = real_root_mountflags;
20024 if (mount_initrd && ROOT_DEV != real_root_dev
20025 && MAJOR(ROOT_DEV) == RAMDISK_MAJOR
20026 && MINOR(ROOT_DEV) == 0) {
20027 int error;
20028 int i, pid;
20029
20030 pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
20031 if (pid>0)
20032 while (pid != wait(&i));
20033 if (MAJOR(real_root_dev) != RAMDISK_MAJOR
20034 || MINOR(real_root_dev) != 0) {
20035 error = change_root(real_root_dev,"/initrd");
20036 if (error)
20037 printk(KERN_ERR "Change root to /initrd: "
20038 "error %d\n",error);
20039 }
20040 }
20041 #endif
20042 }
20043
20044 static int init(void * unused)
20045 {
20046 lock_kernel();
20047 do_basic_setup();
20048
20049 /* OK, we have completed the initial bootup, and we're
20050 * essentially up and running. Get rid of the initmem
20051 * segments and start the user-mode stuff.. */
20052 free_initmem();
20053 unlock_kernel();
20054
20055 if (open("/dev/console", O_RDWR, 0) < 0)
20056 printk("Warning: unable to open an initial "
20057 "console.\n");
20058
20059 (void) dup(0);
20060 (void) dup(0);
20061
20062 /* We try each of these until one succeeds.
20063 *
20064 * The Bourne shell can be used instead of init if we
20065 * are trying to recover a really broken machine. */
20066
20067 if (execute_command)
20068 execve(execute_command,argv_init,envp_init);
20069 execve("/sbin/init",argv_init,envp_init);
20070 execve("/etc/init",argv_init,envp_init);
20071 execve("/bin/init",argv_init,envp_init);
20072 execve("/bin/sh",argv_init,envp_init);
20073 panic("No init found. "
20074 "Try passing init= option to kernel.");
20075 }
Сайт управляется системой
uCoz