Evan Frey
Linux Engineer
/**linux/init/main.c**Copyright(C)1991,1992LinusTorvalds**GK2/5/95-ChangedtosupportmountingrootfsviaNFS*Addedinitrd&change_root:WernerAlmesberger&HansLermen,Feb'96*Moanearlyifgccisold,avoidingboguskernels-PaulGortmaker,May'96*Simplifiedstartingofinit:Michae
lA.Griffith<[email protected]>*/#define__KERNEL_SYSCALLS__#include<linux/config.h>#include<linux/proc_fs.h>#include<linux/unistd.h>#include<linux/ctype.h>#include<linux/delay.h>#include<linux/utsname.h>#include<linux/ioport.h>#include<linux/init.h>#include<linux
/smp_lock.h>#include<linux/blk.h>#include<linux/hdreg.h>#include<asm/io.h>#include<asm/bugs.h>#ifdefCONFIG_PCI#include<linux/pci.h>#endif#ifdefCONFIG_DIO#include<linux/dio.h>#endif#ifdefCONFIG_ZORRO#include<linux/zorro.h>#endif#ifdefCONFIG_MTRR#include<asm/
mtrr.h>#endif#ifdefCONFIG_APM#include<linux/apm_bios.h>#endif/**Versionsofgccolderthanthatlistedbelowmayactuallycompile*andlinkokay,buttheendproductcanhavesubtleruntimebugs.*Toavoidassociatedbogusbugreports,weflatlyrefusetocompile*withagccthatisknowntobetoo
oldfromtheverybeginning.*/#if__GNUC__<2||(__GNUC__==2&&__GNUC_MINOR__<6)#errorsorry,yourGCCistooold.Itbuildsincorrectkernels.#endifexternchar_stext,_etext;externchar*linux_banner;externintconsole_loglevel;staticintinit(void*);externintbdflush(void*);externi
ntkswapd(void*);externvoidkswapd_setup(void);externvoidinit_IRQ(void);externvoidinit_modules(void);externlongconsole_init(long,long);externvoidsock_init(void);externvoiduidcache_init(void);externvoidmca_init(void);externvoidsbus_init(void);externvoidpowerma
c_init(void);externvoidsysctl_init(void);externvoidfilescache_init(void);externvoidsignals_init(void);externvoiddevice_setup(void);externvoidbinfmt_setup(void);externvoidfree_initmem(void);externvoidfilesystem_setup(void);#ifdefCONFIG_ARCH_ACORNexternvoidec
ard_init(void);#endifexternvoidsmp_setup(char*str,int*ints);#ifdef__i386__externvoidioapic_pirq_setup(char*str,int*ints);externvoidioapic_setup(char*str,int*ints);#endifexternvoidno_scroll(char*str,int*ints);externvoidkbd_reset_setup(char*str,int*ints);exte
rnvoidpanic_setup(char*str,int*ints);externvoidbmouse_setup(char*str,int*ints);externvoidmsmouse_setup(char*str,int*ints);externvoidconsole_setup(char*str,int*ints);#ifdefCONFIG_PRINTERexternvoidlp_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_AMIGAextern
voidjs_am_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_ANALOGexternvoidjs_an_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_ASSASINexternvoidjs_as_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_CONSOLEexternvoidjs_console_setup(char*str,int*ints);#endi
f#ifdefCONFIG_JOY_DB9externvoidjs_db9_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_TURBOGRAFXexternvoidjs_tg_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_LIGHTNINGexternvoidjs_l4_setup(char*str,int*ints);#endifexternvoideth_setup(char*str,int*ints);#i
fdefCONFIG_ARCNET_COM20020externvoidcom20020_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_RIM_Iexternvoidarcrimi_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_COM90xxIOexternvoidcom90io_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_COM90xxex
ternvoidcom90xx_setup(char*str,int*ints);#endif#ifdefCONFIG_DECNETexternvoiddecnet_setup(char*str,int*ints);#endif#ifdefCONFIG_BLK_DEV_XDexternvoidxd_setup(char*str,int*ints);externvoidxd_manual_geo_init(char*str,int*ints);#endif#ifdefCONFIG_BLK_DEV_IDEexte
rnvoidide_setup(char*);#endif#ifdefCONFIG_PARIDE_PDexternvoidpd_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PFexternvoidpf_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PTexternvoidpt_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PGexternvo
idpg_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PCDexternvoidpcd_setup(char*str,int*ints);#endifexternvoidfloppy_setup(char*str,int*ints);externvoidst_setup(char*str,int*ints);externvoidst0x_setup(char*str,int*ints);externvoidadvansys_setup(char*str
,int*ints);externvoidtmc8xx_setup(char*str,int*ints);externvoidt128_setup(char*str,int*ints);externvoidpas16_setup(char*str,int*ints);externvoidgeneric_NCR5380_setup(char*str,int*intr);externvoidgeneric_NCR53C400_setup(char*str,int*intr);externvoidgeneric_N
CR53C400A_setup(char*str,int*intr);externvoidgeneric_DTC3181E_setup(char*str,int*intr);externvoidaha152x_setup(char*str,int*ints);externvoidaha1542_setup(char*str,int*ints);externvoidgdth_setup(char*str,int*ints);externvoidaic7xxx_setup(char*str,int*ints);e
xternvoidAM53C974_setup(char*str,int*ints);externvoidBusLogic_Setup(char*str,int*ints);externvoidncr53c8xx_setup(char*str,int*ints);externvoideata2x_setup(char*str,int*ints);externvoidu14_34f_setup(char*str,int*ints);externvoidfdomain_setup(char*str,int*int
s);externvoidibmmca_scsi_setup(char*str,int*ints);externvoidin2000_setup(char*str,int*ints);externvoidNCR53c406a_setup(char*str,int*ints);externvoidwd7000_setup(char*str,int*ints);externvoiddc390_setup(char*str,int*ints);externvoidscsi_luns_setup(char*str,i
nt*ints);externvoidscsi_logging_setup(char*str,int*ints);externvoidsound_setup(char*str,int*ints);externvoidreboot_setup(char*str,int*ints);externvoidvideo_setup(char*str,int*ints);#ifdefCONFIG_CDU31Aexternvoidcdu31a_setup(char*str,int*ints);#endifCONFIG_CD
U31A#ifdefCONFIG_BLK_DEV_PS2externvoided_setup(char*str,int*ints);externvoidtp720_setup(char*str,int*ints);#endifCONFIG_BLK_DEV_PS2#ifdefCONFIG_MCDexternvoidmcd_setup(char*str,int*ints);#endifCONFIG_MCD#ifdefCONFIG_MCDXexternvoidmcdx_setup(char*str,int*ints
);#endifCONFIG_MCDX#ifdefCONFIG_SBPCDexternvoidsbpcd_setup(char*str,int*ints);#endifCONFIG_SBPCD#ifdefCONFIG_AZTCDexternvoidaztcd_setup(char*str,int*ints);#endifCONFIG_AZTCD#ifdefCONFIG_CDU535externvoidsonycd535_setup(char*str,int*ints);#endifCONFIG_CDU535#
ifdefCONFIG_GSCDexternvoidgscd_setup(char*str,int*ints);#endifCONFIG_GSCD#ifdefCONFIG_CM206externvoidcm206_setup(char*str,int*ints);#endifCONFIG_CM206#ifdefCONFIG_OPTCDexternvoidoptcd_setup(char*str,int*ints);#endifCONFIG_OPTCD#ifdefCONFIG_SJCDexternvoidsjc
d_setup(char*str,int*ints);#endifCONFIG_SJCD#ifdefCONFIG_ISP16_CDIexternvoidisp16_setup(char*str,int*ints);#endifCONFIG_ISP16_CDI#ifdefCONFIG_BLK_DEV_RAMstaticvoidramdisk_start_setup(char*str,int*ints);staticvoidload_ramdisk(char*str,int*ints);staticvoidpro
mpt_ramdisk(char*str,int*ints);staticvoidramdisk_size(char*str,int*ints);#ifdefCONFIG_BLK_DEV_INITRDstaticvoidno_initrd(char*s,int*ints);#endif#endifCONFIG_BLK_DEV_RAM#ifdefCONFIG_ISDN_DRV_ICNexternvoidicn_setup(char*str,int*ints);#endif#ifdefCONFIG_ISDN_DR
V_HISAXexternvoidHiSax_setup(char*str,int*ints);#endif#ifdefCONFIG_DIGIEPCAexternvoidepca_setup(char*str,int*ints);#endif#ifdefCONFIG_ISDN_DRV_PCBITexternvoidpcbit_setup(char*str,int*ints);#endif#ifdefCONFIG_ATARIMOUSEexternvoidatari_mouse_setup(char*str,in
t*ints);#endif#ifdefCONFIG_DMASOUNDexternvoiddmasound_setup(char*str,int*ints);#endif#ifdefCONFIG_ATARI_SCSIexternvoidatari_scsi_setup(char*str,int*ints);#endifexternvoidstram_swap_setup(char*str,int*ints);externvoidwd33c93_setup(char*str,int*ints);externvo
idgvp11_setup(char*str,int*ints);externvoidncr53c7xx_setup(char*str,int*ints);#ifdefCONFIG_MAC_SCSIexternvoidmac_scsi_setup(char*str,int*ints);#endif#ifdefCONFIG_CYCLADESexternvoidcy_setup(char*str,int*ints);#endif#ifdefCONFIG_DIGIexternvoidpcxx_setup(char*
str,int*ints);#endif#ifdefCONFIG_RISCOM8externvoidriscom8_setup(char*str,int*ints);#endif#ifdefCONFIG_SPECIALIXexternvoidspecialix_setup(char*str,int*ints);#endif#ifdefCONFIG_DMASCCexternvoiddmascc_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_PARexter
nvoidbaycom_par_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_SER_FDXexternvoidbaycom_ser_fdx_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_SER_HDXexternvoidbaycom_ser_hdx_setup(char*str,int*ints);#endif#ifdefCONFIG_SOUNDMODEMexternvoidsm_setup(ch
ar*str,int*ints);#endif#ifdefCONFIG_ADBMOUSEexternvoidadb_mouse_setup(char*str,int*ints);#endif#ifdefCONFIG_WDTexternvoidwdt_setup(char*str,int*ints);#endif#ifdefCONFIG_PARPORTexternvoidparport_setup(char*str,int*ints);#endif#ifdefCONFIG_PLIPexternvoidplip_
setup(char*str,int*ints);#endif#ifdefCONFIG_HFMODEMexternvoidhfmodem_setup(char*str,int*ints);#endif#ifdefCONFIG_IP_PNPexternvoidip_auto_config_setup(char*str,int*ints);#endif#ifdefCONFIG_ROOT_NFSexternvoidnfs_root_setup(char*str,int*ints);#endif#ifdefCONFI
G_FTAPEexternvoidftape_setup(char*str,int*ints);#endif#ifdefCONFIG_MDA_CONSOLEexternvoidmdacon_setup(char*str,int*ints);#endif#ifdefCONFIG_LTPCexternvoidltpc_setup(char*str,int*ints);#endif#ifdefined(CONFIG_SYSVIPC)externvoidipc_init(void);#endif#ifdefined(
CONFIG_QUOTA)externvoiddquot_init_hash(void);#endif#ifdefCONFIG_MD_BOOTexternvoidmd_setup(char*str,int*ints)__init;#endif/**Bootcommand-linearguments*/#defineMAX_INIT_ARGS8#defineMAX_INIT_ENVS8externvoidtime_init(void);staticunsignedlongmemory_start=0;stati
cunsignedlongmemory_end=0;introws,cols;#ifdefCONFIG_BLK_DEV_RAMexternintrd_doload;/*1=loadramdisk,0=don'tload*/externintrd_prompt;/*1=promptforramdisk,0=don'tprompt*/externintrd_size;/*Sizeoftheramdisk(s)*/externintrd_image_start;/*startingblock#ofimage*/#i
fdefCONFIG_BLK_DEV_INITRDkdev_treal_root_dev;#endif#endifintroot_mountflags=MS_RDONLY;char*execute_command=NULL;staticchar*argv_init[MAX_INIT_ARGS+2]={"init",NULL,};staticchar*envp_init[MAX_INIT_ENVS+2]={"HOME=/","TERM=linux",NULL,};char*get_options(char*st
r,int*ints){char*cur=str;inti=1;while(cur&&(*cur=='-'||isdigit(*cur))&&i<=10){ints[i++]=simple_strtol(cur,NULL,0);if((cur=strchr(cur,','))!=NULL)cur++;}ints[0]=i-1;return(cur);}staticvoid__initprofile_setup(char*str,int*ints){if(ints[0]>0)prof_shift=(unsign
edlong)ints[1];elseprof_shift=2;}staticstructdev_name_struct{constchar*name;constintnum;}root_dev_names[]__initdata={#ifdefCONFIG_ROOT_NFS{"nfs",0x00ff},#endif#ifdefCONFIG_BLK_DEV_IDE{"hda",0x0300},{"hdb",0x0340},{"hdc",0x1600},{"hdd",0x1640},{"hde",0x2100}
,{"hdf",0x2140},{"hdg",0x2200},{"hdh",0x2240},{"hdi",0x3800},{"hdj",0x3840},{"hdk",0x3900},{"hdl",0x3940},#endif#ifdefCONFIG_BLK_DEV_SD{"sda",0x0800},{"sdb",0x0810},{"sdc",0x0820},{"sdd",0x0830},{"sde",0x0840},{"sdf",0x0850},{"sdg",0x0860},{"sdh",0x0870},{"
sdi",0x0880},{"sdj",0x0890},{"sdk",0x08a0},{"sdl",0x08b0},{"sdm",0x08c0},{"sdn",0x08d0},{"sdo",0x08e0},{"sdp",0x08f0},#endif#ifdefCONFIG_ATARI_ACSI{"ada",0x1c00},{"adb",0x1c10},{"adc",0x1c20},{"add",0x1c30},{"ade",0x1c40},#endif#ifdefCONFIG_BLK_DEV_FD{"fd",
0x0200},#endif#ifdefCONFIG_MD_BOOT{"md",0x0900},#endif#ifdefCONFIG_BLK_DEV_XD{"xda",0x0d00},{"xdb",0x0d40},#endif#ifdefCONFIG_BLK_DEV_RAM{"ram",0x0100},#endif#ifdefCONFIG_BLK_DEV_SR{"scd",0x0b00},#endif#ifdefCONFIG_MCD{"mcd",0x1700},#endif#ifdefCONFIG_CDU53
5{"cdu535",0x1800},{"sonycd",0x1800},#endif#ifdefCONFIG_AZTCD{"aztcd",0x1d00},#endif#ifdefCONFIG_CM206{"cm206cd",0x2000},#endif#ifdefCONFIG_GSCD{"gscd",0x1000},#endif#ifdefCONFIG_SBPCD{"sbpcd",0x1900},#endif#ifdefCONFIG_BLK_DEV_PS2{"eda",0x2400},{"edb",0x24
40},#endif#ifdefCONFIG_PARIDE_PD{"pda",0x2d00},{"pdb",0x2d10},{"pdc",0x2d20},{"pdd",0x2d30},#endif#ifdefCONFIG_PARIDE_PCD{"pcd",0x2e00},#endif#ifdefCONFIG_PARIDE_PF{"pf",0x2f00},#endif#ifCONFIG_APBLOCK{"apblock",APBLOCK_MAJOR<<8},#endif#ifCONFIG_DDV{"ddv",D
DV_MAJOR<<8},#endif{NULL,0}};kdev_t__initname_to_kdev_t(char*line){intbase=0;if(strncmp(line,"/dev/",5)==0){structdev_name_struct*dev=root_dev_names;line+=5;do{intlen=strlen(dev->name);if(strncmp(line,dev->name,len)==0){line+=len;base=dev->num;break;}dev++;
}while(dev->name);}returnto_kdev_t(base+simple_strtoul(line,NULL,base?10:16));}staticvoid__initroot_dev_setup(char*line,int*num){ROOT_DEV=name_to_kdev_t(line);}/**Listofkernelcommandlineparameters.Thefirsttablelistsparameters*whicharesubjecttovaluesparsing(
leadingnumbersareconvertedto*anarrayofintsandchoppedoffthestring),thesecondtablecontains*thefewexceptionswhichobeytheirownsyntaxrules.*/structkernel_param{constchar*str;void(*setup_func)(char*,int*);};staticstructkernel_paramcooked_params[]__initdata={/*FIX
ME:makePNPjustbecomereserve_setup*/#ifndefCONFIG_KERNEL_PNP_RESOURCE{"reserve=",reserve_setup},#else{"reserve=",pnp_reserve_setup},#endif{"profile=",profile_setup},#ifdef__SMP__{"nosmp",smp_setup},{"maxcpus=",smp_setup},#ifdefCONFIG_X86_IO_APIC{"noapic",ioa
pic_setup},{"pirq=",ioapic_pirq_setup},#endif#endif#ifdefCONFIG_BLK_DEV_RAM{"ramdisk_start=",ramdisk_start_setup},{"load_ramdisk=",load_ramdisk},{"prompt_ramdisk=",prompt_ramdisk},{"ramdisk=",ramdisk_size},{"ramdisk_size=",ramdisk_size},#ifdefCONFIG_BLK_DEV
_INITRD{"noinitrd",no_initrd},#endif#endif#ifdefCONFIG_FB{"video=",video_setup},#endif{"panic=",panic_setup},{"console=",console_setup},#ifdefCONFIG_VGA_CONSOLE{"no-scroll",no_scroll},#endif#ifdefCONFIG_MDA_CONSOLE{"mdacon=",mdacon_setup},#endif#ifdefCONFIG
_VT{"kbd-reset",kbd_reset_setup},#endif#ifdefCONFIG_BUGi386{"no-hlt",no_halt},{"no387",no_387},{"reboot=",reboot_setup},#endif#ifdefCONFIG_INET{"ether=",eth_setup},#endif#ifdefCONFIG_ARCNET_COM20020{"com20020=",com20020_setup},#endif#ifdefCONFIG_ARCNET_RIM_
I{"arcrimi=",arcrimi_setup},#endif#ifdefCONFIG_ARCNET_COM90xxIO{"com90io=",com90io_setup},#endif#ifdefCONFIG_ARCNET_COM90xx{"com90xx=",com90xx_setup},#endif#ifdefCONFIG_DECNET{"decnet=",decnet_setup},#endif#ifdefCONFIG_PRINTER{"lp=",lp_setup},#endif#ifdefCO
NFIG_JOY_AMIGA{"js_am=",js_am_setup},#endif#ifdefCONFIG_JOY_ANALOG{"js_an=",js_an_setup},#endif#ifdefCONFIG_JOY_ASSASIN{"js_as=",js_as_setup},#endif#ifdefCONFIG_JOY_CONSOLE{"js_console=",js_console_setup},{"js_console2=",js_console_setup},{"js_console3=",js
_console_setup},#endif#ifdefCONFIG_JOY_DB9{"js_db9=",js_db9_setup},{"js_db9_2=",js_db9_setup},{"js_db9_3=",js_db9_setup},#endif#ifdefCONFIG_JOY_TURBOGRAFX{"js_tg=",js_tg_setup},{"js_tg_2=",js_tg_setup},{"js_tg_3=",js_tg_setup},#endif#ifdefCONFIG_SCSI{"max_s
csi_luns=",scsi_luns_setup},{"scsi_logging=",scsi_logging_setup},#endif#ifdefCONFIG_JOY_LIGHTNING{"js_l4=",js_l4_setup},#endif#ifdefCONFIG_SCSI_ADVANSYS{"advansys=",advansys_setup},#endif#ifdefined(CONFIG_BLK_DEV_HD){"hd=",hd_setup},#endif#ifdefCONFIG_CHR_D
EV_ST{"st=",st_setup},#endif#ifdefCONFIG_BUSMOUSE{"bmouse=",bmouse_setup},#endif#ifdefCONFIG_MS_BUSMOUSE{"msmouse=",msmouse_setup},#endif#ifdefCONFIG_SCSI_SEAGATE{"st0x=",st0x_setup},{"tmc8xx=",tmc8xx_setup},#endif#ifdefCONFIG_SCSI_T128{"t128=",t128_setup},
#endif#ifdefCONFIG_SCSI_PAS16{"pas16=",pas16_setup},#endif#ifdefCONFIG_SCSI_GENERIC_NCR5380{"ncr5380=",generic_NCR5380_setup},{"ncr53c400=",generic_NCR53C400_setup},{"ncr53c400a=",generic_NCR53C400A_setup},{"dtc3181e=",generic_DTC3181E_setup},#endif#ifdefCO
NFIG_SCSI_AHA152X{"aha152x=",aha152x_setup},#endif#ifdefCONFIG_SCSI_AHA1542{"aha1542=",aha1542_setup},#endif#ifdefCONFIG_SCSI_GDTH{"gdth=",gdth_setup},#endif#ifdefCONFIG_SCSI_AIC7XXX{"aic7xxx=",aic7xxx_setup},#endif#ifdefCONFIG_SCSI_BUSLOGIC{"BusLogic=",Bus
Logic_Setup},#endif#ifdefCONFIG_SCSI_NCR53C8XX{"ncr53c8xx=",ncr53c8xx_setup},#endif#ifdefCONFIG_SCSI_EATA{"eata=",eata2x_setup},#endif#ifdefCONFIG_SCSI_U14_34F{"u14-34f=",u14_34f_setup},#endif#ifdefCONFIG_SCSI_AM53C974{"AM53C974=",AM53C974_setup},#endif#ifd
efCONFIG_SCSI_NCR53C406A{"ncr53c406a=",NCR53c406a_setup},#endif#ifdefCONFIG_SCSI_FUTURE_DOMAIN{"fdomain=",fdomain_setup},#endif#ifdefCONFIG_SCSI_IN2000{"in2000=",in2000_setup},#endif#ifdefCONFIG_SCSI_7000FASST{"wd7000=",wd7000_setup},#endif#ifdefCONFIG_SCSI
_IBMMCA{"ibmmcascsi=",ibmmca_scsi_setup},#endif#ifdefined(CONFIG_SCSI_DC390T)&&!defined(CONFIG_SCSI_DC390T_NOGENSUPP){"tmscsim=",dc390_setup},#endif#ifdefCONFIG_BLK_DEV_XD{"xd=",xd_setup},{"xd_geo=",xd_manual_geo_init},#endif#ifdefined(CONFIG_BLK_DEV_FD)||d
efined(CONFIG_AMIGA_FLOPPY)||defined(CONFIG_ATARI_FLOPPY){"floppy=",floppy_setup},#endif#ifdefCONFIG_BLK_DEV_PS2{"eda=",ed_setup},{"edb=",ed_setup},{"tp720=",tp720_setup},#endif#ifdefCONFIG_CDU31A{"cdu31a=",cdu31a_setup},#endifCONFIG_CDU31A#ifdefCONFIG_MCD{
"mcd=",mcd_setup},#endifCONFIG_MCD#ifdefCONFIG_MCDX{"mcdx=",mcdx_setup},#endifCONFIG_MCDX#ifdefCONFIG_SBPCD{"sbpcd=",sbpcd_setup},#endifCONFIG_SBPCD#ifdefCONFIG_AZTCD{"aztcd=",aztcd_setup},#endifCONFIG_AZTCD#ifdefCONFIG_CDU535{"sonycd535=",sonycd535_setup},
#endifCONFIG_CDU535#ifdefCONFIG_GSCD{"gscd=",gscd_setup},#endifCONFIG_GSCD#ifdefCONFIG_CM206{"cm206=",cm206_setup},#endifCONFIG_CM206#ifdefCONFIG_OPTCD{"optcd=",optcd_setup},#endifCONFIG_OPTCD#ifdefCONFIG_SJCD{"sjcd=",sjcd_setup},#endifCONFIG_SJCD#ifdefCONF
IG_ISP16_CDI{"isp16=",isp16_setup},#endifCONFIG_ISP16_CDI#ifdefCONFIG_SOUND_OSS{"sound=",sound_setup},#endif#ifdefCONFIG_ISDN_DRV_ICN{"icn=",icn_setup},#endif#ifdefCONFIG_ISDN_DRV_HISAX{"hisax=",HiSax_setup},{"HiSax=",HiSax_setup},#endif#ifdefCONFIG_ISDN_DR
V_PCBIT{"pcbit=",pcbit_setup},#endif#ifdefCONFIG_ATARIMOUSE{"atamouse=",atari_mouse_setup},#endif#ifdefCONFIG_DMASOUND{"dmasound=",dmasound_setup},#endif#ifdefCONFIG_ATARI_SCSI{"atascsi=",atari_scsi_setup},#endif#ifdefCONFIG_STRAM_SWAP{"stram_swap=",stram_s
wap_setup},#endif#ifdefined(CONFIG_A4000T_SCSI)||defined(CONFIG_WARPENGINE_SCSI)\||defined(CONFIG_A4091_SCSI)||defined(CONFIG_MVME16x_SCSI)\||defined(CONFIG_BVME6000_SCSI){"53c7xx=",ncr53c7xx_setup},#endif#ifdefined(CONFIG_A3000_SCSI)||defined(CONFIG_A2091_
SCSI)\||defined(CONFIG_GVP11_SCSI){"wd33c93=",wd33c93_setup},#endif#ifdefined(CONFIG_GVP11_SCSI){"gvp11=",gvp11_setup},#endif#ifdefCONFIG_MAC_SCSI{"mac5380=",mac_scsi_setup},#endif#ifdefCONFIG_CYCLADES{"cyclades=",cy_setup},#endif#ifdefCONFIG_DIGI{"digi=",p
cxx_setup},#endif#ifdefCONFIG_DIGIEPCA{"digiepca=",epca_setup},#endif#ifdefCONFIG_RISCOM8{"riscom8=",riscom8_setup},#endif#ifdefCONFIG_DMASCC{"dmascc=",dmascc_setup},#endif#ifdefCONFIG_SPECIALIX{"specialix=",specialix_setup},#endif#ifdefCONFIG_BAYCOM_PAR{"b
aycom_par=",baycom_par_setup},#endif#ifdefCONFIG_BAYCOM_SER_FDX{"baycom_ser_fdx=",baycom_ser_fdx_setup},#endif#ifdefCONFIG_BAYCOM_SER_HDX{"baycom_ser_hdx=",baycom_ser_hdx_setup},#endif#ifdefCONFIG_SOUNDMODEM{"soundmodem=",sm_setup},#endif#ifdefCONFIG_WDT{"w
dt=",wdt_setup},#endif#ifdefCONFIG_PARPORT{"parport=",parport_setup},#endif#ifdefCONFIG_PLIP{"plip=",plip_setup},#endif#ifdefCONFIG_HFMODEM{"hfmodem=",hfmodem_setup},#endif#ifdefCONFIG_FTAPE{"ftape=",ftape_setup},#endif#ifdefCONFIG_MD_BOOT{"md=",md_setup},#
endif#ifdefCONFIG_ADBMOUSE{"adb_buttons=",adb_mouse_setup},#endif#ifdefCONFIG_LTPC{"ltpc=",ltpc_setup},#endif{0,0}};staticstructkernel_paramraw_params[]__initdata={{"root=",root_dev_setup},#ifdefCONFIG_ROOT_NFS{"nfsroot=",nfs_root_setup},{"nfsaddrs=",ip_aut
o_config_setup},#endif#ifdefCONFIG_IP_PNP{"ip=",ip_auto_config_setup},#endif#ifdefCONFIG_PCI{"pci=",pci_setup},#endif#ifdefCONFIG_PARIDE_PD{"pd.",pd_setup},#endif#ifdefCONFIG_PARIDE_PCD{"pcd.",pcd_setup},#endif#ifdefCONFIG_PARIDE_PF{"pf.",pf_setup},#endif#i
fdefCONFIG_PARIDE_PT{"pt.",pt_setup},#endif#ifdefCONFIG_PARIDE_PG{"pg.",pg_setup},#endif#ifdefCONFIG_APM{"apm=",apm_setup},#endif{0,0}};#ifdefCONFIG_BLK_DEV_RAMstaticvoid__initramdisk_start_setup(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_image_start=in
ts[1];}staticvoid__initload_ramdisk(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_doload=ints[1]&1;}staticvoid__initprompt_ramdisk(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_prompt=ints[1]&1;}staticvoid__initramdisk_size(char*str,int*ints){if(ints[0]>0
&&ints[1]>=0)rd_size=ints[1];}#endifstaticint__initchecksetup(char*line){inti,ints[11];#ifdefCONFIG_BLK_DEV_IDE/*idedriverneedsthebasicstring,ratherthanpre-processedvalues*/if(!strncmp(line,"ide",3)||(!strncmp(line,"hd",2)&&line[2]!='=')){ide_setup(line);re
turn1;}#endiffor(i=0;raw_params[i].str;i++){intn=strlen(raw_params[i].str);if(!strncmp(line,raw_params[i].str,n)){raw_params[i].setup_func(line+n,NULL);return1;}}for(i=0;cooked_params[i].str;i++){intn=strlen(cooked_params[i].str);if(!strncmp(line,cooked_par
ams[i].str,n)){cooked_params[i].setup_func(get_options(line+n,ints),ints);return1;}}return0;}/*thisshouldbeapprox2Bo*oMipstostart(noteinitialshift),andwillstillworkevenifinitiallytoolarge,itwilljusttakeslightlylonger*/unsignedlongloops_per_sec=(1<<12);/*Thi
sisthenumberofbitsofprecisionfortheloops_per_second.Eachbittakesonaverage1.5/HZseconds.This(liketheoriginal)isalittlebetterthan1%*/#defineLPS_PREC8void__initcalibrate_delay(void){unsignedlongticks,loopbit;intlps_precision=LPS_PREC;loops_per_sec=(1<<12);prin
tk("Calibratingdelayloop...");while(loops_per_sec<<=1){/*waitfor"startof"clocktick*/ticks=jiffies;while(ticks==jiffies)/*nothing*/;/*Go..*/ticks=jiffies;__delay(loops_per_sec);ticks=jiffies-ticks;if(ticks)break;}/*Doabinaryapproximationtogetloops_per_second
settoequaloneclock(uptolps_precisionbits)*/loops_per_sec>>=1;loopbit=loops_per_sec;while(lps_precision--&&(loopbit>>=1)){loops_per_sec|=loopbit;ticks=jiffies;while(ticks==jiffies);ticks=jiffies;__delay(loops_per_sec);if(jiffies!=ticks)/*longerthan1tick*/loo
ps_per_sec&=~loopbit;}/*finally,adjustloopspersecondintermsofsecondsinsteadofclocks*/loops_per_sec*=HZ;/*Roundthevalueandprintit*/printk("%lu.%02luBogoMIPS\n",(loops_per_sec+2500)/500000,((loops_per_sec+2500)/5000)%100);}/**Thisisasimplekernelcommandlinepar
singfunction:itparses*thecommandline,andfillsinthearguments/environmenttoinit*asappropriate.Anycmd-lineoptionistakentobeanenvironment*variableifitcontainsthecharacter'='.**Thisroutinealsochecksforoptionsmeantforthekernel.*Theseoptionsarenotgiventoinit-theya
reforinternalkerneluseonly.*/staticvoid__initparse_options(char*line){char*next;intargs,envs;if(!*line)return;args=0;envs=1;/*TERMissetto'linux'bydefault*/next=line;while((line=next)!=NULL){if((next=strchr(line,''))!=NULL)*next++=0;/**checkforkerneloptionsf
irst..*/if(!strcmp(line,"ro")){root_mountflags|=MS_RDONLY;continue;}if(!strcmp(line,"rw")){root_mountflags&=~MS_RDONLY;continue;}if(!strcmp(line,"debug")){console_loglevel=10;continue;}if(!strncmp(line,"init=",5)){line+=5;execute_command=line;/*IncaseLILOis
goingtobootuswithdefaultcommandline,*itprepends"auto"beforethewholecmdlinewhichmakes*theshellthinkitshouldexecuteascriptwithsuchname.*Soweignoreallargumentsentered_before_init=...[MJ]*/args=0;continue;}if(checksetup(line))continue;/**Thencheckifit'sanenviro
nmentvariableor*anoption.*/if(strchr(line,'=')){if(envs>=MAX_INIT_ENVS)break;envp_init[++envs]=line;}else{if(args>=MAX_INIT_ARGS)break;argv_init[++args]=line;}}argv_init[args+1]=NULL;envp_init[envs+1]=NULL;}externvoidsetup_arch(char**,unsignedlong*,unsigned
long*);#ifndef__SMP__/**Uniprocessoridlethread*/intcpu_idle(void*unused){for(;;)idle();}#definesmp_init()do{}while(0)#else/**Multiprocessoridlethreadisinarch/...*/externintcpu_idle(void*unused);/*Calledbybootprocessortoactivatetherest.*/staticvoid__initsmp_
init(void){/*Getotherprocessorsintotheirbootupholdingpatterns.*/smp_boot_cpus();smp_threads_ready=1;smp_commence();}#endifexternvoidinitialize_secondary(void);/**Activatethefirstprocessor.*/asmlinkagevoid__initstart_kernel(void){char*command_line;#ifdef__SM
P__staticintboot_cpu=1;/*"current"hasbeensetup,weneedtoloaditnow*/if(!boot_cpu)initialize_secondary();boot_cpu=0;#endif/**Interruptsarestilldisabled.Donecessarysetups,then*enablethem*/printk(linux_banner);setup_arch(&command_line,&memory_start,&memory_end);
memory_start=paging_init(memory_start,memory_end);trap_init();init_IRQ();sched_init();time_init();parse_options(command_line);/**HACKALERT!Thisisearly.We'reenablingtheconsolebefore*we'vedonePCIsetupsetc,andconsole_init()mustbeawareof*this.Butwedowantoutpute
arly,incasesomethinggoeswrong.*/memory_start=console_init(memory_start,memory_end);#ifdefCONFIG_MODULESinit_modules();#endifif(prof_shift){prof_buffer=(unsignedint*)memory_start;/*onlytextisprofiled*/prof_len=(unsignedlong)&_etext-(unsignedlong)&_stext;prof
_len>>=prof_shift;memory_start+=prof_len*sizeof(unsignedint);memset(prof_buffer,0,prof_len*sizeof(unsignedint));}memory_start=kmem_cache_init(memory_start,memory_end);sti();calibrate_delay();#ifdefCONFIG_BLK_DEV_INITRDif(initrd_start&&!initrd_below_start_ok
&&initrd_start<memory_start){printk(KERN_CRIT"initrdoverwritten(0x%08lx<0x%08lx)-""disablingit.\n",initrd_start,memory_start);initrd_start=0;}#endifmem_init(memory_start,memory_end);kmem_cache_sizes_init();#ifdefCONFIG_PROC_FSproc_root_init();#endifuidcache
_init();filescache_init();dcache_init();vma_init();buffer_init();signals_init();inode_init();file_table_init();#ifdefined(CONFIG_SYSVIPC)ipc_init();#endif#ifdefined(CONFIG_QUOTA)dquot_init_hash();#endifcheck_bugs();printk("POSIXconformancetestingbyUNIFIX\n"
);/**Wecountontheinitialthreadgoingok*Likeidlersinitisanunlockedkernelthread,whichwill*makesyscalls(andthusbelocked).*/smp_init();kernel_thread(init,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);current->need_resched=1;cpu_idle(NULL);}#ifdefCONFIG_BLK_DEV_INITRD
staticintdo_linuxrc(void*shell){staticchar*argv[]={"linuxrc",NULL,};close(0);close(1);close(2);setsid();(void)open("/dev/console",O_RDWR,0);(void)dup(0);(void)dup(0);returnexecve(shell,argv,envp_init);}staticvoid__initno_initrd(char*s,int*ints){mount_initrd
=0;}#endifstructtask_struct*child_reaper=&init_task;/**Ok,themachineisnowinitialized.Noneofthedevices*havebeentouchedyet,buttheCPUsubsystemisupand*running,andmemoryandprocessmanagementworks.**Nowwecanfinallystartdoingsomerealwork..*/staticvoid__initdo_basic
_setup(void){#ifdefCONFIG_BLK_DEV_INITRDintreal_root_mountflags;#endif/**Telltheworldthatwe'regoingtobethegrim*reaperofinnocentorphanedchildren.**Wedon'twantpeopletohavetomakeincorrect*assumptionsaboutwhereinthetaskarraythis*canbefound.*/child_reaper=curren
t;#ifdefined(CONFIG_MTRR)/*DothisafterSMPinitialization*//**Weshouldprobablycreatesomearchitecture-dependent"fixupafter*everythingisup"stylefunctionwherethiswouldbelongbetter*thanininit/main.c..*/mtrr_init();#endif#ifdefCONFIG_SYSCTLsysctl_init();#endif/**O
k,atthispointallCPU'sshouldbeinitialized,so*wecanstartlookingintodevices..*/#ifdefCONFIG_PCIpci_init();#endif#ifdefCONFIG_SBUSsbus_init();#endif#ifdefined(CONFIG_PPC)powermac_init();#endif#ifdefCONFIG_MCAmca_init();#endif#ifdefCONFIG_ARCH_ACORNecard_init();
#endif#ifdefCONFIG_ZORROzorro_init();#endif#ifdefCONFIG_DIOdio_init();#endif/*Networkinginitializationneedsaprocesscontext*/sock_init();/*Launchbdflushfromhere,insteadoftheoldsyscallway.*/kernel_thread(bdflush,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);/*Star
tthebackgroundpageoutdaemon.*/kswapd_setup();kernel_thread(kswapd,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);#ifCONFIG_AP1000/*Starttheasyncpagingdaemon.*/{externintasyncd(void*);kernel_thread(asyncd,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);}#endif#ifdefCONFI
G_BLK_DEV_INITRDreal_root_dev=ROOT_DEV;real_root_mountflags=root_mountflags;if(initrd_start&&mount_initrd)root_mountflags&=~MS_RDONLY;elsemount_initrd=0;#endif/*Setupdevices..*/device_setup();/*..executableformats..*/binfmt_setup();/*..filesystems..*/filesy
stem_setup();/*Mounttherootfilesystem..*/mount_root();#ifdefCONFIG_UMSDOS_FS{/*Whenmountingaumsdosfsasroot,wedetectthepseudo_root(/linux)andinitialiseithere.pseudo_rootisdefinedinfs/umsdos/inode.c*/externstructinode*pseudo_root;if(pseudo_root!=NULL){current
->fs->root=pseudo_root->i_sb->s_root;current->fs->pwd=pseudo_root->i_sb->s_root;}}#endif#ifdefCONFIG_BLK_DEV_INITRDroot_mountflags=real_root_mountflags;if(mount_initrd&&ROOT_DEV!=real_root_dev&&MAJOR(ROOT_DEV)==RAMDISK_MAJOR&&MINOR(ROOT_DEV)==0){interror;in
ti,pid;pid=kernel_thread(do_linuxrc,"/linuxrc",SIGCHLD);if(pid>0)while(pid!=wait(&i));if(MAJOR(real_root_dev)!=RAMDISK_MAJOR||MINOR(real_root_dev)!=0){error=change_root(real_root_dev,"/initrd");if(error)printk(KERN_ERR"Changerootto/initrd:""error%d\n",error
);}}#endif}staticintinit(void*unused){lock_kernel();do_basic_setup();/**Ok,wehavecompletedtheinitialbootup,and*we'reessentiallyupandrunning.Getridofthe*initmemsegmentsandstarttheuser-modestuff..*/free_initmem();unlock_kernel();if(open("/dev/console",O_RDWR,
0)<0)printk("Warning:unabletoopenaninitialconsole.\n");(void)dup(0);(void)dup(0);/**Wetryeachoftheseuntilonesucceeds.**TheBourneshellcanbeusedinsteadofinitifweare*tryingtorecoverareallybrokenmachine.*/if(execute_command)execve(execute_command,argv_init,envp
_init);execve("/sbin/init",argv_init,envp_init);execve("/etc/init",argv_init,envp_init);execve("/bin/init",argv_init,envp_init);execve("/bin/sh",argv_init,envp_init);panic("Noinitfound.Trypassinginit=optiontokernel.");}/**linux/init/main.c**Copyright(C)1991
,1992LinusTorvalds**GK2/5/95-ChangedtosupportmountingrootfsviaNFS*Addedinitrd&change_root:WernerAlmesberger&HansLermen,Feb'96*Moanearlyifgccisold,avoidingboguskernels-PaulGortmaker,May'96*Simplifiedstartingofinit:MichaelA.Griffith<[email protected]>*/#define__KE
RNEL_SYSCALLS__#include<linux/config.h>#include<linux/proc_fs.h>#include<linux/unistd.h>#include<linux/ctype.h>#include<linux/delay.h>#include<linux/utsname.h>#include<linux/ioport.h>#include<linux/init.h>#include<linux/smp_lock.h>#include<linux/blk.h>#incl
ude<linux/hdreg.h>#include<asm/io.h>#include<asm/bugs.h>#ifdefCONFIG_PCI#include<linux/pci.h>#endif#ifdefCONFIG_DIO#include<linux/dio.h>#endif#ifdefCONFIG_ZORRO#include<linux/zorro.h>#endif#ifdefCONFIG_MTRR#include<asm/mtrr.h>#endif#ifdefCONFIG_APM#include<
linux/apm_bios.h>#endif/**Versionsofgccolderthanthatlistedbelowmayactuallycompile*andlinkokay,buttheendproductcanhavesubtleruntimebugs.*Toavoidassociatedbogusbugreports,weflatlyrefusetocompile*withagccthatisknowntobetoooldfromtheverybeginning.*/#if__GNUC__<
2||(__GNUC__==2&&__GNUC_MINOR__<6)#errorsorry,yourGCCistooold.Itbuildsincorrectkernels.#endifexternchar_stext,_etext;externchar*linux_banner;externintconsole_loglevel;staticintinit(void*);externintbdflush(void*);externintkswapd(void*);externvoidkswapd_setup
(void);externvoidinit_IRQ(void);externvoidinit_modules(void);externlongconsole_init(long,long);externvoidsock_init(void);externvoiduidcache_init(void);externvoidmca_init(void);externvoidsbus_init(void);externvoidpowermac_init(void);externvoidsysctl_init(voi
d);externvoidfilescache_init(void);externvoidsignals_init(void);externvoiddevice_setup(void);externvoidbinfmt_setup(void);externvoidfree_initmem(void);externvoidfilesystem_setup(void);#ifdefCONFIG_ARCH_ACORNexternvoidecard_init(void);#endifexternvoidsmp_set
up(char*str,int*ints);#ifdef__i386__externvoidioapic_pirq_setup(char*str,int*ints);externvoidioapic_setup(char*str,int*ints);#endifexternvoidno_scroll(char*str,int*ints);externvoidkbd_reset_setup(char*str,int*ints);externvoidpanic_setup(char*str,int*ints);e
xternvoidbmouse_setup(char*str,int*ints);externvoidmsmouse_setup(char*str,int*ints);externvoidconsole_setup(char*str,int*ints);#ifdefCONFIG_PRINTERexternvoidlp_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_AMIGAexternvoidjs_am_setup(char*str,int*ints);#en
dif#ifdefCONFIG_JOY_ANALOGexternvoidjs_an_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_ASSASINexternvoidjs_as_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_CONSOLEexternvoidjs_console_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_DB9externvoidjs_db9_
setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_TURBOGRAFXexternvoidjs_tg_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_LIGHTNINGexternvoidjs_l4_setup(char*str,int*ints);#endifexternvoideth_setup(char*str,int*ints);#ifdefCONFIG_ARCNET_COM20020externvoidco
m20020_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_RIM_Iexternvoidarcrimi_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_COM90xxIOexternvoidcom90io_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_COM90xxexternvoidcom90xx_setup(char*str,int*int
s);#endif#ifdefCONFIG_DECNETexternvoiddecnet_setup(char*str,int*ints);#endif#ifdefCONFIG_BLK_DEV_XDexternvoidxd_setup(char*str,int*ints);externvoidxd_manual_geo_init(char*str,int*ints);#endif#ifdefCONFIG_BLK_DEV_IDEexternvoidide_setup(char*);#endif#ifdefCON
FIG_PARIDE_PDexternvoidpd_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PFexternvoidpf_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PTexternvoidpt_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PGexternvoidpg_setup(char*str,int*ints);#endif#i
fdefCONFIG_PARIDE_PCDexternvoidpcd_setup(char*str,int*ints);#endifexternvoidfloppy_setup(char*str,int*ints);externvoidst_setup(char*str,int*ints);externvoidst0x_setup(char*str,int*ints);externvoidadvansys_setup(char*str,int*ints);externvoidtmc8xx_setup(char
*str,int*ints);externvoidt128_setup(char*str,int*ints);externvoidpas16_setup(char*str,int*ints);externvoidgeneric_NCR5380_setup(char*str,int*intr);externvoidgeneric_NCR53C400_setup(char*str,int*intr);externvoidgeneric_NCR53C400A_setup(char*str,int*intr);ext
ernvoidgeneric_DTC3181E_setup(char*str,int*intr);externvoidaha152x_setup(char*str,int*ints);externvoidaha1542_setup(char*str,int*ints);externvoidgdth_setup(char*str,int*ints);externvoidaic7xxx_setup(char*str,int*ints);externvoidAM53C974_setup(char*str,int*i
nts);externvoidBusLogic_Setup(char*str,int*ints);externvoidncr53c8xx_setup(char*str,int*ints);externvoideata2x_setup(char*str,int*ints);externvoidu14_34f_setup(char*str,int*ints);externvoidfdomain_setup(char*str,int*ints);externvoidibmmca_scsi_setup(char*st
r,int*ints);externvoidin2000_setup(char*str,int*ints);externvoidNCR53c406a_setup(char*str,int*ints);externvoidwd7000_setup(char*str,int*ints);externvoiddc390_setup(char*str,int*ints);externvoidscsi_luns_setup(char*str,int*ints);externvoidscsi_logging_setup(
char*str,int*ints);externvoidsound_setup(char*str,int*ints);externvoidreboot_setup(char*str,int*ints);externvoidvideo_setup(char*str,int*ints);#ifdefCONFIG_CDU31Aexternvoidcdu31a_setup(char*str,int*ints);#endifCONFIG_CDU31A#ifdefCONFIG_BLK_DEV_PS2externvoid
ed_setup(char*str,int*ints);externvoidtp720_setup(char*str,int*ints);#endifCONFIG_BLK_DEV_PS2#ifdefCONFIG_MCDexternvoidmcd_setup(char*str,int*ints);#endifCONFIG_MCD#ifdefCONFIG_MCDXexternvoidmcdx_setup(char*str,int*ints);#endifCONFIG_MCDX#ifdefCONFIG_SBPCDe
xternvoidsbpcd_setup(char*str,int*ints);#endifCONFIG_SBPCD#ifdefCONFIG_AZTCDexternvoidaztcd_setup(char*str,int*ints);#endifCONFIG_AZTCD#ifdefCONFIG_CDU535externvoidsonycd535_setup(char*str,int*ints);#endifCONFIG_CDU535#ifdefCONFIG_GSCDexternvoidgscd_setup(c
har*str,int*ints);#endifCONFIG_GSCD#ifdefCONFIG_CM206externvoidcm206_setup(char*str,int*ints);#endifCONFIG_CM206#ifdefCONFIG_OPTCDexternvoidoptcd_setup(char*str,int*ints);#endifCONFIG_OPTCD#ifdefCONFIG_SJCDexternvoidsjcd_setup(char*str,int*ints);#endifCONFI
G_SJCD#ifdefCONFIG_ISP16_CDIexternvoidisp16_setup(char*str,int*ints);#endifCONFIG_ISP16_CDI#ifdefCONFIG_BLK_DEV_RAMstaticvoidramdisk_start_setup(char*str,int*ints);staticvoidload_ramdisk(char*str,int*ints);staticvoidprompt_ramdisk(char*str,int*ints);staticv
oidramdisk_size(char*str,int*ints);#ifdefCONFIG_BLK_DEV_INITRDstaticvoidno_initrd(char*s,int*ints);#endif#endifCONFIG_BLK_DEV_RAM#ifdefCONFIG_ISDN_DRV_ICNexternvoidicn_setup(char*str,int*ints);#endif#ifdefCONFIG_ISDN_DRV_HISAXexternvoidHiSax_setup(char*str,
int*ints);#endif#ifdefCONFIG_DIGIEPCAexternvoidepca_setup(char*str,int*ints);#endif#ifdefCONFIG_ISDN_DRV_PCBITexternvoidpcbit_setup(char*str,int*ints);#endif#ifdefCONFIG_ATARIMOUSEexternvoidatari_mouse_setup(char*str,int*ints);#endif#ifdefCONFIG_DMASOUNDext
ernvoiddmasound_setup(char*str,int*ints);#endif#ifdefCONFIG_ATARI_SCSIexternvoidatari_scsi_setup(char*str,int*ints);#endifexternvoidstram_swap_setup(char*str,int*ints);externvoidwd33c93_setup(char*str,int*ints);externvoidgvp11_setup(char*str,int*ints);exter
nvoidncr53c7xx_setup(char*str,int*ints);#ifdefCONFIG_MAC_SCSIexternvoidmac_scsi_setup(char*str,int*ints);#endif#ifdefCONFIG_CYCLADESexternvoidcy_setup(char*str,int*ints);#endif#ifdefCONFIG_DIGIexternvoidpcxx_setup(char*str,int*ints);#endif#ifdefCONFIG_RISCO
M8externvoidriscom8_setup(char*str,int*ints);#endif#ifdefCONFIG_SPECIALIXexternvoidspecialix_setup(char*str,int*ints);#endif#ifdefCONFIG_DMASCCexternvoiddmascc_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_PARexternvoidbaycom_par_setup(char*str,int*int
s);#endif#ifdefCONFIG_BAYCOM_SER_FDXexternvoidbaycom_ser_fdx_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_SER_HDXexternvoidbaycom_ser_hdx_setup(char*str,int*ints);#endif#ifdefCONFIG_SOUNDMODEMexternvoidsm_setup(char*str,int*ints);#endif#ifdefCONFIG_AD
BMOUSEexternvoidadb_mouse_setup(char*str,int*ints);#endif#ifdefCONFIG_WDTexternvoidwdt_setup(char*str,int*ints);#endif#ifdefCONFIG_PARPORTexternvoidparport_setup(char*str,int*ints);#endif#ifdefCONFIG_PLIPexternvoidplip_setup(char*str,int*ints);#endif#ifdefC
ONFIG_HFMODEMexternvoidhfmodem_setup(char*str,int*ints);#endif#ifdefCONFIG_IP_PNPexternvoidip_auto_config_setup(char*str,int*ints);#endif#ifdefCONFIG_ROOT_NFSexternvoidnfs_root_setup(char*str,int*ints);#endif#ifdefCONFIG_FTAPEexternvoidftape_setup(char*str,
int*ints);#endif#ifdefCONFIG_MDA_CONSOLEexternvoidmdacon_setup(char*str,int*ints);#endif#ifdefCONFIG_LTPCexternvoidltpc_setup(char*str,int*ints);#endif#ifdefined(CONFIG_SYSVIPC)externvoidipc_init(void);#endif#ifdefined(CONFIG_QUOTA)externvoiddquot_init_hash
(void);#endif#ifdefCONFIG_MD_BOOTexternvoidmd_setup(char*str,int*ints)__init;#endif/**Bootcommand-linearguments*/#defineMAX_INIT_ARGS8#defineMAX_INIT_ENVS8externvoidtime_init(void);staticunsignedlongmemory_start=0;staticunsignedlongmemory_end=0;introws,cols
;#ifdefCONFIG_BLK_DEV_RAMexternintrd_doload;/*1=loadramdisk,0=don'tload*/externintrd_prompt;/*1=promptforramdisk,0=don'tprompt*/externintrd_size;/*Sizeoftheramdisk(s)*/externintrd_image_start;/*startingblock#ofimage*/#ifdefCONFIG_BLK_DEV_INITRDkdev_treal_ro
ot_dev;#endif#endifintroot_mountflags=MS_RDONLY;char*execute_command=NULL;staticchar*argv_init[MAX_INIT_ARGS+2]={"init",NULL,};staticchar*envp_init[MAX_INIT_ENVS+2]={"HOME=/","TERM=linux",NULL,};char*get_options(char*str,int*ints){char*cur=str;inti=1;while(
cur&&(*cur=='-'||isdigit(*cur))&&i<=10){ints[i++]=simple_strtol(cur,NULL,0);if((cur=strchr(cur,','))!=NULL)cur++;}ints[0]=i-1;return(cur);}staticvoid__initprofile_setup(char*str,int*ints){if(ints[0]>0)prof_shift=(unsignedlong)ints[1];elseprof_shift=2;}stati
cstructdev_name_struct{constchar*name;constintnum;}root_dev_names[]__initdata={#ifdefCONFIG_ROOT_NFS{"nfs",0x00ff},#endif#ifdefCONFIG_BLK_DEV_IDE{"hda",0x0300},{"hdb",0x0340},{"hdc",0x1600},{"hdd",0x1640},{"hde",0x2100},{"hdf",0x2140},{"hdg",0x2200},{"hdh",
0x2240},{"hdi",0x3800},{"hdj",0x3840},{"hdk",0x3900},{"hdl",0x3940},#endif#ifdefCONFIG_BLK_DEV_SD{"sda",0x0800},{"sdb",0x0810},{"sdc",0x0820},{"sdd",0x0830},{"sde",0x0840},{"sdf",0x0850},{"sdg",0x0860},{"sdh",0x0870},{"sdi",0x0880},{"sdj",0x0890},{"sdk",0x0
8a0},{"sdl",0x08b0},{"sdm",0x08c0},{"sdn",0x08d0},{"sdo",0x08e0},{"sdp",0x08f0},#endif#ifdefCONFIG_ATARI_ACSI{"ada",0x1c00},{"adb",0x1c10},{"adc",0x1c20},{"add",0x1c30},{"ade",0x1c40},#endif#ifdefCONFIG_BLK_DEV_FD{"fd",0x0200},#endif#ifdefCONFIG_MD_BOOT{"md
",0x0900},#endif#ifdefCONFIG_BLK_DEV_XD{"xda",0x0d00},{"xdb",0x0d40},#endif#ifdefCONFIG_BLK_DEV_RAM{"ram",0x0100},#endif#ifdefCONFIG_BLK_DEV_SR{"scd",0x0b00},#endif#ifdefCONFIG_MCD{"mcd",0x1700},#endif#ifdefCONFIG_CDU535{"cdu535",0x1800},{"sonycd",0x1800},#
endif#ifdefCONFIG_AZTCD{"aztcd",0x1d00},#endif#ifdefCONFIG_CM206{"cm206cd",0x2000},#endif#ifdefCONFIG_GSCD{"gscd",0x1000},#endif#ifdefCONFIG_SBPCD{"sbpcd",0x1900},#endif#ifdefCONFIG_BLK_DEV_PS2{"eda",0x2400},{"edb",0x2440},#endif#ifdefCONFIG_PARIDE_PD{"pda"
,0x2d00},{"pdb",0x2d10},{"pdc",0x2d20},{"pdd",0x2d30},#endif#ifdefCONFIG_PARIDE_PCD{"pcd",0x2e00},#endif#ifdefCONFIG_PARIDE_PF{"pf",0x2f00},#endif#ifCONFIG_APBLOCK{"apblock",APBLOCK_MAJOR<<8},#endif#ifCONFIG_DDV{"ddv",DDV_MAJOR<<8},#endif{NULL,0}};kdev_t__i
nitname_to_kdev_t(char*line){intbase=0;if(strncmp(line,"/dev/",5)==0){structdev_name_struct*dev=root_dev_names;line+=5;do{intlen=strlen(dev->name);if(strncmp(line,dev->name,len)==0){line+=len;base=dev->num;break;}dev++;}while(dev->name);}returnto_kdev_t(bas
e+simple_strtoul(line,NULL,base?10:16));}staticvoid__initroot_dev_setup(char*line,int*num){ROOT_DEV=name_to_kdev_t(line);}/**Listofkernelcommandlineparameters.Thefirsttablelistsparameters*whicharesubjecttovaluesparsing(leadingnumbersareconvertedto*anarrayof
intsandchoppedoffthestring),thesecondtablecontains*thefewexceptionswhichobeytheirownsyntaxrules.*/structkernel_param{constchar*str;void(*setup_func)(char*,int*);};staticstructkernel_paramcooked_params[]__initdata={/*FIXME:makePNPjustbecomereserve_setup*/#if
ndefCONFIG_KERNEL_PNP_RESOURCE{"reserve=",reserve_setup},#else{"reserve=",pnp_reserve_setup},#endif{"profile=",profile_setup},#ifdef__SMP__{"nosmp",smp_setup},{"maxcpus=",smp_setup},#ifdefCONFIG_X86_IO_APIC{"noapic",ioapic_setup},{"pirq=",ioapic_pirq_setup}
,#endif#endif#ifdefCONFIG_BLK_DEV_RAM{"ramdisk_start=",ramdisk_start_setup},{"load_ramdisk=",load_ramdisk},{"prompt_ramdisk=",prompt_ramdisk},{"ramdisk=",ramdisk_size},{"ramdisk_size=",ramdisk_size},#ifdefCONFIG_BLK_DEV_INITRD{"noinitrd",no_initrd},#endif#e
ndif#ifdefCONFIG_FB{"video=",video_setup},#endif{"panic=",panic_setup},{"console=",console_setup},#ifdefCONFIG_VGA_CONSOLE{"no-scroll",no_scroll},#endif#ifdefCONFIG_MDA_CONSOLE{"mdacon=",mdacon_setup},#endif#ifdefCONFIG_VT{"kbd-reset",kbd_reset_setup},#endi
f#ifdefCONFIG_BUGi386{"no-hlt",no_halt},{"no387",no_387},{"reboot=",reboot_setup},#endif#ifdefCONFIG_INET{"ether=",eth_setup},#endif#ifdefCONFIG_ARCNET_COM20020{"com20020=",com20020_setup},#endif#ifdefCONFIG_ARCNET_RIM_I{"arcrimi=",arcrimi_setup},#endif#ifd
efCONFIG_ARCNET_COM90xxIO{"com90io=",com90io_setup},#endif#ifdefCONFIG_ARCNET_COM90xx{"com90xx=",com90xx_setup},#endif#ifdefCONFIG_DECNET{"decnet=",decnet_setup},#endif#ifdefCONFIG_PRINTER{"lp=",lp_setup},#endif#ifdefCONFIG_JOY_AMIGA{"js_am=",js_am_setup},#
endif#ifdefCONFIG_JOY_ANALOG{"js_an=",js_an_setup},#endif#ifdefCONFIG_JOY_ASSASIN{"js_as=",js_as_setup},#endif#ifdefCONFIG_JOY_CONSOLE{"js_console=",js_console_setup},{"js_console2=",js_console_setup},{"js_console3=",js_console_setup},#endif#ifdefCONFIG_JOY
_DB9{"js_db9=",js_db9_setup},{"js_db9_2=",js_db9_setup},{"js_db9_3=",js_db9_setup},#endif#ifdefCONFIG_JOY_TURBOGRAFX{"js_tg=",js_tg_setup},{"js_tg_2=",js_tg_setup},{"js_tg_3=",js_tg_setup},#endif#ifdefCONFIG_SCSI{"max_scsi_luns=",scsi_luns_setup},{"scsi_log
ging=",scsi_logging_setup},#endif#ifdefCONFIG_JOY_LIGHTNING{"js_l4=",js_l4_setup},#endif#ifdefCONFIG_SCSI_ADVANSYS{"advansys=",advansys_setup},#endif#ifdefined(CONFIG_BLK_DEV_HD){"hd=",hd_setup},#endif#ifdefCONFIG_CHR_DEV_ST{"st=",st_setup},#endif#ifdefCONF
IG_BUSMOUSE{"bmouse=",bmouse_setup},#endif#ifdefCONFIG_MS_BUSMOUSE{"msmouse=",msmouse_setup},#endif#ifdefCONFIG_SCSI_SEAGATE{"st0x=",st0x_setup},{"tmc8xx=",tmc8xx_setup},#endif#ifdefCONFIG_SCSI_T128{"t128=",t128_setup},#endif#ifdefCONFIG_SCSI_PAS16{"pas16="
,pas16_setup},#endif#ifdefCONFIG_SCSI_GENERIC_NCR5380{"ncr5380=",generic_NCR5380_setup},{"ncr53c400=",generic_NCR53C400_setup},{"ncr53c400a=",generic_NCR53C400A_setup},{"dtc3181e=",generic_DTC3181E_setup},#endif#ifdefCONFIG_SCSI_AHA152X{"aha152x=",aha152x_s
etup},#endif#ifdefCONFIG_SCSI_AHA1542{"aha1542=",aha1542_setup},#endif#ifdefCONFIG_SCSI_GDTH{"gdth=",gdth_setup},#endif#ifdefCONFIG_SCSI_AIC7XXX{"aic7xxx=",aic7xxx_setup},#endif#ifdefCONFIG_SCSI_BUSLOGIC{"BusLogic=",BusLogic_Setup},#endif#ifdefCONFIG_SCSI_N
CR53C8XX{"ncr53c8xx=",ncr53c8xx_setup},#endif#ifdefCONFIG_SCSI_EATA{"eata=",eata2x_setup},#endif#ifdefCONFIG_SCSI_U14_34F{"u14-34f=",u14_34f_setup},#endif#ifdefCONFIG_SCSI_AM53C974{"AM53C974=",AM53C974_setup},#endif#ifdefCONFIG_SCSI_NCR53C406A{"ncr53c406a="
,NCR53c406a_setup},#endif#ifdefCONFIG_SCSI_FUTURE_DOMAIN{"fdomain=",fdomain_setup},#endif#ifdefCONFIG_SCSI_IN2000{"in2000=",in2000_setup},#endif#ifdefCONFIG_SCSI_7000FASST{"wd7000=",wd7000_setup},#endif#ifdefCONFIG_SCSI_IBMMCA{"ibmmcascsi=",ibmmca_scsi_setu
p},#endif#ifdefined(CONFIG_SCSI_DC390T)&&!defined(CONFIG_SCSI_DC390T_NOGENSUPP){"tmscsim=",dc390_setup},#endif#ifdefCONFIG_BLK_DEV_XD{"xd=",xd_setup},{"xd_geo=",xd_manual_geo_init},#endif#ifdefined(CONFIG_BLK_DEV_FD)||defined(CONFIG_AMIGA_FLOPPY)||defined(C
ONFIG_ATARI_FLOPPY){"floppy=",floppy_setup},#endif#ifdefCONFIG_BLK_DEV_PS2{"eda=",ed_setup},{"edb=",ed_setup},{"tp720=",tp720_setup},#endif#ifdefCONFIG_CDU31A{"cdu31a=",cdu31a_setup},#endifCONFIG_CDU31A#ifdefCONFIG_MCD{"mcd=",mcd_setup},#endifCONFIG_MCD#ifd
efCONFIG_MCDX{"mcdx=",mcdx_setup},#endifCONFIG_MCDX#ifdefCONFIG_SBPCD{"sbpcd=",sbpcd_setup},#endifCONFIG_SBPCD#ifdefCONFIG_AZTCD{"aztcd=",aztcd_setup},#endifCONFIG_AZTCD#ifdefCONFIG_CDU535{"sonycd535=",sonycd535_setup},#endifCONFIG_CDU535#ifdefCONFIG_GSCD{"
gscd=",gscd_setup},#endifCONFIG_GSCD#ifdefCONFIG_CM206{"cm206=",cm206_setup},#endifCONFIG_CM206#ifdefCONFIG_OPTCD{"optcd=",optcd_setup},#endifCONFIG_OPTCD#ifdefCONFIG_SJCD{"sjcd=",sjcd_setup},#endifCONFIG_SJCD#ifdefCONFIG_ISP16_CDI{"isp16=",isp16_setup},#en
difCONFIG_ISP16_CDI#ifdefCONFIG_SOUND_OSS{"sound=",sound_setup},#endif#ifdefCONFIG_ISDN_DRV_ICN{"icn=",icn_setup},#endif#ifdefCONFIG_ISDN_DRV_HISAX{"hisax=",HiSax_setup},{"HiSax=",HiSax_setup},#endif#ifdefCONFIG_ISDN_DRV_PCBIT{"pcbit=",pcbit_setup},#endif#i
fdefCONFIG_ATARIMOUSE{"atamouse=",atari_mouse_setup},#endif#ifdefCONFIG_DMASOUND{"dmasound=",dmasound_setup},#endif#ifdefCONFIG_ATARI_SCSI{"atascsi=",atari_scsi_setup},#endif#ifdefCONFIG_STRAM_SWAP{"stram_swap=",stram_swap_setup},#endif#ifdefined(CONFIG_A40
00T_SCSI)||defined(CONFIG_WARPENGINE_SCSI)\||defined(CONFIG_A4091_SCSI)||defined(CONFIG_MVME16x_SCSI)\||defined(CONFIG_BVME6000_SCSI){"53c7xx=",ncr53c7xx_setup},#endif#ifdefined(CONFIG_A3000_SCSI)||defined(CONFIG_A2091_SCSI)\||defined(CONFIG_GVP11_SCSI){"wd
33c93=",wd33c93_setup},#endif#ifdefined(CONFIG_GVP11_SCSI){"gvp11=",gvp11_setup},#endif#ifdefCONFIG_MAC_SCSI{"mac5380=",mac_scsi_setup},#endif#ifdefCONFIG_CYCLADES{"cyclades=",cy_setup},#endif#ifdefCONFIG_DIGI{"digi=",pcxx_setup},#endif#ifdefCONFIG_DIGIEPCA
{"digiepca=",epca_setup},#endif#ifdefCONFIG_RISCOM8{"riscom8=",riscom8_setup},#endif#ifdefCONFIG_DMASCC{"dmascc=",dmascc_setup},#endif#ifdefCONFIG_SPECIALIX{"specialix=",specialix_setup},#endif#ifdefCONFIG_BAYCOM_PAR{"baycom_par=",baycom_par_setup},#endif#i
fdefCONFIG_BAYCOM_SER_FDX{"baycom_ser_fdx=",baycom_ser_fdx_setup},#endif#ifdefCONFIG_BAYCOM_SER_HDX{"baycom_ser_hdx=",baycom_ser_hdx_setup},#endif#ifdefCONFIG_SOUNDMODEM{"soundmodem=",sm_setup},#endif#ifdefCONFIG_WDT{"wdt=",wdt_setup},#endif#ifdefCONFIG_PAR
PORT{"parport=",parport_setup},#endif#ifdefCONFIG_PLIP{"plip=",plip_setup},#endif#ifdefCONFIG_HFMODEM{"hfmodem=",hfmodem_setup},#endif#ifdefCONFIG_FTAPE{"ftape=",ftape_setup},#endif#ifdefCONFIG_MD_BOOT{"md=",md_setup},#endif#ifdefCONFIG_ADBMOUSE{"adb_button
s=",adb_mouse_setup},#endif#ifdefCONFIG_LTPC{"ltpc=",ltpc_setup},#endif{0,0}};staticstructkernel_paramraw_params[]__initdata={{"root=",root_dev_setup},#ifdefCONFIG_ROOT_NFS{"nfsroot=",nfs_root_setup},{"nfsaddrs=",ip_auto_config_setup},#endif#ifdefCONFIG_IP_
PNP{"ip=",ip_auto_config_setup},#endif#ifdefCONFIG_PCI{"pci=",pci_setup},#endif#ifdefCONFIG_PARIDE_PD{"pd.",pd_setup},#endif#ifdefCONFIG_PARIDE_PCD{"pcd.",pcd_setup},#endif#ifdefCONFIG_PARIDE_PF{"pf.",pf_setup},#endif#ifdefCONFIG_PARIDE_PT{"pt.",pt_setup},#
endif#ifdefCONFIG_PARIDE_PG{"pg.",pg_setup},#endif#ifdefCONFIG_APM{"apm=",apm_setup},#endif{0,0}};#ifdefCONFIG_BLK_DEV_RAMstaticvoid__initramdisk_start_setup(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_image_start=ints[1];}staticvoid__initload_ramdisk(ch
ar*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_doload=ints[1]&1;}staticvoid__initprompt_ramdisk(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_prompt=ints[1]&1;}staticvoid__initramdisk_size(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_size=ints[1];}#endifst
aticint__initchecksetup(char*line){inti,ints[11];#ifdefCONFIG_BLK_DEV_IDE/*idedriverneedsthebasicstring,ratherthanpre-processedvalues*/if(!strncmp(line,"ide",3)||(!strncmp(line,"hd",2)&&line[2]!='=')){ide_setup(line);return1;}#endiffor(i=0;raw_params[i].str
;i++){intn=strlen(raw_params[i].str);if(!strncmp(line,raw_params[i].str,n)){raw_params[i].setup_func(line+n,NULL);return1;}}for(i=0;cooked_params[i].str;i++){intn=strlen(cooked_params[i].str);if(!strncmp(line,cooked_params[i].str,n)){cooked_params[i].setup_
func(get_options(line+n,ints),ints);return1;}}return0;}/*thisshouldbeapprox2Bo*oMipstostart(noteinitialshift),andwillstillworkevenifinitiallytoolarge,itwilljusttakeslightlylonger*/unsignedlongloops_per_sec=(1<<12);/*Thisisthenumberofbitsofprecisionfortheloo
ps_per_second.Eachbittakesonaverage1.5/HZseconds.This(liketheoriginal)isalittlebetterthan1%*/#defineLPS_PREC8void__initcalibrate_delay(void){unsignedlongticks,loopbit;intlps_precision=LPS_PREC;loops_per_sec=(1<<12);printk("Calibratingdelayloop...");while(lo
ops_per_sec<<=1){/*waitfor"startof"clocktick*/ticks=jiffies;while(ticks==jiffies)/*nothing*/;/*Go..*/ticks=jiffies;__delay(loops_per_sec);ticks=jiffies-ticks;if(ticks)break;}/*Doabinaryapproximationtogetloops_per_secondsettoequaloneclock(uptolps_precisionbi
ts)*/loops_per_sec>>=1;loopbit=loops_per_sec;while(lps_precision--&&(loopbit>>=1)){loops_per_sec|=loopbit;ticks=jiffies;while(ticks==jiffies);ticks=jiffies;__delay(loops_per_sec);if(jiffies!=ticks)/*longerthan1tick*/loops_per_sec&=~loopbit;}/*finally,adjust
loopspersecondintermsofsecondsinsteadofclocks*/loops_per_sec*=HZ;/*Roundthevalueandprintit*/printk("%lu.%02luBogoMIPS\n",(loops_per_sec+2500)/500000,((loops_per_sec+2500)/5000)%100);}/**Thisisasimplekernelcommandlineparsingfunction:itparses*thecommandline,a
ndfillsinthearguments/environmenttoinit*asappropriate.Anycmd-lineoptionistakentobeanenvironment*variableifitcontainsthecharacter'='.**Thisroutinealsochecksforoptionsmeantforthekernel.*Theseoptionsarenotgiventoinit-theyareforinternalkerneluseonly.*/staticvoi
d__initparse_options(char*line){char*next;intargs,envs;if(!*line)return;args=0;envs=1;/*TERMissetto'linux'bydefault*/next=line;while((line=next)!=NULL){if((next=strchr(line,''))!=NULL)*next++=0;/**checkforkerneloptionsfirst..*/if(!strcmp(line,"ro")){root_mo
untflags|=MS_RDONLY;continue;}if(!strcmp(line,"rw")){root_mountflags&=~MS_RDONLY;continue;}if(!strcmp(line,"debug")){console_loglevel=10;continue;}if(!strncmp(line,"init=",5)){line+=5;execute_command=line;/*IncaseLILOisgoingtobootuswithdefaultcommandline,*i
tprepends"auto"beforethewholecmdlinewhichmakes*theshellthinkitshouldexecuteascriptwithsuchname.*Soweignoreallargumentsentered_before_init=...[MJ]*/args=0;continue;}if(checksetup(line))continue;/**Thencheckifit'sanenvironmentvariableor*anoption.*/if(strchr(l
ine,'=')){if(envs>=MAX_INIT_ENVS)break;envp_init[++envs]=line;}else{if(args>=MAX_INIT_ARGS)break;argv_init[++args]=line;}}argv_init[args+1]=NULL;envp_init[envs+1]=NULL;}externvoidsetup_arch(char**,unsignedlong*,unsignedlong*);#ifndef__SMP__/**Uniprocessorid
lethread*/intcpu_idle(void*unused){for(;;)idle();}#definesmp_init()do{}while(0)#else/**Multiprocessoridlethreadisinarch/...*/externintcpu_idle(void*unused);/*Calledbybootprocessortoactivatetherest.*/staticvoid__initsmp_init(void){/*Getotherprocessorsintothe
irbootupholdingpatterns.*/smp_boot_cpus();smp_threads_ready=1;smp_commence();}#endifexternvoidinitialize_secondary(void);/**Activatethefirstprocessor.*/asmlinkagevoid__initstart_kernel(void){char*command_line;#ifdef__SMP__staticintboot_cpu=1;/*"current"hasb
eensetup,weneedtoloaditnow*/if(!boot_cpu)initialize_secondary();boot_cpu=0;#endif/**Interruptsarestilldisabled.Donecessarysetups,then*enablethem*/printk(linux_banner);setup_arch(&command_line,&memory_start,&memory_end);memory_start=paging_init(memory_start,
memory_end);trap_init();init_IRQ();sched_init();time_init();parse_options(command_line);/**HACKALERT!Thisisearly.We'reenablingtheconsolebefore*we'vedonePCIsetupsetc,andconsole_init()mustbeawareof*this.Butwedowantoutputearly,incasesomethinggoeswrong.*/memory
_start=console_init(memory_start,memory_end);#ifdefCONFIG_MODULESinit_modules();#endifif(prof_shift){prof_buffer=(unsignedint*)memory_start;/*onlytextisprofiled*/prof_len=(unsignedlong)&_etext-(unsignedlong)&_stext;prof_len>>=prof_shift;memory_start+=prof_l
en*sizeof(unsignedint);memset(prof_buffer,0,prof_len*sizeof(unsignedint));}memory_start=kmem_cache_init(memory_start,memory_end);sti();calibrate_delay();#ifdefCONFIG_BLK_DEV_INITRDif(initrd_start&&!initrd_below_start_ok&&initrd_start<memory_start){printk(KE
RN_CRIT"initrdoverwritten(0x%08lx<0x%08lx)-""disablingit.\n",initrd_start,memory_start);initrd_start=0;}#endifmem_init(memory_start,memory_end);kmem_cache_sizes_init();#ifdefCONFIG_PROC_FSproc_root_init();#endifuidcache_init();filescache_init();dcache_init(
);vma_init();buffer_init();signals_init();inode_init();file_table_init();#ifdefined(CONFIG_SYSVIPC)ipc_init();#endif#ifdefined(CONFIG_QUOTA)dquot_init_hash();#endifcheck_bugs();printk("POSIXconformancetestingbyUNIFIX\n");/**Wecountontheinitialthreadgoingok*
Likeidlersinitisanunlockedkernelthread,whichwill*makesyscalls(andthusbelocked).*/smp_init();kernel_thread(init,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);current->need_resched=1;cpu_idle(NULL);}#ifdefCONFIG_BLK_DEV_INITRDstaticintdo_linuxrc(void*shell){static
char*argv[]={"linuxrc",NULL,};close(0);close(1);close(2);setsid();(void)open("/dev/console",O_RDWR,0);(void)dup(0);(void)dup(0);returnexecve(shell,argv,envp_init);}staticvoid__initno_initrd(char*s,int*ints){mount_initrd=0;}#endifstructtask_struct*child_reap
er=&init_task;/**Ok,themachineisnowinitialized.Noneofthedevices*havebeentouchedyet,buttheCPUsubsystemisupand*running,andmemoryandprocessmanagementworks.**Nowwecanfinallystartdoingsomerealwork..*/staticvoid__initdo_basic_setup(void){#ifdefCONFIG_BLK_DEV_INIT
RDintreal_root_mountflags;#endif/**Telltheworldthatwe'regoingtobethegrim*reaperofinnocentorphanedchildren.**Wedon'twantpeopletohavetomakeincorrect*assumptionsaboutwhereinthetaskarraythis*canbefound.*/child_reaper=current;#ifdefined(CONFIG_MTRR)/*Dothisafter
SMPinitialization*//**Weshouldprobablycreatesomearchitecture-dependent"fixupafter*everythingisup"stylefunctionwherethiswouldbelongbetter*thanininit/main.c..*/mtrr_init();#endif#ifdefCONFIG_SYSCTLsysctl_init();#endif/**Ok,atthispointallCPU'sshouldbeinitializ
ed,so*wecanstartlookingintodevices..*/#ifdefCONFIG_PCIpci_init();#endif#ifdefCONFIG_SBUSsbus_init();#endif#ifdefined(CONFIG_PPC)powermac_init();#endif#ifdefCONFIG_MCAmca_init();#endif#ifdefCONFIG_ARCH_ACORNecard_init();#endif#ifdefCONFIG_ZORROzorro_init();#
endif#ifdefCONFIG_DIOdio_init();#endif/*Networkinginitializationneedsaprocesscontext*/sock_init();/*Launchbdflushfromhere,insteadoftheoldsyscallway.*/kernel_thread(bdflush,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);/*Startthebackgroundpageoutdaemon.*/kswapd_s
etup();kernel_thread(kswapd,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);#ifCONFIG_AP1000/*Starttheasyncpagingdaemon.*/{externintasyncd(void*);kernel_thread(asyncd,NULL,CLONE_FS|CLONE_FILES|CLONE_SIGHAND);}#endif#ifdefCONFIG_BLK_DEV_INITRDreal_root_dev=ROOT_DEV
;real_root_mountflags=root_mountflags;if(initrd_start&&mount_initrd)root_mountflags&=~MS_RDONLY;elsemount_initrd=0;#endif/*Setupdevices..*/device_setup();/*..executableformats..*/binfmt_setup();/*..filesystems..*/filesystem_setup();/*Mounttherootfilesystem.
.*/mount_root();#ifdefCONFIG_UMSDOS_FS{/*Whenmountingaumsdosfsasroot,wedetectthepseudo_root(/linux)andinitialiseithere.pseudo_rootisdefinedinfs/umsdos/inode.c*/externstructinode*pseudo_root;if(pseudo_root!=NULL){current->fs->root=pseudo_root->i_sb->s_root;c
urrent->fs->pwd=pseudo_root->i_sb->s_root;}}#endif#ifdefCONFIG_BLK_DEV_INITRDroot_mountflags=real_root_mountflags;if(mount_initrd&&ROOT_DEV!=real_root_dev&&MAJOR(ROOT_DEV)==RAMDISK_MAJOR&&MINOR(ROOT_DEV)==0){interror;inti,pid;pid=kernel_thread(do_linuxrc,"/
linuxrc",SIGCHLD);if(pid>0)while(pid!=wait(&i));if(MAJOR(real_root_dev)!=RAMDISK_MAJOR||MINOR(real_root_dev)!=0){error=change_root(real_root_dev,"/initrd");if(error)printk(KERN_ERR"Changerootto/initrd:""error%d\n",error);}}#endif}staticintinit(void*unused){
lock_kernel();do_basic_setup();/**Ok,wehavecompletedtheinitialbootup,and*we'reessentiallyupandrunning.Getridofthe*initmemsegmentsandstarttheuser-modestuff..*/free_initmem();unlock_kernel();if(open("/dev/console",O_RDWR,0)<0)printk("Warning:unabletoopenanini
tialconsole.\n");(void)dup(0);(void)dup(0);/**Wetryeachoftheseuntilonesucceeds.**TheBourneshellcanbeusedinsteadofinitifweare*tryingtorecoverareallybrokenmachine.*/if(execute_command)execve(execute_command,argv_init,envp_init);execve("/sbin/init",argv_init,e
nvp_init);execve("/etc/init",argv_init,envp_init);execve("/bin/init",argv_init,envp_init);execve("/bin/sh",argv_init,envp_init);panic("Noinitfound.Trypassinginit=optiontokernel.");}/**linux/init/main.c**Copyright(C)1991,1992LinusTorvalds**GK2/5/95-Changedto
supportmountingrootfsviaNFS*Addedinitrd&change_root:WernerAlmesberger&HansLermen,Feb'96*Moanearlyifgccisold,avoidingboguskernels-PaulGortmaker,May'96*Simplifiedstartingofinit:MichaelA.Griffith<[email protected]>*/#define__KERNEL_SYSCALLS__#include<linux/config.h
>#include<linux/proc_fs.h>#include<linux/unistd.h>#include<linux/ctype.h>#include<linux/delay.h>#include<linux/utsname.h>#include<linux/ioport.h>#include<linux/init.h>#include<linux/smp_lock.h>#include<linux/blk.h>#include<linux/hdreg.h>#include<asm/io.h>#i
nclude<asm/bugs.h>#ifdefCONFIG_PCI#include<linux/pci.h>#endif#ifdefCONFIG_DIO#include<linux/dio.h>#endif#ifdefCONFIG_ZORRO#include<linux/zorro.h>#endif#ifdefCONFIG_MTRR#include<asm/mtrr.h>#endif#ifdefCONFIG_APM#include<linux/apm_bios.h>#endif/**Versionsofgc
colderthanthatlistedbelowmayactuallycompile*andlinkokay,buttheendproductcanhavesubtleruntimebugs.*Toavoidassociatedbogusbugreports,weflatlyrefusetocompile*withagccthatisknowntobetoooldfromtheverybeginning.*/#if__GNUC__<2||(__GNUC__==2&&__GNUC_MINOR__<6)#err
orsorry,yourGCCistooold.Itbuildsincorrectkernels.#endifexternchar_stext,_etext;externchar*linux_banner;externintconsole_loglevel;staticintinit(void*);externintbdflush(void*);externintkswapd(void*);externvoidkswapd_setup(void);externvoidinit_IRQ(void);extern
voidinit_modules(void);externlongconsole_init(long,long);externvoidsock_init(void);externvoiduidcache_init(void);externvoidmca_init(void);externvoidsbus_init(void);externvoidpowermac_init(void);externvoidsysctl_init(void);externvoidfilescache_init(void);ext
ernvoidsignals_init(void);externvoiddevice_setup(void);externvoidbinfmt_setup(void);externvoidfree_initmem(void);externvoidfilesystem_setup(void);#ifdefCONFIG_ARCH_ACORNexternvoidecard_init(void);#endifexternvoidsmp_setup(char*str,int*ints);#ifdef__i386__ex
ternvoidioapic_pirq_setup(char*str,int*ints);externvoidioapic_setup(char*str,int*ints);#endifexternvoidno_scroll(char*str,int*ints);externvoidkbd_reset_setup(char*str,int*ints);externvoidpanic_setup(char*str,int*ints);externvoidbmouse_setup(char*str,int*int
s);externvoidmsmouse_setup(char*str,int*ints);externvoidconsole_setup(char*str,int*ints);#ifdefCONFIG_PRINTERexternvoidlp_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_AMIGAexternvoidjs_am_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_ANALOGexternvoidjs
_an_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_ASSASINexternvoidjs_as_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_CONSOLEexternvoidjs_console_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_DB9externvoidjs_db9_setup(char*str,int*ints);#endif#ifdefC
ONFIG_JOY_TURBOGRAFXexternvoidjs_tg_setup(char*str,int*ints);#endif#ifdefCONFIG_JOY_LIGHTNINGexternvoidjs_l4_setup(char*str,int*ints);#endifexternvoideth_setup(char*str,int*ints);#ifdefCONFIG_ARCNET_COM20020externvoidcom20020_setup(char*str,int*ints);#endif
#ifdefCONFIG_ARCNET_RIM_Iexternvoidarcrimi_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_COM90xxIOexternvoidcom90io_setup(char*str,int*ints);#endif#ifdefCONFIG_ARCNET_COM90xxexternvoidcom90xx_setup(char*str,int*ints);#endif#ifdefCONFIG_DECNETexternvoid
decnet_setup(char*str,int*ints);#endif#ifdefCONFIG_BLK_DEV_XDexternvoidxd_setup(char*str,int*ints);externvoidxd_manual_geo_init(char*str,int*ints);#endif#ifdefCONFIG_BLK_DEV_IDEexternvoidide_setup(char*);#endif#ifdefCONFIG_PARIDE_PDexternvoidpd_setup(char*s
tr,int*ints);#endif#ifdefCONFIG_PARIDE_PFexternvoidpf_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PTexternvoidpt_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PGexternvoidpg_setup(char*str,int*ints);#endif#ifdefCONFIG_PARIDE_PCDexternvoidpcd_set
up(char*str,int*ints);#endifexternvoidfloppy_setup(char*str,int*ints);externvoidst_setup(char*str,int*ints);externvoidst0x_setup(char*str,int*ints);externvoidadvansys_setup(char*str,int*ints);externvoidtmc8xx_setup(char*str,int*ints);externvoidt128_setup(ch
ar*str,int*ints);externvoidpas16_setup(char*str,int*ints);externvoidgeneric_NCR5380_setup(char*str,int*intr);externvoidgeneric_NCR53C400_setup(char*str,int*intr);externvoidgeneric_NCR53C400A_setup(char*str,int*intr);externvoidgeneric_DTC3181E_setup(char*str
,int*intr);externvoidaha152x_setup(char*str,int*ints);externvoidaha1542_setup(char*str,int*ints);externvoidgdth_setup(char*str,int*ints);externvoidaic7xxx_setup(char*str,int*ints);externvoidAM53C974_setup(char*str,int*ints);externvoidBusLogic_Setup(char*str
,int*ints);externvoidncr53c8xx_setup(char*str,int*ints);externvoideata2x_setup(char*str,int*ints);externvoidu14_34f_setup(char*str,int*ints);externvoidfdomain_setup(char*str,int*ints);externvoidibmmca_scsi_setup(char*str,int*ints);externvoidin2000_setup(cha
r*str,int*ints);externvoidNCR53c406a_setup(char*str,int*ints);externvoidwd7000_setup(char*str,int*ints);externvoiddc390_setup(char*str,int*ints);externvoidscsi_luns_setup(char*str,int*ints);externvoidscsi_logging_setup(char*str,int*ints);externvoidsound_set
up(char*str,int*ints);externvoidreboot_setup(char*str,int*ints);externvoidvideo_setup(char*str,int*ints);#ifdefCONFIG_CDU31Aexternvoidcdu31a_setup(char*str,int*ints);#endifCONFIG_CDU31A#ifdefCONFIG_BLK_DEV_PS2externvoided_setup(char*str,int*ints);externvoid
tp720_setup(char*str,int*ints);#endifCONFIG_BLK_DEV_PS2#ifdefCONFIG_MCDexternvoidmcd_setup(char*str,int*ints);#endifCONFIG_MCD#ifdefCONFIG_MCDXexternvoidmcdx_setup(char*str,int*ints);#endifCONFIG_MCDX#ifdefCONFIG_SBPCDexternvoidsbpcd_setup(char*str,int*ints
);#endifCONFIG_SBPCD#ifdefCONFIG_AZTCDexternvoidaztcd_setup(char*str,int*ints);#endifCONFIG_AZTCD#ifdefCONFIG_CDU535externvoidsonycd535_setup(char*str,int*ints);#endifCONFIG_CDU535#ifdefCONFIG_GSCDexternvoidgscd_setup(char*str,int*ints);#endifCONFIG_GSCD#if
defCONFIG_CM206externvoidcm206_setup(char*str,int*ints);#endifCONFIG_CM206#ifdefCONFIG_OPTCDexternvoidoptcd_setup(char*str,int*ints);#endifCONFIG_OPTCD#ifdefCONFIG_SJCDexternvoidsjcd_setup(char*str,int*ints);#endifCONFIG_SJCD#ifdefCONFIG_ISP16_CDIexternvoid
isp16_setup(char*str,int*ints);#endifCONFIG_ISP16_CDI#ifdefCONFIG_BLK_DEV_RAMstaticvoidramdisk_start_setup(char*str,int*ints);staticvoidload_ramdisk(char*str,int*ints);staticvoidprompt_ramdisk(char*str,int*ints);staticvoidramdisk_size(char*str,int*ints);#if
defCONFIG_BLK_DEV_INITRDstaticvoidno_initrd(char*s,int*ints);#endif#endifCONFIG_BLK_DEV_RAM#ifdefCONFIG_ISDN_DRV_ICNexternvoidicn_setup(char*str,int*ints);#endif#ifdefCONFIG_ISDN_DRV_HISAXexternvoidHiSax_setup(char*str,int*ints);#endif#ifdefCONFIG_DIGIEPCAe
xternvoidepca_setup(char*str,int*ints);#endif#ifdefCONFIG_ISDN_DRV_PCBITexternvoidpcbit_setup(char*str,int*ints);#endif#ifdefCONFIG_ATARIMOUSEexternvoidatari_mouse_setup(char*str,int*ints);#endif#ifdefCONFIG_DMASOUNDexternvoiddmasound_setup(char*str,int*int
s);#endif#ifdefCONFIG_ATARI_SCSIexternvoidatari_scsi_setup(char*str,int*ints);#endifexternvoidstram_swap_setup(char*str,int*ints);externvoidwd33c93_setup(char*str,int*ints);externvoidgvp11_setup(char*str,int*ints);externvoidncr53c7xx_setup(char*str,int*ints
);#ifdefCONFIG_MAC_SCSIexternvoidmac_scsi_setup(char*str,int*ints);#endif#ifdefCONFIG_CYCLADESexternvoidcy_setup(char*str,int*ints);#endif#ifdefCONFIG_DIGIexternvoidpcxx_setup(char*str,int*ints);#endif#ifdefCONFIG_RISCOM8externvoidriscom8_setup(char*str,int
*ints);#endif#ifdefCONFIG_SPECIALIXexternvoidspecialix_setup(char*str,int*ints);#endif#ifdefCONFIG_DMASCCexternvoiddmascc_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_PARexternvoidbaycom_par_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_SER_FDXex
ternvoidbaycom_ser_fdx_setup(char*str,int*ints);#endif#ifdefCONFIG_BAYCOM_SER_HDXexternvoidbaycom_ser_hdx_setup(char*str,int*ints);#endif#ifdefCONFIG_SOUNDMODEMexternvoidsm_setup(char*str,int*ints);#endif#ifdefCONFIG_ADBMOUSEexternvoidadb_mouse_setup(char*s
tr,int*ints);#endif#ifdefCONFIG_WDTexternvoidwdt_setup(char*str,int*ints);#endif#ifdefCONFIG_PARPORTexternvoidparport_setup(char*str,int*ints);#endif#ifdefCONFIG_PLIPexternvoidplip_setup(char*str,int*ints);#endif#ifdefCONFIG_HFMODEMexternvoidhfmodem_setup(c
har*str,int*ints);#endif#ifdefCONFIG_IP_PNPexternvoidip_auto_config_setup(char*str,int*ints);#endif#ifdefCONFIG_ROOT_NFSexternvoidnfs_root_setup(char*str,int*ints);#endif#ifdefCONFIG_FTAPEexternvoidftape_setup(char*str,int*ints);#endif#ifdefCONFIG_MDA_CONSO
LEexternvoidmdacon_setup(char*str,int*ints);#endif#ifdefCONFIG_LTPCexternvoidltpc_setup(char*str,int*ints);#endif#ifdefined(CONFIG_SYSVIPC)externvoidipc_init(void);#endif#ifdefined(CONFIG_QUOTA)externvoiddquot_init_hash(void);#endif#ifdefCONFIG_MD_BOOTexter
nvoidmd_setup(char*str,int*ints)__init;#endif/**Bootcommand-linearguments*/#defineMAX_INIT_ARGS8#defineMAX_INIT_ENVS8externvoidtime_init(void);staticunsignedlongmemory_start=0;staticunsignedlongmemory_end=0;introws,cols;#ifdefCONFIG_BLK_DEV_RAMexternintrd_d
oload;/*1=loadramdisk,0=don'tload*/externintrd_prompt;/*1=promptforramdisk,0=don'tprompt*/externintrd_size;/*Sizeoftheramdisk(s)*/externintrd_image_start;/*startingblock#ofimage*/#ifdefCONFIG_BLK_DEV_INITRDkdev_treal_root_dev;#endif#endifintroot_mountflags=
MS_RDONLY;char*execute_command=NULL;staticchar*argv_init[MAX_INIT_ARGS+2]={"init",NULL,};staticchar*envp_init[MAX_INIT_ENVS+2]={"HOME=/","TERM=linux",NULL,};char*get_options(char*str,int*ints){char*cur=str;inti=1;while(cur&&(*cur=='-'||isdigit(*cur))&&i<=10
){ints[i++]=simple_strtol(cur,NULL,0);if((cur=strchr(cur,','))!=NULL)cur++;}ints[0]=i-1;return(cur);}staticvoid__initprofile_setup(char*str,int*ints){if(ints[0]>0)prof_shift=(unsignedlong)ints[1];elseprof_shift=2;}staticstructdev_name_struct{constchar*name;
constintnum;}root_dev_names[]__initdata={#ifdefCONFIG_ROOT_NFS{"nfs",0x00ff},#endif#ifdefCONFIG_BLK_DEV_IDE{"hda",0x0300},{"hdb",0x0340},{"hdc",0x1600},{"hdd",0x1640},{"hde",0x2100},{"hdf",0x2140},{"hdg",0x2200},{"hdh",0x2240},{"hdi",0x3800},{"hdj",0x3840},
{"hdk",0x3900},{"hdl",0x3940},#endif#ifdefCONFIG_BLK_DEV_SD{"sda",0x0800},{"sdb",0x0810},{"sdc",0x0820},{"sdd",0x0830},{"sde",0x0840},{"sdf",0x0850},{"sdg",0x0860},{"sdh",0x0870},{"sdi",0x0880},{"sdj",0x0890},{"sdk",0x08a0},{"sdl",0x08b0},{"sdm",0x08c0},{"s
dn",0x08d0},{"sdo",0x08e0},{"sdp",0x08f0},#endif#ifdefCONFIG_ATARI_ACSI{"ada",0x1c00},{"adb",0x1c10},{"adc",0x1c20},{"add",0x1c30},{"ade",0x1c40},#endif#ifdefCONFIG_BLK_DEV_FD{"fd",0x0200},#endif#ifdefCONFIG_MD_BOOT{"md",0x0900},#endif#ifdefCONFIG_BLK_DEV_X
D{"xda",0x0d00},{"xdb",0x0d40},#endif#ifdefCONFIG_BLK_DEV_RAM{"ram",0x0100},#endif#ifdefCONFIG_BLK_DEV_SR{"scd",0x0b00},#endif#ifdefCONFIG_MCD{"mcd",0x1700},#endif#ifdefCONFIG_CDU535{"cdu535",0x1800},{"sonycd",0x1800},#endif#ifdefCONFIG_AZTCD{"aztcd",0x1d00
},#endif#ifdefCONFIG_CM206{"cm206cd",0x2000},#endif#ifdefCONFIG_GSCD{"gscd",0x1000},#endif#ifdefCONFIG_SBPCD{"sbpcd",0x1900},#endif#ifdefCONFIG_BLK_DEV_PS2{"eda",0x2400},{"edb",0x2440},#endif#ifdefCONFIG_PARIDE_PD{"pda",0x2d00},{"pdb",0x2d10},{"pdc",0x2d20}
,{"pdd",0x2d30},#endif#ifdefCONFIG_PARIDE_PCD{"pcd",0x2e00},#endif#ifdefCONFIG_PARIDE_PF{"pf",0x2f00},#endif#ifCONFIG_APBLOCK{"apblock",APBLOCK_MAJOR<<8},#endif#ifCONFIG_DDV{"ddv",DDV_MAJOR<<8},#endif{NULL,0}};kdev_t__initname_to_kdev_t(char*line){intbase=0
;if(strncmp(line,"/dev/",5)==0){structdev_name_struct*dev=root_dev_names;line+=5;do{intlen=strlen(dev->name);if(strncmp(line,dev->name,len)==0){line+=len;base=dev->num;break;}dev++;}while(dev->name);}returnto_kdev_t(base+simple_strtoul(line,NULL,base?10:16)
);}staticvoid__initroot_dev_setup(char*line,int*num){ROOT_DEV=name_to_kdev_t(line);}/**Listofkernelcommandlineparameters.Thefirsttablelistsparameters*whicharesubjecttovaluesparsing(leadingnumbersareconvertedto*anarrayofintsandchoppedoffthestring),thesecondt
ablecontains*thefewexceptionswhichobeytheirownsyntaxrules.*/structkernel_param{constchar*str;void(*setup_func)(char*,int*);};staticstructkernel_paramcooked_params[]__initdata={/*FIXME:makePNPjustbecomereserve_setup*/#ifndefCONFIG_KERNEL_PNP_RESOURCE{"reserv
e=",reserve_setup},#else{"reserve=",pnp_reserve_setup},#endif{"profile=",profile_setup},#ifdef__SMP__{"nosmp",smp_setup},{"maxcpus=",smp_setup},#ifdefCONFIG_X86_IO_APIC{"noapic",ioapic_setup},{"pirq=",ioapic_pirq_setup},#endif#endif#ifdefCONFIG_BLK_DEV_RAM{
"ramdisk_start=",ramdisk_start_setup},{"load_ramdisk=",load_ramdisk},{"prompt_ramdisk=",prompt_ramdisk},{"ramdisk=",ramdisk_size},{"ramdisk_size=",ramdisk_size},#ifdefCONFIG_BLK_DEV_INITRD{"noinitrd",no_initrd},#endif#endif#ifdefCONFIG_FB{"video=",video_set
up},#endif{"panic=",panic_setup},{"console=",console_setup},#ifdefCONFIG_VGA_CONSOLE{"no-scroll",no_scroll},#endif#ifdefCONFIG_MDA_CONSOLE{"mdacon=",mdacon_setup},#endif#ifdefCONFIG_VT{"kbd-reset",kbd_reset_setup},#endif#ifdefCONFIG_BUGi386{"no-hlt",no_halt
},{"no387",no_387},{"reboot=",reboot_setup},#endif#ifdefCONFIG_INET{"ether=",eth_setup},#endif#ifdefCONFIG_ARCNET_COM20020{"com20020=",com20020_setup},#endif#ifdefCONFIG_ARCNET_RIM_I{"arcrimi=",arcrimi_setup},#endif#ifdefCONFIG_ARCNET_COM90xxIO{"com90io=",c
om90io_setup},#endif#ifdefCONFIG_ARCNET_COM90xx{"com90xx=",com90xx_setup},#endif#ifdefCONFIG_DECNET{"decnet=",decnet_setup},#endif#ifdefCONFIG_PRINTER{"lp=",lp_setup},#endif#ifdefCONFIG_JOY_AMIGA{"js_am=",js_am_setup},#endif#ifdefCONFIG_JOY_ANALOG{"js_an=",
js_an_setup},#endif#ifdefCONFIG_JOY_ASSASIN{"js_as=",js_as_setup},#endif#ifdefCONFIG_JOY_CONSOLE{"js_console=",js_console_setup},{"js_console2=",js_console_setup},{"js_console3=",js_console_setup},#endif#ifdefCONFIG_JOY_DB9{"js_db9=",js_db9_setup},{"js_db9_
2=",js_db9_setup},{"js_db9_3=",js_db9_setup},#endif#ifdefCONFIG_JOY_TURBOGRAFX{"js_tg=",js_tg_setup},{"js_tg_2=",js_tg_setup},{"js_tg_3=",js_tg_setup},#endif#ifdefCONFIG_SCSI{"max_scsi_luns=",scsi_luns_setup},{"scsi_logging=",scsi_logging_setup},#endif#ifde
fCONFIG_JOY_LIGHTNING{"js_l4=",js_l4_setup},#endif#ifdefCONFIG_SCSI_ADVANSYS{"advansys=",advansys_setup},#endif#ifdefined(CONFIG_BLK_DEV_HD){"hd=",hd_setup},#endif#ifdefCONFIG_CHR_DEV_ST{"st=",st_setup},#endif#ifdefCONFIG_BUSMOUSE{"bmouse=",bmouse_setup},#e
ndif#ifdefCONFIG_MS_BUSMOUSE{"msmouse=",msmouse_setup},#endif#ifdefCONFIG_SCSI_SEAGATE{"st0x=",st0x_setup},{"tmc8xx=",tmc8xx_setup},#endif#ifdefCONFIG_SCSI_T128{"t128=",t128_setup},#endif#ifdefCONFIG_SCSI_PAS16{"pas16=",pas16_setup},#endif#ifdefCONFIG_SCSI_
GENERIC_NCR5380{"ncr5380=",generic_NCR5380_setup},{"ncr53c400=",generic_NCR53C400_setup},{"ncr53c400a=",generic_NCR53C400A_setup},{"dtc3181e=",generic_DTC3181E_setup},#endif#ifdefCONFIG_SCSI_AHA152X{"aha152x=",aha152x_setup},#endif#ifdefCONFIG_SCSI_AHA1542{
"aha1542=",aha1542_setup},#endif#ifdefCONFIG_SCSI_GDTH{"gdth=",gdth_setup},#endif#ifdefCONFIG_SCSI_AIC7XXX{"aic7xxx=",aic7xxx_setup},#endif#ifdefCONFIG_SCSI_BUSLOGIC{"BusLogic=",BusLogic_Setup},#endif#ifdefCONFIG_SCSI_NCR53C8XX{"ncr53c8xx=",ncr53c8xx_setup}
,#endif#ifdefCONFIG_SCSI_EATA{"eata=",eata2x_setup},#endif#ifdefCONFIG_SCSI_U14_34F{"u14-34f=",u14_34f_setup},#endif#ifdefCONFIG_SCSI_AM53C974{"AM53C974=",AM53C974_setup},#endif#ifdefCONFIG_SCSI_NCR53C406A{"ncr53c406a=",NCR53c406a_setup},#endif#ifdefCONFIG_
SCSI_FUTURE_DOMAIN{"fdomain=",fdomain_setup},#endif#ifdefCONFIG_SCSI_IN2000{"in2000=",in2000_setup},#endif#ifdefCONFIG_SCSI_7000FASST{"wd7000=",wd7000_setup},#endif#ifdefCONFIG_SCSI_IBMMCA{"ibmmcascsi=",ibmmca_scsi_setup},#endif#ifdefined(CONFIG_SCSI_DC390T
)&&!defined(CONFIG_SCSI_DC390T_NOGENSUPP){"tmscsim=",dc390_setup},#endif#ifdefCONFIG_BLK_DEV_XD{"xd=",xd_setup},{"xd_geo=",xd_manual_geo_init},#endif#ifdefined(CONFIG_BLK_DEV_FD)||defined(CONFIG_AMIGA_FLOPPY)||defined(CONFIG_ATARI_FLOPPY){"floppy=",floppy_s
etup},#endif#ifdefCONFIG_BLK_DEV_PS2{"eda=",ed_setup},{"edb=",ed_setup},{"tp720=",tp720_setup},#endif#ifdefCONFIG_CDU31A{"cdu31a=",cdu31a_setup},#endifCONFIG_CDU31A#ifdefCONFIG_MCD{"mcd=",mcd_setup},#endifCONFIG_MCD#ifdefCONFIG_MCDX{"mcdx=",mcdx_setup},#end
ifCONFIG_MCDX#ifdefCONFIG_SBPCD{"sbpcd=",sbpcd_setup},#endifCONFIG_SBPCD#ifdefCONFIG_AZTCD{"aztcd=",aztcd_setup},#endifCONFIG_AZTCD#ifdefCONFIG_CDU535{"sonycd535=",sonycd535_setup},#endifCONFIG_CDU535#ifdefCONFIG_GSCD{"gscd=",gscd_setup},#endifCONFIG_GSCD#i
fdefCONFIG_CM206{"cm206=",cm206_setup},#endifCONFIG_CM206#ifdefCONFIG_OPTCD{"optcd=",optcd_setup},#endifCONFIG_OPTCD#ifdefCONFIG_SJCD{"sjcd=",sjcd_setup},#endifCONFIG_SJCD#ifdefCONFIG_ISP16_CDI{"isp16=",isp16_setup},#endifCONFIG_ISP16_CDI#ifdefCONFIG_SOUND_
OSS{"sound=",sound_setup},#endif#ifdefCONFIG_ISDN_DRV_ICN{"icn=",icn_setup},#endif#ifdefCONFIG_ISDN_DRV_HISAX{"hisax=",HiSax_setup},{"HiSax=",HiSax_setup},#endif#ifdefCONFIG_ISDN_DRV_PCBIT{"pcbit=",pcbit_setup},#endif#ifdefCONFIG_ATARIMOUSE{"atamouse=",atar
i_mouse_setup},#endif#ifdefCONFIG_DMASOUND{"dmasound=",dmasound_setup},#endif#ifdefCONFIG_ATARI_SCSI{"atascsi=",atari_scsi_setup},#endif#ifdefCONFIG_STRAM_SWAP{"stram_swap=",stram_swap_setup},#endif#ifdefined(CONFIG_A4000T_SCSI)||defined(CONFIG_WARPENGINE_S
CSI)\||defined(CONFIG_A4091_SCSI)||defined(CONFIG_MVME16x_SCSI)\||defined(CONFIG_BVME6000_SCSI){"53c7xx=",ncr53c7xx_setup},#endif#ifdefined(CONFIG_A3000_SCSI)||defined(CONFIG_A2091_SCSI)\||defined(CONFIG_GVP11_SCSI){"wd33c93=",wd33c93_setup},#endif#ifdefine
d(CONFIG_GVP11_SCSI){"gvp11=",gvp11_setup},#endif#ifdefCONFIG_MAC_SCSI{"mac5380=",mac_scsi_setup},#endif#ifdefCONFIG_CYCLADES{"cyclades=",cy_setup},#endif#ifdefCONFIG_DIGI{"digi=",pcxx_setup},#endif#ifdefCONFIG_DIGIEPCA{"digiepca=",epca_setup},#endif#ifdefC
ONFIG_RISCOM8{"riscom8=",riscom8_setup},#endif#ifdefCONFIG_DMASCC{"dmascc=",dmascc_setup},#endif#ifdefCONFIG_SPECIALIX{"specialix=",specialix_setup},#endif#ifdefCONFIG_BAYCOM_PAR{"baycom_par=",baycom_par_setup},#endif#ifdefCONFIG_BAYCOM_SER_FDX{"baycom_ser_
fdx=",baycom_ser_fdx_setup},#endif#ifdefCONFIG_BAYCOM_SER_HDX{"baycom_ser_hdx=",baycom_ser_hdx_setup},#endif#ifdefCONFIG_SOUNDMODEM{"soundmodem=",sm_setup},#endif#ifdefCONFIG_WDT{"wdt=",wdt_setup},#endif#ifdefCONFIG_PARPORT{"parport=",parport_setup},#endif#
ifdefCONFIG_PLIP{"plip=",plip_setup},#endif#ifdefCONFIG_HFMODEM{"hfmodem=",hfmodem_setup},#endif#ifdefCONFIG_FTAPE{"ftape=",ftape_setup},#endif#ifdefCONFIG_MD_BOOT{"md=",md_setup},#endif#ifdefCONFIG_ADBMOUSE{"adb_buttons=",adb_mouse_setup},#endif#ifdefCONFI
G_LTPC{"ltpc=",ltpc_setup},#endif{0,0}};staticstructkernel_paramraw_params[]__initdata={{"root=",root_dev_setup},#ifdefCONFIG_ROOT_NFS{"nfsroot=",nfs_root_setup},{"nfsaddrs=",ip_auto_config_setup},#endif#ifdefCONFIG_IP_PNP{"ip=",ip_auto_config_setup},#endif
#ifdefCONFIG_PCI{"pci=",pci_setup},#endif#ifdefCONFIG_PARIDE_PD{"pd.",pd_setup},#endif#ifdefCONFIG_PARIDE_PCD{"pcd.",pcd_setup},#endif#ifdefCONFIG_PARIDE_PF{"pf.",pf_setup},#endif#ifdefCONFIG_PARIDE_PT{"pt.",pt_setup},#endif#ifdefCONFIG_PARIDE_PG{"pg.",pg_s
etup},#endif#ifdefCONFIG_APM{"apm=",apm_setup},#endif{0,0}};#ifdefCONFIG_BLK_DEV_RAMstaticvoid__initramdisk_start_setup(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_image_start=ints[1];}staticvoid__initload_ramdisk(char*str,int*ints){if(ints[0]>0&&ints[1]
>=0)rd_doload=ints[1]&1;}staticvoid__initprompt_ramdisk(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_prompt=ints[1]&1;}staticvoid__initramdisk_size(char*str,int*ints){if(ints[0]>0&&ints[1]>=0)rd_size=ints[1];}#endifstaticint__initchecksetup(char*line){int
i,ints[11];#ifdefCONFIG_BLK_DEV_IDE/*idedriverneedsthebasicstring,ratherthanpre-processedvalues*/if(!strncmp(line,"ide",3)||(!strncmp(line,"hd",2)&&line[2]!='=')){ide_setup(line);return1;}#endiffor(i=0;raw_params[i].str;i++){intn=strlen(raw_params[i].str);i
f(!strncmp(line,raw_params[i].str,n)){raw_params[i].setup_func(line+n,NULL);return1;}}for(i=0;cooked_params[i].str;i++){intn=strlen(cooked_params[i].str);if(!strncmp(line,cooked_params[i].str,n)){cooked_params[i].setup_func(get_options(line+n,ints),ints);re
turn1;}}return0;}/*thisshouldbeapprox2Bo*oMipstostart(noteinitialshift),andwillstillworkevenifinitiallytoolarge,itwilljusttakeslightlylonger*/unsignedlongloops_per_sec=(1<<12);/*Thisisthenumberofbitsofprecisionfortheloops_per_second.Eachbittakesonaverage1.5
/HZseconds.This(liketheoriginal)isalittlebetterthan1%*/#defineLPS_PREC8void__initcalibrate_delay(void){unsignedlongticks,loopbit;intlps_precision=LPS_PREC;loops_per_sec=(1<<12);printk("Calibratingdelayloop...");while(loops_per_sec<<=1){/*waitfor"startof"clo
cktick*/ticks=jiffies;while(ticks==jiffies)/*nothing*/;/*Go..*/ticks=jiffies;__delay(loops_per_sec);ticks=jiffies-ticks;if(ticks)break;}/*Doabinaryapproximationtogetloops_per_secondsettoequaloneclock(uptolps_precisionbits)*/loops_per_sec>>=1;loopbit=loops_p
er_sec;while(lps_precision--&&(loopbit>>=1)){loops_per_sec|=loopbit;ticks=jiffies;while(ticks==jiffies);ticks=jiffies;__delay(loops_per_sec);if(jiffies!=ticks)/*longerthan1tick*/loops_per_sec&=~loopbit;}/*finally,adjustloopspersecondintermsofsecondsinsteado
fclocks*/loops_per_sec*=HZ;/*Roundthevalueandprintit*/printk("%lu.%02luBogoMIPS\n",(loops_per_sec+2500)/500000,((loops_per_sec+2500)/5000)%100);}/**Thisisasimplekernelcommandlineparsingfunction:itparses*thecommandline,andfillsinthearguments/environmenttoini
t*asappropriate.Anycmd-lineoptionistakentobeanenvironment*variableifitcontainsthecharacter'='.**Thisroutinealsochecksforoptionsmeantforthekernel.*Theseoptionsarenotgiventoinit-theyareforinternalkerneluseonly.*/staticvoid__initparse_options(char*line){char*n
ext;intargs,envs;if(!*line)return;args=0;envs=1;/*TERMissetto'linux'bydefault*/next=line;while((line=next)!=NULL){if((next=strchr(line,''))!=NULL)*next++=0;/**checkforkerneloptionsfirst..*/if(!strcmp(line,"ro")){root_mountflags|=MS_RDONLY;continue;}if(!strc
mp(line,"rw")){root_mountflags&=~MS_RDONLY;continue;}if(!strcmp(line,"debug")){console_loglevel=10;continue;}if(!strncmp(line,"init=",5)){line+=5;execute_command=line;/*IncaseLILOisgoingtobootuswithdefaultcommandline,*itprepends"auto"beforethewholecmdlinewh
ichmakes*theshellthinkitshouldexecuteascriptwithsuchname.*Soweignoreallargumentsentered_before_init=...[MJ]*/args=0;continue;}if(checksetup(line))continue;/**Thencheckifit'sanenvironmentvariableor*anoption.*/if(strchr(line,'=')){if(envs>=MAX_INIT_ENVS)brea>