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

📄 pmac_setup.c

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * BK Id: %F% %I% %G% %U% %#% *//* *  arch/ppc/platforms/setup.c * *  PowerPC version  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) * *  Adapted for Power Macintosh by Paul Mackerras *    Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au) * *  Derived from "arch/alpha/kernel/setup.c" *    Copyright (C) 1995 Linus Torvalds * *  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. * *//* * bootup setup stuff.. */#include <linux/config.h>#include <linux/init.h>#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/string.h>#include <linux/delay.h>#include <linux/ioport.h>#include <linux/major.h>#include <linux/blk.h>#include <linux/vt_kern.h>#include <linux/console.h>#include <linux/ide.h>#include <linux/pci.h>#include <linux/adb.h>#include <linux/cuda.h>#include <linux/pmu.h>#include <linux/irq.h>#include <linux/seq_file.h>#include <linux/blkdev.h>#include <linux/genhd.h>#include <asm/processor.h>#include <asm/sections.h>#include <asm/prom.h>#include <asm/system.h>#include <asm/pgtable.h>#include <asm/bitops.h>#include <asm/io.h>#include <asm/pci-bridge.h>#include <asm/ohare.h>#include <asm/mediabay.h>#include <asm/machdep.h>#include <asm/keyboard.h>#include <asm/dma.h>#include <asm/bootx.h>#include <asm/cputable.h>#include <asm/btext.h>#include <asm/pmac_feature.h>#include <asm/time.h>#include "pmac_pic.h"#include "mem_pieces.h"#include "scsi.h" /* sd_find_target */#include "sd.h"#include "mac.h"extern long pmac_time_init(void);extern unsigned long pmac_get_rtc_time(void);extern int pmac_set_rtc_time(unsigned long nowtime);extern void pmac_read_rtc_time(void);extern void pmac_calibrate_decr(void);extern void pmac_pcibios_fixup(void);extern void pmac_find_bridges(void);extern int pmac_ide_check_base(ide_ioreg_t base);extern ide_ioreg_t pmac_ide_get_base(int index);extern void pmac_ide_init_hwif_ports(hw_regs_t *hw,	ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq);extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode);extern int mackbd_getkeycode(unsigned int scancode);extern int mackbd_translate(unsigned char keycode, unsigned char *keycodep,		     char raw_mode);extern char mackbd_unexpected_up(unsigned char keycode);extern void mackbd_leds(unsigned char leds);extern void __init mackbd_init_hw(void);extern int mac_hid_kbd_translate(unsigned char scancode, unsigned char *keycode,				 char raw_mode);extern char mac_hid_kbd_unexpected_up(unsigned char keycode);extern void mac_hid_init_hw(void);extern unsigned char mac_hid_kbd_sysrq_xlate[];extern unsigned char pckbd_sysrq_xlate[];extern unsigned char mackbd_sysrq_xlate[];extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);extern int pckbd_getkeycode(unsigned int scancode);extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,			   char raw_mode);extern char pckbd_unexpected_up(unsigned char keycode);extern int keyboard_sends_linux_keycodes;extern void pmac_nvram_update(void);extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial);extern void pmac_pcibios_after_init(void);struct device_node *memory_node;unsigned char drive_info;int ppc_override_l2cr = 0;int ppc_override_l2cr_value;int has_l2cache = 0;static int current_root_goodness = -1;extern char saved_command_line[];extern int pmac_newworld;#define DEFAULT_ROOT_DEVICE 0x0801	/* sda1 - slightly silly choice */extern void zs_kgdb_hook(int tty_num);static void ohare_init(void);#ifdef CONFIG_BOOTX_TEXTvoid pmac_progress(char *s, unsigned short hex);#endifsys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;#ifdef CONFIG_SMPextern struct smp_ops_t psurge_smp_ops;extern struct smp_ops_t core99_smp_ops;#endif /* CONFIG_SMP *//* * Assume here that all clock rates are the same in a * smp system.  -- Cort */int __openfirmwareof_show_percpuinfo(struct seq_file *m, int i){	struct device_node *cpu_node;	int *fp, s;				cpu_node = find_type_devices("cpu");	if (!cpu_node)		return 0;	for (s = 0; s < i && cpu_node->next; s++)		cpu_node = cpu_node->next;	fp = (int *) get_property(cpu_node, "clock-frequency", NULL);	if (fp)		seq_printf(m, "clock\t\t: %dMHz\n", *fp / 1000000);	return 0;}int __pmacpmac_show_cpuinfo(struct seq_file *m){	struct device_node *np;	char *pp;	int plen;	int mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO,		NULL, PMAC_MB_INFO_MODEL, 0);	unsigned int mbflags = (unsigned int)pmac_call_feature(PMAC_FTR_GET_MB_INFO,		NULL, PMAC_MB_INFO_FLAGS, 0);	char* mbname;	if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME, (int)&mbname) != 0)		mbname = "Unknown";			/* find motherboard type */	seq_printf(m, "machine\t\t: ");	np = find_devices("device-tree");	if (np != NULL) {		pp = (char *) get_property(np, "model", NULL);		if (pp != NULL)			seq_printf(m, "%s\n", pp);		else			seq_printf(m, "PowerMac\n");		pp = (char *) get_property(np, "compatible", &plen);		if (pp != NULL) {			seq_printf(m, "motherboard\t:");			while (plen > 0) {				int l = strlen(pp) + 1;				seq_printf(m, " %s", pp);				plen -= l;				pp += l;			}			seq_printf(m, "\n");		}	} else		seq_printf(m, "PowerMac\n");	/* print parsed model */	seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname);	seq_printf(m, "pmac flags\t: %08x\n", mbflags);	/* find l2 cache info */	np = find_devices("l2-cache");	if (np == 0)		np = find_type_devices("cache");	if (np != 0) {		unsigned int *ic = (unsigned int *)			get_property(np, "i-cache-size", NULL);		unsigned int *dc = (unsigned int *)			get_property(np, "d-cache-size", NULL);		seq_printf(m, "L2 cache\t:");		has_l2cache = 1;		if (get_property(np, "cache-unified", NULL) != 0 && dc) {			seq_printf(m, " %dK unified", *dc / 1024);		} else {			if (ic)				seq_printf(m, " %dK instruction", *ic / 1024);			if (dc)				seq_printf(m, "%s %dK data",					   (ic? " +": ""), *dc / 1024);		}		pp = get_property(np, "ram-type", NULL);		if (pp)			seq_printf(m, " %s", pp);		seq_printf(m, "\n");	}	/* find ram info */	np = find_devices("memory");	if (np != 0) {		int n;		struct reg_property *reg = (struct reg_property *)			get_property(np, "reg", &n);				if (reg != 0) {			unsigned long total = 0;			for (n /= sizeof(struct reg_property); n > 0; --n)				total += (reg++)->size;			seq_printf(m, "memory\t\t: %luMB\n", total >> 20);		}	}	/* Checks "l2cr-value" property in the registry */	np = find_devices("cpus");			if (np == 0)		np = find_type_devices("cpu");			if (np != 0) {		unsigned int *l2cr = (unsigned int *)			get_property(np, "l2cr-value", NULL);		if (l2cr != 0) {			seq_printf(m, "l2cr override\t: 0x%x\n", *l2cr);		}	}		/* Indicate newworld/oldworld */	seq_printf(m, "pmac-generation\t: %s\n",		   pmac_newworld ? "NewWorld" : "OldWorld");		return 0;}#ifdef CONFIG_VT/* * Dummy mksound function that does nothing. * The real one is in the dmasound driver. */static void __pmacpmac_mksound(unsigned int hz, unsigned int ticks){}#endif /* CONFIG_VT */static volatile u32 *sysctrl_regs;void __initpmac_setup_arch(void){	struct device_node *cpu;	int *fp;	unsigned long pvr;		pvr = PVR_VER(mfspr(PVR));	/* Set loops_per_jiffy to a half-way reasonable value,	   for use until calibrate_delay gets called. */	cpu = find_type_devices("cpu");	if (cpu != 0) {		fp = (int *) get_property(cpu, "clock-frequency", NULL);		if (fp != 0) {			if (pvr == 4 || pvr >= 8)				/* 604, G3, G4 etc. */				loops_per_jiffy = *fp / HZ;			else				/* 601, 603, etc. */				loops_per_jiffy = *fp / (2*HZ);		} else			loops_per_jiffy = 50000000 / HZ;	}	/* this area has the CPU identification register	   and some registers used by smp boards */	sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);	ohare_init();	/* Lookup PCI hosts */	pmac_find_bridges();		/* Checks "l2cr-value" property in the registry */	if (cur_cpu_spec[0]->cpu_features & CPU_FTR_L2CR) {		struct device_node *np = find_devices("cpus");				if (np == 0)			np = find_type_devices("cpu");				if (np != 0) {			unsigned int *l2cr = (unsigned int *)				get_property(np, "l2cr-value", NULL);			if (l2cr != 0) {				ppc_override_l2cr = 1;				ppc_override_l2cr_value = *l2cr;				_set_L2CR(0);				_set_L2CR(ppc_override_l2cr_value);			}		}	}	if (ppc_override_l2cr)		printk(KERN_INFO "L2CR overriden (0x%x), backside cache is %s\n",			ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000)				? "enabled" : "disabled");	#ifdef CONFIG_KGDB	zs_kgdb_hook(0);#endif#ifdef CONFIG_ADB_CUDA	find_via_cuda();#else	if (find_devices("via-cuda")) {		printk("WARNING ! Your machine is Cuda based but your kernel\n");		printk("          wasn't compiled with CONFIG_ADB_CUDA option !\n");	}#endif	#ifdef CONFIG_ADB_PMU	find_via_pmu();#else	if (find_devices("via-pmu")) {		printk("WARNING ! Your machine is PMU based but your kernel\n");		printk("          wasn't compiled with CONFIG_ADB_PMU option !\n");	}#endif	#ifdef CONFIG_NVRAM	pmac_nvram_init();#endif#ifdef CONFIG_DUMMY_CONSOLE	conswitchp = &dummy_con;#endif#ifdef CONFIG_VT	kd_mksound = pmac_mksound;#endif#ifdef CONFIG_BLK_DEV_INITRD	if (initrd_start)		ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);	else#endif		ROOT_DEV = to_kdev_t(DEFAULT_ROOT_DEVICE);#ifdef CONFIG_SMP	/* Check for Core99 */	if (find_devices("uni-n"))		ppc_md.smp_ops = &core99_smp_ops;	else		ppc_md.smp_ops = &psurge_smp_ops;#endif /* CONFIG_SMP */	pci_create_OF_bus_map();}static void __init ohare_init(void){	/*	 * Turn on the L2 cache.	 * We assume that we have a PSX memory controller iff	 * we have an ohare I/O controller.	 */	if (find_devices("ohare") != NULL) {		if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {			if (sysctrl_regs[4] & 0x10)				sysctrl_regs[4] |= 0x04000020;			else				sysctrl_regs[4] |= 0x04000000;			if(has_l2cache)				printk(KERN_INFO "Level 2 cache enabled\n");		}	}}extern char *bootpath;extern char *bootdevice;void *boot_host;int boot_target;int boot_part;extern kdev_t boot_dev;void __initpmac_init2(void){#ifdef CONFIG_ADB_PMU	via_pmu_start();#endif#ifdef CONFIG_ADB_CUDA	via_cuda_start();#endif#ifdef CONFIG_PMAC_PBOOK	media_bay_init();#endif	pmac_feature_late_init();}/* Borrowed from fs/partition/check.c */static unsigned char* __initread_one_block(struct block_device *bdev, unsigned long n, struct page **v){	struct address_space *mapping = bdev->bd_inode->i_mapping;	int sect = PAGE_CACHE_SIZE / 512;	struct page *page;	page = read_cache_page(mapping, n/sect,			(filler_t *)mapping->a_ops->readpage, NULL);	if (!IS_ERR(page)) {		wait_on_page(page);		if (!Page_Uptodate(page))			goto fail;		if (PageError(page))			goto fail;		*v = page;		return (unsigned char *)page_address(page) + 512 * (n % sect);fail:		page_cache_release(page);	}	*v = NULL;	return NULL;}#ifdef CONFIG_SCSIvoid __initnote_scsi_host(struct device_node *node, void *host){	int l;	char *p;

⌨️ 快捷键说明

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