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

📄 setup.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * $Id: setup.c,v 1.160 1999/10/08 01:56:38 paulus Exp $ * Common prep/pmac/chrp boot and setup code. */#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/blk.h>#include <linux/ide.h>#include <asm/init.h>#include <asm/residual.h>#include <asm/io.h>#include <asm/prom.h>#include <asm/processor.h>#include <asm/pgtable.h>#include <asm/bootinfo.h>#include <asm/setup.h>#include <asm/amigappc.h>#include <asm/smp.h>#include <asm/elf.h>#ifdef CONFIG_8xx#include <asm/mpc8xx.h>#include <asm/8xx_immap.h>#endif#ifdef CONFIG_8260#include <asm/mpc8260.h>#include <asm/immap_8260.h>#endif#include <asm/bootx.h>#include <asm/machdep.h>#include <asm/feature.h>#include <asm/uaccess.h>#ifdef CONFIG_OAK#include "oak_setup.h"#endif /* CONFIG_OAK */extern void pmac_init(unsigned long r3,                      unsigned long r4,                      unsigned long r5,                      unsigned long r6,                      unsigned long r7);extern void chrp_init(unsigned long r3,                      unsigned long r4,                      unsigned long r5,                      unsigned long r6,                      unsigned long r7);extern void prep_init(unsigned long r3,                      unsigned long r4,                      unsigned long r5,                      unsigned long r6,                      unsigned long r7);extern void m8xx_init(unsigned long r3,		     unsigned long r4,		     unsigned long r5,		     unsigned long r6,		     unsigned long r7);extern void apus_init(unsigned long r3,                      unsigned long r4,                      unsigned long r5,                      unsigned long r6,                      unsigned long r7);extern void gemini_init(unsigned long r3,                      unsigned long r4,                      unsigned long r5,                      unsigned long r6,                      unsigned long r7);#ifdef CONFIG_XMONextern void xmon_map_scc(void);#endifextern boot_infos_t *boot_infos;char saved_command_line[256];unsigned char aux_device_present;struct int_control_struct int_control ={	__no_use_cli,	__no_use_sti,	__no_use_restore_flags,	__no_use_save_flags};struct ide_machdep_calls ppc_ide_md;int parse_bootinfo(void);unsigned long ISA_DMA_THRESHOLD;unsigned long DMA_MODE_READ, DMA_MODE_WRITE;#ifndef CONFIG_MACH_SPECIFICint _machine = 0;int have_of = 0;#endif /* CONFIG_MACH_SPECIFIC */#ifdef CONFIG_MAGIC_SYSRQunsigned long SYSRQ_KEY;#endif /* CONFIG_MAGIC_SYSRQ */struct machdep_calls ppc_md;/* * 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;/* * 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 */ #if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) && !defined(CONFIG_8260)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 */};/* * I really need to add multiple-console support... -- Cort */int __init pmac_display_supported(char *name){	return 0;}void __init pmac_find_display(void){}#else /* CONFIG_4xx || CONFIG_8xx *//* We need this to satisfy some external references until we can * strip the kernel down. */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 */};#endif /* !CONFIG_4xx && !CONFIG_8xx */void machine_restart(char *cmd){	ppc_md.restart(cmd);}  void machine_power_off(void){	ppc_md.power_off();}  void machine_halt(void){	ppc_md.halt();}  unsigned long cpu_temp(void){	unsigned char thres = 0;	#if 0	/* disable thrm2 */	_set_THRM2( 0 );	/* threshold 0 C, tid: exceeding threshold, tie: don't generate interrupt */	_set_THRM1( THRM1_V );	/* we need 20us to do the compare - assume 300MHz processor clock */	_set_THRM3(0);	_set_THRM3(THRM3_E | (300*30)<<18 );	udelay(100);	/* wait for the compare to complete */	/*while ( !(_get_THRM1() & THRM1_TIV) ) ;*/	if ( !(_get_THRM1() & THRM1_TIV) )		printk("no tiv\n");	if ( _get_THRM1() & THRM1_TIN )		printk("crossed\n");	/* turn everything off */	_set_THRM3(0);	_set_THRM1(0);#endif			return thres;}int get_cpuinfo(char *buffer){	unsigned long len = 0;	unsigned long bogosum = 0;	unsigned long i;	unsigned int pvr;	unsigned short maj, min;	#ifdef CONFIG_SMP#define CPU_PRESENT(x) (cpu_callin_map[(x)])#define GET_PVR ((long int)(cpu_data[i].pvr))#define CD(x) (cpu_data[i].x)#else#define CPU_PRESENT(x) ((x)==0)#define smp_num_cpus 1#define GET_PVR ((long int)_get_PVR())#define CD(x) (x)#endif		for ( i = 0; i < smp_num_cpus ; i++ )	{		if ( !CPU_PRESENT(i) )			continue;		if ( i )			len += sprintf(len+buffer,"\n");		len += sprintf(len+buffer,"processor\t: %lu\n",i);		len += sprintf(len+buffer,"cpu\t\t: ");		pvr = GET_PVR;			switch (PVR_VER(pvr))		{		case 0x0001:			len += sprintf(len+buffer, "601\n");			break;		case 0x0003:			len += sprintf(len+buffer, "603\n");			break;		case 0x0004:			len += sprintf(len+buffer, "604\n");			break;		case 0x0006:			len += sprintf(len+buffer, "603e\n");			break;		case 0x0007:			len += sprintf(len+buffer, "603");			if (((pvr >> 12) & 0xF) == 1) {				pvr ^= 0x00001000;	/* revision fix-up */				len += sprintf(len+buffer, "r\n");			} else {				len += sprintf(len+buffer, "ev\n");			}			break;		case 0x0008:		/* 740/750(P) */		case 0x1008:			len += sprintf(len+buffer, "750%s\n",				       PVR_VER(pvr) == 0x1008 ? "P" : "");			len += sprintf(len+buffer, "temperature \t: %lu C\n",				       cpu_temp());			break;		case 0x0009:		/* 604e/604r */		case 0x000A:			len += sprintf(len+buffer, "604");			if (PVR_VER(pvr) == 0x000A ||			    ((pvr >> 12) & 0xF) != 0) {				pvr &= ~0x00003000;	/* revision fix-up */				len += sprintf(len+buffer, "r\n");			} else {				len += sprintf(len+buffer, "e\n");			}			break;		case 0x000C:			len += sprintf(len+buffer, "7400 (G4");#ifdef CONFIG_ALTIVEC			len += sprintf(len+buffer, ", altivec supported");#endif /* CONFIG_ALTIVEC */			len += sprintf(len+buffer, ")\n");			break;		case 0x0020:			len += sprintf(len+buffer, "403G");			switch ((pvr >> 8) & 0xFF) {			case 0x02:				len += sprintf(len+buffer, "C\n");    				break;				      			case 0x14:				len += sprintf(len+buffer, "CX\n");				break;			}			break;		case 0x0035:			len += sprintf(len+buffer, "POWER4\n");			break;		case 0x0040:			len += sprintf(len+buffer, "POWER3 (630)\n");			break;		case 0x0041:			len += sprintf(len+buffer, "POWER3 (630+)\n");			break;		case 0x0050:			len += sprintf(len+buffer, "8xx\n");			break;		case 0x0081:			len += sprintf(len+buffer, "82xx\n");			break;		case 0x4011:			len += sprintf(len+buffer, "405GP\n");			break;		default:			len += sprintf(len+buffer, "unknown (%08x)\n", pvr);			break;		}				/*		 * Assume here that all clock rates are the same in a		 * smp system.  -- Cort		 */#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx) && !defined(CONFIG_8260)		if ( have_of )		{			struct device_node *cpu_node;			int *fp;						cpu_node = find_type_devices("cpu");			if ( !cpu_node ) break;			{				int s;				for ( s = 0; (s < i) && cpu_node->next ;				      s++, cpu_node = cpu_node->next )					/* nothing */ ;#if 0 /* SMP Pmacs don't have all cpu nodes -- Cort */				if ( s != i )					printk("get_cpuinfo(): ran out of "					       "cpu nodes.\n");#endif			}			fp = (int *) get_property(cpu_node, "clock-frequency", NULL);			if ( !fp ) break;			len += sprintf(len+buffer, "clock\t\t: %dMHz\n",				       *fp / 1000000);		}#endif /* !CONFIG_4xx && !CONFIG_8xx */		if (ppc_md.setup_residual != NULL)		{			len += ppc_md.setup_residual(buffer + len);		}				switch (PVR_VER(pvr))		{		case 0x0020:			maj = PVR_MAJ(pvr) + 1;			min = PVR_MIN(pvr);			break;		case 0x1008:			maj = ((pvr >> 8) & 0xFF) - 1;			min = pvr & 0xFF;			break;		default:			maj = (pvr >> 8) & 0xFF;			min = pvr & 0xFF;			break;		}		len += sprintf(len+buffer, "revision\t: %hd.%hd\n", maj, min);		len += sprintf(buffer+len, "bogomips\t: %lu.%02lu\n",			       (CD(loops_per_sec)+2500)/500000,			       (CD(loops_per_sec)+2500)/5000 % 100);		bogosum += CD(loops_per_sec);	}#ifdef CONFIG_SMP	if ( i )		len += sprintf(buffer+len, "\n");	len += sprintf(buffer+len,"total bogomips\t: %lu.%02lu\n",		       (bogosum+2500)/500000,		       (bogosum+2500)/5000 % 100);#endif /* CONFIG_SMP */	/*	 * Ooh's and aah's info about zero'd pages in idle task	 */ 	len += sprintf(buffer+len,"zero pages\t: total: %u (%luKb) "		       "current: %u (%luKb) hits: %u/%u (%u%%)\n",		       atomic_read(&zero_cache_total),		       (atomic_read(&zero_cache_total)*PAGE_SIZE)>>10,		       atomic_read(&zero_cache_sz),		       (atomic_read(&zero_cache_sz)*PAGE_SIZE)>>10,		       atomic_read(&zero_cache_hits),atomic_read(&zero_cache_calls),		       /* : 1 below is so we don't div by zero */		       (atomic_read(&zero_cache_hits)*100) /		       ((atomic_read(&zero_cache_calls))?atomic_read(&zero_cache_calls):1));	if (ppc_md.get_cpuinfo != NULL)	{		len += ppc_md.get_cpuinfo(buffer+len);	}	return len;}

⌨️ 快捷键说明

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