setup.c

来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 756 行 · 第 1/2 页

C
756
字号
/* *  * Common boot and setup code. * * Copyright (C) 2001 PPC64 Team, IBM Corp * *      This program is free software; you can redistribute it and/or *      modify it under the terms of the GNU General Public License *      as published by the Free Software Foundation; either version *      2 of the License, or (at your option) any later version. */#include <linux/config.h>#include <linux/module.h>#include <linux/string.h>#include <linux/sched.h>#include <linux/init.h>#include <linux/reboot.h>#include <linux/delay.h>#include <linux/initrd.h>#include <linux/ide.h>#include <linux/seq_file.h>#include <linux/ioport.h>#include <linux/console.h>#include <linux/version.h>#include <linux/tty.h>#include <linux/root_dev.h>#include <linux/notifier.h>#include <linux/cpu.h>#include <asm/io.h>#include <asm/prom.h>#include <asm/processor.h>#include <asm/pgtable.h>#include <asm/bootinfo.h>#include <asm/smp.h>#include <asm/elf.h>#include <asm/machdep.h>#include <asm/iSeries/LparData.h>#include <asm/naca.h>#include <asm/paca.h>#include <asm/ppcdebug.h>#include <asm/time.h>#include <asm/cputable.h>#include <asm/sections.h>#include <asm/btext.h>#include <asm/nvram.h>#include <asm/setup.h>#include <asm/system.h>#include <asm/rtas.h>extern unsigned long klimit;/* extern void *stab; */extern HTAB htab_data;extern unsigned long loops_per_jiffy;int have_of = 1;extern void  chrp_init(unsigned long r3,		       unsigned long r4,		       unsigned long r5,		       unsigned long r6,		       unsigned long r7);extern void  pmac_init(unsigned long r3,		       unsigned long r4,		       unsigned long r5,		       unsigned long r6,		       unsigned long r7);extern void iSeries_init( void );extern void iSeries_init_early( void );extern void pSeries_init_early( void );extern void pSeriesLP_init_early(void);extern void pmac_init_early(void);extern void mm_init_ppc64( void ); extern void pseries_secondary_smp_init(unsigned long); extern int  idle_setup(void);extern void vpa_init(int cpu);unsigned long decr_overclock = 1;unsigned long decr_overclock_proc0 = 1;unsigned long decr_overclock_set = 0;unsigned long decr_overclock_proc0_set = 0;int powersave_nap;unsigned char aux_device_present;void parse_cmd_line(unsigned long r3, unsigned long r4, unsigned long r5,		    unsigned long r6, unsigned long r7);int parse_bootinfo(void);#ifdef CONFIG_MAGIC_SYSRQunsigned long SYSRQ_KEY;#endif /* CONFIG_MAGIC_SYSRQ */struct machdep_calls ppc_md;static int ppc64_panic_event(struct notifier_block *, unsigned long, void *);static struct notifier_block ppc64_panic_block = {	notifier_call: ppc64_panic_event,	priority: INT_MIN /* may not return; must be done last */};/* * Perhaps we can put the pmac screen_info[] here * on pmac as well so we don't need the ifdef's. * Until we get multiple-console support in here * that is.  -- Cort * Maybe tie it to serial consoles, since this is really what * these processors use on existing boards.  -- Dan */ 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 */	1,			/* orig-video-isVGA */	16			/* orig-video-points */};/* * These are used in binfmt_elf.c to put aux entries on the stack * for each elf executable being started. */int dcache_bsize;int icache_bsize;int ucache_bsize;/* * Initialize the PPCDBG state.  Called before relocation has been enabled. */void ppcdbg_initialize(void) {	unsigned long offset = reloc_offset();	struct naca_struct *_naca = RELOC(naca);	_naca->debug_switch = PPC_DEBUG_DEFAULT; /* | PPCDBG_BUSWALK | PPCDBG_PHBINIT | PPCDBG_MM | PPCDBG_MMINIT | PPCDBG_TCEINIT | PPCDBG_TCE */;}static struct console udbg_console = {	.name	= "udbg",	.write	= udbg_console_write,	.flags	= CON_PRINTBUFFER,	.index	= -1,};static int early_console_initialized;void __init disable_early_printk(void){	if (!early_console_initialized)		return;	unregister_console(&udbg_console);	early_console_initialized = 0;}/* * Do some initial setup of the system.  The parameters are those which  * were passed in from the bootloader. */void setup_system(unsigned long r3, unsigned long r4, unsigned long r5,		  unsigned long r6, unsigned long r7){#if defined(CONFIG_SMP) && defined(CONFIG_PPC_PSERIES)	int ret, i;#endif#ifdef CONFIG_XMON_DEFAULT	xmon_init();#endif#ifdef CONFIG_PPC_ISERIES	/* pSeries systems are identified in prom.c via OF. */	if ( itLpNaca.xLparInstalled == 1 )		systemcfg->platform = PLATFORM_ISERIES_LPAR;#endif		switch (systemcfg->platform) {#ifdef CONFIG_PPC_ISERIES	case PLATFORM_ISERIES_LPAR:		iSeries_init_early();		break;#endif#ifdef CONFIG_PPC_PSERIES	case PLATFORM_PSERIES:		pSeries_init_early();		parse_bootinfo();		break;	case PLATFORM_PSERIES_LPAR:		pSeriesLP_init_early();		parse_bootinfo();		break;#endif /* CONFIG_PPC_PSERIES */#ifdef CONFIG_PPC_PMAC	case PLATFORM_POWERMAC:		pmac_init_early();		parse_bootinfo();#endif /* CONFIG_PPC_PMAC */	}	/* If we were passed an initrd, set the ROOT_DEV properly if the values	 * look sensible. If not, clear initrd reference.	 */#ifdef CONFIG_BLK_DEV_INITRD	if (initrd_start >= KERNELBASE && initrd_end >= KERNELBASE &&	    initrd_end > initrd_start)		ROOT_DEV = Root_RAM0;	else		initrd_start = initrd_end = 0;#endif /* CONFIG_BLK_DEV_INITRD */#ifdef CONFIG_BOOTX_TEXT	map_boot_text();	if (systemcfg->platform == PLATFORM_POWERMAC) {		early_console_initialized = 1;		register_console(&udbg_console);	}#endif /* CONFIG_BOOTX_TEXT */#ifdef CONFIG_PPC_PSERIES	if (systemcfg->platform & PLATFORM_PSERIES) {		early_console_initialized = 1;		register_console(&udbg_console);		__irq_offset_value = NUM_ISA_INTERRUPTS;		finish_device_tree();		chrp_init(r3, r4, r5, r6, r7);#ifdef CONFIG_SMP		/* Start secondary threads on SMT systems */		for (i = 0; i < NR_CPUS; i++) {			if (cpu_available(i) && !cpu_possible(i)) {				printk("%16.16x : starting thread\n", i);				rtas_call(rtas_token("start-cpu"), 3, 1, &ret,					  get_hard_smp_processor_id(i), 					  (u32)*((unsigned long *)pseries_secondary_smp_init),					  i);				cpu_set(i, cpu_possible_map);				systemcfg->processorCount++;			}		}#endif /* CONFIG_SMP */	}#endif /* CONFIG_PPC_PSERIES */#ifdef CONFIG_PPC_PMAC	if (systemcfg->platform == PLATFORM_POWERMAC) {		finish_device_tree();		pmac_init(r3, r4, r5, r6, r7);	}#endif /* CONFIG_PPC_PMAC */#if defined(CONFIG_HOTPLUG_CPU) &&  !defined(CONFIG_PPC_PMAC)	rtas_stop_self_args.token = rtas_token("stop-self");#endif /* CONFIG_HOTPLUG_CPU && !CONFIG_PPC_PMAC */	/* Finish initializing the hash table (do the dynamic	 * patching for the fast-path hashtable.S code)	 */	htab_finish_init();	printk("Starting Linux PPC64 %s\n", UTS_RELEASE);	printk("-----------------------------------------------------\n");	printk("naca                          = 0x%p\n", naca);	printk("naca->pftSize                 = 0x%lx\n", naca->pftSize);	printk("naca->debug_switch            = 0x%lx\n", naca->debug_switch);	printk("naca->interrupt_controller    = 0x%ld\n", naca->interrupt_controller);	printk("systemcfg                     = 0x%p\n", systemcfg);	printk("systemcfg->processorCount     = 0x%lx\n", systemcfg->processorCount);	printk("systemcfg->physicalMemorySize = 0x%lx\n", systemcfg->physicalMemorySize);	printk("systemcfg->dCacheL1LineSize   = 0x%x\n", systemcfg->dCacheL1LineSize);	printk("systemcfg->iCacheL1LineSize   = 0x%x\n", systemcfg->iCacheL1LineSize);	printk("htab_data.htab                = 0x%p\n", htab_data.htab);	printk("htab_data.num_ptegs           = 0x%lx\n", htab_data.htab_num_ptegs);	printk("-----------------------------------------------------\n");	mm_init_ppc64();#if defined(CONFIG_SMP) && defined(CONFIG_PPC_PSERIES)	if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR) {		vpa_init(boot_cpuid);	}#endif	/* Select the correct idle loop for the platform. */	idle_setup();	switch (systemcfg->platform) {#ifdef CONFIG_PPC_ISERIES	case PLATFORM_ISERIES_LPAR:		iSeries_init();		break;#endif	default:		/* The following relies on the device tree being */		/* fully configured.                             */		parse_cmd_line(r3, r4, r5, r6, r7);	}}void machine_restart(char *cmd){	if (ppc_md.nvram_sync)		ppc_md.nvram_sync();	ppc_md.restart(cmd);}EXPORT_SYMBOL(machine_restart);  void machine_power_off(void){	if (ppc_md.nvram_sync)		ppc_md.nvram_sync();	ppc_md.power_off();}EXPORT_SYMBOL(machine_power_off);  void machine_halt(void){	if (ppc_md.nvram_sync)		ppc_md.nvram_sync();	ppc_md.halt();}EXPORT_SYMBOL(machine_halt);unsigned long ppc_proc_freq;unsigned long ppc_tb_freq;static int ppc64_panic_event(struct notifier_block *this,                             unsigned long event, void *ptr){	ppc_md.panic((char *)ptr);  /* May not return */	return NOTIFY_DONE;}#ifdef CONFIG_SMPDEFINE_PER_CPU(unsigned int, pvr);#endifstatic int show_cpuinfo(struct seq_file *m, void *v){	unsigned long cpu_id = (unsigned long)v - 1;	unsigned int pvr;	unsigned short maj;	unsigned short min;	if (cpu_id == NR_CPUS) {		seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);		if (ppc_md.get_cpuinfo != NULL)			ppc_md.get_cpuinfo(m);		return 0;	}	/* We only show online cpus: disable preempt (overzealous, I	 * knew) to prevent cpu going down. */	preempt_disable();	if (!cpu_online(cpu_id)) {		preempt_enable();		return 0;	}#ifdef CONFIG_SMP	pvr = per_cpu(pvr, cpu_id);#else	pvr = _get_PVR();#endif	maj = (pvr >> 8) & 0xFF;

⌨️ 快捷键说明

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