📄 setup.c
字号:
/* * Copyright (C) 1999,2001-2003 Silicon Graphics, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * Further, this software is distributed without any warranty that it is * free of the rightful claim of any third person regarding infringement * or the like. Any license provided herein, whether implied or * otherwise, applies only to this software file. Patent licenses, if * any, provided herein do not apply to combinations of this program with * other software, or any other product whatsoever. * * You should have received a copy of the GNU General Public * License along with this program; if not, write the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, * Mountain View, CA 94043, or: * * http://www.sgi.com * * For further information regarding this notice, see: * * http://oss.sgi.com/projects/GenInfo/NoticeExplan */#include <linux/config.h>#include <linux/init.h>#include <linux/delay.h>#include <linux/kernel.h>#include <linux/kdev_t.h>#include <linux/string.h>#include <linux/tty.h>#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>#include <asm/io.h>#include <asm/sal.h>#include <asm/machvec.h>#include <asm/system.h>#include <asm/processor.h>#include <asm/pgalloc.h>#include <asm/sn/sgi.h>#include <asm/sn/io.h>#include <asm/sn/pci/pciio.h>#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/sn_private.h>#include <asm/sn/simulator.h>#include <asm/sn/leds.h>#include <asm/sn/bte.h>#include <asm/sn/clksupport.h>#include <asm/sn/sn_sal.h>#include <asm/sn/sn2/shub.h>#define pxm_to_nasid(pxm) (((pxm)<<1) | (get_nasid() & ~0x1ff))#define MAX_PHYS_MEMORY (1UL << 49) /* 1 TB */extern void bte_init_node (nodepda_t *, cnodeid_t);extern void bte_init_cpu (void);extern void sn_timer_init(void);extern unsigned long last_time_offset;extern void init_platform_hubinfo(nodepda_t **nodepdaindr);extern void (*ia64_mark_idle)(int);extern void (*ia64_platform_timer_extras)(void);extern void sn_timer_interrupt_extras(void);extern void snidle(int);extern unsigned char acpi_kbd_controller_present;unsigned long sn_rtc_cycles_per_second; partid_t sn_partid = -1;char sn_system_serial_number_string[128];u64 sn_partition_serial_number;short physical_node_map[MAX_PHYSNODE_ID];int numionodes;/* * This is the address of the RRegs in the HSpace of the global * master. It is used by a hack in serial.c (serial_[in|out], * printk.c (early_printk), and kdb_io.c to put console output on that * node's Bedrock UART. It is initialized here to 0, so that * early_printk won't try to access the UART before * master_node_bedrock_address is properly calculated. */u64 master_node_bedrock_address;static void sn_init_pdas(char **);static nodepda_t *nodepdaindr[MAX_COMPACT_NODES];irqpda_t *irqpdaindr;/* * 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};/* * This is here so we can use the CMOS detection in ide-probe.c to * determine what drives are present. In theory, we don't need this * as the auto-detection could be done via ide-probe.c:do_probe() but * in practice that would be much slower, which is painful when * running in the simulator. Note that passing zeroes in DRIVE_INFO * is sufficient (the IDE driver will autodetect the drive geometry). */#ifdef CONFIG_IA64_GENERICextern char drive_info[4*16];#elsechar drive_info[4*16];#endif/** * 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. */#if defined(CONFIG_IA64_EARLY_PRINTK_SGI_SN) || defined(CONFIG_IA64_SGI_SN_SIM)void __initearly_sn_setup(void){ void ia64_sal_handler_init (void *entry_point, void *gpval); 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; /* * 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 (i = 0; i < sal_systab->entry_count; i++) { 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)); break; } p += SAL_DESC_SIZE(*p); } } } if ( IS_RUNNING_ON_SIMULATOR() ) { master_node_bedrock_address = (u64)REMOTE_HUB(get_nasid(), SH_JUNK_BUS_UART0); printk(KERN_DEBUG "early_sn_setup: setting master_node_bedrock_address to 0x%lx\n", master_node_bedrock_address); }}#endif /* CONFIG_IA64_EARLY_PRINTK_SGI_SN */#ifdef CONFIG_IA64_MCAextern int platform_intr_list[];#endifextern nasid_t master_nasid;static int shub_1_1_found __initdata;/* * sn_check_for_wars * * Set flag for enabling shub specific wars */static inline int __initis_shub_1_1(int nasid){ unsigned long id; int rev; id = REMOTE_HUB_L(nasid, SH_SHUB_ID); rev = (id & SH_SHUB_ID_REVISION_MASK) >> SH_SHUB_ID_REVISION_SHFT; return rev <= 2;}static void __initsn_check_for_wars(void){ int cnode; for (cnode=0; cnode< numnodes; cnode++) if (is_shub_1_1(cnodeid_to_nasid(cnode))) shub_1_1_found = 1;}/* * SN2 requires very slightly different alternate data-TLB miss handle than what * the mainline linux kernel provides. At some point this approach could be used * to allow the use of the low-memory thrown away on other platforms when VGA is * present. * * On SN2 we want to load small TCs for granule-0 (and aliases of) faulting * addresses. The details of this are more sublte than at which they first * appear. */static void __initsn2_replace_ivt(void){ extern unsigned char alt_dtlb_miss[], ia64_ivt_page_fault[]; extern unsigned char sn2_alt_dtlb_miss[], sn2_alt_dtlb_miss_end[]; extern unsigned char sn2_alt_dtlb_miss_patch1[]; unsigned char *s, *d; u64 *p; u64 len = (u64)sn2_alt_dtlb_miss_end - (u64)sn2_alt_dtlb_miss; u64 broffs = (ia64_ivt_page_fault - alt_dtlb_miss) - (sn2_alt_dtlb_miss_patch1 - sn2_alt_dtlb_miss); u64 psr; int i; /* printk(KERN_DEBUG "Replacing alternate data-TLB miss handler.\n"); */ /* Check the code isn't too large */ if (len > 1024) { printk(KERN_ERR "SGI: Specific alt_dtlb_misse too large! Not replacing\n"); return; } /* check the offset is sane (should always be) */ if ((broffs>>4) + (1<<20) >= (1<<21)) { printk(KERN_ERR "SGI: IVT patch ivt offset %ld invalid! Not replacing!\n", broffs); return; } /* 2nd half of bundle to patch (has slot 2) */ p = (u64*)sn2_alt_dtlb_miss_patch1 + 1; /* patch the offset into slot 2 (imm20b + s) */ *p = (*p & ~(0x8fffff000000000)) | ((broffs & 0x1000000) << 35) | ((broffs & 0x0fffff0) << 32); /* don't want any interrupts when doing this */ psr = ia64_clear_ic(); /* copy over the existing code, flush i-cache as required */ d = alt_dtlb_miss; s = sn2_alt_dtlb_miss; for (i=0; i<len; ++i, ++s) { *d++ = *s; if ((((u64)s) & 63) == 63) { ia64_insn_group_barrier(); ia64_fc((void*)s); } } ia64_insn_group_barrier(); ia64_fc((void*)s); /* sync & serialize instruction stream */ ia64_sync_i(); ia64_srlz_i(); /* restore interrupt status */ ia64_set_psr(psr); /* flush any TC's we have had previously loaded that could cause problems here */ local_flush_tlb_all(); printk(KERN_DEBUG "SGI: Replaced alt_dtlb_miss handler.\n");}/** * sn_setup - SN platform setup routine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -