📄 setup.c
字号:
/* $Id: setup.c,v 1.1.1.1.2.7 2003/06/20 13:13:25 trent Exp $ * * linux/arch/sh/kernel/setup.c * * Copyright (C) 1999 Niibe Yutaka * *//* * This file handles the architecture-dependent parts of initialization */#include <linux/errno.h>#include <linux/sched.h>#include <linux/kernel.h>#include <linux/mm.h>#include <linux/stddef.h>#include <linux/unistd.h>#include <linux/ptrace.h>#include <linux/slab.h>#include <linux/user.h>#include <linux/a.out.h>#include <linux/tty.h>#include <linux/ioport.h>#include <linux/delay.h>#include <linux/config.h>#include <linux/init.h>#ifdef CONFIG_BLK_DEV_RAM#include <linux/blk.h>#endif#include <linux/bootmem.h>#include <linux/console.h>#include <linux/ctype.h>#include <linux/seq_file.h>#include <asm/processor.h>#include <asm/page.h>#include <asm/pgtable.h>#include <asm/uaccess.h>#include <asm/system.h>#include <asm/io.h>#include <asm/io_generic.h>#include <asm/machvec.h>#ifdef CONFIG_SH_EARLY_PRINTK#include <asm/sh_bios.h>#endif#ifdef CONFIG_SH_KGDB#include <asm/kgdb.h>static int kgdb_parse_options(char *options);#endif/* * 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;unsigned char aux_device_present = 0xaa;#if defined(CONFIG_SH_GENERIC) || 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 fpu_init(void);extern int root_mountflags;extern int _text, _etext, _edata, _end;#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 COMMAND_LINE_SIZE 256#define RAMDISK_IMAGE_START_MASK 0x07FF#define RAMDISK_PROMPT_FLAG 0x8000#define RAMDISK_LOAD_FLAG 0x4000 static char command_line[COMMAND_LINE_SIZE] = { 0, }; char saved_command_line[COMMAND_LINE_SIZE];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;#ifdef CONFIG_SH_EARLY_PRINTK/* * Print a string through the BIOS */static void sh_console_write(struct console *co, const char *s, unsigned count){ sh_bios_console_write(s, count);}static kdev_t sh_console_device(struct console *c){ /* TODO: this is totally bogus */ /* return MKDEV(SCI_MAJOR, SCI_MINOR_START + c->index); */ return 0;}/* * Setup initial baud/bits/parity. We do two things here: * - construct a cflag setting for the first rs_open() * - initialize the serial port * Return non-zero if we didn't find a serial port. */static int __init sh_console_setup(struct console *co, char *options){ int cflag = CREAD | HUPCL | CLOCAL; /* * Now construct a cflag setting. * TODO: this is a totally bogus cflag, as we have * no idea what serial settings the BIOS is using, or * even if its using the serial port at all. */ cflag |= B115200 | CS8 | /*no parity*/0; co->cflag = cflag; return 0;}static struct console sh_console = { name: "bios", write: sh_console_write, device: sh_console_device, setup: sh_console_setup, flags: CON_PRINTBUFFER, index: -1,};void sh_console_init(void){ register_console(&sh_console);}void sh_console_unregister(void){ unregister_console(&sh_console);}#endifstatic 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;}void __init setup_arch(char **cmdline_p){#if defined(CONFIG_SH_GENERIC) || 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; unsigned long bootmap_size; unsigned long start_pfn, max_pfn, max_low_pfn;#ifdef CONFIG_SH_EARLY_PRINTK sh_console_init();#endif ROOT_DEV = to_kdev_t(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; parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base, &mv_mmio_enable);#ifdef CONFIG_CMDLINE_BOOL sprintf(*cmdline_p, CONFIG_CMDLINE);#endif#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#if defined(CONFIG_SH_GENERIC) || defined(CONFIG_SH_UNKNOWN) if (mv_io_base != 0) { sh_mv.mv_inb = generic_inb; sh_mv.mv_inw = generic_inw; sh_mv.mv_inl = generic_inl; sh_mv.mv_outb = generic_outb; sh_mv.mv_outw = generic_outw; sh_mv.mv_outl = generic_outl; sh_mv.mv_inb_p = generic_inb_p;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -