pmac_setup.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 693 行 · 第 1/2 页
C
693 行
*/ 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 dev_t boot_dev;#ifdef CONFIG_SCSIvoid __initnote_scsi_host(struct device_node *node, void *host){ int l; char *p; l = strlen(node->full_name); if (bootpath != NULL && bootdevice != NULL && strncmp(node->full_name, bootdevice, l) == 0 && (bootdevice[l] == '/' || bootdevice[l] == 0)) { boot_host = host; /* * There's a bug in OF 1.0.5. (Why am I not surprised.) * If you pass a path like scsi/sd@1:0 to canon, it returns * something like /bandit@F2000000/gc@10/53c94@10000/sd@0,0 * That is, the scsi target number doesn't get preserved. * So we pick the target number out of bootpath and use that. */ p = strstr(bootpath, "/sd@"); if (p != NULL) { p += 4; boot_target = simple_strtoul(p, NULL, 10); p = strchr(p, ':'); if (p != NULL) boot_part = simple_strtoul(p + 1, NULL, 10); } }}#endif#if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)static dev_t __initfind_ide_boot(void){ char *p; int n; dev_t __init pmac_find_ide_boot(char *bootdevice, int n); if (bootdevice == NULL) return 0; p = strrchr(bootdevice, '/'); if (p == NULL) return 0; n = p - bootdevice; return pmac_find_ide_boot(bootdevice, n);}#endif /* CONFIG_BLK_DEV_IDE && CONFIG_BLK_DEV_IDE_PMAC */void __initfind_boot_device(void){#if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC) boot_dev = find_ide_boot();#endif}static int initializing = 1;static int pmac_late_init(void){ initializing = 0; return 0;}late_initcall(pmac_late_init);/* can't be __init - can be called whenever a disk is first accessed */void __pmacnote_bootable_part(dev_t dev, int part, int goodness){ static int found_boot = 0; char *p; if (!initializing) return; if ((goodness <= current_root_goodness) && ROOT_DEV != DEFAULT_ROOT_DEVICE) return; p = strstr(saved_command_line, "root="); if (p != NULL && (p == saved_command_line || p[-1] == ' ')) return; if (!found_boot) { find_boot_device(); found_boot = 1; } if (!boot_dev || dev == boot_dev) { ROOT_DEV = dev + part; boot_dev = 0; current_root_goodness = goodness; }}void __pmacpmac_restart(char *cmd){#ifdef CONFIG_ADB_CUDA struct adb_request req;#endif /* CONFIG_ADB_CUDA */ switch (sys_ctrler) {#ifdef CONFIG_ADB_CUDA case SYS_CTRLER_CUDA: cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM); for (;;) cuda_poll(); break;#endif /* CONFIG_ADB_CUDA */#ifdef CONFIG_ADB_PMU case SYS_CTRLER_PMU: pmu_restart(); break;#endif /* CONFIG_ADB_PMU */ default: ; }}void __pmacpmac_power_off(void){#ifdef CONFIG_ADB_CUDA struct adb_request req;#endif /* CONFIG_ADB_CUDA */ switch (sys_ctrler) {#ifdef CONFIG_ADB_CUDA case SYS_CTRLER_CUDA: cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN); for (;;) cuda_poll(); break;#endif /* CONFIG_ADB_CUDA */#ifdef CONFIG_ADB_PMU case SYS_CTRLER_PMU: pmu_shutdown(); break;#endif /* CONFIG_ADB_PMU */ default: ; }}void __pmacpmac_halt(void){ pmac_power_off();}/* * Read in a property describing some pieces of memory. */static int __initget_mem_prop(char *name, struct mem_pieces *mp){ struct reg_property *rp; int i, s; unsigned int *ip; int nac = prom_n_addr_cells(memory_node); int nsc = prom_n_size_cells(memory_node); ip = (unsigned int *) get_property(memory_node, name, &s); if (ip == NULL) { printk(KERN_ERR "error: couldn't get %s property on /memory\n", name); return 0; } s /= (nsc + nac) * 4; rp = mp->regions; for (i = 0; i < s; ++i, ip += nac+nsc) { if (nac >= 2 && ip[nac-2] != 0) continue; rp->address = ip[nac-1]; if (nsc >= 2 && ip[nac+nsc-2] != 0) rp->size = ~0U; else rp->size = ip[nac+nsc-1]; ++rp; } mp->n_regions = rp - mp->regions; /* Make sure the pieces are sorted. */ mem_pieces_sort(mp); mem_pieces_coalesce(mp); return 1;}/* * On systems with Open Firmware, collect information about * physical RAM and which pieces are already in use. * At this point, we have (at least) the first 8MB mapped with a BAT. * Our text, data, bss use something over 1MB, starting at 0. * Open Firmware may be using 1MB at the 4MB point. */unsigned long __initpmac_find_end_of_memory(void){ unsigned long a, total; struct mem_pieces phys_mem; /* * Find out where physical memory is, and check that it * starts at 0 and is contiguous. It seems that RAM is * always physically contiguous on Power Macintoshes. * * Supporting discontiguous physical memory isn't hard, * it just makes the virtual <-> physical mapping functions * more complicated (or else you end up wasting space * in mem_map). */ memory_node = find_devices("memory"); if (memory_node == NULL || !get_mem_prop("reg", &phys_mem) || phys_mem.n_regions == 0) panic("No RAM??"); a = phys_mem.regions[0].address; if (a != 0) panic("RAM doesn't start at physical address 0"); total = phys_mem.regions[0].size; if (phys_mem.n_regions > 1) { printk("RAM starting at 0x%x is not contiguous\n", phys_mem.regions[1].address); printk("Using RAM from 0 to 0x%lx\n", total-1); } return total;}void __initpmac_init(unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7){ /* isa_io_base gets set in pmac_find_bridges */ isa_mem_base = PMAC_ISA_MEM_BASE; pci_dram_offset = PMAC_PCI_DRAM_OFFSET; ISA_DMA_THRESHOLD = ~0L; DMA_MODE_READ = 1; DMA_MODE_WRITE = 2; ppc_md.setup_arch = pmac_setup_arch; ppc_md.show_cpuinfo = pmac_show_cpuinfo; ppc_md.show_percpuinfo = pmac_show_percpuinfo; ppc_md.irq_canonicalize = NULL; ppc_md.init_IRQ = pmac_pic_init; ppc_md.get_irq = pmac_get_irq; /* Changed later on ... */ ppc_md.pcibios_fixup = pmac_pcibios_fixup; ppc_md.pcibios_enable_device_hook = pmac_pci_enable_device_hook; ppc_md.pcibios_after_init = pmac_pcibios_after_init; ppc_md.restart = pmac_restart; ppc_md.power_off = pmac_power_off; ppc_md.halt = pmac_halt; ppc_md.time_init = pmac_time_init; ppc_md.set_rtc_time = pmac_set_rtc_time; ppc_md.get_rtc_time = pmac_get_rtc_time; ppc_md.calibrate_decr = pmac_calibrate_decr; ppc_md.find_end_of_memory = pmac_find_end_of_memory; ppc_md.feature_call = pmac_do_feature_call;#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)#ifdef CONFIG_BLK_DEV_IDE_PMAC ppc_ide_md.ide_init_hwif = pmac_ide_init_hwif_ports; ppc_ide_md.default_io_base = pmac_ide_get_base;#endif /* CONFIG_BLK_DEV_IDE_PMAC */#endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */#ifdef CONFIG_BOOTX_TEXT ppc_md.progress = pmac_progress;#endif /* CONFIG_BOOTX_TEXT */ if (ppc_md.progress) ppc_md.progress("pmac_init(): exit", 0);}#ifdef CONFIG_BOOTX_TEXTvoid __initpmac_progress(char *s, unsigned short hex){ if (boot_text_mapped) { btext_drawstring(s); btext_drawchar('\n'); }}#endif /* CONFIG_BOOTX_TEXT */static int __initpmac_declare_of_platform_devices(void){ struct device_node *np; np = find_devices("uni-n"); if (np) { for (np = np->child; np != NULL; np = np->sibling) if (strncmp(np->name, "i2c", 3) == 0) { of_platform_device_create(np, "uni-n-i2c"); break; } } np = find_devices("u3"); if (np) { for (np = np->child; np != NULL; np = np->sibling) if (strncmp(np->name, "i2c", 3) == 0) { of_platform_device_create(np, "u3-i2c"); break; } } np = find_devices("valkyrie"); if (np) of_platform_device_create(np, "valkyrie"); np = find_devices("platinum"); if (np) of_platform_device_create(np, "platinum"); return 0;}device_initcall(pmac_declare_of_platform_devices);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?