summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
committer <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
commit19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch)
tree40b1cb534496a7f1ca0f5c314a523c69f1fee464 /init
parent7206675c40394c78a90e74812bbdbf8cf3cca1be (diff)
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'init')
-rw-r--r--init/main.c316
1 files changed, 169 insertions, 147 deletions
diff --git a/init/main.c b/init/main.c
index 90d3f8f71..882ed0bdc 100644
--- a/init/main.c
+++ b/init/main.c
@@ -6,6 +6,7 @@
* 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__
@@ -21,14 +22,17 @@
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/fs.h>
+#include <linux/proc_fs.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/utsname.h>
#include <linux/ioport.h>
#include <linux/hdreg.h>
#include <linux/mm.h>
+#include <linux/slab.h>
#include <linux/major.h>
#include <linux/blk.h>
+#include <linux/init.h>
#ifdef CONFIG_ROOT_NFS
#include <linux/nfs_fs.h>
#endif
@@ -56,8 +60,6 @@
extern char _stext, _etext;
extern char *linux_banner;
-static char printbuf[1024];
-
extern int console_loglevel;
static int init(void *);
@@ -69,18 +71,26 @@ extern void init_modules(void);
extern long console_init(long, long);
extern long kmalloc_init(long,long);
extern void sock_init(void);
-extern long pci_init(long, long);
+extern unsigned long pci_init(unsigned long, unsigned long);
+extern long mca_init(long, long);
+extern long sbus_init(long, long);
extern void sysctl_init(void);
+extern void smp_setup(char *str, int *ints);
extern void no_scroll(char *str, int *ints);
extern void swap_setup(char *str, int *ints);
extern void buff_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);
+#ifdef CONFIG_PRINTER
extern void lp_setup(char *str, int *ints);
+#endif
extern void eth_setup(char *str, int *ints);
extern void xd_setup(char *str, int *ints);
+#ifdef CONFIG_BLK_DEV_EZ
+extern void ez_setup(char *str, int *ints);
+#endif
extern void floppy_setup(char *str, int *ints);
extern void st_setup(char *str, int *ints);
extern void st0x_setup(char *str, int *ints);
@@ -95,19 +105,28 @@ extern void aha1542_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 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 wd7000_setup(char *str, int *ints);
+#ifdef NOTDEF
extern void ppa_setup(char *str, int *ints);
+#endif
extern void scsi_luns_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_CDU31A
extern void cdu31a_setup(char *str, int *ints);
#endif CONFIG_CDU31A
+#ifdef CONFIG_BLK_DEV_PS2
+extern void ed_setup(char *str, int *ints);
+extern void tp720_setup(char *str, int *ints);
+#endif CONFIG_BLK_DEV_PS2
#ifdef CONFIG_MCD
extern void mcd_setup(char *str, int *ints);
#endif CONFIG_MCD
@@ -126,6 +145,9 @@ extern void sonycd535_setup(char *str, int *ints);
#ifdef CONFIG_GSCD
extern void gscd_setup(char *str, int *ints);
#endif CONFIG_GSCD
+#ifdef CONFIG_BPCD
+extern void bpcd_setup(char *str, int *ints);
+#endif CONFIG_BPCD
#ifdef CONFIG_CM206
extern void cm206_setup(char *str, int *ints);
#endif CONFIG_CM206
@@ -153,6 +175,12 @@ extern void icn_setup(char *str, int *ints);
#ifdef CONFIG_ISDN_DRV_TELES
extern void teles_setup(char *str, int *ints);
#endif
+#ifdef CONFIG_ISDN_DRV_HISAX
+extern void HiSax_setup(char *str, int *ints);
+#endif
+#ifdef CONFIG_ISDN_DRV_PCBIT
+extern void pcbit_setup(char *str, int *ints);
+#endif
#ifdef CONFIG_ATARIMOUSE
extern void atari_mouse_setup (char *str, int *ints);
@@ -169,9 +197,6 @@ extern void gvp11_setup (char *str, int *ints);
#ifdef CONFIG_DIGI
extern void pcxx_setup(char *str, int *ints);
#endif
-#ifdef CONFIG_ISDN_DRV_PCBIT
-extern void pcbit_setup(char *str, int *ints);
-#endif
#ifdef CONFIG_RISCOM8
extern void riscom8_setup(char *str, int *ints);
#endif
@@ -181,7 +206,15 @@ extern void baycom_setup(char *str, int *ints);
#ifdef CONFIG_SOUNDMODEM
extern void sm_setup(char *str, int *ints);
#endif
-
+#ifdef CONFIG_WDT
+extern void wdt_setup(char *str, int *ints);
+#endif
+#ifdef CONFIG_PNP_PARPORT
+extern void parport_setup(char *str, int *ints);
+#endif
+#ifdef CONFIG_PLIP
+extern void plip_setup(char *str, int *ints);
+#endif
#if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
extern void ipc_init(void);
@@ -195,6 +228,10 @@ extern void ipc_init(void);
extern int serial_console;
+#ifdef __sparc__
+extern int serial_console;
+#endif
+
/*
* Boot command-line arguments
*/
@@ -219,7 +256,7 @@ kdev_t real_root_dev;
#endif
int root_mountflags = MS_RDONLY;
-char *execute_command = 0;
+char *execute_command = NULL;
#ifdef CONFIG_ROOT_NFS
char nfs_root_name[NFS_ROOT_NAME_LEN] = { "default" };
@@ -231,10 +268,7 @@ extern void dquot_init(void);
static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
-static char * argv_rc[] = { "/bin/sh", NULL };
-static char * envp_rc[] = { "HOME=/", "TERM=linux", NULL };
-
-char *get_options(char *str, int *ints)
+__initfunc(char *get_options(char *str, int *ints))
{
char *cur = str;
int i=1;
@@ -248,7 +282,7 @@ char *get_options(char *str, int *ints)
return(cur);
}
-static void profile_setup(char *str, int *ints)
+__initfunc(static void profile_setup(char *str, int *ints))
{
if (ints[0] > 0)
prof_shift = (unsigned long) ints[1];
@@ -263,9 +297,13 @@ static void profile_setup(char *str, int *ints)
struct {
const char *str;
void (*setup_func)(char *, int *);
-} bootsetups[] = {
+} bootsetups[] __initdata = {
{ "reserve=", reserve_setup },
{ "profile=", profile_setup },
+#ifdef __SMP__
+ { "nosmp", smp_setup },
+ { "maxcpus=", smp_setup },
+#endif
#ifdef CONFIG_BLK_DEV_RAM
{ "ramdisk_start=", ramdisk_start_setup },
{ "load_ramdisk=", load_ramdisk },
@@ -276,10 +314,15 @@ struct {
{ "noinitrd", no_initrd },
#endif
#endif
+#if defined (CONFIG_AMIGA) || defined (CONFIG_ATARI)
+ { "video=", video_setup },
+#endif
{ "swap=", swap_setup },
{ "buff=", buff_setup },
{ "panic=", panic_setup },
+#ifdef CONFIG_VT
{ "no-scroll", no_scroll },
+#endif
#ifdef CONFIG_BUGi386
{ "no-hlt", no_halt },
{ "no387", no_387 },
@@ -335,6 +378,9 @@ struct {
#ifdef CONFIG_SCSI_BUSLOGIC
{ "BusLogic=", BusLogic_Setup},
#endif
+#ifdef CONFIG_SCSI_NCR53C8XX
+ { "ncr53c8xx=", ncr53c8xx_setup},
+#endif
#ifdef CONFIG_SCSI_EATA
{ "eata=", eata2x_setup},
#endif
@@ -356,15 +402,25 @@ struct {
#ifdef CONFIG_SCSI_7000FASST
{ "wd7000=", wd7000_setup},
#endif
-#ifdef CONFIG_SCSI_PPA
+#ifdef NOTDEF /* CONFIG_SCSI_PPA */
{ "ppa=", ppa_setup },
#endif
+#ifdef CONFIG_SCSI_IBMMCA
+ { "ibmmcascsi=", ibmmca_scsi_setup },
+#endif
#ifdef CONFIG_BLK_DEV_XD
{ "xd=", xd_setup },
#endif
+#ifdef CONFIG_BLK_DEV_EZ
+ { "ez=", ez_setup },
+#endif
#ifdef CONFIG_BLK_DEV_FD
{ "floppy=", floppy_setup },
#endif
+#ifdef CONFIG_BLK_DEV_PS2
+ { "ed=", ed_setup },
+ { "tp720=", tp720_setup },
+#endif
#ifdef CONFIG_CDU31A
{ "cdu31a=", cdu31a_setup },
#endif CONFIG_CDU31A
@@ -386,6 +442,9 @@ struct {
#ifdef CONFIG_GSCD
{ "gscd=", gscd_setup },
#endif CONFIG_GSCD
+#ifdef CONFIG_BPCD
+ { "bpcd=", bpcd_setup },
+#endif CONFIG_BPCD
#ifdef CONFIG_CM206
{ "cm206=", cm206_setup },
#endif CONFIG_CM206
@@ -407,6 +466,10 @@ struct {
#ifdef CONFIG_ISDN_DRV_TELES
{ "teles=", teles_setup },
#endif
+#ifdef CONFIG_ISDN_DRV_HISAX
+ { "hisax=", HiSax_setup },
+ { "HiSax=", HiSax_setup },
+#endif
#ifdef CONFIG_ISDN_DRV_PCBIT
{ "pcbit=", pcbit_setup },
#endif
@@ -438,29 +501,38 @@ struct {
#ifdef CONFIG_SOUNDMODEM
{ "soundmodem=", sm_setup },
#endif
+#ifdef CONFIG_WDT
+ { "wdt=", wdt_setup },
+#endif
+#ifdef CONFIG_PNP_PARPORT
+ { "parport=", parport_setup },
+#endif
+#ifdef CONFIG_PLIP
+ { "plip=", plip_setup },
+#endif
{ 0, 0 }
};
#ifdef CONFIG_BLK_DEV_RAM
-static void ramdisk_start_setup(char *str, int *ints)
+__initfunc(static void ramdisk_start_setup(char *str, int *ints))
{
if (ints[0] > 0 && ints[1] >= 0)
rd_image_start = ints[1];
}
-static void load_ramdisk(char *str, int *ints)
+__initfunc(static void load_ramdisk(char *str, int *ints))
{
if (ints[0] > 0 && ints[1] >= 0)
rd_doload = ints[1] & 1;
}
-static void prompt_ramdisk(char *str, int *ints)
+__initfunc(static void prompt_ramdisk(char *str, int *ints))
{
if (ints[0] > 0 && ints[1] >= 0)
rd_prompt = ints[1] & 1;
}
-static void ramdisk_size(char *str, int *ints)
+__initfunc(static void ramdisk_size(char *str, int *ints))
{
if (ints[0] > 0 && ints[1] >= 0)
rd_size = ints[1];
@@ -468,7 +540,7 @@ static void ramdisk_size(char *str, int *ints)
#endif
-static int checksetup(char *line)
+__initfunc(static int checksetup(char *line))
{
int i = 0;
int ints[11];
@@ -500,7 +572,7 @@ unsigned long loops_per_sec = (1<<12);
better than 1% */
#define LPS_PREC 8
-void calibrate_delay(void)
+__initfunc(void calibrate_delay(void))
{
unsigned long ticks, loopbit;
int lps_precision = LPS_PREC;
@@ -543,7 +615,7 @@ void calibrate_delay(void)
((loops_per_sec+2500)/5000) % 100);
}
-static void parse_root_dev(char * line)
+__initfunc(static void parse_root_dev(char * line))
{
int base = 0;
static struct dev_name_struct {
@@ -560,6 +632,11 @@ static void parse_root_dev(char * line)
{ "sdc", 0x0820 },
{ "sdd", 0x0830 },
{ "sde", 0x0840 },
+ { "ada", 0x1c00 },
+ { "adb", 0x1c10 },
+ { "adc", 0x1c20 },
+ { "add", 0x1c30 },
+ { "ade", 0x1c40 },
{ "fd", 0x0200 },
{ "xda", 0x0d00 },
{ "xdb", 0x0d40 },
@@ -572,6 +649,14 @@ static void parse_root_dev(char * line)
{ "gscd", 0x1000 },
{ "sbpcd", 0x1900 },
{ "sonycd", 0x1800 },
+ { "eza", 0x2800 },
+ { "bpcd", 0x2900 },
+#if CONFIG_APBLOCK
+ { "apblock", APBLOCK_MAJOR << 8},
+#endif
+#if CONFIG_DDV
+ { "ddv", DDV_MAJOR << 8},
+#endif
{ NULL, 0 }
};
@@ -601,7 +686,7 @@ static void parse_root_dev(char * line)
* This routine also checks for options meant for the kernel.
* These options are not given to init - they are for internal kernel use only.
*/
-static void parse_options(char *line)
+__initfunc(static void parse_options(char *line))
{
char *next;
int args, envs;
@@ -663,6 +748,7 @@ static void parse_options(char *line)
}
if (checksetup(line))
continue;
+
/*
* Then check if it's an environment variable or
* an option.
@@ -683,7 +769,6 @@ static void parse_options(char *line)
extern void setup_arch(char **, unsigned long *, unsigned long *);
-extern void arch_syms_export(void);
#ifndef __SMP__
@@ -709,7 +794,7 @@ extern int cpu_idle(void * unused);
* Activate a secondary processor.
*/
-asmlinkage void start_secondary(void)
+__initfunc(asmlinkage void start_secondary(void))
{
trap_init();
init_IRQ();
@@ -719,45 +804,28 @@ asmlinkage void start_secondary(void)
-/*
- * Called by CPU#0 to activate the rest.
- */
-
-static void smp_init(void)
+/* Called by boot processor to activate the rest. */
+__initfunc(static void smp_init(void))
{
int i, j;
+
+ /* Get other processors into their bootup holding patterns. */
smp_boot_cpus();
-
- /*
- * Create the slave init tasks as sharing pid 0.
- *
- * This should only happen if we have virtual CPU numbers
- * higher than 0.
- */
+ /* Create the slave init tasks as sharing pid 0. This should only
+ * happen if we have virtual CPU numbers higher than 0.
+ */
for (i=1; i<smp_num_cpus; i++)
{
- struct task_struct *n, *p;
-
- j = cpu_logical_map[i];
- /*
- * We use kernel_thread for the idlers which are
- * unlocked tasks running in kernel space.
+ /* We use kernel_thread for the idlers which are
+ * unlocked tasks running in kernel space.
*/
kernel_thread(cpu_idle, NULL, CLONE_PID);
- /*
- * Don't assume linear processor numbering
- */
+
+ /* Don't assume linear processor numbering */
+ j = cpu_logical_map[i];
current_set[j]=task[i];
current_set[j]->processor=j;
- cli();
- n = task[i]->next_run;
- p = task[i]->prev_run;
- nr_running--;
- n->prev_run = p;
- p->next_run = n;
- task[i]->next_run = task[i]->prev_run = task[i];
- sti();
}
}
@@ -767,7 +835,7 @@ static void smp_init(void)
* they are finished.
*/
-static void smp_begin(void)
+__initfunc(static void smp_begin(void))
{
smp_threads_ready=1;
smp_commence();
@@ -779,7 +847,7 @@ static void smp_begin(void)
* Activate the first processor.
*/
-asmlinkage void start_kernel(void)
+__initfunc(asmlinkage void start_kernel(void))
{
char * command_line;
@@ -825,6 +893,9 @@ asmlinkage void start_kernel(void)
memory_start += prof_len * sizeof(unsigned int);
memset(prof_buffer, 0, prof_len * sizeof(unsigned int));
}
+#ifdef CONFIG_SBUS
+ memory_start = sbus_init(memory_start,memory_end);
+#endif
memory_start = console_init(memory_start,memory_end);
#ifdef CONFIG_REMOTE_DEBUG
set_debug_traps();
@@ -833,27 +904,35 @@ asmlinkage void start_kernel(void)
#ifdef CONFIG_PCI
memory_start = pci_init(memory_start,memory_end);
#endif
+#ifdef CONFIG_MCA
+ memory_start = mca_init(memory_start,memory_end);
+#endif
memory_start = kmalloc_init(memory_start,memory_end);
+ memory_start = kmem_cache_init(memory_start, memory_end);
sti();
calibrate_delay();
- memory_start = inode_init(memory_start,memory_end);
memory_start = file_table_init(memory_start,memory_end);
memory_start = name_cache_init(memory_start,memory_end);
#ifdef CONFIG_BLK_DEV_INITRD
- if (initrd_start && initrd_start < memory_start) {
+ if (initrd_start && !initrd_below_start_ok && initrd_start < memory_start) {
printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
"disabling it.\n",initrd_start,memory_start);
initrd_start = 0;
}
#endif
mem_init(memory_start,memory_end);
+#ifdef CONFIG_PROC_FS
+ proc_root_init();
+#endif
+ kmem_cache_sizes_init();
+ vma_init();
buffer_init();
+ inode_init();
sock_init();
#if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
ipc_init();
#endif
dquot_init();
- arch_syms_export();
sti();
check_bugs();
@@ -862,7 +941,9 @@ asmlinkage void start_kernel(void)
#ifdef __SMP__
smp_init();
#endif
+#ifdef CONFIG_SYSCTL
sysctl_init();
+#endif
/*
* We count on the initial thread going ok
* Like idlers init is an unlocked kernel thread, which will
@@ -881,45 +962,6 @@ asmlinkage void start_kernel(void)
cpu_idle(NULL);
}
-static int printf(const char *fmt, ...)
-{
- va_list args;
- int i;
-
- va_start(args, fmt);
- write(1,printbuf,i=vsprintf(printbuf, fmt, args));
- va_end(args);
- return i;
-}
-
-static int do_rc(void * rc)
-{
- close(0);
- if (open(rc,O_RDONLY,0))
- return -1;
- return execve("/bin/sh", argv_rc, envp_rc);
-}
-
-static int do_shell(void * shell)
-{
- char *argv[2];
-
- close(0);close(1);close(2);
- setsid();
- if (serial_console == 1) {
- (void) open("/dev/ttyS0",O_RDWR,0);
- } else if (serial_console == 2) {
- (void) open("/dev/ttyS1",O_RDWR,0);
- } else {
- (void) open("/dev/tty1",O_RDWR,0);
- }
- (void) dup(0);
- (void) dup(0);
- argv[0] = shell;
- argv[1] = NULL;
- return execve(shell, argv, envp_rc);
-}
-
#ifdef CONFIG_BLK_DEV_INITRD
static int do_linuxrc(void * shell)
{
@@ -928,23 +970,12 @@ static int do_linuxrc(void * shell)
close(0);close(1);close(2);
setsid();
(void) open("/dev/tty1",O_RDWR,0);
-
- /*
- * This keeps serial console MUCH cleaner, but does assume
- * the console driver checks there really is a video device
- * attached (Sparc effectively does).
- */
-
- if ((open("/dev/tty1",O_RDWR,0) < 0) &&
- (open("/dev/ttyS0",O_RDWR,0) < 0))
- printk("Unable to open an initial console.\n");
-
(void) dup(0);
(void) dup(0);
return execve(shell, argv, envp_init);
}
-static void no_initrd(char *s,int *ints)
+__initfunc(static void no_initrd(char *s,int *ints))
{
mount_initrd = 0;
}
@@ -952,7 +983,6 @@ static void no_initrd(char *s,int *ints)
static int init(void * unused)
{
- int pid,i;
#ifdef CONFIG_BLK_DEV_INITRD
int real_root_mountflags;
#endif
@@ -962,6 +992,14 @@ static int init(void * unused)
/* Start the background pageout daemon. */
kernel_thread(kswapd, NULL, 0);
+#if CONFIG_AP1000
+ /* Start the async paging daemon. */
+ {
+ extern int asyncd(void *);
+ kernel_thread(asyncd, NULL, 0);
+ }
+#endif
+
#ifdef CONFIG_BLK_DEV_INITRD
real_root_dev = ROOT_DEV;
real_root_mountflags = root_mountflags;
@@ -979,7 +1017,7 @@ static int init(void * unused)
smp_begin();
#endif
- #ifdef CONFIG_UMSDOS_FS
+#ifdef CONFIG_UMSDOS_FS
{
/*
When mounting a umsdos fs as root, we detect
@@ -992,12 +1030,13 @@ static int init(void * unused)
current->fs->pwd = pseudo_root;
}
}
- #endif
+#endif
#ifdef CONFIG_BLK_DEV_INITRD
root_mountflags = real_root_mountflags;
if (mount_initrd && ROOT_DEV != real_root_dev && ROOT_DEV == MKDEV(RAMDISK_MAJOR,0)) {
int error;
+ int i, pid;
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
if (pid>0)
@@ -1011,41 +1050,24 @@ static int init(void * unused)
}
#endif
- if (serial_console == 1) {
- (void) open("/dev/cua0",O_RDWR,0);
- } else if(serial_console == 2) {
- (void) open("/dev/cua1",O_RDWR,0);
- } else {
- (void) open("/dev/tty1",O_RDWR,0);
- }
+ if (open("/dev/console",O_RDWR,0) < 0)
+ printk("Unable to open an initial console.\n");
+
(void) dup(0);
(void) dup(0);
+
+ /*
+ * We try each of these until one succeeds.
+ *
+ * The Bourne shell can be used instead of init if we are
+ * trying to recover a really broken machine.
+ */
- if (!execute_command) {
- execve("/etc/init",argv_init,envp_init);
- execve("/bin/init",argv_init,envp_init);
- execve("/sbin/init",argv_init,envp_init);
- /* if this fails, fall through to original stuff */
-
- pid = kernel_thread(do_rc, "/etc/rc", SIGCHLD);
- if (pid>0)
- while (pid != wait(&i))
- /* nothing */;
- }
-
- while (1) {
- pid = kernel_thread(do_shell,
- execute_command ? execute_command : "/bin/sh",
- SIGCHLD);
- if (pid < 0) {
- printf("Fork failed in init\n\r");
- continue;
- }
- while (1)
- if (pid == wait(&i))
- break;
- printf("\n\rchild %d died with code %04x\n\r",pid,i);
- sync();
- }
- return -1;
+ 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("No init found. Try passing init= option to kernel.");
}