📄 setup.c
字号:
/* * 64-bit pSeries and RS/6000 setup code. * * Copyright (C) 1995 Linus Torvalds * Adapted from 'alpha' version by Gary Thomas * Modified by Cort Dougan (cort@cs.nmt.edu) * Modified by 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. *//* * bootup setup stuff.. */#undef DEBUG#include <linux/config.h>#include <linux/cpu.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/slab.h>#include <linux/user.h>#include <linux/a.out.h>#include <linux/tty.h>#include <linux/major.h>#include <linux/interrupt.h>#include <linux/reboot.h>#include <linux/init.h>#include <linux/ioport.h>#include <linux/console.h>#include <linux/pci.h>#include <linux/utsname.h>#include <linux/adb.h>#include <linux/module.h>#include <linux/delay.h>#include <linux/irq.h>#include <linux/seq_file.h>#include <linux/root_dev.h>#include <asm/mmu.h>#include <asm/processor.h>#include <asm/io.h>#include <asm/pgtable.h>#include <asm/prom.h>#include <asm/rtas.h>#include <asm/pci-bridge.h>#include <asm/iommu.h>#include <asm/dma.h>#include <asm/machdep.h>#include <asm/irq.h>#include <asm/time.h>#include <asm/nvram.h>#include "xics.h"#include <asm/firmware.h>#include <asm/pmc.h>#include <asm/mpic.h>#include <asm/ppc-pci.h>#include <asm/i8259.h>#include <asm/udbg.h>#include <asm/smp.h>#include "plpar_wrappers.h"#ifdef DEBUG#define DBG(fmt...) udbg_printf(fmt)#else#define DBG(fmt...)#endifextern void find_udbg_vterm(void);extern void system_reset_fwnmi(void); /* from head.S */extern void machine_check_fwnmi(void); /* from head.S */extern void generic_find_legacy_serial_ports(u64 *physport, unsigned int *default_speed);int fwnmi_active; /* TRUE if an FWNMI handler is present */extern void pSeries_system_reset_exception(struct pt_regs *regs);extern int pSeries_machine_check_exception(struct pt_regs *regs);static void pseries_shared_idle(void);static void pseries_dedicated_idle(void);struct mpic *pSeries_mpic;void pSeries_show_cpuinfo(struct seq_file *m){ struct device_node *root; const char *model = ""; root = of_find_node_by_path("/"); if (root) model = get_property(root, "model", NULL); seq_printf(m, "machine\t\t: CHRP %s\n", model); of_node_put(root);}/* Initialize firmware assisted non-maskable interrupts if * the firmware supports this feature. * */static void __init fwnmi_init(void){ int ret; int ibm_nmi_register = rtas_token("ibm,nmi-register"); if (ibm_nmi_register == RTAS_UNKNOWN_SERVICE) return; ret = rtas_call(ibm_nmi_register, 2, 1, NULL, __pa((unsigned long)system_reset_fwnmi), __pa((unsigned long)machine_check_fwnmi)); if (ret == 0) fwnmi_active = 1;}static void __init pSeries_init_mpic(void){ unsigned int *addrp; struct device_node *np; unsigned long intack = 0; /* All ISUs are setup, complete initialization */ mpic_init(pSeries_mpic); /* Check what kind of cascade ACK we have */ if (!(np = of_find_node_by_name(NULL, "pci")) || !(addrp = (unsigned int *) get_property(np, "8259-interrupt-acknowledge", NULL))) printk(KERN_ERR "Cannot find pci to get ack address\n"); else intack = addrp[prom_n_addr_cells(np)-1]; of_node_put(np); /* Setup the legacy interrupts & controller */ i8259_init(intack, 0); /* Hook cascade to mpic */ mpic_setup_cascade(NUM_ISA_INTERRUPTS, i8259_irq_cascade, NULL);}static void __init pSeries_setup_mpic(void){ unsigned int *opprop; unsigned long openpic_addr = 0; unsigned char senses[NR_IRQS - NUM_ISA_INTERRUPTS]; struct device_node *root; int irq_count; /* Find the Open PIC if present */ root = of_find_node_by_path("/"); opprop = (unsigned int *) get_property(root, "platform-open-pic", NULL); if (opprop != 0) { int n = prom_n_addr_cells(root); for (openpic_addr = 0; n > 0; --n) openpic_addr = (openpic_addr << 32) + *opprop++; printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr); } of_node_put(root); BUG_ON(openpic_addr == 0); /* Get the sense values from OF */ prom_get_irq_senses(senses, NUM_ISA_INTERRUPTS, NR_IRQS); /* Setup the openpic driver */ irq_count = NR_IRQS - NUM_ISA_INTERRUPTS - 4; /* leave room for IPIs */ pSeries_mpic = mpic_alloc(openpic_addr, MPIC_PRIMARY, 16, 16, irq_count, /* isu size, irq offset, irq count */ NR_IRQS - 4, /* ipi offset */ senses, irq_count, /* sense & sense size */ " MPIC ");}static void pseries_lpar_enable_pmcs(void){ unsigned long set, reset; power4_enable_pmcs(); set = 1UL << 63; reset = 0; plpar_hcall_norets(H_PERFMON, set, reset); /* instruct hypervisor to maintain PMCs */ if (firmware_has_feature(FW_FEATURE_SPLPAR)) get_paca()->lppaca.pmcregs_in_use = 1;}static void __init pSeries_setup_arch(void){ /* Fixup ppc_md depending on the type of interrupt controller */ if (ppc64_interrupt_controller == IC_OPEN_PIC) { ppc_md.init_IRQ = pSeries_init_mpic; ppc_md.get_irq = mpic_get_irq; /* Allocate the mpic now, so that find_and_init_phbs() can * fill the ISUs */ pSeries_setup_mpic(); } else { ppc_md.init_IRQ = xics_init_IRQ; ppc_md.get_irq = xics_get_irq; }#ifdef CONFIG_SMP smp_init_pSeries();#endif /* openpic global configuration register (64-bit format). */ /* openpic Interrupt Source Unit pointer (64-bit format). */ /* python0 facility area (mmio) (64-bit format) REAL address. */ /* init to some ~sane value until calibrate_delay() runs */ loops_per_jiffy = 50000000; if (ROOT_DEV == 0) { printk("No ramdisk, default root is /dev/sda2\n"); ROOT_DEV = Root_SDA2; } fwnmi_init(); /* Find and initialize PCI host bridges */ init_pci_config_tokens(); find_and_init_phbs(); eeh_init(); pSeries_nvram_init(); /* Choose an idle loop */ if (firmware_has_feature(FW_FEATURE_SPLPAR)) { vpa_init(boot_cpuid); if (get_paca()->lppaca.shared_proc) { printk(KERN_INFO "Using shared processor idle loop\n"); ppc_md.idle_loop = pseries_shared_idle; } else { printk(KERN_INFO "Using dedicated idle loop\n"); ppc_md.idle_loop = pseries_dedicated_idle; } } else { printk(KERN_INFO "Using default idle loop\n"); ppc_md.idle_loop = default_idle; } if (platform_is_lpar()) ppc_md.enable_pmcs = pseries_lpar_enable_pmcs; else ppc_md.enable_pmcs = power4_enable_pmcs;}static int __init pSeries_init_panel(void){ /* Manually leave the kernel version on the panel. */ ppc_md.progress("Linux ppc64\n", 0); ppc_md.progress(system_utsname.version, 0); return 0;}arch_initcall(pSeries_init_panel);/* Build up the ppc64_firmware_features bitmask field * using contents of device-tree/ibm,hypertas-functions. * Ultimately this functionality may be moved into prom.c prom_init(). */static void __init fw_feature_init(void){ struct device_node * dn; char * hypertas; unsigned int len; DBG(" -> fw_feature_init()\n"); ppc64_firmware_features = 0; dn = of_find_node_by_path("/rtas"); if (dn == NULL) { printk(KERN_ERR "WARNING ! Cannot find RTAS in device-tree !\n"); goto no_rtas; } hypertas = get_property(dn, "ibm,hypertas-functions", &len); if (hypertas) { while (len > 0){ int i, hypertas_len; /* check value against table of strings */ for(i=0; i < FIRMWARE_MAX_FEATURES ;i++) { if ((firmware_features_table[i].name) && (strcmp(firmware_features_table[i].name,hypertas))==0) { /* we have a match */ ppc64_firmware_features |= (firmware_features_table[i].val); break; } } hypertas_len = strlen(hypertas); len -= hypertas_len +1; hypertas+= hypertas_len +1; } } of_node_put(dn);no_rtas: DBG(" <- fw_feature_init()\n");}static void __init pSeries_discover_pic(void){ struct device_node *np; char *typep; /* * Setup interrupt mapping options that are needed for finish_device_tree * to properly parse the OF interrupt tree & do the virtual irq mapping */ __irq_offset_value = NUM_ISA_INTERRUPTS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -