patch-2.1.44 linux/arch/mips/kernel/setup.c

Next file: linux/arch/mips/kernel/signal.c
Previous file: linux/arch/mips/kernel/reset.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.43/linux/arch/mips/kernel/setup.c linux/arch/mips/kernel/setup.c
@@ -2,11 +2,13 @@
  *  linux/arch/mips/kernel/setup.c
  *
  *  Copyright (C) 1995  Linus Torvalds
- *  Copyright (C) 1995  Ralf Baechle
+ *  Copyright (C) 1995, 1996  Ralf Baechle
+ *  Copyright (C) 1996  Stoned Elipot
  */
 #include <linux/config.h>
-#include <linux/delay.h>
 #include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -15,198 +17,87 @@
 #include <linux/unistd.h>
 #include <linux/ptrace.h>
 #include <linux/malloc.h>
-#include <linux/ldt.h>
 #include <linux/user.h>
+#include <linux/utsname.h>
 #include <linux/a.out.h>
 #include <linux/tty.h>
+#ifdef CONFIG_BLK_DEV_RAM
+#include <linux/blk.h>
+#endif
+#ifdef CONFIG_RTC
+#include <linux/ioport.h>
+#include <linux/timex.h>
+#endif
 
 #include <asm/asm.h>
 #include <asm/bootinfo.h>
+#include <asm/cachectl.h>
+#include <asm/io.h>
 #include <asm/vector.h>
-#include <asm/segment.h>
 #include <asm/stackframe.h>
 #include <asm/system.h>
+#ifdef CONFIG_SGI
+#include <asm/sgialib.h>
+#endif
 
 /*
  * How to handle the machine's features
  */
 struct feature *feature;
 
-#ifdef CONFIG_ACER_PICA_61
-void acer_pica_61_handle_int(void);
-/*
- * How to access the floppy controller's ports
- */
-unsigned char jazz_fd_inb(unsigned int port);
-void jazz_fd_outb(unsigned char value, unsigned int port);
-/*
- * How to access the floppy DMA functions.
- */
-void jazz_fd_enable_dma(void);
-void jazz_fd_disable_dma(void);
-int jazz_fd_request_dma(void);
-void jazz_fd_free_dma(void);
-void jazz_fd_clear_dma_ff(void);
-void jazz_fd_set_dma_mode(char mode);
-void jazz_fd_set_dma_addr(unsigned int a);
-void jazz_fd_set_dma_count(unsigned int count);
-int jazz_fd_get_dma_residue(void);
-void jazz_fd_enable_irq(void);
-void jazz_fd_disable_irq(void);
-void jazz_fd_cacheflush(unsigned char *addr, unsigned int size);
 /*
- * How to access the RTC functions.
+ * What to do to keep the caches consistent with memory
+ * We don't use the normal cacheflush routine to keep Tyne caches happier.
  */
-unsigned char jazz_rtc_read_data(void);
-void jazz_rtc_write_data(unsigned char data);
+void (*fd_cacheflush)(const void *addr, size_t size);
 
-struct feature acer_pica_61_feature = {
-	acer_pica_61_handle_int,
-	/*
-	 * How to access the floppy controller's ports
-	 */
-	jazz_fd_inb,
-	jazz_fd_outb,
-	/*
-	 * How to access the floppy DMA functions.
-	 */
-	jazz_fd_enable_dma,
-	jazz_fd_disable_dma,
-	jazz_fd_request_dma,
-	jazz_fd_free_dma,
-	jazz_fd_clear_dma_ff,
-	jazz_fd_set_dma_mode,
-	jazz_fd_set_dma_addr,
-	jazz_fd_set_dma_count,
-	jazz_fd_get_dma_residue,
-	jazz_fd_enable_irq,
-	jazz_fd_disable_irq,
-	jazz_fd_cacheflush,
-	/*
-	 * How to access the RTC functions.
-	 */
-	jazz_rtc_read_data,
-	jazz_rtc_write_data
-};
-#endif
-#ifdef CONFIG_DECSTATION
-void decstation_handle_handle_int(void);
-void isa_outb(unsigned char value, unsigned int port);
-unsigned char isa_inb(unsigned int port);
-struct feature decstation_feature = {
-	decstation_handle_handle_int,
-	isa_inb /* Dummy - dunno how to handle this yet */
-	isa_outb, /* Dummy - dunno how to handle this yet */
-};
-#endif
-#ifdef CONFIG_DESKSTATION_RPC44
-void deskstation_rpc44_handle_int(void);
-void isa_outb(unsigned char value, unsigned int port);
-unsigned char isa_inb(unsigned int port);
-struct feature deskstation_rpc44_feature = {
-	deskstation_rpc44_handle_int,
-	isa_inb
-	isa_outb,
-};
-#endif
-#ifdef CONFIG_DESKSTATION_TYNE
-void deskstation_tyne_handle_int(void);
-void isa_outb(unsigned char value, unsigned int port);
-unsigned char isa_inb(unsigned int port);
-struct feature deskstation_tyne_feature = {
-	deskstation_tyne_handle_int,
-	isa_inb,
-	isa_outb,
-};
-#endif
-#ifdef CONFIG_MIPS_MAGNUM_4000
-void mips_magnum_4000_handle_int(void);
-/*
- * How to access the floppy controller's ports
- */
-unsigned char jazz_fd_inb(unsigned int port);
-void jazz_fd_outb(unsigned char value, unsigned int port);
 /*
- * How to access the floppy DMA functions.
+ * Not all of the MIPS CPUs have the "wait" instruction available.  This
+ * is set to true if it is available.  The wait instruction stops the
+ * pipeline and reduces the power consumption of the CPU very much.
  */
-void jazz_fd_enable_dma(void);
-void jazz_fd_disable_dma(void);
-int jazz_fd_request_dma(void);
-void jazz_fd_free_dma(void);
-void jazz_fd_clear_dma_ff(void);
-void jazz_fd_set_dma_mode(char mode);
-void jazz_fd_set_dma_addr(unsigned int a);
-void jazz_fd_set_dma_count(unsigned int count);
-int jazz_fd_get_dma_residue(void);
-void jazz_fd_enable_irq(void);
-void jazz_fd_disable_irq(void);
-void jazz_fd_cacheflush(unsigned char *addr, unsigned int size);
-/*
- * How to access the RTC functions.
- */
-unsigned char jazz_rtc_read_data(void);
-void jazz_rtc_write_data(unsigned char data);
-
-struct feature mips_magnum_4000_feature = {
-	mips_magnum_4000_handle_int,
-	/*
-	 * How to access the floppy controller's ports
-	 */
-	jazz_fd_inb,
-	jazz_fd_outb,
-	/*
-	 * How to access the floppy DMA functions.
-	 */
-	jazz_fd_enable_dma,
-	jazz_fd_disable_dma,
-	jazz_fd_request_dma,
-	jazz_fd_free_dma,
-	jazz_fd_clear_dma_ff,
-	jazz_fd_set_dma_mode,
-	jazz_fd_set_dma_addr,
-	jazz_fd_set_dma_count,
-	jazz_fd_get_dma_residue,
-	jazz_fd_enable_irq,
-	jazz_fd_disable_irq,
-	jazz_fd_cacheflush,
-	/*
-	 * How to access the RTC functions.
-	 */
-	jazz_rtc_read_data,
-	jazz_rtc_write_data
-};
-#endif
+char wait_available;
 
 /*
- * Tell us the machine setup..
+ * There are several bus types available for MIPS machines.  "RISC PC"
+ * type machines have ISA, EISA, VLB or PCI available, DECstations
+ * have Turbochannel or Q-Bus, SGI has GIO, there are lots of VME
+ * boxes ...
+ * This flag is set if a EISA slots are available.
  */
-char wait_available;		/* set if the "wait" instruction available */
+int EISA_bus = 0;
 
 /*
- * Bus types ..
+ * Milo passes some information to the kernel that looks like as if it
+ * had been returned by a Intel PC BIOS.  Milo doesn't fill the passed
+ * drive_info and Linux can find out about this anyway, so I'm going to
+ * remove this sometime.  screen_info contains information about the 
+ * resolution of the text screen.  For VGA graphics based machine this
+ * information is being use to continue the screen output just below
+ * the BIOS printed text and with the same text resolution.
  */
-int EISA_bus = 0;
+struct drive_info_struct drive_info = DEFAULT_DRIVE_INFO;
+struct screen_info screen_info = DEFAULT_SCREEN_INFO;
 
 /*
- * Setup options
+ * setup informations
+ *
+ * These are intialized so they are in the .data section
  */
-struct drive_info_struct drive_info;
-struct screen_info screen_info = SCREEN_INFO;
+unsigned long mips_memory_upper = KSEG0; /* this is set by kernel_entry() */
+unsigned long mips_cputype = CPU_UNKNOWN;
+unsigned long mips_machtype = MACH_UNKNOWN;
+unsigned long mips_machgroup = MACH_GROUP_UNKNOWN;
+unsigned long mips_tlb_entries = 48; /* Guess which CPU I've got :) */
+unsigned long mips_vram_base = KSEG0;
 
 unsigned char aux_device_present;
-extern int ramdisk_size;
 extern int root_mountflags;
 extern int _end;
 
 extern char empty_zero_page[PAGE_SIZE];
 
 /*
- * Initialise this structure so that it will be placed in the
- * .data section of the object file
- */
-struct bootinfo boot_info = BOOT_INFO;
-
-/*
  * This is set up by the setup-routine at boot-time
  */
 #define PARAM	empty_zero_page
@@ -214,137 +105,142 @@
 #define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
 #define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
 #endif
+#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))
+#define KERNEL_START (*(unsigned long *) (PARAM+0x214))
+#define INITRD_START (*(unsigned long *) (PARAM+0x218))
+#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
 
 static char command_line[CL_SIZE] = { 0, };
        char saved_command_line[CL_SIZE];
 
-#if 0
 /*
- * Code for easy access to new style bootinfo
- *
- * Parameter:  tag      -- taglist entry
- *
- * returns  :  (tag *) -- pointer to taglist entry, NULL for not found
+ * The board specific setup routine sets irq_setup to point to a board
+ * specific setup routine.
  */
-tag *
-bi_TagFind(enum bi_tag tag)
-{
-	/* TBD */
-	return 0;
-}
+void (*irq_setup)(void);
 
 /*
- * Only for taglist creators (bootloaders)
- *
- * Parameter:  tag       -- (enum bi_tag) taglist entry
- *
- * returns  :  1         -- success
- *             0         -- failure
+ * isa_slot_offset is the address where E(ISA) busaddress 0 is is mapped
+ * for the processor.
  */
-int
-bi_TagAdd(enum bi_tag tag, unsigned long size, void *tagdata)
+unsigned long isa_slot_offset;
+
+__initfunc(static void default_irq_setup(void))
 {
-	/* TBD */
-	return 0;
+	panic("Unknown machtype in init_IRQ");
 }
-#endif /* 0 */
 
-void setup_arch(char **cmdline_p,
-	unsigned long * memory_start_p, unsigned long * memory_end_p)
+__initfunc(static void default_fd_cacheflush(const void *addr, size_t size))
 {
-	unsigned long memory_start, memory_end;
+}
+
+__initfunc(void setup_arch(char **cmdline_p,
+           unsigned long * memory_start_p, unsigned long * memory_end_p))
+{
+	unsigned long memory_end;
+	tag* atag;
+	void decstation_setup(void);
+	void deskstation_setup(void);
+	void jazz_setup(void);
+	void sni_rm200_pci_setup(void);
+	void sgi_setup(void);
+
+	/* Perhaps a lot of tags are not getting 'snarfed' - */
+	/* please help yourself */
+
+	atag = bi_TagFind(tag_machtype);
+	memcpy(&mips_machtype, TAGVALPTR(atag), atag->size);
+
+	atag = bi_TagFind(tag_machgroup);
+	memcpy(&mips_machgroup, TAGVALPTR(atag), atag->size);
+
+	atag = bi_TagFind(tag_vram_base);
+	memcpy(&mips_vram_base, TAGVALPTR(atag), atag->size);
 
-	switch(boot_info.machtype)
+	irq_setup = default_irq_setup;
+	fd_cacheflush = default_fd_cacheflush;
+
+	switch(mips_machgroup)
 	{
-#ifdef CONFIG_ACER_PICA_61
-	case MACH_ACER_PICA_61:
-		feature = &acer_pica_61_feature;
+#ifdef CONFIG_MIPS_DECSTATION
+	case MACH_GROUP_DEC:
+		decstation_setup();
 		break;
 #endif
-#ifdef CONFIG_DECSTATION
-	case MACH_DECSTATION:
-		feature = &decstation_feature;
+#if defined(CONFIG_MIPS_ARC) 
+/* Perhaps arch/mips/deskstation should be renommed arch/mips/arc.
+ * For now CONFIG_MIPS_ARC means DeskStation. -Stoned.
+ */
+	case MACH_GROUP_ARC:
+		deskstation_setup();
 		break;
 #endif
-#ifdef CONFIG_DESKSTATION_RPC
-	case MACH_DESKSTATION_RPC:
-		feature = &deskstation_rpc44_feature;
+#ifdef CONFIG_MIPS_JAZZ
+	case MACH_GROUP_JAZZ:
+		jazz_setup();
 		break;
 #endif
-#ifdef CONFIG_DESKSTATION_TYNE
-	case MACH_DESKSTATION_TYNE:
-		feature = &deskstation_tyne_feature;
+#ifdef CONFIG_SGI
+	case MACH_GROUP_SGI:
+		sgi_setup();
 		break;
 #endif
-#ifdef CONFIG_MIPS_MAGNUM_4000
-	case MACH_MIPS_MAGNUM_4000:
-		feature = &mips_magnum_4000_feature;
+#ifdef CONFIG_SNI_RM200_PCI
+	case MACH_GROUP_SNI_RM:
+		sni_rm200_pci_setup();
 		break;
 #endif
 	default:
 		panic("Unsupported architecture");
 	}
 
-#if 0
- 	ROOT_DEV = to_kdev_t(ORIG_ROOT_DEV);
-#else
-#ifdef CONFIG_BLK_DEV_FD
-	ROOT_DEV = to_kdev_t(0x021c);	/* fd0H1440 */
-#else
-	ROOT_DEV = to_kdev_t(0x0101);	/* ram */ 
-#endif
-/*	ROOT_DEV = to_kdev_t(0x00ff); */	/* NFS */
-#endif
- 	memcpy(&drive_info, &boot_info.drive_info, sizeof(drive_info));
+	atag = bi_TagFind(tag_drive_info);
+	memcpy(&drive_info, TAGVALPTR(atag), atag->size);
 #if 0
 	aux_device_present = AUX_DEVICE_INFO;
 #endif
-	memory_end = boot_info.memupper;
+
+	memory_end = mips_memory_upper;
+	/*
+	 * Due to prefetching and similar mechanism the CPU sometimes
+	 * generates addresses beyond the end of memory.  We leave the size
+	 * of one cache line at the end of memory unused to make shure we
+	 * don't catch this type of bus errors.
+	 */
+	memory_end -= 128;
 	memory_end &= PAGE_MASK;
-	ramdisk_size = boot_info.ramdisk_size;
-	if (boot_info.mount_root_rdonly)
-		root_mountflags |= MS_RDONLY;
 
-	memory_start = (unsigned long) &_end;
-	memory_start += (ramdisk_size << 10);
+#ifdef CONFIG_BLK_DEV_RAM
+	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
+	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
+	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
+#endif
+
+	atag = bi_TagFind(tag_mount_root_rdonly);
+	if (atag)
+	  root_mountflags |= MS_RDONLY;
+
+	atag = bi_TagFind(tag_command_line);
+	if (atag)
+		memcpy(&command_line, TAGVALPTR(atag), atag->size);	  
 
 	memcpy(saved_command_line, command_line, CL_SIZE);
 	saved_command_line[CL_SIZE-1] = '\0';
 
 	*cmdline_p = command_line;
-	*memory_start_p = memory_start;
+	*memory_start_p = (unsigned long) &_end;
 	*memory_end_p = memory_end;
 
-#if 0
-	/*
-	 * Check that struct pt_regs is defined properly
-	 * (Should be optimized away, but gcc 2.6.3 is too bad..)
-	 */
-	if (FR_SIZE != sizeof(struct pt_regs) ||
-	    FR_SIZE & 7)
-	{
-		panic("Check_definition_of_struct_pt_regs\n");
+#ifdef CONFIG_BLK_DEV_INITRD
+	if (LOADER_TYPE) {
+		initrd_start = INITRD_START;
+		initrd_end = INITRD_START+INITRD_SIZE;
+		if (initrd_end > memory_end) {
+			printk("initrd extends beyond end of memory "
+			       "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
+			       initrd_end,memory_end);
+		initrd_start = 0;
+		}
 	}
 #endif
 }
-
-#ifdef CONFIG_PROC_FS
-/*
- * BUFFER is PAGE_SIZE bytes long.
- */
-int get_cpuinfo(char *buffer)
-{
-	const char *cpu_name[] = CPU_NAMES;
-	const char *mach_name[] = MACH_NAMES;
-
-	return sprintf(buffer,
-		       "cpu\t\t\t: MIPS\n"
-		       "cpu model\t\t: %s\n"
-		       "system type\t\t: %s\n"
-		       "BogoMIPS\t\t: %lu.%02lu\n",
-
-		       cpu_name[boot_info.cputype < CPU_LAST ? boot_info.cputype : CPU_UNKNOWN],
-		       mach_name[boot_info.machtype < CPU_LAST ? boot_info.machtype : CPU_UNKNOWN],
-		       loops_per_sec / 500000, (loops_per_sec / 5000) % 100);
-}
-#endif /* CONFIG_PROC_FS */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov