⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setup.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
/* $Id: setup.c,v 1.30 2003/10/13 07:21:19 lethal Exp $ * *  linux/arch/sh/kernel/setup.c * *  Copyright (C) 1999  Niibe Yutaka *  Copyright (C) 2002, 2003  Paul Mundt *//* * This file handles the architecture-dependent parts of initialization */#include <linux/tty.h>#include <linux/ioport.h>#include <linux/init.h>#include <linux/initrd.h>#include <linux/bootmem.h>#include <linux/console.h>#include <linux/seq_file.h>#include <linux/root_dev.h>#include <linux/utsname.h>#include <linux/cpu.h>#include <asm/uaccess.h>#include <asm/io.h>#include <asm/io_generic.h>#include <asm/sections.h>#include <asm/irq.h>#include <asm/setup.h>#ifdef CONFIG_SH_KGDB#include <asm/kgdb.h>static int kgdb_parse_options(char *options);#endifextern void * __rd_start, * __rd_end;/* * Machine setup.. *//* * Initialize loops_per_jiffy as 10000000 (1000MIPS). * This value will be used at the very early stage of serial setup. * The bigger value means no problem. */struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 0, 10000000, };struct screen_info screen_info;#if defined(CONFIG_SH_UNKNOWN)struct sh_machine_vector sh_mv;#endif/* We need this to satisfy some external references. */struct screen_info screen_info = {        0, 25,                  /* orig-x, orig-y */        0,                      /* unused */        0,                      /* orig-video-page */        0,                      /* orig-video-mode */        80,                     /* orig-video-cols */        0,0,0,                  /* ega_ax, ega_bx, ega_cx */        25,                     /* orig-video-lines */        0,                      /* orig-video-isVGA */        16                      /* orig-video-points */};extern void platform_setup(void);extern char *get_system_type(void);extern int root_mountflags;#define MV_NAME_SIZE 32static struct sh_machine_vector* __init get_mv_byname(const char* name);/* * This is set up by the setup-routine at boot-time */#define PARAM	((unsigned char *)empty_zero_page)#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008))#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))#define INITRD_START (*(unsigned long *) (PARAM+0x010))#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))/* ... */#define COMMAND_LINE ((char *) (PARAM+0x100))#define RAMDISK_IMAGE_START_MASK	0x07FF#define RAMDISK_PROMPT_FLAG		0x8000#define RAMDISK_LOAD_FLAG		0x4000static char command_line[COMMAND_LINE_SIZE] = { 0, };struct resource standard_io_resources[] = {	{ "dma1", 0x00, 0x1f },	{ "pic1", 0x20, 0x3f },	{ "timer", 0x40, 0x5f },	{ "keyboard", 0x60, 0x6f },	{ "dma page reg", 0x80, 0x8f },	{ "pic2", 0xa0, 0xbf },	{ "dma2", 0xc0, 0xdf },	{ "fpu", 0xf0, 0xff }};#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))/* System RAM - interrupted by the 640kB-1M hole */#define code_resource (ram_resources[3])#define data_resource (ram_resources[4])static struct resource ram_resources[] = {	{ "System RAM", 0x000000, 0x09ffff, IORESOURCE_BUSY },	{ "System RAM", 0x100000, 0x100000, IORESOURCE_BUSY },	{ "Video RAM area", 0x0a0000, 0x0bffff },	{ "Kernel code", 0x100000, 0 },	{ "Kernel data", 0, 0 }};unsigned long memory_start, memory_end;static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE],				  struct sh_machine_vector** mvp,				  unsigned long *mv_io_base,				  int *mv_mmio_enable){	char c = ' ', *to = command_line, *from = COMMAND_LINE;	int len = 0;	/* Save unparsed command line copy for /proc/cmdline */	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';	memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START;	memory_end = memory_start + __MEMORY_SIZE;	for (;;) {		/*		 * "mem=XXX[kKmM]" defines a size of memory.		 */		if (c == ' ' && !memcmp(from, "mem=", 4)) {			if (to != command_line)				to--;			{				unsigned long mem_size;				mem_size = memparse(from+4, &from);				memory_end = memory_start + mem_size;			}		}		if (c == ' ' && !memcmp(from, "sh_mv=", 6)) {			char* mv_end;			char* mv_comma;			int mv_len;			if (to != command_line)				to--;			from += 6;			mv_end = strchr(from, ' ');			if (mv_end == NULL)				mv_end = from + strlen(from);			mv_comma = strchr(from, ',');			if ((mv_comma != NULL) && (mv_comma < mv_end)) {				int ints[3];				get_options(mv_comma+1, ARRAY_SIZE(ints), ints);				*mv_io_base = ints[1];				*mv_mmio_enable = ints[2];				mv_len = mv_comma - from;			} else {				mv_len = mv_end - from;			}			if (mv_len > (MV_NAME_SIZE-1))				mv_len = MV_NAME_SIZE-1;			memcpy(mv_name, from, mv_len);			mv_name[mv_len] = '\0';			from = mv_end;			*mvp = get_mv_byname(mv_name);		}		c = *(from++);		if (!c)			break;		if (COMMAND_LINE_SIZE <= ++len)			break;		*(to++) = c;	}	*to = '\0';	*cmdline_p = command_line;}static int __init sh_mv_setup(char **cmdline_p){#if defined(CONFIG_SH_UNKNOWN)	extern struct sh_machine_vector mv_unknown;#endif	struct sh_machine_vector *mv = NULL;	char mv_name[MV_NAME_SIZE] = "";	unsigned long mv_io_base = 0;	int mv_mmio_enable = 0;	parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base, &mv_mmio_enable);#ifdef CONFIG_SH_GENERIC	if (mv == NULL) {		mv = &mv_unknown;		if (*mv_name != '\0') {			printk("Warning: Unsupported machine %s, using unknown\n",			       mv_name);		}	}	sh_mv = *mv;#endif#ifdef CONFIG_SH_UNKNOWN	sh_mv = mv_unknown;#endif	/*	 * Manually walk the vec, fill in anything that the board hasn't yet	 * by hand, wrapping to the generic implementation.	 */#define mv_set(elem) do { \	if (!sh_mv.mv_##elem) \		sh_mv.mv_##elem = generic_##elem; \} while (0)	mv_set(inb);	mv_set(inw);	mv_set(inl);	mv_set(outb);	mv_set(outw);	mv_set(outl);	mv_set(inb_p);	mv_set(inw_p);	mv_set(inl_p);	mv_set(outb_p);	mv_set(outw_p);	mv_set(outl_p);	mv_set(insb);	mv_set(insw);	mv_set(insl);	mv_set(outsb);	mv_set(outsw);	mv_set(outsl);	mv_set(readb);	mv_set(readw);	mv_set(readl);	mv_set(writeb);	mv_set(writew);	mv_set(writel);	mv_set(ioremap);	mv_set(iounmap);	mv_set(isa_port2addr);	mv_set(irq_demux);#ifdef CONFIG_SH_UNKNOWN	__set_io_port_base(mv_io_base);#endif	return 0;}void __init setup_arch(char **cmdline_p){	unsigned long bootmap_size;	unsigned long start_pfn, max_pfn, max_low_pfn;#ifdef CONFIG_EARLY_PRINTK	extern void enable_early_printk(void);	enable_early_printk();#endif#ifdef CONFIG_CMDLINE_BOOL        strcpy(COMMAND_LINE, CONFIG_CMDLINE);#endif	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);#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	if (!MOUNT_ROOT_RDONLY)		root_mountflags &= ~MS_RDONLY;	init_mm.start_code = (unsigned long) _text;	init_mm.end_code = (unsigned long) _etext;	init_mm.end_data = (unsigned long) _edata;	init_mm.brk = (unsigned long) _end;	code_resource.start = virt_to_bus(_text);	code_resource.end = virt_to_bus(_etext)-1;	data_resource.start = virt_to_bus(_etext);	data_resource.end = virt_to_bus(_edata)-1;	sh_mv_setup(cmdline_p);#define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)#define PFN_DOWN(x)	((x) >> PAGE_SHIFT)#define PFN_PHYS(x)	((x) << PAGE_SHIFT)	/*	 * Find the highest page frame number we have available	 */	max_pfn = PFN_DOWN(__pa(memory_end));	/*	 * Determine low and high memory ranges:	 */	max_low_pfn = max_pfn;	/*	 * Partially used pages are not usable - thus	 * we are rounding upwards:	 */	start_pfn = PFN_UP(__pa(_end));	/*	 * Find a proper area for the bootmem bitmap. After this	 * bootstrap step all allocations (until the page allocator	 * is intact) must be done via bootmem_alloc().	 */	bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,					 __MEMORY_START>>PAGE_SHIFT,					 max_low_pfn);	/*	 * Register fully available low RAM pages with the bootmem allocator.	 */	{		unsigned long curr_pfn, last_pfn, pages;		/*		 * We are rounding up the start address of usable memory:		 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -