📄 setup.c
字号:
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1999,2001-2006 Silicon Graphics, Inc. All rights reserved. */#include <linux/module.h>#include <linux/init.h>#include <linux/delay.h>#include <linux/kernel.h>#ifndef XEN#include <linux/kdev_t.h>#endif#include <linux/string.h>#ifndef XEN#include <linux/screen_info.h>#endif#include <linux/console.h>#include <linux/timex.h>#include <linux/sched.h>#include <linux/ioport.h>#include <linux/mm.h>#include <linux/serial.h>#include <linux/irq.h>#include <linux/bootmem.h>#include <linux/mmzone.h>#include <linux/interrupt.h>#include <linux/acpi.h>#include <linux/compiler.h>#include <linux/sched.h>#ifndef XEN#include <linux/root_dev.h>#endif#include <linux/nodemask.h>#include <linux/pm.h>#include <linux/efi.h>#include <asm/io.h>#include <asm/sal.h>#include <asm/machvec.h>#include <asm/system.h>#include <asm/processor.h>#ifndef XEN#include <asm/vga.h>#endif#include <asm/sn/arch.h>#include <asm/sn/addrs.h>#include <asm/sn/pda.h>#include <asm/sn/nodepda.h>#include <asm/sn/sn_cpuid.h>#include <asm/sn/simulator.h>#include <asm/sn/leds.h>#ifndef XEN#include <asm/sn/bte.h>#endif#include <asm/sn/shub_mmr.h>#ifndef XEN#include <asm/sn/clksupport.h>#endif#include <asm/sn/sn_sal.h>#include <asm/sn/geo.h>#include <asm/sn/sn_feature_sets.h>#ifndef XEN#include "xtalk/xwidgetdev.h"#include "xtalk/hubdev.h"#else#include "asm/sn/xwidgetdev.h"#include "asm/sn/hubdev.h"#endif#include <asm/sn/klconfig.h>#ifdef XEN#include <asm/sn/shubio.h>#endifDEFINE_PER_CPU(struct pda_s, pda_percpu);#define MAX_PHYS_MEMORY (1UL << IA64_MAX_PHYS_BITS) /* Max physical address supported */extern void bte_init_node(nodepda_t *, cnodeid_t);extern void sn_timer_init(void);extern unsigned long last_time_offset;extern void (*ia64_mark_idle) (int);extern void snidle(int);extern unsigned long long (*ia64_printk_clock)(void);unsigned long sn_rtc_cycles_per_second;EXPORT_SYMBOL(sn_rtc_cycles_per_second);DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);EXPORT_PER_CPU_SYMBOL(__sn_hub_info);DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_COMPACT_NODES]);EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);EXPORT_PER_CPU_SYMBOL(__sn_nodepda);char sn_system_serial_number_string[128];EXPORT_SYMBOL(sn_system_serial_number_string);u64 sn_partition_serial_number;EXPORT_SYMBOL(sn_partition_serial_number);u8 sn_partition_id;EXPORT_SYMBOL(sn_partition_id);u8 sn_system_size;EXPORT_SYMBOL(sn_system_size);u8 sn_sharing_domain_size;EXPORT_SYMBOL(sn_sharing_domain_size);u8 sn_coherency_id;EXPORT_SYMBOL(sn_coherency_id);u8 sn_region_size;EXPORT_SYMBOL(sn_region_size);int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */short physical_node_map[MAX_NUMALINK_NODES];static unsigned long sn_prom_features[MAX_PROM_FEATURE_SETS];EXPORT_SYMBOL(physical_node_map);int num_cnodes;static void sn_init_pdas(char **);static void build_cnode_tables(void);static nodepda_t *nodepdaindr[MAX_COMPACT_NODES];#ifndef XEN/* * The format of "screen_info" is strange, and due to early i386-setup * code. This is just enough to make the console code think we're on a * VGA color display. */struct screen_info sn_screen_info = { .orig_x = 0, .orig_y = 0, .orig_video_mode = 3, .orig_video_cols = 80, .orig_video_ega_bx = 3, .orig_video_lines = 25, .orig_video_isVGA = 1, .orig_video_points = 16};#endif/* * This routine can only be used during init, since * smp_boot_data is an init data structure. * We have to use smp_boot_data.cpu_phys_id to find * the physical id of the processor because the normal * cpu_physical_id() relies on data structures that * may not be initialized yet. */static int __init pxm_to_nasid(int pxm){ int i; int nid; nid = pxm_to_node(pxm); for (i = 0; i < num_node_memblks; i++) { if (node_memblk[i].nid == nid) { return NASID_GET(node_memblk[i].start_paddr); } } return -1;}/** * early_sn_setup - early setup routine for SN platforms * * Sets up an initial console to aid debugging. Intended primarily * for bringup. See start_kernel() in init/main.c. */void __init early_sn_setup(void){ efi_system_table_t *efi_systab; efi_config_table_t *config_tables; struct ia64_sal_systab *sal_systab; struct ia64_sal_desc_entry_point *ep; char *p; int i, j; /* * Parse enough of the SAL tables to locate the SAL entry point. Since, console * IO on SN2 is done via SAL calls, early_printk won't work without this. * * This code duplicates some of the ACPI table parsing that is in efi.c & sal.c. * Any changes to those file may have to be made hereas well. */ efi_systab = (efi_system_table_t *) __va(ia64_boot_param->efi_systab); config_tables = __va(efi_systab->tables); for (i = 0; i < efi_systab->nr_tables; i++) { if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) { sal_systab = __va(config_tables[i].table); p = (char *)(sal_systab + 1); for (j = 0; j < sal_systab->entry_count; j++) { if (*p == SAL_DESC_ENTRY_POINT) { ep = (struct ia64_sal_desc_entry_point *)p; ia64_sal_handler_init(__va (ep->sal_proc), __va(ep->gp)); return; } p += SAL_DESC_SIZE(*p); } } } /* Uh-oh, SAL not available?? */ printk(KERN_ERR "failed to find SAL entry point\n");}extern int platform_intr_list[];static int __initdata shub_1_1_found;/* * sn_check_for_wars * * Set flag for enabling shub specific wars */static inline int __init is_shub_1_1(int nasid){ unsigned long id; int rev; if (is_shub2()) return 0; id = REMOTE_HUB_L(nasid, SH1_SHUB_ID); rev = (id & SH1_SHUB_ID_REVISION_MASK) >> SH1_SHUB_ID_REVISION_SHFT; return rev <= 2;}static void __init sn_check_for_wars(void){ int cnode; if (is_shub2()) { /* none yet */ } else { for_each_online_node(cnode) { if (is_shub_1_1(cnodeid_to_nasid(cnode))) shub_1_1_found = 1; } }}#ifndef XEN/* * Scan the EFI PCDP table (if it exists) for an acceptable VGA console * output device. If one exists, pick it and set sn_legacy_{io,mem} to * reflect the bus offsets needed to address it. * * Since pcdp support in SN is not supported in the 2.4 kernel (or at least * the one lbs is based on) just declare the needed structs here. * * Reference spec http://www.dig64.org/specifications/DIG64_PCDPv20.pdf * * Returns 0 if no acceptable vga is found, !0 otherwise. * * Note: This stuff is duped here because Altix requires the PCDP to * locate a usable VGA device due to lack of proper ACPI support. Structures * could be used from drivers/firmware/pcdp.h, but it was decided that moving * this file to a more public location just for Altix use was undesireable. */struct hcdp_uart_desc { u8 pad[45];};struct pcdp { u8 signature[4]; /* should be 'HCDP' */ u32 length; u8 rev; /* should be >=3 for pcdp, <3 for hcdp */ u8 sum; u8 oem_id[6]; u64 oem_tableid; u32 oem_rev; u32 creator_id; u32 creator_rev; u32 num_type0; struct hcdp_uart_desc uart[0]; /* num_type0 of these */ /* pcdp descriptors follow */} __attribute__((packed));struct pcdp_device_desc { u8 type; u8 primary; u16 length; u16 index; /* interconnect specific structure follows */ /* device specific structure follows that */} __attribute__((packed));struct pcdp_interface_pci { u8 type; /* 1 == pci */ u8 reserved; u16 length; u8 segment; u8 bus; u8 dev; u8 fun; u16 devid; u16 vendid; u32 acpi_interrupt; u64 mmio_tra; u64 ioport_tra; u8 flags; u8 translation;} __attribute__((packed));struct pcdp_vga_device { u8 num_eas_desc; /* ACPI Extended Address Space Desc follows */} __attribute__((packed));/* from pcdp_device_desc.primary */#define PCDP_PRIMARY_CONSOLE 0x01/* from pcdp_device_desc.type */#define PCDP_CONSOLE_INOUT 0x0#define PCDP_CONSOLE_DEBUG 0x1#define PCDP_CONSOLE_OUT 0x2#define PCDP_CONSOLE_IN 0x3#define PCDP_CONSOLE_TYPE_VGA 0x8#define PCDP_CONSOLE_VGA (PCDP_CONSOLE_TYPE_VGA | PCDP_CONSOLE_OUT)/* from pcdp_interface_pci.type */#define PCDP_IF_PCI 1/* from pcdp_interface_pci.translation */#define PCDP_PCI_TRANS_IOPORT 0x02#define PCDP_PCI_TRANS_MMIO 0x01#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)static voidsn_scan_pcdp(void){ u8 *bp; struct pcdp *pcdp; struct pcdp_device_desc device; struct pcdp_interface_pci if_pci; extern struct efi efi; if (efi.hcdp == EFI_INVALID_TABLE_ADDR) return; /* no hcdp/pcdp table */ pcdp = __va(efi.hcdp); if (pcdp->rev < 3) return; /* only support PCDP (rev >= 3) */ for (bp = (u8 *)&pcdp->uart[pcdp->num_type0]; bp < (u8 *)pcdp + pcdp->length; bp += device.length) { memcpy(&device, bp, sizeof(device)); if (! (device.primary & PCDP_PRIMARY_CONSOLE)) continue; /* not primary console */ if (device.type != PCDP_CONSOLE_VGA) continue; /* not VGA descriptor */ memcpy(&if_pci, bp+sizeof(device), sizeof(if_pci)); if (if_pci.type != PCDP_IF_PCI) continue; /* not PCI interconnect */ if (if_pci.translation & PCDP_PCI_TRANS_IOPORT) vga_console_iobase = if_pci.ioport_tra | __IA64_UNCACHED_OFFSET; if (if_pci.translation & PCDP_PCI_TRANS_MMIO) vga_console_membase = if_pci.mmio_tra | __IA64_UNCACHED_OFFSET; break; /* once we find the primary, we're done */ }}#endifstatic unsigned long sn2_rtc_initial;static unsigned long long ia64_sn2_printk_clock(void){ unsigned long rtc_now = rtc_time(); return (rtc_now - sn2_rtc_initial) * (1000000000 / sn_rtc_cycles_per_second);}#endif/** * sn_setup - SN platform setup routine * @cmdline_p: kernel command line * * Handles platform setup for SN machines. This includes determining * the RTC frequency (via a SAL call), initializing secondary CPUs, and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -