linux-old/init/main.c
<<
>>
Prefs
   1/*
   2 *  linux/init/main.c
   3 *
   4 *  Copyright (C) 1991, 1992  Linus Torvalds
   5 *
   6 *  GK 2/5/95  -  Changed to support mounting root fs via NFS
   7 *  Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
   8 *  Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
   9 *  Simplified starting of init:  Michael A. Griffith <grif@acm.org> 
  10 */
  11
  12#define __KERNEL_SYSCALLS__
  13
  14#include <linux/config.h>
  15#include <linux/proc_fs.h>
  16#include <linux/unistd.h>
  17#include <linux/ctype.h>
  18#include <linux/delay.h>
  19#include <linux/utsname.h>
  20#include <linux/ioport.h>
  21#include <linux/init.h>
  22#include <linux/smp_lock.h>
  23#include <linux/blk.h>
  24#include <linux/hdreg.h>
  25
  26#include <asm/io.h>
  27#include <asm/bugs.h>
  28
  29#ifdef CONFIG_PCI
  30#include <linux/pci.h>
  31#endif
  32
  33#ifdef CONFIG_DIO
  34#include <linux/dio.h>
  35#endif
  36
  37#ifdef CONFIG_ZORRO
  38#include <linux/zorro.h>
  39#endif
  40
  41#ifdef CONFIG_MTRR
  42#  include <asm/mtrr.h>
  43#endif
  44
  45#ifdef CONFIG_APM
  46#include <linux/apm_bios.h>
  47#endif
  48
  49#ifdef CONFIG_DASD
  50#include "../drivers/s390/block/dasd.h"
  51#endif
  52
  53#ifdef CONFIG_MAC
  54extern void nubus_init(void);
  55#endif
  56
  57/*
  58 * Versions of gcc older than that listed below may actually compile
  59 * and link okay, but the end product can have subtle run time bugs.
  60 * To avoid associated bogus bug reports, we flatly refuse to compile
  61 * with a gcc that is known to be too old from the very beginning.
  62 */
  63#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
  64#error sorry, your GCC is too old. It builds incorrect kernels.
  65#endif
  66
  67extern char _stext, _etext;
  68extern char *linux_banner;
  69
  70extern int console_loglevel;
  71
  72static int init(void *);
  73extern int bdflush(void *);
  74extern int kupdate(void *);
  75extern int kswapd(void *);
  76extern int kpiod(void *);
  77extern void kswapd_setup(void);
  78extern unsigned long init_IRQ( unsigned long);
  79extern void init_modules(void);
  80extern long console_init(long, long);
  81extern void sock_init(void);
  82extern void uidcache_init(void);
  83extern void mca_init(void);
  84extern void sbus_init(void);
  85extern void ppc_init(void);
  86extern void sysctl_init(void);
  87extern void filescache_init(void);
  88extern void signals_init(void);
  89
  90extern void device_setup(void);
  91extern void binfmt_setup(void);
  92extern void free_initmem(void);
  93extern void filesystem_setup(void);
  94
  95#ifdef CONFIG_ARCH_ACORN
  96extern void ecard_init(void);
  97#endif
  98
  99extern void smp_setup(char *str, int *ints);
 100#ifdef __i386__
 101extern void ioapic_pirq_setup(char *str, int *ints);
 102extern void ioapic_setup(char *str, int *ints);
 103#endif
 104extern void no_scroll(char *str, int *ints);
 105extern void kbd_reset_setup(char *str, int *ints);
 106extern void panic_setup(char *str, int *ints);
 107extern void bmouse_setup(char *str, int *ints);
 108extern void msmouse_setup(char *str, int *ints);
 109extern void console_setup(char *str, int *ints);
 110#ifdef CONFIG_PRINTER
 111extern void lp_setup(char *str, int *ints);
 112#endif
 113#ifdef CONFIG_VIDEO_CPIA_PP
 114extern void cpia_pp_setup(char *str, int *ints);
 115#endif
 116#ifdef CONFIG_JOY_AMIGA
 117extern void js_am_setup(char *str, int *ints);
 118#endif
 119#ifdef CONFIG_JOY_ANALOG
 120extern void js_an_setup(char *str, int *ints);
 121#endif
 122#ifdef CONFIG_JOY_ASSASSIN
 123extern void js_as_setup(char *str, int *ints);
 124#endif
 125#ifdef CONFIG_JOY_CONSOLE
 126extern void js_console_setup(char *str, int *ints);
 127extern void js_console_setup_2(char *str, int *ints);
 128extern void js_console_setup_3(char *str, int *ints);
 129#endif
 130#ifdef CONFIG_JOY_DB9
 131extern void js_db9_setup(char *str, int *ints);
 132extern void js_db9_setup_2(char *str, int *ints);
 133extern void js_db9_setup_3(char *str, int *ints);
 134#endif
 135#ifdef CONFIG_JOY_TURBOGRAFX
 136extern void js_tg_setup(char *str, int *ints);
 137extern void js_tg_setup_2(char *str, int *ints);
 138extern void js_tg_setup_3(char *str, int *ints);
 139#endif
 140#ifdef CONFIG_JOY_LIGHTNING
 141extern void js_l4_setup(char *str, int *ints);
 142#endif
 143#ifdef CONFIG_JOY_PCI
 144extern void js_pci_setup(char *str, int *ints);
 145#endif
 146extern void eth_setup(char *str, int *ints);
 147#ifdef CONFIG_ARCNET_COM20020
 148extern void com20020_setup(char *str, int *ints);
 149#endif
 150#ifdef CONFIG_ARCNET_RIM_I
 151extern void arcrimi_setup(char *str, int *ints);
 152#endif
 153#ifdef CONFIG_CTC  
 154extern void ctc_setup(char *str, int *ints);
 155#endif
 156#ifdef CONFIG_IUCV
 157extern void iucv_setup(char *str, int *ints);
 158#endif
 159#ifdef CONFIG_ARCNET_COM90xxIO
 160extern void com90io_setup(char *str, int *ints);
 161#endif
 162#ifdef CONFIG_ARCNET_COM90xx
 163extern void com90xx_setup(char *str, int *ints);
 164#endif
 165#ifdef CONFIG_DECNET
 166extern void decnet_setup(char *str, int *ints);
 167#endif
 168#ifdef CONFIG_BLK_DEV_XD
 169extern void xd_setup(char *str, int *ints);
 170extern void xd_manual_geo_init(char *str, int *ints);
 171#endif
 172#ifdef CONFIG_BLK_DEV_IDE
 173extern void ide_setup(char *);
 174#endif
 175#ifdef CONFIG_PARIDE_PD
 176extern void pd_setup(char *str, int *ints);
 177#endif
 178#ifdef CONFIG_PARIDE_PF
 179extern void pf_setup(char *str, int *ints);
 180#endif
 181#ifdef CONFIG_PARIDE_PT
 182extern void pt_setup(char *str, int *ints);
 183#endif
 184#ifdef CONFIG_PARIDE_PG
 185extern void pg_setup(char *str, int *ints);
 186#endif
 187#ifdef CONFIG_PARIDE_PCD
 188extern void pcd_setup(char *str, int *ints);
 189#endif
 190#ifdef CONFIG_3215
 191extern void con3215_setup(char *str, int *ints);
 192#endif
 193#ifdef CONFIG_3215
 194extern void con3215_setup(char *str, int *ints);
 195#endif
 196#ifdef CONFIG_MDISK
 197extern void mdisk_setup(char *str, int *ints);
 198#endif
 199#ifdef CONFIG_DASD
 200extern void dasd_setup(char *str, int *ints);
 201#endif
 202extern void floppy_setup(char *str, int *ints);
 203extern void st_setup(char *str, int *ints);
 204extern void st0x_setup(char *str, int *ints);
 205extern void advansys_setup(char *str, int *ints);
 206extern void tmc8xx_setup(char *str, int *ints);
 207extern void t128_setup(char *str, int *ints);
 208extern void pas16_setup(char *str, int *ints);
 209extern void generic_NCR5380_setup(char *str, int *intr);
 210extern void generic_NCR53C400_setup(char *str, int *intr);
 211extern void generic_NCR53C400A_setup(char *str, int *intr);
 212extern void generic_DTC3181E_setup(char *str, int *intr);
 213extern void aha152x_setup(char *str, int *ints);
 214extern void aha1542_setup(char *str, int *ints);
 215extern void gdth_setup(char *str, int *ints);
 216extern void aic7xxx_setup(char *str, int *ints);
 217extern void AM53C974_setup(char *str, int *ints);
 218extern void BusLogic_Setup(char *str, int *ints);
 219extern void ncr53c8xx_setup(char *str, int *ints);
 220extern void sym53c8xx_setup(char *str, int *ints);
 221extern void eata2x_setup(char *str, int *ints);
 222extern void u14_34f_setup(char *str, int *ints);
 223extern void fdomain_setup(char *str, int *ints);
 224extern void ibmmca_scsi_setup(char *str, int *ints);
 225extern void fd_mcs_setup(char *str, int *ints);
 226extern void in2000_setup(char *str, int *ints);
 227extern void NCR53c406a_setup(char *str, int *ints);
 228extern void sym53c416_setup(char *str, int *ints);
 229extern void wd7000_setup(char *str, int *ints);
 230extern void dc390_setup(char* str, int *ints);
 231extern void scsi_luns_setup(char *str, int *ints);
 232extern void scsi_logging_setup(char *str, int *ints);
 233extern void sound_setup(char *str, int *ints);
 234extern void reboot_setup(char *str, int *ints);
 235extern void video_setup(char *str, int *ints);
 236#ifdef CONFIG_CDU31A
 237extern void cdu31a_setup(char *str, int *ints);
 238#endif CONFIG_CDU31A
 239#ifdef CONFIG_BLK_DEV_PS2
 240extern void ed_setup(char *str, int *ints);
 241extern void tp720_setup(char *str, int *ints);
 242#endif CONFIG_BLK_DEV_PS2
 243#ifdef CONFIG_MCD
 244extern void mcd_setup(char *str, int *ints);
 245#endif CONFIG_MCD
 246#ifdef CONFIG_MCDX
 247extern void mcdx_setup(char *str, int *ints);
 248#endif CONFIG_MCDX
 249#ifdef CONFIG_SBPCD
 250extern void sbpcd_setup(char *str, int *ints);
 251#endif CONFIG_SBPCD
 252#ifdef CONFIG_AZTCD
 253extern void aztcd_setup(char *str, int *ints);
 254#endif CONFIG_AZTCD
 255#ifdef CONFIG_CDU535
 256extern void sonycd535_setup(char *str, int *ints);
 257#endif CONFIG_CDU535
 258#ifdef CONFIG_GSCD
 259extern void gscd_setup(char *str, int *ints);
 260#endif CONFIG_GSCD
 261#ifdef CONFIG_CM206
 262extern void cm206_setup(char *str, int *ints);
 263#endif CONFIG_CM206
 264#ifdef CONFIG_OPTCD
 265extern void optcd_setup(char *str, int *ints);
 266#endif CONFIG_OPTCD
 267#ifdef CONFIG_SJCD
 268extern void sjcd_setup(char *str, int *ints);
 269#endif CONFIG_SJCD
 270#ifdef CONFIG_ISP16_CDI
 271extern void isp16_setup(char *str, int *ints);
 272#endif CONFIG_ISP16_CDI
 273#ifdef CONFIG_BLK_DEV_RAM
 274static void ramdisk_start_setup(char *str, int *ints);
 275static void load_ramdisk(char *str, int *ints);
 276static void prompt_ramdisk(char *str, int *ints);
 277static void ramdisk_size(char *str, int *ints);
 278#ifdef CONFIG_BLK_DEV_INITRD
 279static void no_initrd(char *s,int *ints);
 280#endif
 281#endif CONFIG_BLK_DEV_RAM
 282#ifdef CONFIG_ISDN_DRV_ICN
 283extern void icn_setup(char *str, int *ints);
 284#endif
 285#ifdef CONFIG_ISDN_DRV_HISAX
 286extern void HiSax_setup(char *str, int *ints);
 287#endif
 288#ifdef CONFIG_DIGIEPCA
 289extern void epca_setup(char *str, int *ints);
 290#endif
 291#ifdef CONFIG_ISDN_DRV_PCBIT
 292extern void pcbit_setup(char *str, int *ints);
 293#endif
 294
 295#ifdef CONFIG_ATARIMOUSE
 296extern void atari_mouse_setup (char *str, int *ints);
 297#endif
 298#ifdef CONFIG_DMASOUND
 299extern void dmasound_setup (char *str, int *ints);
 300#endif
 301#ifdef CONFIG_ATARI_SCSI
 302extern void atari_scsi_setup (char *str, int *ints);
 303#endif
 304extern void stram_swap_setup (char *str, int *ints);
 305extern void wd33c93_setup (char *str, int *ints);
 306extern void gvp11_setup (char *str, int *ints);
 307extern void ncr53c7xx_setup (char *str, int *ints);
 308extern void sim710_setup (char *str, int *ints);
 309#ifdef CONFIG_MAC_SCSI
 310extern void mac_scsi_setup (char *str, int *ints);
 311#endif
 312
 313#ifdef CONFIG_CYCLADES
 314extern void cy_setup(char *str, int *ints);
 315#endif
 316#ifdef CONFIG_DIGI
 317extern void pcxx_setup(char *str, int *ints);
 318#endif
 319#ifdef CONFIG_RISCOM8
 320extern void riscom8_setup(char *str, int *ints);
 321#endif
 322#ifdef CONFIG_SPECIALIX
 323extern void specialix_setup(char *str, int *ints);
 324#endif
 325#ifdef CONFIG_DMASCC
 326extern void dmascc_setup(char *str, int *ints);
 327#endif
 328#ifdef CONFIG_BAYCOM_PAR
 329extern void baycom_par_setup(char *str, int *ints);
 330#endif
 331#ifdef CONFIG_BAYCOM_SER_FDX
 332extern void baycom_ser_fdx_setup(char *str, int *ints);
 333#endif
 334#ifdef CONFIG_BAYCOM_SER_HDX
 335extern void baycom_ser_hdx_setup(char *str, int *ints);
 336#endif
 337#ifdef CONFIG_SOUNDMODEM
 338extern void sm_setup(char *str, int *ints);
 339#endif
 340#ifdef CONFIG_ADBMOUSE
 341extern void adb_mouse_setup(char *str, int *ints);
 342#endif
 343#ifdef CONFIG_WDT
 344extern void wdt_setup(char *str, int *ints);
 345#endif
 346#ifdef CONFIG_PARPORT
 347extern void parport_setup(char *str, int *ints);
 348#endif
 349#ifdef CONFIG_PLIP
 350extern void plip_setup(char *str, int *ints);
 351#endif
 352#ifdef CONFIG_HFMODEM
 353extern void hfmodem_setup(char *str, int *ints);
 354#endif
 355#ifdef CONFIG_IP_PNP
 356extern void ip_auto_config_setup(char *str, int *ints);
 357#endif
 358#ifdef CONFIG_ROOT_NFS
 359extern void nfs_root_setup(char *str, int *ints);
 360#endif
 361#ifdef CONFIG_FTAPE
 362extern void ftape_setup(char *str, int *ints);
 363#endif
 364#ifdef CONFIG_3215_CONSOLE
 365extern int con3215_activate(void);
 366#endif
 367#ifdef CONFIG_MDA_CONSOLE
 368extern void mdacon_setup(char *str, int *ints);
 369#endif
 370#ifdef CONFIG_LTPC
 371extern void ltpc_setup(char *str, int *ints);
 372#endif
 373#ifdef CONFIG_BLK_CPQ_DA
 374extern void cpqarray_setup(char *str, int *ints);
 375#endif
 376
 377#if defined(CONFIG_SYSVIPC)
 378extern void ipc_init(void);
 379#endif
 380#if defined(CONFIG_QUOTA)
 381extern void dquot_init_hash(void);
 382#endif
 383
 384#ifdef CONFIG_MD_BOOT
 385extern void md_setup(char *str,int *ints) __init;
 386#endif
 387
 388/*
 389 * Boot command-line arguments
 390 */
 391#define MAX_INIT_ARGS 8
 392#define MAX_INIT_ENVS 8
 393
 394extern void time_init(void);
 395
 396static unsigned long memory_start = 0;
 397static unsigned long memory_end = 0;
 398
 399int rows, cols;
 400
 401#ifdef CONFIG_BLK_DEV_RAM
 402extern int rd_doload;           /* 1 = load ramdisk, 0 = don't load 2 = dual disk */
 403extern int rd_prompt;           /* 1 = prompt for ramdisk, 0 = don't prompt */
 404extern int rd_size;             /* Size of the ramdisk(s) */
 405extern int rd_image_start;      /* starting block # of image */
 406#ifdef CONFIG_BLK_DEV_INITRD
 407kdev_t real_root_dev;
 408#endif
 409#endif
 410
 411int root_mountflags = MS_RDONLY;
 412char *execute_command = NULL;
 413
 414static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
 415static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
 416
 417char *get_options(char *str, int *ints)
 418{
 419        char *cur = str;
 420        int i=1;
 421
 422        while (cur && (*cur=='-' || isdigit(*cur)) && i <= 10) {
 423                ints[i++] = simple_strtol(cur,NULL,0);
 424                if ((cur = strchr(cur,',')) != NULL)
 425                        cur++;
 426        }
 427        ints[0] = i-1;
 428        return(cur);
 429}
 430
 431static void __init profile_setup(char *str, int *ints)
 432{
 433        if (ints[0] > 0)
 434                prof_shift = (unsigned long) ints[1];
 435        else
 436                prof_shift = 2;
 437}
 438
 439
 440static struct dev_name_struct {
 441        const char *name;
 442        const int num;
 443} root_dev_names[] __initdata = {
 444#ifdef CONFIG_ROOT_NFS
 445        { "nfs",     0x00ff },
 446#endif
 447#ifdef CONFIG_BLK_DEV_LOOP
 448        { "loop",    0x0700 },
 449#endif
 450#ifdef CONFIG_BLK_DEV_IDE
 451        { "hda",     0x0300 },
 452        { "hdb",     0x0340 },
 453        { "hdc",     0x1600 },
 454        { "hdd",     0x1640 },
 455        { "hde",     0x2100 },
 456        { "hdf",     0x2140 },
 457        { "hdg",     0x2200 },
 458        { "hdh",     0x2240 },
 459        { "hdi",     0x3800 },
 460        { "hdj",     0x3840 },
 461        { "hdk",     0x3900 },
 462        { "hdl",     0x3940 },
 463#endif
 464#ifdef CONFIG_BLK_DEV_SD
 465        { "sda",     0x0800 },
 466        { "sdb",     0x0810 },
 467        { "sdc",     0x0820 },
 468        { "sdd",     0x0830 },
 469        { "sde",     0x0840 },
 470        { "sdf",     0x0850 },
 471        { "sdg",     0x0860 },
 472        { "sdh",     0x0870 },
 473        { "sdi",     0x0880 },
 474        { "sdj",     0x0890 },
 475        { "sdk",     0x08a0 },
 476        { "sdl",     0x08b0 },
 477        { "sdm",     0x08c0 },
 478        { "sdn",     0x08d0 },
 479        { "sdo",     0x08e0 },
 480        { "sdp",     0x08f0 },
 481#endif
 482#ifdef CONFIG_BLK_DEV_DAC960
 483        { "rd/c0d0p",0x3000 },
 484        { "rd/c0d1p",0x3008 },
 485        { "rd/c0d2p",0x3010 },
 486        { "rd/c0d3p",0x3018 },
 487        { "rd/c0d4p",0x3020 },
 488        { "rd/c0d5p",0x3028 },
 489        { "rd/c0d6p",0x3030 },
 490        { "rd/c0d7p",0x3038 },
 491        { "rd/c0d8p",0x3040 },
 492        { "rd/c0d9p",0x3048 },
 493        { "rd/c0d10p",0x3050 },
 494        { "rd/c0d11p",0x3058 },
 495        { "rd/c0d12p",0x3060 },
 496        { "rd/c0d13p",0x3068 },
 497        { "rd/c0d14p",0x3070 },
 498        { "rd/c0d15p",0x3078 },
 499#endif
 500#if defined(CONFIG_BLK_CPQ_DA) || defined(CONFIG_BLK_CPQ_DA_MODULE)
 501        { "ida/c0d0p",0x4800 },
 502        { "ida/c0d1p",0x4810 },
 503        { "ida/c0d2p",0x4820 },
 504        { "ida/c0d3p",0x4830 },
 505        { "ida/c0d4p",0x4840 },
 506        { "ida/c0d5p",0x4850 },
 507        { "ida/c0d6p",0x4860 },
 508        { "ida/c0d7p",0x4870 },
 509        { "ida/c0d8p",0x4880 },
 510        { "ida/c0d9p",0x4890 },
 511        { "ida/c0d10p",0x48A0 },
 512        { "ida/c0d11p",0x48B0 },
 513        { "ida/c0d12p",0x48C0 },
 514        { "ida/c0d13p",0x48D0 },
 515        { "ida/c0d14p",0x48E0 },
 516        { "ida/c0d15p",0x48F0 },
 517#endif
 518#ifdef CONFIG_ATARI_ACSI
 519        { "ada",     0x1c00 },
 520        { "adb",     0x1c10 },
 521        { "adc",     0x1c20 },
 522        { "add",     0x1c30 },
 523        { "ade",     0x1c40 },
 524#endif
 525#ifdef CONFIG_BLK_DEV_FD
 526        { "fd",      0x0200 },
 527#endif
 528#ifdef CONFIG_MD_BOOT
 529        { "md",      0x0900 },       
 530#endif     
 531#ifdef CONFIG_BLK_DEV_XD
 532        { "xda",     0x0d00 },
 533        { "xdb",     0x0d40 },
 534#endif
 535#ifdef CONFIG_BLK_DEV_RAM
 536        { "ram",     0x0100 },
 537#endif
 538#ifdef CONFIG_BLK_DEV_SR
 539        { "scd",     0x0b00 },
 540#endif
 541#ifdef CONFIG_MCD
 542        { "mcd",     0x1700 },
 543#endif
 544#ifdef CONFIG_CDU535
 545        { "cdu535",  0x1800 },
 546        { "sonycd",  0x1800 },
 547#endif
 548#ifdef CONFIG_AZTCD
 549        { "aztcd",   0x1d00 },
 550#endif
 551#ifdef CONFIG_CM206
 552        { "cm206cd", 0x2000 },
 553#endif
 554#ifdef CONFIG_GSCD
 555        { "gscd",    0x1000 },
 556#endif
 557#ifdef CONFIG_SBPCD
 558        { "sbpcd",   0x1900 },
 559#endif
 560#ifdef CONFIG_BLK_DEV_PS2
 561        { "eda",     0x2400 },
 562        { "edb",     0x2440 },
 563#endif
 564#ifdef CONFIG_PARIDE_PD
 565        { "pda",        0x2d00 },
 566        { "pdb",        0x2d10 },
 567        { "pdc",        0x2d20 },
 568        { "pdd",        0x2d30 },
 569#endif
 570#ifdef CONFIG_PARIDE_PCD
 571        { "pcd",        0x2e00 },
 572#endif
 573#ifdef CONFIG_PARIDE_PF
 574        { "pf",         0x2f00 },
 575#endif
 576#if CONFIG_APBLOCK
 577        { "apblock", APBLOCK_MAJOR << 8},
 578#endif
 579#if CONFIG_DDV
 580        { "ddv", DDV_MAJOR << 8},
 581#endif
 582#ifdef CONFIG_MDISK
 583        { "mnda", (MDISK_MAJOR << MINORBITS)},
 584        { "mndb", (MDISK_MAJOR << MINORBITS) + 1},
 585        { "mndc", (MDISK_MAJOR << MINORBITS) + 2},
 586        { "mndd", (MDISK_MAJOR << MINORBITS) + 3},
 587        { "mnde", (MDISK_MAJOR << MINORBITS) + 4},
 588        { "mndf", (MDISK_MAJOR << MINORBITS) + 5},
 589        { "mndg", (MDISK_MAJOR << MINORBITS) + 6},
 590        { "mndh", (MDISK_MAJOR << MINORBITS) + 7},
 591#endif
 592#ifdef CONFIG_DASD
 593       { "dasda", (DASD_MAJOR << MINORBITS) },
 594       { "dasdb", (DASD_MAJOR << MINORBITS) + (1 << 2) },
 595       { "dasdc", (DASD_MAJOR << MINORBITS) + (2 << 2) },
 596       { "dasdd", (DASD_MAJOR << MINORBITS) + (3 << 2) },
 597       { "dasde", (DASD_MAJOR << MINORBITS) + (4 << 2) },
 598       { "dasdf", (DASD_MAJOR << MINORBITS) + (5 << 2) },
 599       { "dasdg", (DASD_MAJOR << MINORBITS) + (6 << 2) },
 600       { "dasdh", (DASD_MAJOR << MINORBITS) + (7 << 2) },
 601#endif
 602        { NULL, 0 }
 603};
 604
 605kdev_t __init name_to_kdev_t(char *line)
 606{
 607        int base = 0;
 608        if (strncmp(line,"/dev/",5) == 0) {
 609                struct dev_name_struct *dev = root_dev_names;
 610                line += 5;
 611                do {
 612                        int len = strlen(dev->name);
 613                        if (strncmp(line,dev->name,len) == 0) {
 614                                line += len;
 615                                base = dev->num;
 616                                break;
 617                        }
 618                        dev++;
 619                } while (dev->name);
 620        }
 621        return to_kdev_t(base + simple_strtoul(line,NULL,base?10:16));
 622}
 623
 624static void __init root_dev_setup(char *line, int *num)
 625{
 626        ROOT_DEV = name_to_kdev_t(line);
 627}
 628
 629/*
 630 * List of kernel command line parameters. The first table lists parameters
 631 * which are subject to values parsing (leading numbers are converted to
 632 * an array of ints and chopped off the string), the second table contains
 633 * the few exceptions which obey their own syntax rules.
 634 */
 635
 636struct kernel_param {
 637        const char *str;
 638        void (*setup_func)(char *, int *);
 639};
 640
 641static struct kernel_param cooked_params[] __initdata = {
 642/* FIXME: make PNP just become reserve_setup */
 643#ifndef CONFIG_KERNEL_PNP_RESOURCE
 644        { "reserve=", reserve_setup },
 645#else
 646        { "reserve=", pnp_reserve_setup },
 647#endif
 648        { "profile=", profile_setup },
 649#ifdef __SMP__
 650        { "nosmp", smp_setup },
 651        { "maxcpus=", smp_setup },
 652#ifdef CONFIG_X86_IO_APIC
 653        { "noapic", ioapic_setup },
 654        { "pirq=", ioapic_pirq_setup },
 655#endif
 656#endif
 657#ifdef CONFIG_BLK_DEV_RAM
 658        { "ramdisk_start=", ramdisk_start_setup },
 659        { "load_ramdisk=", load_ramdisk },
 660        { "prompt_ramdisk=", prompt_ramdisk },
 661        { "ramdisk=", ramdisk_size },
 662        { "ramdisk_size=", ramdisk_size },
 663#ifdef CONFIG_BLK_DEV_INITRD
 664        { "noinitrd", no_initrd },
 665#endif
 666
 667#ifdef CONFIG_CTC
 668        { "ctc=", ctc_setup } ,
 669#endif
 670#ifdef CONFIG_IUCV
 671        { "iucv=", iucv_setup } ,
 672#endif
 673
 674#endif
 675
 676#ifdef CONFIG_FB
 677        { "video=", video_setup },
 678#endif
 679        { "panic=", panic_setup },
 680        { "console=", console_setup },
 681#ifdef CONFIG_VGA_CONSOLE
 682        { "no-scroll", no_scroll },
 683#endif
 684#ifdef CONFIG_MDA_CONSOLE
 685        { "mdacon=", mdacon_setup },
 686#endif
 687#ifdef CONFIG_VT
 688        { "kbd-reset", kbd_reset_setup },
 689#endif
 690#ifdef CONFIG_BUGi386
 691        { "no-hlt", no_halt },
 692        { "no387", no_387 },
 693        { "reboot=", reboot_setup },
 694#endif
 695#ifdef CONFIG_MCA
 696        { "mca-pentium", mca_pentium },
 697#endif
 698#ifdef CONFIG_INET
 699        { "ether=", eth_setup },
 700#endif
 701#ifdef CONFIG_ARCNET_COM20020
 702        { "com20020=", com20020_setup },
 703#endif
 704#ifdef CONFIG_ARCNET_RIM_I
 705        { "arcrimi=", arcrimi_setup },
 706#endif
 707#ifdef CONFIG_ARCNET_COM90xxIO
 708        { "com90io=", com90io_setup },
 709#endif
 710#ifdef CONFIG_ARCNET_COM90xx
 711        { "com90xx=", com90xx_setup },
 712#endif
 713#ifdef CONFIG_DECNET
 714        { "decnet=", decnet_setup },
 715#endif
 716#ifdef CONFIG_PRINTER
 717        { "lp=", lp_setup },
 718#endif
 719#ifdef CONFIG_VIDEO_CPIA_PP
 720        { "cpia_pp=", cpia_pp_setup },
 721#endif
 722#ifdef CONFIG_JOY_AMIGA
 723        { "js_am=", js_am_setup },
 724#endif
 725#ifdef CONFIG_JOY_ANALOG
 726        { "js_an=", js_an_setup },
 727#endif
 728#ifdef CONFIG_JOY_ASSASSIN
 729        { "js_as=", js_as_setup },
 730#endif
 731#ifdef CONFIG_JOY_CONSOLE
 732        { "js_console=", js_console_setup },
 733        { "js_console2=", js_console_setup_2 },
 734        { "js_console3=", js_console_setup_3 },
 735#endif
 736#ifdef CONFIG_JOY_DB9
 737        { "js_db9=", js_db9_setup },
 738        { "js_db9_2=", js_db9_setup_2 },
 739        { "js_db9_3=", js_db9_setup_3 },
 740#endif
 741#ifdef CONFIG_JOY_TURBOGRAFX
 742        { "js_tg=", js_tg_setup },
 743        { "js_tg_2=", js_tg_setup_2 },
 744        { "js_tg_3=", js_tg_setup_3 },
 745#endif
 746#ifdef CONFIG_JOY_LIGHTNING
 747        { "js_l4=", js_l4_setup },
 748#endif
 749#ifdef CONFIG_JOY_PCI
 750        { "js_pci=", js_pci_setup },
 751#endif
 752#ifdef CONFIG_SCSI
 753        { "max_scsi_luns=", scsi_luns_setup },
 754        { "scsi_logging=", scsi_logging_setup },
 755#endif
 756#ifdef CONFIG_SCSI_ADVANSYS
 757        { "advansys=", advansys_setup },
 758#endif
 759#if defined(CONFIG_BLK_DEV_HD)
 760        { "hd=", hd_setup },
 761#endif
 762#ifdef CONFIG_CHR_DEV_ST
 763        { "st=", st_setup },
 764#endif
 765#ifdef CONFIG_BUSMOUSE
 766        { "bmouse=", bmouse_setup },
 767#endif
 768#ifdef CONFIG_MS_BUSMOUSE
 769        { "msmouse=", msmouse_setup },
 770#endif
 771#ifdef CONFIG_SCSI_SEAGATE
 772        { "st0x=", st0x_setup },
 773        { "tmc8xx=", tmc8xx_setup },
 774#endif
 775#ifdef CONFIG_SCSI_T128
 776        { "t128=", t128_setup },
 777#endif
 778#ifdef CONFIG_SCSI_PAS16
 779        { "pas16=", pas16_setup },
 780#endif
 781#ifdef CONFIG_SCSI_GENERIC_NCR5380
 782        { "ncr5380=", generic_NCR5380_setup },
 783        { "ncr53c400=", generic_NCR53C400_setup },
 784        { "ncr53c400a=", generic_NCR53C400A_setup },
 785        { "dtc3181e=", generic_DTC3181E_setup },
 786#endif
 787#ifdef CONFIG_SCSI_AHA152X
 788        { "aha152x=", aha152x_setup},
 789#endif
 790#ifdef CONFIG_SCSI_AHA1542
 791        { "aha1542=", aha1542_setup},
 792#endif
 793#ifdef CONFIG_SCSI_GDTH
 794        { "gdth=", gdth_setup},
 795#endif
 796#ifdef CONFIG_SCSI_AIC7XXX
 797        { "aic7xxx=", aic7xxx_setup},
 798#endif
 799#ifdef CONFIG_SCSI_BUSLOGIC
 800        { "BusLogic=", BusLogic_Setup},
 801#endif
 802#ifdef CONFIG_SCSI_NCR53C8XX
 803        { "ncr53c8xx=", ncr53c8xx_setup},
 804#endif
 805#ifdef CONFIG_SCSI_SYM53C8XX
 806        { "sym53c8xx=", sym53c8xx_setup},
 807#endif
 808#ifdef CONFIG_SCSI_EATA
 809        { "eata=", eata2x_setup},
 810#endif
 811#ifdef CONFIG_SCSI_U14_34F
 812        { "u14-34f=", u14_34f_setup},
 813#endif
 814#ifdef CONFIG_SCSI_AM53C974
 815        { "AM53C974=", AM53C974_setup},
 816#endif
 817#ifdef CONFIG_SCSI_NCR53C406A
 818        { "ncr53c406a=", NCR53c406a_setup},
 819#endif
 820#ifdef CONFIG_SCSI_SYM53C416
 821        { "sym53c416=", sym53c416_setup},
 822#endif
 823#ifdef CONFIG_SCSI_FUTURE_DOMAIN
 824        { "fdomain=", fdomain_setup},
 825#endif
 826#ifdef CONFIG_SCSI_IN2000
 827        { "in2000=", in2000_setup},
 828#endif
 829#ifdef CONFIG_SCSI_7000FASST
 830        { "wd7000=", wd7000_setup},
 831#endif
 832#ifdef CONFIG_SCSI_IBMMCA
 833        { "ibmmcascsi=", ibmmca_scsi_setup },
 834#endif
 835#ifdef CONFIG_SCSI_FD_MCS
 836        { "fd_mcs=", fd_mcs_setup },
 837#endif
 838#if defined(CONFIG_SCSI_DC390T) && ! defined(CONFIG_SCSI_DC390T_NOGENSUPP)
 839        { "tmscsim=", dc390_setup },
 840#endif
 841#ifdef CONFIG_BLK_DEV_XD
 842        { "xd=", xd_setup },
 843        { "xd_geo=", xd_manual_geo_init },
 844#endif
 845#if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_AMIGA_FLOPPY) || defined(CONFIG_ATARI_FLOPPY)
 846        { "floppy=", floppy_setup },
 847#endif
 848#ifdef CONFIG_BLK_DEV_PS2
 849        { "eda=", ed_setup },
 850        { "edb=", ed_setup },
 851        { "tp720=", tp720_setup },
 852#endif
 853#ifdef CONFIG_CDU31A
 854        { "cdu31a=", cdu31a_setup },
 855#endif CONFIG_CDU31A
 856#ifdef CONFIG_MCD
 857        { "mcd=", mcd_setup },
 858#endif CONFIG_MCD
 859#ifdef CONFIG_MCDX
 860        { "mcdx=", mcdx_setup },
 861#endif CONFIG_MCDX
 862#ifdef CONFIG_SBPCD
 863        { "sbpcd=", sbpcd_setup },
 864#endif CONFIG_SBPCD
 865#ifdef CONFIG_AZTCD
 866        { "aztcd=", aztcd_setup },
 867#endif CONFIG_AZTCD
 868#ifdef CONFIG_CDU535
 869        { "sonycd535=", sonycd535_setup },
 870#endif CONFIG_CDU535
 871#ifdef CONFIG_GSCD
 872        { "gscd=", gscd_setup },
 873#endif CONFIG_GSCD
 874#ifdef CONFIG_CM206
 875        { "cm206=", cm206_setup },
 876#endif CONFIG_CM206
 877#ifdef CONFIG_OPTCD
 878        { "optcd=", optcd_setup },
 879#endif CONFIG_OPTCD
 880#ifdef CONFIG_SJCD
 881        { "sjcd=", sjcd_setup },
 882#endif CONFIG_SJCD
 883#ifdef CONFIG_ISP16_CDI
 884        { "isp16=", isp16_setup },
 885#endif CONFIG_ISP16_CDI
 886#ifdef CONFIG_SOUND_OSS
 887        { "sound=", sound_setup },
 888#endif
 889#ifdef CONFIG_ISDN_DRV_ICN
 890        { "icn=", icn_setup },
 891#endif
 892#ifdef CONFIG_ISDN_DRV_HISAX
 893       { "hisax=", HiSax_setup },
 894       { "HiSax=", HiSax_setup },
 895#endif
 896#ifdef CONFIG_ISDN_DRV_PCBIT
 897        { "pcbit=", pcbit_setup },
 898#endif
 899#ifdef CONFIG_ATARIMOUSE
 900        { "atamouse=", atari_mouse_setup },
 901#endif
 902#ifdef CONFIG_DMASOUND
 903        { "dmasound=", dmasound_setup },
 904#endif
 905#ifdef CONFIG_ATARI_SCSI
 906        { "atascsi=", atari_scsi_setup },
 907#endif
 908#ifdef CONFIG_STRAM_SWAP
 909        { "stram_swap=", stram_swap_setup },
 910#endif
 911#if defined(CONFIG_A4000T_SCSI) || defined(CONFIG_WARPENGINE_SCSI) \
 912            || defined(CONFIG_A4091_SCSI) || defined(CONFIG_MVME16x_SCSI) \
 913            || defined(CONFIG_BVME6000_SCSI) \
 914            || defined(CONFIG_BLZ603EPLUS_SCSI)
 915        { "53c7xx=", ncr53c7xx_setup },
 916#endif
 917#if defined(CONFIG_SCSI_SIM710)
 918        { "sim710=", sim710_setup },
 919#endif
 920#if defined(CONFIG_A3000_SCSI) || defined(CONFIG_A2091_SCSI) \
 921            || defined(CONFIG_GVP11_SCSI)
 922        { "wd33c93=", wd33c93_setup },
 923#endif
 924#if defined(CONFIG_GVP11_SCSI)
 925        { "gvp11=", gvp11_setup },
 926#endif
 927#ifdef CONFIG_MAC_SCSI
 928        { "mac5380=", mac_scsi_setup },
 929#endif
 930#ifdef CONFIG_CYCLADES
 931        { "cyclades=", cy_setup },
 932#endif
 933#ifdef CONFIG_DIGI
 934        { "digi=", pcxx_setup },
 935#endif
 936#ifdef CONFIG_DIGIEPCA
 937        { "digiepca=", epca_setup },
 938#endif
 939#ifdef CONFIG_RISCOM8
 940        { "riscom8=", riscom8_setup },
 941#endif
 942#ifdef CONFIG_DMASCC
 943        { "dmascc=", dmascc_setup },
 944#endif
 945#ifdef CONFIG_SPECIALIX
 946        { "specialix=", specialix_setup },
 947#endif
 948#ifdef CONFIG_BAYCOM_PAR
 949        { "baycom_par=", baycom_par_setup },
 950#endif
 951#ifdef CONFIG_BAYCOM_SER_FDX
 952        { "baycom_ser_fdx=", baycom_ser_fdx_setup },
 953#endif
 954#ifdef CONFIG_BAYCOM_SER_HDX
 955        { "baycom_ser_hdx=", baycom_ser_hdx_setup },
 956#endif
 957#ifdef CONFIG_SOUNDMODEM
 958        { "soundmodem=", sm_setup },
 959#endif
 960#ifdef CONFIG_WDT
 961        { "wdt=", wdt_setup },
 962#endif
 963#ifdef CONFIG_PARPORT
 964        { "parport=", parport_setup },
 965#endif
 966#ifdef CONFIG_PLIP
 967        { "plip=", plip_setup },
 968#endif
 969#ifdef CONFIG_HFMODEM
 970        { "hfmodem=", hfmodem_setup },
 971#endif
 972#ifdef CONFIG_FTAPE
 973        { "ftape=", ftape_setup},
 974#endif
 975#ifdef CONFIG_MD_BOOT
 976        { "md=", md_setup},
 977#endif
 978#ifdef CONFIG_ADBMOUSE
 979        { "adb_buttons=", adb_mouse_setup },
 980#endif
 981#ifdef CONFIG_LTPC
 982        { "ltpc=", ltpc_setup },
 983#endif
 984#ifdef CONFIG_BLK_CPQ_DA
 985        { "smart2=", cpqarray_setup },
 986#endif
 987        { 0, 0 }
 988};
 989
 990static struct kernel_param raw_params[] __initdata = {
 991        { "root=", root_dev_setup },
 992#ifdef CONFIG_ROOT_NFS
 993        { "nfsroot=", nfs_root_setup },
 994        { "nfsaddrs=", ip_auto_config_setup },
 995#endif
 996#ifdef CONFIG_IP_PNP
 997        { "ip=", ip_auto_config_setup },
 998#endif
 999#ifdef CONFIG_PCI
1000        { "pci=", pci_setup },
1001#endif
1002#ifdef CONFIG_PARIDE_PD
1003        { "pd.", pd_setup },
1004#endif
1005#ifdef CONFIG_PARIDE_PCD
1006        { "pcd.", pcd_setup },
1007#endif
1008#ifdef CONFIG_PARIDE_PF
1009        { "pf.", pf_setup },
1010#endif
1011#ifdef CONFIG_PARIDE_PT
1012        { "pt.", pt_setup },
1013#endif
1014#ifdef CONFIG_PARIDE_PG
1015        { "pg.", pg_setup },
1016#endif
1017#ifdef CONFIG_APM
1018        { "apm=", apm_setup },
1019#endif
1020#ifdef CONFIG_3215
1021        { "condev=", con3215_setup },
1022#endif
1023#ifdef CONFIG_3215
1024        { "condev=", con3215_setup },
1025#endif
1026#ifdef CONFIG_MDISK
1027        { "mdisk=", mdisk_setup },
1028#endif
1029#ifdef CONFIG_DASD
1030        { "dasd=", dasd_setup },
1031#endif
1032        { 0, 0 }
1033};
1034
1035#ifdef CONFIG_BLK_DEV_RAM
1036static void __init ramdisk_start_setup(char *str, int *ints)
1037{
1038   if (ints[0] > 0 && ints[1] >= 0)
1039      rd_image_start = ints[1];
1040}
1041
1042static void __init load_ramdisk(char *str, int *ints)
1043{
1044   if (ints[0] > 0 && ints[1] >= 0)
1045      rd_doload = ints[1] & 3;
1046}
1047
1048static void __init prompt_ramdisk(char *str, int *ints)
1049{
1050   if (ints[0] > 0 && ints[1] >= 0)
1051      rd_prompt = ints[1] & 1;
1052}
1053
1054static void __init ramdisk_size(char *str, int *ints)
1055{
1056        if (ints[0] > 0 && ints[1] >= 0)
1057                rd_size = ints[1];
1058}
1059#endif
1060
1061static int __init checksetup(char *line)
1062{
1063        int i, ints[11];
1064
1065#ifdef CONFIG_BLK_DEV_IDE
1066        /* ide driver needs the basic string, rather than pre-processed values */
1067        if (!strncmp(line,"ide",3) || (!strncmp(line,"hd",2) && line[2] != '=')) {
1068                ide_setup(line);
1069                return 1;
1070        }
1071#endif
1072        for (i=0; raw_params[i].str; i++) {
1073                int n = strlen(raw_params[i].str);
1074                if (!strncmp(line,raw_params[i].str,n)) {
1075                        raw_params[i].setup_func(line+n, NULL);
1076                        return 1;
1077                }
1078        }
1079        for (i=0; cooked_params[i].str; i++) {
1080                int n = strlen(cooked_params[i].str);
1081                if (!strncmp(line,cooked_params[i].str,n)) {
1082                        cooked_params[i].setup_func(get_options(line+n, ints), ints);
1083                        return 1;
1084                }
1085        }
1086        return 0;
1087}
1088
1089/* this should be approx 2 Bo*oMips to start (note initial shift), and will
1090   still work even if initially too large, it will just take slightly longer */
1091unsigned long loops_per_sec = (1<<12);
1092
1093/* This is the number of bits of precision for the loops_per_second.  Each
1094   bit takes on average 1.5/HZ seconds.  This (like the original) is a little
1095   better than 1% */
1096#define LPS_PREC 8
1097
1098void __init calibrate_delay(void)
1099{
1100        unsigned long ticks, loopbit;
1101        int lps_precision = LPS_PREC;
1102
1103        loops_per_sec = (1<<12);
1104
1105        printk("Calibrating delay loop... ");
1106        while (loops_per_sec <<= 1) {
1107                /* wait for "start of" clock tick */
1108                ticks = jiffies;
1109                while (ticks == jiffies)
1110                        /* nothing */;
1111                /* Go .. */
1112                ticks = jiffies;
1113                __delay(loops_per_sec);
1114                ticks = jiffies - ticks;
1115                if (ticks)
1116                        break;
1117        }
1118
1119/* Do a binary approximation to get loops_per_second set to equal one clock
1120   (up to lps_precision bits) */
1121        loops_per_sec >>= 1;
1122        loopbit = loops_per_sec;
1123        while ( lps_precision-- && (loopbit >>= 1) ) {
1124                loops_per_sec |= loopbit;
1125                ticks = jiffies;
1126                while (ticks == jiffies);
1127                ticks = jiffies;
1128                __delay(loops_per_sec);
1129                if (jiffies != ticks)   /* longer than 1 tick */
1130                        loops_per_sec &= ~loopbit;
1131        }
1132
1133/* finally, adjust loops per second in terms of seconds instead of clocks */    
1134        loops_per_sec *= HZ;
1135/* Round the value and print it */      
1136        printk("%lu.%02lu BogoMIPS\n",
1137                (loops_per_sec+2500)/500000,
1138                ((loops_per_sec+2500)/5000) % 100);
1139}
1140
1141/*
1142 * This is a simple kernel command line parsing function: it parses
1143 * the command line, and fills in the arguments/environment to init
1144 * as appropriate. Any cmd-line option is taken to be an environment
1145 * variable if it contains the character '='.
1146 *
1147 * This routine also checks for options meant for the kernel.
1148 * These options are not given to init - they are for internal kernel use only.
1149 */
1150static void __init parse_options(char *line)
1151{
1152        char *next;
1153        int args, envs;
1154
1155        if (!*line)
1156                return;
1157        args = 0;
1158        envs = 1;       /* TERM is set to 'linux' by default */
1159        next = line;
1160        while ((line = next) != NULL) {
1161                if ((next = strchr(line,' ')) != NULL)
1162                        *next++ = 0;
1163                /*
1164                 * check for kernel options first..
1165                 */
1166                if (!strcmp(line,"ro")) {
1167                        root_mountflags |= MS_RDONLY;
1168                        continue;
1169                }
1170                if (!strcmp(line,"rw")) {
1171                        root_mountflags &= ~MS_RDONLY;
1172                        continue;
1173                }
1174                if (!strcmp(line,"debug")) {
1175                        console_loglevel = 10;
1176                        continue;
1177                }
1178                if (!strncmp(line,"init=",5)) {
1179                        line += 5;
1180                        execute_command = line;
1181                        /* In case LILO is going to boot us with default command line,
1182                         * it prepends "auto" before the whole cmdline which makes
1183                         * the shell think it should execute a script with such name.
1184                         * So we ignore all arguments entered _before_ init=... [MJ]
1185                         */
1186                        args = 0;
1187                        continue;
1188                }
1189                if (checksetup(line))
1190                        continue;
1191                
1192                /*
1193                 * Then check if it's an environment variable or
1194                 * an option.
1195                 */
1196                if (strchr(line,'=')) {
1197                        if (envs >= MAX_INIT_ENVS)
1198                                break;
1199                        envp_init[++envs] = line;
1200                } else {
1201                        if (args >= MAX_INIT_ARGS)
1202                                break;
1203                        argv_init[++args] = line;
1204                }
1205        }
1206        argv_init[args+1] = NULL;
1207        envp_init[envs+1] = NULL;
1208}
1209
1210
1211extern void setup_arch(char **, unsigned long *, unsigned long *);
1212
1213#ifndef __SMP__
1214
1215/*
1216 *      Uniprocessor idle thread
1217 */
1218 
1219int cpu_idle(void *unused)
1220{
1221        for(;;)
1222                idle();
1223}
1224
1225#define smp_init()      do { } while (0)
1226
1227#else
1228
1229/*
1230 *      Multiprocessor idle thread is in arch/...
1231 */
1232 
1233extern int cpu_idle(void * unused);
1234
1235/* Called by boot processor to activate the rest. */
1236static void __init smp_init(void)
1237{
1238        /* Get other processors into their bootup holding patterns. */
1239        smp_boot_cpus();
1240        smp_threads_ready=1;
1241        smp_commence();
1242}               
1243
1244#endif
1245
1246extern void initialize_secondary(void);
1247
1248/*
1249 *      Activate the first processor.
1250 */
1251 
1252asmlinkage void __init start_kernel(void)
1253{
1254        char * command_line;
1255
1256#ifdef __SMP__
1257        static int boot_cpu = 1;
1258        /* "current" has been set up, we need to load it now */
1259        if (!boot_cpu)
1260                initialize_secondary();
1261        boot_cpu = 0;
1262#endif
1263
1264/*
1265 * Interrupts are still disabled. Do necessary setups, then
1266 * enable them
1267 */
1268        printk(linux_banner);
1269        setup_arch(&command_line, &memory_start, &memory_end);
1270        memory_start = paging_init(memory_start,memory_end);
1271        trap_init();
1272        memory_start = init_IRQ( memory_start );
1273        sched_init();
1274        time_init();
1275        parse_options(command_line);
1276
1277        /*
1278         * HACK ALERT! This is early. We're enabling the console before
1279         * we've done PCI setups etc, and console_init() must be aware of
1280         * this. But we do want output early, in case something goes wrong.
1281         */
1282        memory_start = console_init(memory_start,memory_end);
1283#ifdef CONFIG_MODULES
1284        init_modules();
1285#endif
1286        if (prof_shift) {
1287                prof_buffer = (unsigned int *) memory_start;
1288                /* only text is profiled */
1289                prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
1290                prof_len >>= prof_shift;
1291                memory_start += prof_len * sizeof(unsigned int);
1292                memset(prof_buffer, 0, prof_len * sizeof(unsigned int));
1293        }
1294
1295        memory_start = kmem_cache_init(memory_start, memory_end);
1296        sti();
1297        calibrate_delay();
1298#ifdef CONFIG_BLK_DEV_INITRD
1299        if (initrd_start && !initrd_below_start_ok && initrd_start < memory_start) {
1300                printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
1301                    "disabling it.\n",initrd_start,memory_start);
1302                initrd_start = 0;
1303        }
1304#endif
1305        mem_init(memory_start,memory_end);
1306        kmem_cache_sizes_init();
1307#ifdef CONFIG_3215_CONSOLE
1308        con3215_activate();
1309#endif
1310#ifdef CONFIG_PROC_FS
1311        proc_root_init();
1312#endif
1313        uidcache_init();
1314        filescache_init();
1315        dcache_init();
1316        vma_init();
1317        buffer_init(memory_end-memory_start);
1318        page_cache_init(memory_end-memory_start);
1319        signals_init();
1320        inode_init();
1321        file_table_init();
1322#if defined(CONFIG_SYSVIPC)
1323        ipc_init();
1324#endif
1325#if defined(CONFIG_QUOTA)
1326        dquot_init_hash();
1327#endif
1328        check_bugs();
1329        printk("POSIX conformance testing by UNIFIX\n");
1330
1331        /* 
1332         *      We count on the initial thread going ok 
1333         *      Like idlers init is an unlocked kernel thread, which will
1334         *      make syscalls (and thus be locked).
1335         */
1336        smp_init();
1337        kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1338        current->need_resched = 1;
1339        cpu_idle(NULL);
1340}
1341
1342#ifdef CONFIG_BLK_DEV_INITRD
1343static int do_linuxrc(void * shell)
1344{
1345        static char *argv[] = { "linuxrc", NULL, };
1346
1347        close(0);close(1);close(2);
1348        setsid();
1349        (void) open("/dev/console",O_RDWR,0);
1350        (void) dup(0);
1351        (void) dup(0);
1352        return execve(shell, argv, envp_init);
1353}
1354
1355static void __init no_initrd(char *s,int *ints)
1356{
1357        mount_initrd = 0;
1358}
1359#endif
1360
1361struct task_struct *child_reaper = &init_task;
1362
1363/*
1364 * Ok, the machine is now initialized. None of the devices
1365 * have been touched yet, but the CPU subsystem is up and
1366 * running, and memory and process management works.
1367 *
1368 * Now we can finally start doing some real work..
1369 */
1370static void __init do_basic_setup(void)
1371{
1372#ifdef CONFIG_BLK_DEV_INITRD
1373        int real_root_mountflags;
1374#endif
1375
1376        /*
1377         * Tell the world that we're going to be the grim
1378         * reaper of innocent orphaned children.
1379         *
1380         * We don't want people to have to make incorrect
1381         * assumptions about where in the task array this
1382         * can be found.
1383         */
1384        child_reaper = current;
1385
1386#if defined(CONFIG_MTRR)        /* Do this after SMP initialization */
1387/*
1388 * We should probably create some architecture-dependent "fixup after
1389 * everything is up" style function where this would belong better
1390 * than in init/main.c..
1391 */
1392        mtrr_init();
1393#endif
1394
1395#ifdef CONFIG_SYSCTL
1396        sysctl_init();
1397#endif
1398
1399        /*
1400         * Ok, at this point all CPU's should be initialized, so
1401         * we can start looking into devices..
1402         */
1403#ifdef CONFIG_PCI
1404        pci_init();
1405#endif
1406#ifdef CONFIG_SBUS
1407        sbus_init();
1408#endif
1409#if defined(CONFIG_PPC)
1410        ppc_init();
1411#endif
1412#ifdef CONFIG_MCA
1413        mca_init();
1414#endif
1415#ifdef CONFIG_ARCH_ACORN
1416        ecard_init();
1417#endif
1418#ifdef CONFIG_ZORRO
1419        zorro_init();
1420#endif
1421#ifdef CONFIG_DIO
1422        dio_init();
1423#endif
1424#ifdef CONFIG_MAC
1425        nubus_init();
1426#endif
1427
1428        /* Networking initialization needs a process context */ 
1429        sock_init();
1430
1431        /* Launch bdflush from here, instead of the old syscall way. */
1432        kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1433        kernel_thread(kupdate, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1434        /* Start the background pageout daemon. */
1435        kswapd_setup();
1436        kernel_thread(kpiod, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1437        kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1438
1439#if CONFIG_AP1000
1440        /* Start the async paging daemon. */
1441        {
1442          extern int asyncd(void *);     
1443          kernel_thread(asyncd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
1444        }
1445#endif
1446
1447#ifdef CONFIG_BLK_DEV_INITRD
1448
1449        real_root_dev = ROOT_DEV;
1450        real_root_mountflags = root_mountflags;
1451        if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY;
1452        else mount_initrd =0;
1453#endif
1454
1455        /* Set up devices .. */
1456        device_setup();
1457
1458        /* .. executable formats .. */
1459        binfmt_setup();
1460
1461        /* .. filesystems .. */
1462        filesystem_setup();
1463
1464#ifdef CONFIG_IRDA
1465        irda_device_init(); /* Must be done after protocol initialization */
1466#endif
1467
1468        /* Mount the root filesystem.. */
1469        mount_root();
1470
1471#ifdef CONFIG_BLK_DEV_INITRD
1472        root_mountflags = real_root_mountflags;
1473        if (mount_initrd && ROOT_DEV != real_root_dev
1474            && MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) {
1475                int error;
1476                int i, pid;
1477
1478                pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
1479                if (pid>0)
1480                        while (pid != wait(&i));
1481                if (MAJOR(real_root_dev) != RAMDISK_MAJOR
1482                     || MINOR(real_root_dev) != 0) {
1483                        error = change_root(real_root_dev,"/initrd");
1484                        if (error)
1485                                printk(KERN_ERR "Change root to /initrd: "
1486                                    "error %d\n",error);
1487                }
1488        }
1489#endif
1490}
1491
1492static int init(void * unused)
1493{
1494        lock_kernel();
1495        do_basic_setup();
1496
1497        /*
1498         * Ok, we have completed the initial bootup, and
1499         * we're essentially up and running. Get rid of the
1500         * initmem segments and start the user-mode stuff..
1501         */
1502        free_initmem();
1503        unlock_kernel();
1504
1505        if (open("/dev/console", O_RDWR, 0) < 0)
1506                printk("Warning: unable to open an initial console.\n");
1507
1508        (void) dup(0);
1509        (void) dup(0);
1510        
1511        /*
1512         * We try each of these until one succeeds.
1513         *
1514         * The Bourne shell can be used instead of init if we are 
1515         * trying to recover a really broken machine.
1516         */
1517
1518        if (execute_command)
1519                execve(execute_command,argv_init,envp_init);
1520        execve("/sbin/init",argv_init,envp_init);
1521        execve("/etc/init",argv_init,envp_init);
1522        execve("/bin/init",argv_init,envp_init);
1523        execve("/bin/sh",argv_init,envp_init);
1524        panic("No init found.  Try passing init= option to kernel.");
1525}
1526
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.