xref: /openbmc/linux/arch/ia64/kernel/setup.c (revision 6c38e300)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * Architecture-specific setup.
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 1998-2001, 2003-2004 Hewlett-Packard Co
61da177e4SLinus Torvalds  *	David Mosberger-Tang <davidm@hpl.hp.com>
71da177e4SLinus Torvalds  *	Stephane Eranian <eranian@hpl.hp.com>
8e927ecb0SSuresh Siddha  * Copyright (C) 2000, 2004 Intel Corp
9e927ecb0SSuresh Siddha  * 	Rohit Seth <rohit.seth@intel.com>
10e927ecb0SSuresh Siddha  * 	Suresh Siddha <suresh.b.siddha@intel.com>
11e927ecb0SSuresh Siddha  * 	Gordon Jin <gordon.jin@intel.com>
121da177e4SLinus Torvalds  * Copyright (C) 1999 VA Linux Systems
131da177e4SLinus Torvalds  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
141da177e4SLinus Torvalds  *
15e927ecb0SSuresh Siddha  * 12/26/04 S.Siddha, G.Jin, R.Seth
16e927ecb0SSuresh Siddha  *			Add multi-threading and multi-core detection
171da177e4SLinus Torvalds  * 11/12/01 D.Mosberger Convert get_cpuinfo() to seq_file based show_cpuinfo().
181da177e4SLinus Torvalds  * 04/04/00 D.Mosberger renamed cpu_initialized to cpu_online_map
191da177e4SLinus Torvalds  * 03/31/00 R.Seth	cpu_initialized and current->processor fixes
201da177e4SLinus Torvalds  * 02/04/00 D.Mosberger	some more get_cpuinfo fixes...
211da177e4SLinus Torvalds  * 02/01/00 R.Seth	fixed get_cpuinfo for SMP
221da177e4SLinus Torvalds  * 01/07/99 S.Eranian	added the support for command line argument
231da177e4SLinus Torvalds  * 06/24/99 W.Drummond	added boot_cpu_data.
2408357f82SZoltan Menyhart  * 05/28/05 Z. Menyhart	Dynamic stride size for "flush_icache_range()"
251da177e4SLinus Torvalds  */
261da177e4SLinus Torvalds #include <linux/module.h>
271da177e4SLinus Torvalds #include <linux/init.h>
2865fddcfcSMike Rapoport #include <linux/pgtable.h>
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds #include <linux/acpi.h>
311da177e4SLinus Torvalds #include <linux/console.h>
321da177e4SLinus Torvalds #include <linux/delay.h>
331777e463SIngo Molnar #include <linux/cpu.h>
34fa809d70SChristoph Hellwig #include <linux/kdev_t.h>
351da177e4SLinus Torvalds #include <linux/kernel.h>
36f6280099SMike Rapoport #include <linux/memblock.h>
371da177e4SLinus Torvalds #include <linux/reboot.h>
3868e21be2SIngo Molnar #include <linux/sched/mm.h>
39e6017571SIngo Molnar #include <linux/sched/clock.h>
4068db0cf1SIngo Molnar #include <linux/sched/task_stack.h>
411da177e4SLinus Torvalds #include <linux/seq_file.h>
421da177e4SLinus Torvalds #include <linux/string.h>
431da177e4SLinus Torvalds #include <linux/threads.h>
44894673eeSJon Smirl #include <linux/screen_info.h>
453ed3bce8SMatt Domsch #include <linux/dmi.h>
46fa809d70SChristoph Hellwig #include <linux/root_dev.h>
471da177e4SLinus Torvalds #include <linux/serial.h>
481da177e4SLinus Torvalds #include <linux/serial_core.h>
491da177e4SLinus Torvalds #include <linux/efi.h>
501da177e4SLinus Torvalds #include <linux/initrd.h>
516c4fa560SVenkatesh Pallipadi #include <linux/pm.h>
5295235ca2SVenkatesh Pallipadi #include <linux/cpufreq.h>
53a7956113SZou Nan hai #include <linux/kexec.h>
54a7956113SZou Nan hai #include <linux/crash_dump.h>
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds #include <asm/mca.h>
571da177e4SLinus Torvalds #include <asm/meminit.h>
581da177e4SLinus Torvalds #include <asm/page.h>
591da177e4SLinus Torvalds #include <asm/patch.h>
601da177e4SLinus Torvalds #include <asm/processor.h>
611da177e4SLinus Torvalds #include <asm/sal.h>
621da177e4SLinus Torvalds #include <asm/sections.h>
631da177e4SLinus Torvalds #include <asm/setup.h>
641da177e4SLinus Torvalds #include <asm/smp.h>
652046b94eSFenghua Yu #include <asm/tlbflush.h>
661da177e4SLinus Torvalds #include <asm/unistd.h>
67df41017eSChristoph Hellwig #include <asm/uv/uv.h>
68b3545192SPeter Zijlstra #include <asm/xtp.h>
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds #if defined(CONFIG_SMP) && (IA64_CPU_SIZE > PAGE_SIZE)
711da177e4SLinus Torvalds # error "struct cpuinfo_ia64 too big!"
721da177e4SLinus Torvalds #endif
731da177e4SLinus Torvalds 
74df41017eSChristoph Hellwig char ia64_platform_name[64];
75df41017eSChristoph Hellwig 
761da177e4SLinus Torvalds #ifdef CONFIG_SMP
771da177e4SLinus Torvalds unsigned long __per_cpu_offset[NR_CPUS];
781da177e4SLinus Torvalds EXPORT_SYMBOL(__per_cpu_offset);
791da177e4SLinus Torvalds #endif
801da177e4SLinus Torvalds 
81877105ccSTejun Heo DEFINE_PER_CPU(struct cpuinfo_ia64, ia64_cpu_info);
82e007c533SAl Viro EXPORT_SYMBOL(ia64_cpu_info);
831da177e4SLinus Torvalds DEFINE_PER_CPU(unsigned long, local_per_cpu_offset);
84e007c533SAl Viro #ifdef CONFIG_SMP
85e007c533SAl Viro EXPORT_SYMBOL(local_per_cpu_offset);
86e007c533SAl Viro #endif
871da177e4SLinus Torvalds unsigned long ia64_cycles_per_usec;
881da177e4SLinus Torvalds struct ia64_boot_param *ia64_boot_param;
891da177e4SLinus Torvalds struct screen_info screen_info;
9066b7f8a3SMark Maule unsigned long vga_console_iobase;
9166b7f8a3SMark Maule unsigned long vga_console_membase;
921da177e4SLinus Torvalds 
93be379124SKhalid Aziz static struct resource data_resource = {
94be379124SKhalid Aziz 	.name	= "Kernel data",
9503cb525eSToshi Kani 	.flags	= IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
96be379124SKhalid Aziz };
97be379124SKhalid Aziz 
98be379124SKhalid Aziz static struct resource code_resource = {
99be379124SKhalid Aziz 	.name	= "Kernel code",
10003cb525eSToshi Kani 	.flags	= IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
101be379124SKhalid Aziz };
10200bf4098SBernhard Walle 
10300bf4098SBernhard Walle static struct resource bss_resource = {
10400bf4098SBernhard Walle 	.name	= "Kernel bss",
10503cb525eSToshi Kani 	.flags	= IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
10600bf4098SBernhard Walle };
107be379124SKhalid Aziz 
1081da177e4SLinus Torvalds unsigned long ia64_max_cacheline_size;
109e1531b42SJohn W. Linville 
1101da177e4SLinus Torvalds unsigned long ia64_iobase;	/* virtual address for I/O accesses */
1111da177e4SLinus Torvalds EXPORT_SYMBOL(ia64_iobase);
1121da177e4SLinus Torvalds struct io_space io_space[MAX_IO_SPACES];
1131da177e4SLinus Torvalds EXPORT_SYMBOL(io_space);
1141da177e4SLinus Torvalds unsigned int num_io_spaces;
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds /*
11708357f82SZoltan Menyhart  * "flush_icache_range()" needs to know what processor dependent stride size to use
11808357f82SZoltan Menyhart  * when it makes i-cache(s) coherent with d-caches.
11908357f82SZoltan Menyhart  */
12008357f82SZoltan Menyhart #define	I_CACHE_STRIDE_SHIFT	5	/* Safest way to go: 32 bytes by 32 bytes */
12108357f82SZoltan Menyhart unsigned long ia64_i_cache_stride_shift = ~0;
12262fdd767SFenghua Yu /*
12362fdd767SFenghua Yu  * "clflush_cache_range()" needs to know what processor dependent stride size to
12462fdd767SFenghua Yu  * use when it flushes cache lines including both d-cache and i-cache.
12562fdd767SFenghua Yu  */
12662fdd767SFenghua Yu /* Safest way to go: 32 bytes by 32 bytes */
12762fdd767SFenghua Yu #define	CACHE_STRIDE_SHIFT	5
12862fdd767SFenghua Yu unsigned long ia64_cache_stride_shift = ~0;
12908357f82SZoltan Menyhart 
13008357f82SZoltan Menyhart /*
1311da177e4SLinus Torvalds  * We use a special marker for the end of memory and it uses the extra (+1) slot
1321da177e4SLinus Torvalds  */
133dae28066SChen, Kenneth W struct rsvd_region rsvd_region[IA64_MAX_RSVD_REGIONS + 1] __initdata;
1347e4265c8SGeert Uytterhoeven static int num_rsvd_regions __initdata;
1351da177e4SLinus Torvalds 
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds /*
1381da177e4SLinus Torvalds  * Filter incoming memory segments based on the primitive map created from the boot
1391da177e4SLinus Torvalds  * parameters. Segments contained in the map are removed from the memory ranges. A
1401da177e4SLinus Torvalds  * caller-specified function is called with the memory ranges that remain after filtering.
1411da177e4SLinus Torvalds  * This routine does not assume the incoming segments are sorted.
1421da177e4SLinus Torvalds  */
143dae28066SChen, Kenneth W int __init
filter_rsvd_memory(u64 start,u64 end,void * arg)144e088a4adSMatthew Wilcox filter_rsvd_memory (u64 start, u64 end, void *arg)
1451da177e4SLinus Torvalds {
146e088a4adSMatthew Wilcox 	u64 range_start, range_end, prev_start;
1471da177e4SLinus Torvalds 	void (*func)(unsigned long, unsigned long, int);
1481da177e4SLinus Torvalds 	int i;
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds #if IGNORE_PFN0
1511da177e4SLinus Torvalds 	if (start == PAGE_OFFSET) {
1521da177e4SLinus Torvalds 		printk(KERN_WARNING "warning: skipping physical page 0\n");
1531da177e4SLinus Torvalds 		start += PAGE_SIZE;
1541da177e4SLinus Torvalds 		if (start >= end) return 0;
1551da177e4SLinus Torvalds 	}
1561da177e4SLinus Torvalds #endif
1571da177e4SLinus Torvalds 	/*
1581da177e4SLinus Torvalds 	 * lowest possible address(walker uses virtual)
1591da177e4SLinus Torvalds 	 */
1601da177e4SLinus Torvalds 	prev_start = PAGE_OFFSET;
1611da177e4SLinus Torvalds 	func = arg;
1621da177e4SLinus Torvalds 
1631da177e4SLinus Torvalds 	for (i = 0; i < num_rsvd_regions; ++i) {
1641da177e4SLinus Torvalds 		range_start = max(start, prev_start);
1651da177e4SLinus Torvalds 		range_end   = min(end, rsvd_region[i].start);
1661da177e4SLinus Torvalds 
1671da177e4SLinus Torvalds 		if (range_start < range_end)
1681da177e4SLinus Torvalds 			call_pernode_memory(__pa(range_start), range_end - range_start, func);
1691da177e4SLinus Torvalds 
1701da177e4SLinus Torvalds 		/* nothing more available in this segment */
1711da177e4SLinus Torvalds 		if (range_end == end) return 0;
1721da177e4SLinus Torvalds 
1731da177e4SLinus Torvalds 		prev_start = rsvd_region[i].end;
1741da177e4SLinus Torvalds 	}
1751da177e4SLinus Torvalds 	/* end of memory marker allows full processing inside loop body */
1761da177e4SLinus Torvalds 	return 0;
1771da177e4SLinus Torvalds }
1781da177e4SLinus Torvalds 
17998075d24SZoltan Menyhart /*
18098075d24SZoltan Menyhart  * Similar to "filter_rsvd_memory()", but the reserved memory ranges
18198075d24SZoltan Menyhart  * are not filtered out.
18298075d24SZoltan Menyhart  */
18398075d24SZoltan Menyhart int __init
filter_memory(u64 start,u64 end,void * arg)184e088a4adSMatthew Wilcox filter_memory(u64 start, u64 end, void *arg)
18598075d24SZoltan Menyhart {
18698075d24SZoltan Menyhart 	void (*func)(unsigned long, unsigned long, int);
18798075d24SZoltan Menyhart 
18898075d24SZoltan Menyhart #if IGNORE_PFN0
18998075d24SZoltan Menyhart 	if (start == PAGE_OFFSET) {
19098075d24SZoltan Menyhart 		printk(KERN_WARNING "warning: skipping physical page 0\n");
19198075d24SZoltan Menyhart 		start += PAGE_SIZE;
19298075d24SZoltan Menyhart 		if (start >= end)
19398075d24SZoltan Menyhart 			return 0;
19498075d24SZoltan Menyhart 	}
19598075d24SZoltan Menyhart #endif
19698075d24SZoltan Menyhart 	func = arg;
19798075d24SZoltan Menyhart 	if (start < end)
19898075d24SZoltan Menyhart 		call_pernode_memory(__pa(start), end - start, func);
19998075d24SZoltan Menyhart 	return 0;
20098075d24SZoltan Menyhart }
20198075d24SZoltan Menyhart 
202dae28066SChen, Kenneth W static void __init
sort_regions(struct rsvd_region * rsvd_region,int max)2031da177e4SLinus Torvalds sort_regions (struct rsvd_region *rsvd_region, int max)
2041da177e4SLinus Torvalds {
2051da177e4SLinus Torvalds 	int j;
2061da177e4SLinus Torvalds 
2071da177e4SLinus Torvalds 	/* simple bubble sorting */
2081da177e4SLinus Torvalds 	while (max--) {
2091da177e4SLinus Torvalds 		for (j = 0; j < max; ++j) {
2101da177e4SLinus Torvalds 			if (rsvd_region[j].start > rsvd_region[j+1].start) {
2116c4420b0SYang Guang 				swap(rsvd_region[j], rsvd_region[j + 1]);
2121da177e4SLinus Torvalds 			}
2131da177e4SLinus Torvalds 		}
2141da177e4SLinus Torvalds 	}
2151da177e4SLinus Torvalds }
2161da177e4SLinus Torvalds 
21776d71ebdSPetr Tesarik /* merge overlaps */
21876d71ebdSPetr Tesarik static int __init
merge_regions(struct rsvd_region * rsvd_region,int max)21976d71ebdSPetr Tesarik merge_regions (struct rsvd_region *rsvd_region, int max)
22076d71ebdSPetr Tesarik {
22176d71ebdSPetr Tesarik 	int i;
22276d71ebdSPetr Tesarik 	for (i = 1; i < max; ++i) {
22376d71ebdSPetr Tesarik 		if (rsvd_region[i].start >= rsvd_region[i-1].end)
22476d71ebdSPetr Tesarik 			continue;
22576d71ebdSPetr Tesarik 		if (rsvd_region[i].end > rsvd_region[i-1].end)
22676d71ebdSPetr Tesarik 			rsvd_region[i-1].end = rsvd_region[i].end;
22776d71ebdSPetr Tesarik 		--max;
22876d71ebdSPetr Tesarik 		memmove(&rsvd_region[i], &rsvd_region[i+1],
22976d71ebdSPetr Tesarik 			(max - i) * sizeof(struct rsvd_region));
23076d71ebdSPetr Tesarik 	}
23176d71ebdSPetr Tesarik 	return max;
23276d71ebdSPetr Tesarik }
23376d71ebdSPetr Tesarik 
234be379124SKhalid Aziz /*
235be379124SKhalid Aziz  * Request address space for all standard resources
236be379124SKhalid Aziz  */
register_memory(void)237be379124SKhalid Aziz static int __init register_memory(void)
238be379124SKhalid Aziz {
239be379124SKhalid Aziz 	code_resource.start = ia64_tpa(_text);
240be379124SKhalid Aziz 	code_resource.end   = ia64_tpa(_etext) - 1;
241be379124SKhalid Aziz 	data_resource.start = ia64_tpa(_etext);
24200bf4098SBernhard Walle 	data_resource.end   = ia64_tpa(_edata) - 1;
243b898a424SBernhard Walle 	bss_resource.start  = ia64_tpa(__bss_start);
24400bf4098SBernhard Walle 	bss_resource.end    = ia64_tpa(_end) - 1;
24500bf4098SBernhard Walle 	efi_initialize_iomem_resources(&code_resource, &data_resource,
24600bf4098SBernhard Walle 			&bss_resource);
247be379124SKhalid Aziz 
248be379124SKhalid Aziz 	return 0;
249be379124SKhalid Aziz }
250be379124SKhalid Aziz 
251be379124SKhalid Aziz __initcall(register_memory);
252be379124SKhalid Aziz 
253cb380853SBernhard Walle 
254cb380853SBernhard Walle #ifdef CONFIG_KEXEC
2558a3360f0SBernhard Walle 
2568a3360f0SBernhard Walle /*
2578a3360f0SBernhard Walle  * This function checks if the reserved crashkernel is allowed on the specific
2588a3360f0SBernhard Walle  * IA64 machine flavour. Machines without an IO TLB use swiotlb and require
2598a3360f0SBernhard Walle  * some memory below 4 GB (i.e. in 32 bit area), see the implementation of
260392e879aSAndy Shevchenko  * kernel/dma/swiotlb.c. The hpzx1 architecture has an IO TLB but cannot use that
2618a3360f0SBernhard Walle  * in kdump case. See the comment in sba_init() in sba_iommu.c.
2628a3360f0SBernhard Walle  *
2638a3360f0SBernhard Walle  * So, the only machvec that really supports loading the kdump kernel
264cf07cb1fSChristoph Hellwig  * over 4 GB is "uv".
2658a3360f0SBernhard Walle  */
check_crashkernel_memory(unsigned long pbase,size_t size)2668a3360f0SBernhard Walle static int __init check_crashkernel_memory(unsigned long pbase, size_t size)
2678a3360f0SBernhard Walle {
268df41017eSChristoph Hellwig 	if (is_uv_system())
2698a3360f0SBernhard Walle 		return 1;
2708a3360f0SBernhard Walle 	else
2718a3360f0SBernhard Walle 		return pbase < (1UL << 32);
2728a3360f0SBernhard Walle }
2738a3360f0SBernhard Walle 
setup_crashkernel(unsigned long total,int * n)274cb380853SBernhard Walle static void __init setup_crashkernel(unsigned long total, int *n)
275cb380853SBernhard Walle {
276cb380853SBernhard Walle 	unsigned long long base = 0, size = 0;
277cb380853SBernhard Walle 	int ret;
278cb380853SBernhard Walle 
279cb380853SBernhard Walle 	ret = parse_crashkernel(boot_command_line, total,
280cb380853SBernhard Walle 			&size, &base);
281cb380853SBernhard Walle 	if (ret == 0 && size > 0) {
282cb380853SBernhard Walle 		if (!base) {
283cb380853SBernhard Walle 			sort_regions(rsvd_region, *n);
28476d71ebdSPetr Tesarik 			*n = merge_regions(rsvd_region, *n);
285cb380853SBernhard Walle 			base = kdump_find_rsvd_region(size,
286cb380853SBernhard Walle 					rsvd_region, *n);
287cb380853SBernhard Walle 		}
2888a3360f0SBernhard Walle 
2898a3360f0SBernhard Walle 		if (!check_crashkernel_memory(base, size)) {
29094348b81SKefeng Wang 			pr_warn("crashkernel: There would be kdump memory "
2918a3360f0SBernhard Walle 				"at %ld GB but this is unusable because it "
2928a3360f0SBernhard Walle 				"must\nbe below 4 GB. Change the memory "
2938a3360f0SBernhard Walle 				"configuration of the machine.\n",
2948a3360f0SBernhard Walle 				(unsigned long)(base >> 30));
2958a3360f0SBernhard Walle 			return;
2968a3360f0SBernhard Walle 		}
2978a3360f0SBernhard Walle 
298cb380853SBernhard Walle 		if (base != ~0UL) {
299cb380853SBernhard Walle 			printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
300cb380853SBernhard Walle 					"for crashkernel (System RAM: %ldMB)\n",
301cb380853SBernhard Walle 					(unsigned long)(size >> 20),
302cb380853SBernhard Walle 					(unsigned long)(base >> 20),
303cb380853SBernhard Walle 					(unsigned long)(total >> 20));
304cb380853SBernhard Walle 			rsvd_region[*n].start =
305cb380853SBernhard Walle 				(unsigned long)__va(base);
306cb380853SBernhard Walle 			rsvd_region[*n].end =
307cb380853SBernhard Walle 				(unsigned long)__va(base + size);
308cb380853SBernhard Walle 			(*n)++;
309cb380853SBernhard Walle 			crashk_res.start = base;
310cb380853SBernhard Walle 			crashk_res.end = base + size - 1;
311cb380853SBernhard Walle 		}
312cb380853SBernhard Walle 	}
313cb380853SBernhard Walle 	efi_memmap_res.start = ia64_boot_param->efi_memmap;
314cb380853SBernhard Walle 	efi_memmap_res.end = efi_memmap_res.start +
315cb380853SBernhard Walle 		ia64_boot_param->efi_memmap_size;
316cb380853SBernhard Walle 	boot_param_res.start = __pa(ia64_boot_param);
317cb380853SBernhard Walle 	boot_param_res.end = boot_param_res.start +
318cb380853SBernhard Walle 		sizeof(*ia64_boot_param);
319cb380853SBernhard Walle }
320cb380853SBernhard Walle #else
setup_crashkernel(unsigned long total,int * n)321cb380853SBernhard Walle static inline void __init setup_crashkernel(unsigned long total, int *n)
322cb380853SBernhard Walle {}
323cb380853SBernhard Walle #endif
324cb380853SBernhard Walle 
32570b2e991SGeert Uytterhoeven #ifdef CONFIG_CRASH_DUMP
reserve_elfcorehdr(u64 * start,u64 * end)32670b2e991SGeert Uytterhoeven static int __init reserve_elfcorehdr(u64 *start, u64 *end)
32770b2e991SGeert Uytterhoeven {
32870b2e991SGeert Uytterhoeven 	u64 length;
32970b2e991SGeert Uytterhoeven 
33070b2e991SGeert Uytterhoeven 	/* We get the address using the kernel command line,
33170b2e991SGeert Uytterhoeven 	 * but the size is extracted from the EFI tables.
33270b2e991SGeert Uytterhoeven 	 * Both address and size are required for reservation
33370b2e991SGeert Uytterhoeven 	 * to work properly.
33470b2e991SGeert Uytterhoeven 	 */
33570b2e991SGeert Uytterhoeven 
33670b2e991SGeert Uytterhoeven 	if (!is_vmcore_usable())
33770b2e991SGeert Uytterhoeven 		return -EINVAL;
33870b2e991SGeert Uytterhoeven 
33970b2e991SGeert Uytterhoeven 	if ((length = vmcore_find_descriptor_size(elfcorehdr_addr)) == 0) {
34070b2e991SGeert Uytterhoeven 		vmcore_unusable();
34170b2e991SGeert Uytterhoeven 		return -EINVAL;
34270b2e991SGeert Uytterhoeven 	}
34370b2e991SGeert Uytterhoeven 
34470b2e991SGeert Uytterhoeven 	*start = (unsigned long)__va(elfcorehdr_addr);
34570b2e991SGeert Uytterhoeven 	*end = *start + length;
34670b2e991SGeert Uytterhoeven 	return 0;
34770b2e991SGeert Uytterhoeven }
34870b2e991SGeert Uytterhoeven #endif /* CONFIG_CRASH_DUMP */
34970b2e991SGeert Uytterhoeven 
3501da177e4SLinus Torvalds /**
3511da177e4SLinus Torvalds  * reserve_memory - setup reserved memory areas
3521da177e4SLinus Torvalds  *
3531da177e4SLinus Torvalds  * Setup the reserved memory areas set aside for the boot parameters,
3541da177e4SLinus Torvalds  * initrd, etc.  There are currently %IA64_MAX_RSVD_REGIONS defined,
3557f30491cSTony Luck  * see arch/ia64/include/asm/meminit.h if you need to define more.
3561da177e4SLinus Torvalds  */
357dae28066SChen, Kenneth W void __init
reserve_memory(void)3581da177e4SLinus Torvalds reserve_memory (void)
3591da177e4SLinus Torvalds {
3601da177e4SLinus Torvalds 	int n = 0;
361cb380853SBernhard Walle 	unsigned long total_memory;
3621da177e4SLinus Torvalds 
3631da177e4SLinus Torvalds 	/*
3641da177e4SLinus Torvalds 	 * none of the entries in this table overlap
3651da177e4SLinus Torvalds 	 */
3661da177e4SLinus Torvalds 	rsvd_region[n].start = (unsigned long) ia64_boot_param;
3671da177e4SLinus Torvalds 	rsvd_region[n].end   = rsvd_region[n].start + sizeof(*ia64_boot_param);
3681da177e4SLinus Torvalds 	n++;
3691da177e4SLinus Torvalds 
3701da177e4SLinus Torvalds 	rsvd_region[n].start = (unsigned long) __va(ia64_boot_param->efi_memmap);
3711da177e4SLinus Torvalds 	rsvd_region[n].end   = rsvd_region[n].start + ia64_boot_param->efi_memmap_size;
3721da177e4SLinus Torvalds 	n++;
3731da177e4SLinus Torvalds 
3741da177e4SLinus Torvalds 	rsvd_region[n].start = (unsigned long) __va(ia64_boot_param->command_line);
3751da177e4SLinus Torvalds 	rsvd_region[n].end   = (rsvd_region[n].start
3761da177e4SLinus Torvalds 				+ strlen(__va(ia64_boot_param->command_line)) + 1);
3771da177e4SLinus Torvalds 	n++;
3781da177e4SLinus Torvalds 
3791da177e4SLinus Torvalds 	rsvd_region[n].start = (unsigned long) ia64_imva((void *)KERNEL_START);
3801da177e4SLinus Torvalds 	rsvd_region[n].end   = (unsigned long) ia64_imva(_end);
3811da177e4SLinus Torvalds 	n++;
3821da177e4SLinus Torvalds 
3831da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
3841da177e4SLinus Torvalds 	if (ia64_boot_param->initrd_start) {
3851da177e4SLinus Torvalds 		rsvd_region[n].start = (unsigned long)__va(ia64_boot_param->initrd_start);
3861da177e4SLinus Torvalds 		rsvd_region[n].end   = rsvd_region[n].start + ia64_boot_param->initrd_size;
3871da177e4SLinus Torvalds 		n++;
3881da177e4SLinus Torvalds 	}
3891da177e4SLinus Torvalds #endif
3901da177e4SLinus Torvalds 
39117c1f07eSJay Lan #ifdef CONFIG_CRASH_DUMP
392cee87af2SMagnus Damm 	if (reserve_elfcorehdr(&rsvd_region[n].start,
393cee87af2SMagnus Damm 			       &rsvd_region[n].end) == 0)
394cee87af2SMagnus Damm 		n++;
395cee87af2SMagnus Damm #endif
396cee87af2SMagnus Damm 
397cb380853SBernhard Walle 	total_memory = efi_memmap_init(&rsvd_region[n].start, &rsvd_region[n].end);
398d8c97d5fSTony Luck 	n++;
399d8c97d5fSTony Luck 
400cb380853SBernhard Walle 	setup_crashkernel(total_memory, &n);
401cb380853SBernhard Walle 
4021da177e4SLinus Torvalds 	/* end of memory marker */
4031da177e4SLinus Torvalds 	rsvd_region[n].start = ~0UL;
4041da177e4SLinus Torvalds 	rsvd_region[n].end   = ~0UL;
4051da177e4SLinus Torvalds 	n++;
4061da177e4SLinus Torvalds 
4071da177e4SLinus Torvalds 	num_rsvd_regions = n;
4085eb1d63fSAlex Williamson 	BUG_ON(IA64_MAX_RSVD_REGIONS + 1 < n);
4091da177e4SLinus Torvalds 
4101da177e4SLinus Torvalds 	sort_regions(rsvd_region, num_rsvd_regions);
41176d71ebdSPetr Tesarik 	num_rsvd_regions = merge_regions(rsvd_region, num_rsvd_regions);
4121da177e4SLinus Torvalds 
413f6280099SMike Rapoport 	/* reserve all regions except the end of memory marker with memblock */
414f6280099SMike Rapoport 	for (n = 0; n < num_rsvd_regions - 1; n++) {
415f6280099SMike Rapoport 		struct rsvd_region *region = &rsvd_region[n];
416f6280099SMike Rapoport 		phys_addr_t addr = __pa(region->start);
417f6280099SMike Rapoport 		phys_addr_t size = region->end - region->start;
418f6280099SMike Rapoport 
419f6280099SMike Rapoport 		memblock_reserve(addr, size);
420f6280099SMike Rapoport 	}
421f6280099SMike Rapoport }
422a7956113SZou Nan hai 
4231da177e4SLinus Torvalds /**
4241da177e4SLinus Torvalds  * find_initrd - get initrd parameters from the boot parameter structure
4251da177e4SLinus Torvalds  *
4261da177e4SLinus Torvalds  * Grab the initrd start and end from the boot parameter struct given us by
4271da177e4SLinus Torvalds  * the boot loader.
4281da177e4SLinus Torvalds  */
429dae28066SChen, Kenneth W void __init
find_initrd(void)4301da177e4SLinus Torvalds find_initrd (void)
4311da177e4SLinus Torvalds {
4321da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4331da177e4SLinus Torvalds 	if (ia64_boot_param->initrd_start) {
4341da177e4SLinus Torvalds 		initrd_start = (unsigned long)__va(ia64_boot_param->initrd_start);
4351da177e4SLinus Torvalds 		initrd_end   = initrd_start+ia64_boot_param->initrd_size;
4361da177e4SLinus Torvalds 
437e088a4adSMatthew Wilcox 		printk(KERN_INFO "Initial ramdisk at: 0x%lx (%llu bytes)\n",
4381da177e4SLinus Torvalds 		       initrd_start, ia64_boot_param->initrd_size);
4391da177e4SLinus Torvalds 	}
4401da177e4SLinus Torvalds #endif
4411da177e4SLinus Torvalds }
4421da177e4SLinus Torvalds 
4431da177e4SLinus Torvalds static void __init
io_port_init(void)4441da177e4SLinus Torvalds io_port_init (void)
4451da177e4SLinus Torvalds {
4461da177e4SLinus Torvalds 	unsigned long phys_iobase;
4471da177e4SLinus Torvalds 
4481da177e4SLinus Torvalds 	/*
44944c45120SBjorn Helgaas 	 * Set `iobase' based on the EFI memory map or, failing that, the
45044c45120SBjorn Helgaas 	 * value firmware left in ar.k0.
4511da177e4SLinus Torvalds 	 *
45244c45120SBjorn Helgaas 	 * Note that in ia32 mode, IN/OUT instructions use ar.k0 to compute
45344c45120SBjorn Helgaas 	 * the port's virtual address, so ia32_load_state() loads it with a
45444c45120SBjorn Helgaas 	 * user virtual address.  But in ia64 mode, glibc uses the
45544c45120SBjorn Helgaas 	 * *physical* address in ar.k0 to mmap the appropriate area from
45644c45120SBjorn Helgaas 	 * /dev/mem, and the inX()/outX() interfaces use MMIO.  In both
45744c45120SBjorn Helgaas 	 * cases, user-mode can only use the legacy 0-64K I/O port space.
45844c45120SBjorn Helgaas 	 *
45944c45120SBjorn Helgaas 	 * ar.k0 is not involved in kernel I/O port accesses, which can use
46044c45120SBjorn Helgaas 	 * any of the I/O port spaces and are done via MMIO using the
46144c45120SBjorn Helgaas 	 * virtual mmio_base from the appropriate io_space[].
4621da177e4SLinus Torvalds 	 */
4631da177e4SLinus Torvalds 	phys_iobase = efi_get_iobase();
46444c45120SBjorn Helgaas 	if (!phys_iobase) {
4651da177e4SLinus Torvalds 		phys_iobase = ia64_get_kr(IA64_KR_IO_BASE);
46644c45120SBjorn Helgaas 		printk(KERN_INFO "No I/O port range found in EFI memory map, "
46744c45120SBjorn Helgaas 			"falling back to AR.KR0 (0x%lx)\n", phys_iobase);
4681da177e4SLinus Torvalds 	}
4691da177e4SLinus Torvalds 	ia64_iobase = (unsigned long) ioremap(phys_iobase, 0);
47044c45120SBjorn Helgaas 	ia64_set_kr(IA64_KR_IO_BASE, __pa(ia64_iobase));
4711da177e4SLinus Torvalds 
4721da177e4SLinus Torvalds 	/* setup legacy IO port space */
4731da177e4SLinus Torvalds 	io_space[0].mmio_base = ia64_iobase;
4741da177e4SLinus Torvalds 	io_space[0].sparse = 1;
4751da177e4SLinus Torvalds 	num_io_spaces = 1;
4761da177e4SLinus Torvalds }
4771da177e4SLinus Torvalds 
4781da177e4SLinus Torvalds /**
4791da177e4SLinus Torvalds  * early_console_setup - setup debugging console
4801da177e4SLinus Torvalds  *
4811da177e4SLinus Torvalds  * Consoles started here require little enough setup that we can start using
4821da177e4SLinus Torvalds  * them very early in the boot process, either right after the machine
4831da177e4SLinus Torvalds  * vector initialization, or even before if the drivers can detect their hw.
4841da177e4SLinus Torvalds  *
4851da177e4SLinus Torvalds  * Returns non-zero if a console couldn't be setup.
4861da177e4SLinus Torvalds  */
4871da177e4SLinus Torvalds static inline int __init
early_console_setup(char * cmdline)4881da177e4SLinus Torvalds early_console_setup (char *cmdline)
4891da177e4SLinus Torvalds {
4901da177e4SLinus Torvalds #ifdef CONFIG_EFI_PCDP
4911da177e4SLinus Torvalds 	if (!efi_setup_pcdp_console(cmdline))
492fc5bad03SChristoph Hellwig 		return 0;
4931da177e4SLinus Torvalds #endif
494fc5bad03SChristoph Hellwig 	return -1;
4951da177e4SLinus Torvalds }
4961da177e4SLinus Torvalds 
497a8384e6cSChristoph Hellwig static void __init
screen_info_setup(void)498a8384e6cSChristoph Hellwig screen_info_setup(void)
499a8384e6cSChristoph Hellwig {
500a8384e6cSChristoph Hellwig 	unsigned int orig_x, orig_y, num_cols, num_rows, font_height;
501a8384e6cSChristoph Hellwig 
502a8384e6cSChristoph Hellwig 	memset(&screen_info, 0, sizeof(screen_info));
503a8384e6cSChristoph Hellwig 
504a8384e6cSChristoph Hellwig 	if (!ia64_boot_param->console_info.num_rows ||
505a8384e6cSChristoph Hellwig 	    !ia64_boot_param->console_info.num_cols) {
506a8384e6cSChristoph Hellwig 		printk(KERN_WARNING "invalid screen-info, guessing 80x25\n");
507a8384e6cSChristoph Hellwig 		orig_x = 0;
508a8384e6cSChristoph Hellwig 		orig_y = 0;
509a8384e6cSChristoph Hellwig 		num_cols = 80;
510a8384e6cSChristoph Hellwig 		num_rows = 25;
511a8384e6cSChristoph Hellwig 		font_height = 16;
512a8384e6cSChristoph Hellwig 	} else {
513a8384e6cSChristoph Hellwig 		orig_x = ia64_boot_param->console_info.orig_x;
514a8384e6cSChristoph Hellwig 		orig_y = ia64_boot_param->console_info.orig_y;
515a8384e6cSChristoph Hellwig 		num_cols = ia64_boot_param->console_info.num_cols;
516a8384e6cSChristoph Hellwig 		num_rows = ia64_boot_param->console_info.num_rows;
517a8384e6cSChristoph Hellwig 		font_height = 400 / num_rows;
518a8384e6cSChristoph Hellwig 	}
519a8384e6cSChristoph Hellwig 
520a8384e6cSChristoph Hellwig 	screen_info.orig_x = orig_x;
521a8384e6cSChristoph Hellwig 	screen_info.orig_y = orig_y;
522a8384e6cSChristoph Hellwig 	screen_info.orig_video_cols  = num_cols;
523a8384e6cSChristoph Hellwig 	screen_info.orig_video_lines = num_rows;
524a8384e6cSChristoph Hellwig 	screen_info.orig_video_points = font_height;
525a8384e6cSChristoph Hellwig 	screen_info.orig_video_mode = 3;	/* XXX fake */
526a8384e6cSChristoph Hellwig 	screen_info.orig_video_isVGA = 1;	/* XXX fake */
527a8384e6cSChristoph Hellwig 	screen_info.orig_video_ega_bx = 3;	/* XXX fake */
528a8384e6cSChristoph Hellwig }
529a8384e6cSChristoph Hellwig 
5301da177e4SLinus Torvalds static inline void
mark_bsp_online(void)5311da177e4SLinus Torvalds mark_bsp_online (void)
5321da177e4SLinus Torvalds {
5331da177e4SLinus Torvalds #ifdef CONFIG_SMP
5341da177e4SLinus Torvalds 	/* If we register an early console, allow CPU 0 to printk */
5357d7f9848SSrivatsa S. Bhat 	set_cpu_online(smp_processor_id(), true);
5361da177e4SLinus Torvalds #endif
5371da177e4SLinus Torvalds }
5381da177e4SLinus Torvalds 
539a5b00bb4SHorms static __initdata int nomca;
setup_nomca(char * s)540a5b00bb4SHorms static __init int setup_nomca(char *s)
541a5b00bb4SHorms {
542a5b00bb4SHorms 	nomca = 1;
543a5b00bb4SHorms 	return 0;
544a5b00bb4SHorms }
545a5b00bb4SHorms early_param("nomca", setup_nomca);
546a5b00bb4SHorms 
5471da177e4SLinus Torvalds void __init
setup_arch(char ** cmdline_p)5481da177e4SLinus Torvalds setup_arch (char **cmdline_p)
5491da177e4SLinus Torvalds {
5501da177e4SLinus Torvalds 	unw_init();
5511da177e4SLinus Torvalds 
5521da177e4SLinus Torvalds 	ia64_patch_vtop((u64) __start___vtop_patchlist, (u64) __end___vtop_patchlist);
5531da177e4SLinus Torvalds 
5541da177e4SLinus Torvalds 	*cmdline_p = __va(ia64_boot_param->command_line);
555216e71f1SWolfram Sang 	strscpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
5561da177e4SLinus Torvalds 
5571da177e4SLinus Torvalds 	efi_init();
5581da177e4SLinus Torvalds 	io_port_init();
5591da177e4SLinus Torvalds 
560df41017eSChristoph Hellwig 	uv_probe_system_type();
561a07ee862SHorms 	parse_early_param();
562a07ee862SHorms 
5631da177e4SLinus Torvalds 	if (early_console_setup(*cmdline_p) == 0)
5641da177e4SLinus Torvalds 		mark_bsp_online();
5651da177e4SLinus Torvalds 
5661da177e4SLinus Torvalds 	/* Initialize the ACPI boot-time table parser */
5671da177e4SLinus Torvalds 	acpi_table_init();
56862ee0540SDoug Chapman 	early_acpi_boot_init();
5691da177e4SLinus Torvalds #ifdef CONFIG_ACPI_NUMA
5701da177e4SLinus Torvalds 	acpi_numa_init();
571312521d0SRobert Richter 	acpi_numa_fixup();
57262ee0540SDoug Chapman #ifdef CONFIG_ACPI_HOTPLUG_CPU
57362ee0540SDoug Chapman 	prefill_possible_map();
57462ee0540SDoug Chapman #endif
575b6dad11dSYury Norov 	per_cpu_scan_finalize((cpumask_empty(&early_cpu_possible_map) ?
5765d2068daSRusty Russell 		32 : cpumask_weight(&early_cpu_possible_map)),
577dd4f0888STony Luck 		additional_cpus > 0 ? additional_cpus : 0);
5782e0f2b16SChristoph Hellwig #endif /* CONFIG_ACPI_NUMA */
5791da177e4SLinus Torvalds 
58012cda817STejun Heo #ifdef CONFIG_SMP
58112cda817STejun Heo 	smp_build_cpu_map();
58212cda817STejun Heo #endif
5831da177e4SLinus Torvalds 	find_memory();
5841da177e4SLinus Torvalds 
5851da177e4SLinus Torvalds 	/* process SAL system table: */
5865828efb9SArd Biesheuvel 	ia64_sal_init(__va(sal_systab_phys));
5871da177e4SLinus Torvalds 
5884dcc29e1STony Luck #ifdef CONFIG_ITANIUM
5894dcc29e1STony Luck 	ia64_patch_rse((u64) __start___rse_patchlist, (u64) __end___rse_patchlist);
5904dcc29e1STony Luck #else
5914dcc29e1STony Luck 	{
592e088a4adSMatthew Wilcox 		unsigned long num_phys_stacked;
5934dcc29e1STony Luck 
5944dcc29e1STony Luck 		if (ia64_pal_rse_info(&num_phys_stacked, 0) == 0 && num_phys_stacked > 96)
5954dcc29e1STony Luck 			ia64_patch_rse((u64) __start___rse_patchlist, (u64) __end___rse_patchlist);
5964dcc29e1STony Luck 	}
5974dcc29e1STony Luck #endif
5984dcc29e1STony Luck 
5991da177e4SLinus Torvalds #ifdef CONFIG_SMP
6001da177e4SLinus Torvalds 	cpu_physical_id(0) = hard_smp_processor_id();
6011da177e4SLinus Torvalds #endif
6021da177e4SLinus Torvalds 
6031da177e4SLinus Torvalds 	cpu_init();	/* initialize the bootstrap CPU */
604dcc17d1bSPeter Keilty 	mmu_context_init();	/* initialize context_id bitmap */
6051da177e4SLinus Torvalds 
6061da177e4SLinus Torvalds #ifdef CONFIG_VT
6071da177e4SLinus Torvalds 	if (!conswitchp) {
6081da177e4SLinus Torvalds # if defined(CONFIG_VGA_CONSOLE)
6091da177e4SLinus Torvalds 		/*
6101da177e4SLinus Torvalds 		 * Non-legacy systems may route legacy VGA MMIO range to system
6111da177e4SLinus Torvalds 		 * memory.  vga_con probes the MMIO hole, so memory looks like
6121da177e4SLinus Torvalds 		 * a VGA device to it.  The EFI memory map can tell us if it's
6131da177e4SLinus Torvalds 		 * memory so we can avoid this problem.
6141da177e4SLinus Torvalds 		 */
6151da177e4SLinus Torvalds 		if (efi_mem_type(0xA0000) != EFI_CONVENTIONAL_MEMORY)
6161da177e4SLinus Torvalds 			conswitchp = &vga_con;
6171da177e4SLinus Torvalds # endif
6181da177e4SLinus Torvalds 	}
6191da177e4SLinus Torvalds #endif
6201da177e4SLinus Torvalds 
6211da177e4SLinus Torvalds 	/* enable IA-64 Machine Check Abort Handling unless disabled */
622a5b00bb4SHorms 	if (!nomca)
6231da177e4SLinus Torvalds 		ia64_mca_init();
6241da177e4SLinus Torvalds 
625fa809d70SChristoph Hellwig 	/*
626fa809d70SChristoph Hellwig 	 * Default to /dev/sda2.  This assumes that the EFI partition
627fa809d70SChristoph Hellwig 	 * is physical disk 1 partition 1 and the Linux root disk is
628fa809d70SChristoph Hellwig 	 * physical disk 1 partition 2.
629fa809d70SChristoph Hellwig 	 */
630fa809d70SChristoph Hellwig 	ROOT_DEV = MKDEV(SCSI_DISK0_MAJOR, 2);
631fa809d70SChristoph Hellwig 
632df41017eSChristoph Hellwig 	if (is_uv_system())
633df41017eSChristoph Hellwig 		uv_setup(cmdline_p);
634df41017eSChristoph Hellwig #ifdef CONFIG_SMP
635df41017eSChristoph Hellwig 	else
636df41017eSChristoph Hellwig 		init_smp_config();
637df41017eSChristoph Hellwig #endif
638df41017eSChristoph Hellwig 
639a8384e6cSChristoph Hellwig 	screen_info_setup();
6401da177e4SLinus Torvalds 	paging_init();
641acb04058SPeter Zijlstra 
642acb04058SPeter Zijlstra 	clear_sched_clock_stable();
6431da177e4SLinus Torvalds }
6441da177e4SLinus Torvalds 
6451da177e4SLinus Torvalds /*
64672fdbdceSSimon Arlott  * Display cpu info for all CPUs.
6471da177e4SLinus Torvalds  */
6481da177e4SLinus Torvalds static int
show_cpuinfo(struct seq_file * m,void * v)6491da177e4SLinus Torvalds show_cpuinfo (struct seq_file *m, void *v)
6501da177e4SLinus Torvalds {
6511da177e4SLinus Torvalds #ifdef CONFIG_SMP
6521da177e4SLinus Torvalds #	define lpj	c->loops_per_jiffy
6531da177e4SLinus Torvalds #	define cpunum	c->cpu
6541da177e4SLinus Torvalds #else
6551da177e4SLinus Torvalds #	define lpj	loops_per_jiffy
6561da177e4SLinus Torvalds #	define cpunum	0
6571da177e4SLinus Torvalds #endif
6581da177e4SLinus Torvalds 	static struct {
6591da177e4SLinus Torvalds 		unsigned long mask;
6601da177e4SLinus Torvalds 		const char *feature_name;
6611da177e4SLinus Torvalds 	} feature_bits[] = {
6621da177e4SLinus Torvalds 		{ 1UL << 0, "branchlong" },
6631da177e4SLinus Torvalds 		{ 1UL << 1, "spontaneous deferral"},
6641da177e4SLinus Torvalds 		{ 1UL << 2, "16-byte atomic ops" }
6651da177e4SLinus Torvalds 	};
666ae0af3e3SAron Griffis 	char features[128], *cp, *sep;
6671da177e4SLinus Torvalds 	struct cpuinfo_ia64 *c = v;
6681da177e4SLinus Torvalds 	unsigned long mask;
66938c0b2c2STony Luck 	unsigned long proc_freq;
670ae0af3e3SAron Griffis 	int i, size;
6711da177e4SLinus Torvalds 
6721da177e4SLinus Torvalds 	mask = c->features;
6731da177e4SLinus Torvalds 
6741da177e4SLinus Torvalds 	/* build the feature string: */
675ae0af3e3SAron Griffis 	memcpy(features, "standard", 9);
6761da177e4SLinus Torvalds 	cp = features;
677ae0af3e3SAron Griffis 	size = sizeof(features);
678ae0af3e3SAron Griffis 	sep = "";
679ae0af3e3SAron Griffis 	for (i = 0; i < ARRAY_SIZE(feature_bits) && size > 1; ++i) {
6801da177e4SLinus Torvalds 		if (mask & feature_bits[i].mask) {
681ae0af3e3SAron Griffis 			cp += snprintf(cp, size, "%s%s", sep,
682ae0af3e3SAron Griffis 				       feature_bits[i].feature_name),
683ae0af3e3SAron Griffis 			sep = ", ";
6841da177e4SLinus Torvalds 			mask &= ~feature_bits[i].mask;
685ae0af3e3SAron Griffis 			size = sizeof(features) - (cp - features);
6861da177e4SLinus Torvalds 		}
6871da177e4SLinus Torvalds 	}
688ae0af3e3SAron Griffis 	if (mask && size > 1) {
689ae0af3e3SAron Griffis 		/* print unknown features as a hex value */
690ae0af3e3SAron Griffis 		snprintf(cp, size, "%s0x%lx", sep, mask);
6911da177e4SLinus Torvalds 	}
6921da177e4SLinus Torvalds 
69395235ca2SVenkatesh Pallipadi 	proc_freq = cpufreq_quick_get(cpunum);
69495235ca2SVenkatesh Pallipadi 	if (!proc_freq)
69595235ca2SVenkatesh Pallipadi 		proc_freq = c->proc_freq / 1000;
69695235ca2SVenkatesh Pallipadi 
6971da177e4SLinus Torvalds 	seq_printf(m,
6981da177e4SLinus Torvalds 		   "processor  : %d\n"
6991da177e4SLinus Torvalds 		   "vendor     : %s\n"
7001da177e4SLinus Torvalds 		   "arch       : IA-64\n"
70176d08bb3STony Luck 		   "family     : %u\n"
7021da177e4SLinus Torvalds 		   "model      : %u\n"
70376d08bb3STony Luck 		   "model name : %s\n"
7041da177e4SLinus Torvalds 		   "revision   : %u\n"
7051da177e4SLinus Torvalds 		   "archrev    : %u\n"
706ae0af3e3SAron Griffis 		   "features   : %s\n"
7071da177e4SLinus Torvalds 		   "cpu number : %lu\n"
7081da177e4SLinus Torvalds 		   "cpu regs   : %u\n"
7098a3a78d1SVenki Pallipadi 		   "cpu MHz    : %lu.%03lu\n"
7101da177e4SLinus Torvalds 		   "itc MHz    : %lu.%06lu\n"
711e927ecb0SSuresh Siddha 		   "BogoMIPS   : %lu.%02lu\n",
71276d08bb3STony Luck 		   cpunum, c->vendor, c->family, c->model,
71376d08bb3STony Luck 		   c->model_name, c->revision, c->archrev,
7141da177e4SLinus Torvalds 		   features, c->ppn, c->number,
71595235ca2SVenkatesh Pallipadi 		   proc_freq / 1000, proc_freq % 1000,
7161da177e4SLinus Torvalds 		   c->itc_freq / 1000000, c->itc_freq % 1000000,
7171da177e4SLinus Torvalds 		   lpj*HZ/500000, (lpj*HZ/5000) % 100);
718e927ecb0SSuresh Siddha #ifdef CONFIG_SMP
7195d2068daSRusty Russell 	seq_printf(m, "siblings   : %u\n",
7205d2068daSRusty Russell 		   cpumask_weight(&cpu_core_map[cpunum]));
721113134fcSAlex Chiang 	if (c->socket_id != -1)
722113134fcSAlex Chiang 		seq_printf(m, "physical id: %u\n", c->socket_id);
723e927ecb0SSuresh Siddha 	if (c->threads_per_core > 1 || c->cores_per_socket > 1)
724e927ecb0SSuresh Siddha 		seq_printf(m,
725e927ecb0SSuresh Siddha 			   "core id    : %u\n"
726e927ecb0SSuresh Siddha 			   "thread id  : %u\n",
727113134fcSAlex Chiang 			   c->core_id, c->thread_id);
728e927ecb0SSuresh Siddha #endif
729e927ecb0SSuresh Siddha 	seq_printf(m,"\n");
730e927ecb0SSuresh Siddha 
7311da177e4SLinus Torvalds 	return 0;
7321da177e4SLinus Torvalds }
7331da177e4SLinus Torvalds 
7341da177e4SLinus Torvalds static void *
c_start(struct seq_file * m,loff_t * pos)7351da177e4SLinus Torvalds c_start (struct seq_file *m, loff_t *pos)
7361da177e4SLinus Torvalds {
7371da177e4SLinus Torvalds #ifdef CONFIG_SMP
7385dd3c994SRusty Russell 	while (*pos < nr_cpu_ids && !cpu_online(*pos))
7391da177e4SLinus Torvalds 		++*pos;
7401da177e4SLinus Torvalds #endif
7415dd3c994SRusty Russell 	return *pos < nr_cpu_ids ? cpu_data(*pos) : NULL;
7421da177e4SLinus Torvalds }
7431da177e4SLinus Torvalds 
7441da177e4SLinus Torvalds static void *
c_next(struct seq_file * m,void * v,loff_t * pos)7451da177e4SLinus Torvalds c_next (struct seq_file *m, void *v, loff_t *pos)
7461da177e4SLinus Torvalds {
7471da177e4SLinus Torvalds 	++*pos;
7481da177e4SLinus Torvalds 	return c_start(m, pos);
7491da177e4SLinus Torvalds }
7501da177e4SLinus Torvalds 
7511da177e4SLinus Torvalds static void
c_stop(struct seq_file * m,void * v)7521da177e4SLinus Torvalds c_stop (struct seq_file *m, void *v)
7531da177e4SLinus Torvalds {
7541da177e4SLinus Torvalds }
7551da177e4SLinus Torvalds 
756a23fe55eSJan Engelhardt const struct seq_operations cpuinfo_op = {
7571da177e4SLinus Torvalds 	.start =	c_start,
7581da177e4SLinus Torvalds 	.next =		c_next,
7591da177e4SLinus Torvalds 	.stop =		c_stop,
7601da177e4SLinus Torvalds 	.show =		show_cpuinfo
7611da177e4SLinus Torvalds };
7621da177e4SLinus Torvalds 
763c5e83e3fSJack Steiner #define MAX_BRANDS	8
764c5e83e3fSJack Steiner static char brandname[MAX_BRANDS][128];
76576d08bb3STony Luck 
766ccce9bb8SPaul Gortmaker static char *
get_model_name(__u8 family,__u8 model)76776d08bb3STony Luck get_model_name(__u8 family, __u8 model)
76876d08bb3STony Luck {
769c5e83e3fSJack Steiner 	static int overflow;
77076d08bb3STony Luck 	char brand[128];
771c5e83e3fSJack Steiner 	int i;
77276d08bb3STony Luck 
77375f6a1deSTony Luck 	memcpy(brand, "Unknown", 8);
77476d08bb3STony Luck 	if (ia64_pal_get_brand_info(brand)) {
77576d08bb3STony Luck 		if (family == 0x7)
77676d08bb3STony Luck 			memcpy(brand, "Merced", 7);
77776d08bb3STony Luck 		else if (family == 0x1f) switch (model) {
77876d08bb3STony Luck 			case 0: memcpy(brand, "McKinley", 9); break;
77976d08bb3STony Luck 			case 1: memcpy(brand, "Madison", 8); break;
78076d08bb3STony Luck 			case 2: memcpy(brand, "Madison up to 9M cache", 23); break;
78175f6a1deSTony Luck 		}
78276d08bb3STony Luck 	}
783c5e83e3fSJack Steiner 	for (i = 0; i < MAX_BRANDS; i++)
784c5e83e3fSJack Steiner 		if (strcmp(brandname[i], brand) == 0)
785c5e83e3fSJack Steiner 			return brandname[i];
786c5e83e3fSJack Steiner 	for (i = 0; i < MAX_BRANDS; i++)
787c5e83e3fSJack Steiner 		if (brandname[i][0] == '\0')
788c5e83e3fSJack Steiner 			return strcpy(brandname[i], brand);
789c5e83e3fSJack Steiner 	if (overflow++ == 0)
790c5e83e3fSJack Steiner 		printk(KERN_ERR
791c5e83e3fSJack Steiner 		       "%s: Table overflow. Some processor model information will be missing\n",
792d4ed8084SHarvey Harrison 		       __func__);
793c5e83e3fSJack Steiner 	return "Unknown";
79476d08bb3STony Luck }
79576d08bb3STony Luck 
796ccce9bb8SPaul Gortmaker static void
identify_cpu(struct cpuinfo_ia64 * c)7971da177e4SLinus Torvalds identify_cpu (struct cpuinfo_ia64 *c)
7981da177e4SLinus Torvalds {
7991da177e4SLinus Torvalds 	union {
8001da177e4SLinus Torvalds 		unsigned long bits[5];
8011da177e4SLinus Torvalds 		struct {
8021da177e4SLinus Torvalds 			/* id 0 & 1: */
8031da177e4SLinus Torvalds 			char vendor[16];
8041da177e4SLinus Torvalds 
8051da177e4SLinus Torvalds 			/* id 2 */
8061da177e4SLinus Torvalds 			u64 ppn;		/* processor serial number */
8071da177e4SLinus Torvalds 
8081da177e4SLinus Torvalds 			/* id 3: */
8091da177e4SLinus Torvalds 			unsigned number		:  8;
8101da177e4SLinus Torvalds 			unsigned revision	:  8;
8111da177e4SLinus Torvalds 			unsigned model		:  8;
8121da177e4SLinus Torvalds 			unsigned family		:  8;
8131da177e4SLinus Torvalds 			unsigned archrev	:  8;
8141da177e4SLinus Torvalds 			unsigned reserved	: 24;
8151da177e4SLinus Torvalds 
8161da177e4SLinus Torvalds 			/* id 4: */
8171da177e4SLinus Torvalds 			u64 features;
8181da177e4SLinus Torvalds 		} field;
8191da177e4SLinus Torvalds 	} cpuid;
8201da177e4SLinus Torvalds 	pal_vm_info_1_u_t vm1;
8211da177e4SLinus Torvalds 	pal_vm_info_2_u_t vm2;
8221da177e4SLinus Torvalds 	pal_status_t status;
8231da177e4SLinus Torvalds 	unsigned long impl_va_msb = 50, phys_addr_size = 44;	/* Itanium defaults */
8241da177e4SLinus Torvalds 	int i;
8251da177e4SLinus Torvalds 	for (i = 0; i < 5; ++i)
8261da177e4SLinus Torvalds 		cpuid.bits[i] = ia64_get_cpuid(i);
8271da177e4SLinus Torvalds 
8281da177e4SLinus Torvalds 	memcpy(c->vendor, cpuid.field.vendor, 16);
8291da177e4SLinus Torvalds #ifdef CONFIG_SMP
8301da177e4SLinus Torvalds 	c->cpu = smp_processor_id();
831e927ecb0SSuresh Siddha 
832e927ecb0SSuresh Siddha 	/* below default values will be overwritten  by identify_siblings()
83372fdbdceSSimon Arlott 	 * for Multi-Threading/Multi-Core capable CPUs
834e927ecb0SSuresh Siddha 	 */
835e927ecb0SSuresh Siddha 	c->threads_per_core = c->cores_per_socket = c->num_log = 1;
836e927ecb0SSuresh Siddha 	c->socket_id = -1;
837e927ecb0SSuresh Siddha 
838e927ecb0SSuresh Siddha 	identify_siblings(c);
839113134fcSAlex Chiang 
840113134fcSAlex Chiang 	if (c->threads_per_core > smp_num_siblings)
841113134fcSAlex Chiang 		smp_num_siblings = c->threads_per_core;
8421da177e4SLinus Torvalds #endif
8431da177e4SLinus Torvalds 	c->ppn = cpuid.field.ppn;
8441da177e4SLinus Torvalds 	c->number = cpuid.field.number;
8451da177e4SLinus Torvalds 	c->revision = cpuid.field.revision;
8461da177e4SLinus Torvalds 	c->model = cpuid.field.model;
8471da177e4SLinus Torvalds 	c->family = cpuid.field.family;
8481da177e4SLinus Torvalds 	c->archrev = cpuid.field.archrev;
8491da177e4SLinus Torvalds 	c->features = cpuid.field.features;
85076d08bb3STony Luck 	c->model_name = get_model_name(c->family, c->model);
8511da177e4SLinus Torvalds 
8521da177e4SLinus Torvalds 	status = ia64_pal_vm_summary(&vm1, &vm2);
8531da177e4SLinus Torvalds 	if (status == PAL_STATUS_SUCCESS) {
8541da177e4SLinus Torvalds 		impl_va_msb = vm2.pal_vm_info_2_s.impl_va_msb;
8551da177e4SLinus Torvalds 		phys_addr_size = vm1.pal_vm_info_1_s.phys_add_size;
8561da177e4SLinus Torvalds 	}
8571da177e4SLinus Torvalds 	c->unimpl_va_mask = ~((7L<<61) | ((1L << (impl_va_msb + 1)) - 1));
8581da177e4SLinus Torvalds 	c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1));
8591da177e4SLinus Torvalds }
8601da177e4SLinus Torvalds 
861872fb6ddSFenghua Yu /*
86262fdd767SFenghua Yu  * Do the following calculations:
86308357f82SZoltan Menyhart  *
86462fdd767SFenghua Yu  * 1. the max. cache line size.
86562fdd767SFenghua Yu  * 2. the minimum of the i-cache stride sizes for "flush_icache_range()".
86662fdd767SFenghua Yu  * 3. the minimum of the cache stride sizes for "clflush_cache_range()".
86708357f82SZoltan Menyhart  */
868ccce9bb8SPaul Gortmaker static void
get_cache_info(void)86962fdd767SFenghua Yu get_cache_info(void)
8701da177e4SLinus Torvalds {
8711da177e4SLinus Torvalds 	unsigned long line_size, max = 1;
872e088a4adSMatthew Wilcox 	unsigned long l, levels, unique_caches;
8731da177e4SLinus Torvalds 	pal_cache_config_info_t cci;
874e088a4adSMatthew Wilcox 	long status;
8751da177e4SLinus Torvalds 
8761da177e4SLinus Torvalds         status = ia64_pal_cache_summary(&levels, &unique_caches);
8771da177e4SLinus Torvalds         if (status != 0) {
8781da177e4SLinus Torvalds                 printk(KERN_ERR "%s: ia64_pal_cache_summary() failed (status=%ld)\n",
879d4ed8084SHarvey Harrison                        __func__, status);
8801da177e4SLinus Torvalds                 max = SMP_CACHE_BYTES;
88108357f82SZoltan Menyhart 		/* Safest setup for "flush_icache_range()" */
88208357f82SZoltan Menyhart 		ia64_i_cache_stride_shift = I_CACHE_STRIDE_SHIFT;
88362fdd767SFenghua Yu 		/* Safest setup for "clflush_cache_range()" */
88462fdd767SFenghua Yu 		ia64_cache_stride_shift = CACHE_STRIDE_SHIFT;
8851da177e4SLinus Torvalds 		goto out;
8861da177e4SLinus Torvalds         }
8871da177e4SLinus Torvalds 
8881da177e4SLinus Torvalds 	for (l = 0; l < levels; ++l) {
88962fdd767SFenghua Yu 		/* cache_type (data_or_unified)=2 */
89062fdd767SFenghua Yu 		status = ia64_pal_cache_config_info(l, 2, &cci);
8911da177e4SLinus Torvalds 		if (status != 0) {
892e088a4adSMatthew Wilcox 			printk(KERN_ERR "%s: ia64_pal_cache_config_info"
893e088a4adSMatthew Wilcox 				"(l=%lu, 2) failed (status=%ld)\n",
894d4ed8084SHarvey Harrison 				__func__, l, status);
8951da177e4SLinus Torvalds 			max = SMP_CACHE_BYTES;
89608357f82SZoltan Menyhart 			/* The safest setup for "flush_icache_range()" */
89708357f82SZoltan Menyhart 			cci.pcci_stride = I_CACHE_STRIDE_SHIFT;
89862fdd767SFenghua Yu 			/* The safest setup for "clflush_cache_range()" */
89962fdd767SFenghua Yu 			ia64_cache_stride_shift = CACHE_STRIDE_SHIFT;
90008357f82SZoltan Menyhart 			cci.pcci_unified = 1;
90162fdd767SFenghua Yu 		} else {
90262fdd767SFenghua Yu 			if (cci.pcci_stride < ia64_cache_stride_shift)
90362fdd767SFenghua Yu 				ia64_cache_stride_shift = cci.pcci_stride;
90462fdd767SFenghua Yu 
9051da177e4SLinus Torvalds 			line_size = 1 << cci.pcci_line_size;
9061da177e4SLinus Torvalds 			if (line_size > max)
9071da177e4SLinus Torvalds 				max = line_size;
90862fdd767SFenghua Yu 		}
90962fdd767SFenghua Yu 
91008357f82SZoltan Menyhart 		if (!cci.pcci_unified) {
91162fdd767SFenghua Yu 			/* cache_type (instruction)=1*/
91262fdd767SFenghua Yu 			status = ia64_pal_cache_config_info(l, 1, &cci);
91308357f82SZoltan Menyhart 			if (status != 0) {
914e088a4adSMatthew Wilcox 				printk(KERN_ERR "%s: ia64_pal_cache_config_info"
915e088a4adSMatthew Wilcox 					"(l=%lu, 1) failed (status=%ld)\n",
916d4ed8084SHarvey Harrison 					__func__, l, status);
917e088a4adSMatthew Wilcox 				/* The safest setup for flush_icache_range() */
91808357f82SZoltan Menyhart 				cci.pcci_stride = I_CACHE_STRIDE_SHIFT;
91908357f82SZoltan Menyhart 			}
92008357f82SZoltan Menyhart 		}
92108357f82SZoltan Menyhart 		if (cci.pcci_stride < ia64_i_cache_stride_shift)
92208357f82SZoltan Menyhart 			ia64_i_cache_stride_shift = cci.pcci_stride;
9231da177e4SLinus Torvalds 	}
9241da177e4SLinus Torvalds   out:
9251da177e4SLinus Torvalds 	if (max > ia64_max_cacheline_size)
9261da177e4SLinus Torvalds 		ia64_max_cacheline_size = max;
9271da177e4SLinus Torvalds }
9281da177e4SLinus Torvalds 
9291da177e4SLinus Torvalds /*
9301da177e4SLinus Torvalds  * cpu_init() initializes state that is per-CPU.  This function acts
9311da177e4SLinus Torvalds  * as a 'CPU state barrier', nothing should get across.
9321da177e4SLinus Torvalds  */
933ccce9bb8SPaul Gortmaker void
cpu_init(void)9341da177e4SLinus Torvalds cpu_init (void)
9351da177e4SLinus Torvalds {
936ccce9bb8SPaul Gortmaker 	extern void ia64_mmu_init(void *);
937a0776ec8SChen, Kenneth W 	static unsigned long max_num_phys_stacked = IA64_NUM_PHYS_STACK_REG;
9381da177e4SLinus Torvalds 	unsigned long num_phys_stacked;
9391da177e4SLinus Torvalds 	pal_vm_info_2_u_t vmi;
9401da177e4SLinus Torvalds 	unsigned int max_ctx;
9411da177e4SLinus Torvalds 	struct cpuinfo_ia64 *cpu_info;
9421da177e4SLinus Torvalds 	void *cpu_data;
9431da177e4SLinus Torvalds 
9441da177e4SLinus Torvalds 	cpu_data = per_cpu_init();
9454d1efed5STony Luck #ifdef CONFIG_SMP
946d5a7430dSMike Travis 	/*
947d5a7430dSMike Travis 	 * insert boot cpu into sibling and core mapes
948d5a7430dSMike Travis 	 * (must be done after per_cpu area is setup)
949d5a7430dSMike Travis 	 */
950d5a7430dSMike Travis 	if (smp_processor_id() == 0) {
9515d2068daSRusty Russell 		cpumask_set_cpu(0, &per_cpu(cpu_sibling_map, 0));
9525d2068daSRusty Russell 		cpumask_set_cpu(0, &cpu_core_map[0]);
95310617bbeSTony Luck 	} else {
9541da177e4SLinus Torvalds 		/*
95510617bbeSTony Luck 		 * Set ar.k3 so that assembly code in MCA handler can compute
9561da177e4SLinus Torvalds 		 * physical addresses of per cpu variables with a simple:
9571da177e4SLinus Torvalds 		 *   phys = ar.k3 + &per_cpu_var
95810617bbeSTony Luck 		 * and the alt-dtlb-miss handler can set per-cpu mapping into
95910617bbeSTony Luck 		 * the TLB when needed. head.S already did this for cpu0.
9601da177e4SLinus Torvalds 		 */
9611da177e4SLinus Torvalds 		ia64_set_kr(IA64_KR_PER_CPU_DATA,
9621da177e4SLinus Torvalds 			    ia64_tpa(cpu_data) - (long) __per_cpu_start);
96310617bbeSTony Luck 	}
96410617bbeSTony Luck #endif
9651da177e4SLinus Torvalds 
96662fdd767SFenghua Yu 	get_cache_info();
9671da177e4SLinus Torvalds 
9681da177e4SLinus Torvalds 	/*
9691da177e4SLinus Torvalds 	 * We can't pass "local_cpu_data" to identify_cpu() because we haven't called
9701da177e4SLinus Torvalds 	 * ia64_mmu_init() yet.  And we can't call ia64_mmu_init() first because it
9711da177e4SLinus Torvalds 	 * depends on the data returned by identify_cpu().  We break the dependency by
9721da177e4SLinus Torvalds 	 * accessing cpu_data() through the canonical per-CPU address.
9731da177e4SLinus Torvalds 	 */
974877105ccSTejun Heo 	cpu_info = cpu_data + ((char *) &__ia64_per_cpu_var(ia64_cpu_info) - __per_cpu_start);
9751da177e4SLinus Torvalds 	identify_cpu(cpu_info);
9761da177e4SLinus Torvalds 
9771da177e4SLinus Torvalds #ifdef CONFIG_MCKINLEY
9781da177e4SLinus Torvalds 	{
9791da177e4SLinus Torvalds #		define FEATURE_SET 16
9801da177e4SLinus Torvalds 		struct ia64_pal_retval iprv;
9811da177e4SLinus Torvalds 
9821da177e4SLinus Torvalds 		if (cpu_info->family == 0x1f) {
9831da177e4SLinus Torvalds 			PAL_CALL_PHYS(iprv, PAL_PROC_GET_FEATURES, 0, FEATURE_SET, 0);
9841da177e4SLinus Torvalds 			if ((iprv.status == 0) && (iprv.v0 & 0x80) && (iprv.v2 & 0x80))
9851da177e4SLinus Torvalds 				PAL_CALL_PHYS(iprv, PAL_PROC_SET_FEATURES,
9861da177e4SLinus Torvalds 				              (iprv.v1 | 0x80), FEATURE_SET, 0);
9871da177e4SLinus Torvalds 		}
9881da177e4SLinus Torvalds 	}
9891da177e4SLinus Torvalds #endif
9901da177e4SLinus Torvalds 
9911da177e4SLinus Torvalds 	/* Clear the stack memory reserved for pt_regs: */
9926450578fSAl Viro 	memset(task_pt_regs(current), 0, sizeof(struct pt_regs));
9931da177e4SLinus Torvalds 
9941da177e4SLinus Torvalds 	ia64_set_kr(IA64_KR_FPU_OWNER, 0);
9951da177e4SLinus Torvalds 
9961da177e4SLinus Torvalds 	/*
9971da177e4SLinus Torvalds 	 * Initialize the page-table base register to a global
9981da177e4SLinus Torvalds 	 * directory with all zeroes.  This ensure that we can handle
9991da177e4SLinus Torvalds 	 * TLB-misses to user address-space even before we created the
10001da177e4SLinus Torvalds 	 * first user address-space.  This may happen, e.g., due to
10011da177e4SLinus Torvalds 	 * aggressive use of lfetch.fault.
10021da177e4SLinus Torvalds 	 */
10031da177e4SLinus Torvalds 	ia64_set_kr(IA64_KR_PT_BASE, __pa(ia64_imva(empty_zero_page)));
10041da177e4SLinus Torvalds 
10051da177e4SLinus Torvalds 	/*
100686ebacd3STony Luck 	 * Initialize default control register to defer speculative faults except
100786ebacd3STony Luck 	 * for those arising from TLB misses, which are not deferred.  The
10081da177e4SLinus Torvalds 	 * kernel MUST NOT depend on a particular setting of these bits (in other words,
10091da177e4SLinus Torvalds 	 * the kernel must have recovery code for all speculative accesses).  Turn on
10101da177e4SLinus Torvalds 	 * dcr.lc as per recommendation by the architecture team.  Most IA-32 apps
10111da177e4SLinus Torvalds 	 * shouldn't be affected by this (moral: keep your ia32 locks aligned and you'll
10121da177e4SLinus Torvalds 	 * be fine).
10131da177e4SLinus Torvalds 	 */
10141da177e4SLinus Torvalds 	ia64_setreg(_IA64_REG_CR_DCR,  (  IA64_DCR_DP | IA64_DCR_DK | IA64_DCR_DX | IA64_DCR_DR
10151da177e4SLinus Torvalds 					| IA64_DCR_DA | IA64_DCR_DD | IA64_DCR_LC));
1016f1f10076SVegard Nossum 	mmgrab(&init_mm);
10171da177e4SLinus Torvalds 	current->active_mm = &init_mm;
101880a03e29SStoyan Gaydarov 	BUG_ON(current->mm);
10191da177e4SLinus Torvalds 
10201da177e4SLinus Torvalds 	ia64_mmu_init(ia64_imva(cpu_data));
10211da177e4SLinus Torvalds 	ia64_mca_cpu_init(ia64_imva(cpu_data));
10221da177e4SLinus Torvalds 
102372fdbdceSSimon Arlott 	/* Clear ITC to eliminate sched_clock() overflows in human time.  */
10241da177e4SLinus Torvalds 	ia64_set_itc(0);
10251da177e4SLinus Torvalds 
10261da177e4SLinus Torvalds 	/* disable all local interrupt sources: */
10271da177e4SLinus Torvalds 	ia64_set_itv(1 << 16);
10281da177e4SLinus Torvalds 	ia64_set_lrr0(1 << 16);
10291da177e4SLinus Torvalds 	ia64_set_lrr1(1 << 16);
10301da177e4SLinus Torvalds 	ia64_setreg(_IA64_REG_CR_PMV, 1 << 16);
10311da177e4SLinus Torvalds 	ia64_setreg(_IA64_REG_CR_CMCV, 1 << 16);
10321da177e4SLinus Torvalds 
10331da177e4SLinus Torvalds 	/* clear TPR & XTP to enable all interrupt classes: */
10341da177e4SLinus Torvalds 	ia64_setreg(_IA64_REG_CR_TPR, 0);
1035f740e6c9SKenji Kaneshige 
1036f740e6c9SKenji Kaneshige 	/* Clear any pending interrupts left by SAL/EFI */
1037f740e6c9SKenji Kaneshige 	while (ia64_get_ivr() != IA64_SPURIOUS_INT_VECTOR)
1038f740e6c9SKenji Kaneshige 		ia64_eoi();
1039f740e6c9SKenji Kaneshige 
10401da177e4SLinus Torvalds #ifdef CONFIG_SMP
10411da177e4SLinus Torvalds 	normal_xtp();
10421da177e4SLinus Torvalds #endif
10431da177e4SLinus Torvalds 
10441da177e4SLinus Torvalds 	/* set ia64_ctx.max_rid to the maximum RID that is supported by all CPUs: */
10452046b94eSFenghua Yu 	if (ia64_pal_vm_summary(NULL, &vmi) == 0) {
10461da177e4SLinus Torvalds 		max_ctx = (1U << (vmi.pal_vm_info_2_s.rid_size - 3)) - 1;
1047a6c75b86SFenghua Yu 		setup_ptcg_sem(vmi.pal_vm_info_2_s.max_purges, NPTCG_FROM_PAL);
10482046b94eSFenghua Yu 	} else {
10491da177e4SLinus Torvalds 		printk(KERN_WARNING "cpu_init: PAL VM summary failed, assuming 18 RID bits\n");
10501da177e4SLinus Torvalds 		max_ctx = (1U << 15) - 1;	/* use architected minimum */
10511da177e4SLinus Torvalds 	}
10521da177e4SLinus Torvalds 	while (max_ctx < ia64_ctx.max_ctx) {
10531da177e4SLinus Torvalds 		unsigned int old = ia64_ctx.max_ctx;
10541da177e4SLinus Torvalds 		if (cmpxchg(&ia64_ctx.max_ctx, old, max_ctx) == old)
10551da177e4SLinus Torvalds 			break;
10561da177e4SLinus Torvalds 	}
10571da177e4SLinus Torvalds 
10581da177e4SLinus Torvalds 	if (ia64_pal_rse_info(&num_phys_stacked, NULL) != 0) {
10591da177e4SLinus Torvalds 		printk(KERN_WARNING "cpu_init: PAL RSE info failed; assuming 96 physical "
10601da177e4SLinus Torvalds 		       "stacked regs\n");
10611da177e4SLinus Torvalds 		num_phys_stacked = 96;
10621da177e4SLinus Torvalds 	}
10631da177e4SLinus Torvalds 	/* size of physical stacked register partition plus 8 bytes: */
1064a0776ec8SChen, Kenneth W 	if (num_phys_stacked > max_num_phys_stacked) {
1065a0776ec8SChen, Kenneth W 		ia64_patch_phys_stack_reg(num_phys_stacked*8 + 8);
1066a0776ec8SChen, Kenneth W 		max_num_phys_stacked = num_phys_stacked;
1067a0776ec8SChen, Kenneth W 	}
10681da177e4SLinus Torvalds }
10691da177e4SLinus Torvalds 
arch_cpu_finalize_init(void)1070*6c38e300SThomas Gleixner void __init arch_cpu_finalize_init(void)
10711da177e4SLinus Torvalds {
10721da177e4SLinus Torvalds 	ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
10731da177e4SLinus Torvalds 			       (unsigned long) __end___mckinley_e9_bundles);
10741da177e4SLinus Torvalds }
10753ed3bce8SMatt Domsch 
run_dmi_scan(void)10763ed3bce8SMatt Domsch static int __init run_dmi_scan(void)
10773ed3bce8SMatt Domsch {
10780fca0812SRobert Richter 	dmi_setup();
10793ed3bce8SMatt Domsch 	return 0;
10803ed3bce8SMatt Domsch }
10813ed3bce8SMatt Domsch core_initcall(run_dmi_scan);
1082