📄 main.c,v
字号:
head 1.1;access;symbols;locks sjzhu:1.1; strict;comment @ * @;1.1date 2000.09.14.02.02.13; author sjzhu; state Exp;branches;next ;desc@debug for OCTOPUS, why enter into machine_halt()@1.1log@Initial revision@text@/* * linux/init/main.c * * Copyright (C) 1991, 1992 Linus Torvalds * * GK 2/5/95 - Changed to support mounting root fs via NFS * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96 * Simplified starting of init: Michael A. Griffith <grif@@acm.org> */#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>#ifdef CONFIG_PCI#include <linux/pci.h>#endif#ifdef CONFIG_USB#define __UUSBD__#include <uusbd/usbd.h>#endif#ifdef CONFIG_DIO#include <linux/dio.h>#endif#ifdef CONFIG_ZORRO#include <linux/zorro.h>#endif#ifdef CONFIG_MTRR# include <asm/mtrr.h>#endif#ifdef CONFIG_APM#include <linux/apm_bios.h>#endif/* * Versions of gcc older than that listed below may actually compile * and link okay, but the end product can have subtle run time bugs. * To avoid associated bogus bug reports, we flatly refuse to compile * with a gcc that is known to be too old from the very beginning. */#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)#error sorry, your GCC is too old. It builds incorrect kernels.#endifextern char _stext, _etext;extern char *linux_banner;extern int console_loglevel;static int init(void *);extern int bdflush(void *);extern int kswapd(void *);extern int kpiod(void *);extern void kswapd_setup(void);extern void init_IRQ(void);extern void init_modules(void);extern long console_init(long, long);extern void sock_init(void);extern void uidcache_init(void);extern void mca_init(void);extern void sbus_init(void);extern void powermac_init(void);extern void sysctl_init(void);extern void filescache_init(void);extern void signals_init(void);extern void device_setup(void);extern void binfmt_setup(void);extern void free_initmem(void);extern void filesystem_setup(void);#ifdef CONFIG_ARCH_ACORNextern void ecard_init(void);#endifextern void smp_setup(char *str, int *ints);#ifdef __i386__extern void ioapic_pirq_setup(char *str, int *ints);extern void ioapic_setup(char *str, int *ints);#endifextern void no_scroll(char *str, int *ints);extern void kbd_reset_setup(char *str, int *ints);extern void panic_setup(char *str, int *ints);extern void bmouse_setup(char *str, int *ints);extern void msmouse_setup(char *str, int *ints);extern void console_setup(char *str, int *ints);#ifdef CONFIG_PRINTERextern void lp_setup(char *str, int *ints);#endif#ifdef CONFIG_JOY_AMIGAextern void js_am_setup(char *str, int *ints);#endif#ifdef CONFIG_JOY_ANALOGextern void js_an_setup(char *str, int *ints);#endif#ifdef CONFIG_JOY_ASSASINextern void js_as_setup(char *str, int *ints);#endif#ifdef CONFIG_JOY_CONSOLEextern void js_console_setup(char *str, int *ints);#endif#ifdef CONFIG_JOY_DB9extern void js_db9_setup(char *str, int *ints);#endif#ifdef CONFIG_JOY_TURBOGRAFXextern void js_tg_setup(char *str, int *ints);#endif#ifdef CONFIG_JOY_LIGHTNINGextern void js_l4_setup(char *str, int *ints);#endifextern void eth_setup(char *str, int *ints);#ifdef CONFIG_ARCNET_COM20020extern void com20020_setup(char *str, int *ints);#endif#ifdef CONFIG_ARCNET_RIM_Iextern void arcrimi_setup(char *str, int *ints);#endif#ifdef CONFIG_ARCNET_COM90xxIOextern void com90io_setup(char *str, int *ints);#endif#ifdef CONFIG_ARCNET_COM90xxextern void com90xx_setup(char *str, int *ints);#endif#ifdef CONFIG_DECNETextern void decnet_setup(char *str, int *ints);#endif#ifdef CONFIG_BLK_DEV_XDextern void xd_setup(char *str, int *ints);extern void xd_manual_geo_init(char *str, int *ints);#endif#ifdef CONFIG_BLK_DEV_IDEextern void ide_setup(char *);#endif#ifdef CONFIG_PARIDE_PDextern void pd_setup(char *str, int *ints);#endif#ifdef CONFIG_PARIDE_PFextern void pf_setup(char *str, int *ints);#endif#ifdef CONFIG_PARIDE_PTextern void pt_setup(char *str, int *ints);#endif#ifdef CONFIG_PARIDE_PGextern void pg_setup(char *str, int *ints);#endif#ifdef CONFIG_PARIDE_PCDextern void pcd_setup(char *str, int *ints);#endifextern void floppy_setup(char *str, int *ints);extern void st_setup(char *str, int *ints);extern void st0x_setup(char *str, int *ints);extern void advansys_setup(char *str, int *ints);extern void tmc8xx_setup(char *str, int *ints);extern void t128_setup(char *str, int *ints);extern void pas16_setup(char *str, int *ints);extern void generic_NCR5380_setup(char *str, int *intr);extern void generic_NCR53C400_setup(char *str, int *intr);extern void generic_NCR53C400A_setup(char *str, int *intr);extern void generic_DTC3181E_setup(char *str, int *intr);extern void aha152x_setup(char *str, int *ints);extern void aha1542_setup(char *str, int *ints);extern void gdth_setup(char *str, int *ints);extern void aic7xxx_setup(char *str, int *ints);extern void AM53C974_setup(char *str, int *ints);extern void BusLogic_Setup(char *str, int *ints);extern void ncr53c8xx_setup(char *str, int *ints);extern void sym53c8xx_setup(char *str, int *ints);extern void eata2x_setup(char *str, int *ints);extern void u14_34f_setup(char *str, int *ints);extern void fdomain_setup(char *str, int *ints);extern void ibmmca_scsi_setup(char *str, int *ints);extern void in2000_setup(char *str, int *ints);extern void NCR53c406a_setup(char *str, int *ints);extern void sym53c416_setup(char *str, int *ints);extern void wd7000_setup(char *str, int *ints);extern void dc390_setup(char* str, int *ints);extern void scsi_luns_setup(char *str, int *ints);extern void scsi_logging_setup(char *str, int *ints);extern void sound_setup(char *str, int *ints);extern void reboot_setup(char *str, int *ints);extern void video_setup(char *str, int *ints);#ifdef CONFIG_CDU31Aextern void cdu31a_setup(char *str, int *ints);#endif CONFIG_CDU31A#ifdef CONFIG_BLK_DEV_PS2extern void ed_setup(char *str, int *ints);extern void tp720_setup(char *str, int *ints);#endif CONFIG_BLK_DEV_PS2#ifdef CONFIG_MCDextern void mcd_setup(char *str, int *ints);#endif CONFIG_MCD#ifdef CONFIG_MCDXextern void mcdx_setup(char *str, int *ints);#endif CONFIG_MCDX#ifdef CONFIG_SBPCDextern void sbpcd_setup(char *str, int *ints);#endif CONFIG_SBPCD#ifdef CONFIG_AZTCDextern void aztcd_setup(char *str, int *ints);#endif CONFIG_AZTCD#ifdef CONFIG_CDU535extern void sonycd535_setup(char *str, int *ints);#endif CONFIG_CDU535#ifdef CONFIG_GSCDextern void gscd_setup(char *str, int *ints);#endif CONFIG_GSCD#ifdef CONFIG_CM206extern void cm206_setup(char *str, int *ints);#endif CONFIG_CM206#ifdef CONFIG_OPTCDextern void optcd_setup(char *str, int *ints);#endif CONFIG_OPTCD#ifdef CONFIG_SJCDextern void sjcd_setup(char *str, int *ints);#endif CONFIG_SJCD#ifdef CONFIG_ISP16_CDIextern void isp16_setup(char *str, int *ints);#endif CONFIG_ISP16_CDI#ifdef CONFIG_BLK_DEV_RAMstatic void ramdisk_start_setup(char *str, int *ints);static void load_ramdisk(char *str, int *ints);static void prompt_ramdisk(char *str, int *ints);static void ramdisk_size(char *str, int *ints);#ifdef CONFIG_BLK_DEV_INITRDstatic void no_initrd(char *s,int *ints);#endif#endif CONFIG_BLK_DEV_RAM#ifdef CONFIG_ISDN_DRV_ICNextern void icn_setup(char *str, int *ints);#endif#ifdef CONFIG_ISDN_DRV_HISAXextern void HiSax_setup(char *str, int *ints);#endif#ifdef CONFIG_DIGIEPCAextern void epca_setup(char *str, int *ints);#endif#ifdef CONFIG_ISDN_DRV_PCBITextern void pcbit_setup(char *str, int *ints);#endif#ifdef CONFIG_ATARIMOUSEextern void atari_mouse_setup (char *str, int *ints);#endif#ifdef CONFIG_DMASOUNDextern void dmasound_setup (char *str, int *ints);#endif#ifdef CONFIG_ATARI_SCSIextern void atari_scsi_setup (char *str, int *ints);#endifextern void stram_swap_setup (char *str, int *ints);extern void wd33c93_setup (char *str, int *ints);extern void gvp11_setup (char *str, int *ints);extern void ncr53c7xx_setup (char *str, int *ints);#ifdef CONFIG_MAC_SCSIextern void mac_scsi_setup (char *str, int *ints);#endif#ifdef CONFIG_CYCLADESextern void cy_setup(char *str, int *ints);#endif#ifdef CONFIG_DIGIextern void pcxx_setup(char *str, int *ints);#endif#ifdef CONFIG_RISCOM8extern void riscom8_setup(char *str, int *ints);#endif#ifdef CONFIG_SPECIALIXextern void specialix_setup(char *str, int *ints);#endif#ifdef CONFIG_DMASCCextern void dmascc_setup(char *str, int *ints);#endif#ifdef CONFIG_BAYCOM_PARextern void baycom_par_setup(char *str, int *ints);#endif#ifdef CONFIG_BAYCOM_SER_FDXextern void baycom_ser_fdx_setup(char *str, int *ints);#endif#ifdef CONFIG_BAYCOM_SER_HDXextern void baycom_ser_hdx_setup(char *str, int *ints);#endif#ifdef CONFIG_SOUNDMODEMextern void sm_setup(char *str, int *ints);#endif#ifdef CONFIG_ADBMOUSEextern void adb_mouse_setup(char *str, int *ints);#endif#ifdef CONFIG_WDTextern void wdt_setup(char *str, int *ints);#endif#ifdef CONFIG_PARPORTextern void parport_setup(char *str, int *ints);#endif#ifdef CONFIG_PLIPextern void plip_setup(char *str, int *ints);#endif#ifdef CONFIG_HFMODEMextern void hfmodem_setup(char *str, int *ints);#endif#ifdef CONFIG_IP_PNPextern void ip_auto_config_setup(char *str, int *ints);#endif#ifdef CONFIG_ROOT_NFSextern void nfs_root_setup(char *str, int *ints);#endif#ifdef CONFIG_FTAPEextern void ftape_setup(char *str, int *ints);#endif#ifdef CONFIG_MDA_CONSOLEextern void mdacon_setup(char *str, int *ints);#endif#ifdef CONFIG_LTPCextern void ltpc_setup(char *str, int *ints);#endif#if defined(CONFIG_SYSVIPC)extern void ipc_init(void);#endif#if defined(CONFIG_QUOTA)extern void dquot_init_hash(void);#endif#ifdef CONFIG_MD_BOOTextern void md_setup(char *str,int *ints) __init;#endif/* * Boot command-line arguments */#define MAX_INIT_ARGS 8#define MAX_INIT_ENVS 8extern void time_init(void);static unsigned long memory_start = 0;static unsigned long memory_end = 0;int rows, cols;#ifdef CONFIG_BLK_DEV_RAMextern int rd_doload; /* 1 = load ramdisk, 0 = don't load */extern int rd_prompt; /* 1 = prompt for ramdisk, 0 = don't prompt */extern int rd_size; /* Size of the ramdisk(s) */extern int rd_image_start; /* starting block # of image */#ifdef CONFIG_BLK_DEV_INITRDkdev_t real_root_dev;#endif#endifint root_mountflags = MS_RDONLY;char *execute_command = NULL;static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };char *get_options(char *str, int *ints){ char *cur = str; int i=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);}static void __init profile_setup(char *str, int *ints){ if (ints[0] > 0) prof_shift = (unsigned long) ints[1]; else prof_shift = 2;}static struct dev_name_struct { const char *name; const int num;} root_dev_names[] __initdata = {#ifdef CONFIG_ROOT_NFS { "nfs", 0x00ff },#endif#ifdef CONFIG_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#ifdef CONFIG_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#ifdef CONFIG_ATARI_ACSI { "ada", 0x1c00 }, { "adb", 0x1c10 }, { "adc", 0x1c20 }, { "add", 0x1c30 }, { "ade", 0x1c40 },#endif#ifdef CONFIG_BLK_DEV_FD { "fd", 0x0200 },#endif#ifdef CONFIG_MD_BOOT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -