2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 1995 Linus Torvalds
|
|
|
|
|
*
|
|
|
|
|
* Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
|
|
|
|
|
*
|
|
|
|
|
* Memory region support
|
|
|
|
|
* David Parsons <orc@pell.chi.il.us>, July-August 1999
|
|
|
|
|
*
|
|
|
|
|
* Added E820 sanitization routine (removes overlapping memory regions);
|
|
|
|
|
* Brian Moyle <bmoyle@mvista.com>, February 2001
|
|
|
|
|
*
|
|
|
|
|
* Moved CPU detection code to cpu/${cpu}.c
|
|
|
|
|
* Patrick Mochel <mochel@osdl.org>, March 2002
|
|
|
|
|
*
|
|
|
|
|
* Provisions for empty E820 memory regions (reported by certain BIOSes).
|
|
|
|
|
* Alex Achenbach <xela@slit.de>, December 2002.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This file handles the architecture-dependent parts of initialization
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <linux/sched.h>
|
|
|
|
|
#include <linux/mm.h>
|
2005-06-23 00:07:57 -07:00
|
|
|
#include <linux/mmzone.h>
|
2006-07-10 04:44:13 -07:00
|
|
|
#include <linux/screen_info.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/ioport.h>
|
|
|
|
|
#include <linux/acpi.h>
|
2009-08-14 15:23:29 -04:00
|
|
|
#include <linux/sfi.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/apm_bios.h>
|
|
|
|
|
#include <linux/initrd.h>
|
|
|
|
|
#include <linux/bootmem.h>
|
2010-08-25 13:39:17 -07:00
|
|
|
#include <linux/memblock.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/seq_file.h>
|
|
|
|
|
#include <linux/console.h>
|
|
|
|
|
#include <linux/root_dev.h>
|
|
|
|
|
#include <linux/highmem.h>
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
#include <linux/efi.h>
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
#include <linux/edd.h>
|
2008-04-09 19:50:41 -07:00
|
|
|
#include <linux/iscsi_ibft.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/nodemask.h>
|
2005-06-25 14:58:01 -07:00
|
|
|
#include <linux/kexec.h>
|
2006-01-11 22:43:33 +01:00
|
|
|
#include <linux/dmi.h>
|
2006-03-27 01:16:04 -08:00
|
|
|
#include <linux/pfn.h>
|
2008-01-30 13:30:16 +01:00
|
|
|
#include <linux/pci.h>
|
2008-06-25 17:51:29 -07:00
|
|
|
#include <asm/pci-direct.h>
|
2008-01-30 13:34:11 +01:00
|
|
|
#include <linux/init_ohci1394_dma.h>
|
2008-02-15 17:52:48 -02:00
|
|
|
#include <linux/kvm_para.h>
|
2011-12-29 13:09:51 +01:00
|
|
|
#include <linux/dma-contiguous.h>
|
2005-06-25 14:58:01 -07:00
|
|
|
|
2008-06-25 17:51:29 -07:00
|
|
|
#include <linux/errno.h>
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
|
#include <linux/user.h>
|
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
|
#include <linux/cpufreq.h>
|
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
|
|
|
|
|
|
#include <linux/percpu.h>
|
|
|
|
|
#include <linux/crash_dump.h>
|
2009-09-01 18:25:07 -07:00
|
|
|
#include <linux/tboot.h>
|
2012-09-04 12:42:27 -04:00
|
|
|
#include <linux/jiffies.h>
|
2008-06-25 17:51:29 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <video/edid.h>
|
2005-06-25 14:58:01 -07:00
|
|
|
|
2008-01-30 13:33:32 +01:00
|
|
|
#include <asm/mtrr.h>
|
2005-06-25 14:57:41 -07:00
|
|
|
#include <asm/apic.h>
|
2012-05-08 21:22:26 +03:00
|
|
|
#include <asm/realmode.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/e820.h>
|
|
|
|
|
#include <asm/mpspec.h>
|
|
|
|
|
#include <asm/setup.h>
|
2008-06-25 17:54:23 -07:00
|
|
|
#include <asm/efi.h>
|
2009-02-23 00:34:39 +01:00
|
|
|
#include <asm/timer.h>
|
|
|
|
|
#include <asm/i8259.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/sections.h>
|
|
|
|
|
#include <asm/io_apic.h>
|
|
|
|
|
#include <asm/ist.h>
|
2009-01-28 19:34:09 +01:00
|
|
|
#include <asm/setup_arch.h>
|
2008-03-17 22:08:17 +03:00
|
|
|
#include <asm/bios_ebda.h>
|
2007-10-21 16:42:01 -07:00
|
|
|
#include <asm/cacheflush.h>
|
2008-03-04 19:57:42 +01:00
|
|
|
#include <asm/processor.h>
|
2008-06-16 16:11:08 -07:00
|
|
|
#include <asm/bugs.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-06-25 17:51:29 -07:00
|
|
|
#include <asm/vsyscall.h>
|
2009-01-07 18:11:35 +05:30
|
|
|
#include <asm/cpu.h>
|
2008-06-25 17:51:29 -07:00
|
|
|
#include <asm/desc.h>
|
|
|
|
|
#include <asm/dma.h>
|
2008-07-11 10:23:42 +09:00
|
|
|
#include <asm/iommu.h>
|
2008-11-27 18:39:15 +01:00
|
|
|
#include <asm/gart.h>
|
2008-06-25 17:51:29 -07:00
|
|
|
#include <asm/mmu_context.h>
|
|
|
|
|
#include <asm/proto.h>
|
|
|
|
|
|
|
|
|
|
#include <asm/paravirt.h>
|
2008-10-27 10:41:46 -07:00
|
|
|
#include <asm/hypervisor.h>
|
2010-06-18 17:46:53 -04:00
|
|
|
#include <asm/olpc_ofw.h>
|
2008-06-25 17:51:29 -07:00
|
|
|
|
|
|
|
|
#include <asm/percpu.h>
|
|
|
|
|
#include <asm/topology.h>
|
|
|
|
|
#include <asm/apicdef.h>
|
2010-09-17 18:03:43 +02:00
|
|
|
#include <asm/amd_nb.h>
|
2009-11-10 09:38:24 +08:00
|
|
|
#include <asm/mce.h>
|
2010-09-17 11:08:51 -04:00
|
|
|
#include <asm/alternative.h>
|
2011-02-22 21:07:37 +01:00
|
|
|
#include <asm/prom.h>
|
2008-06-25 17:51:29 -07:00
|
|
|
|
2009-04-28 16:00:49 +03:00
|
|
|
/*
|
2012-11-16 19:38:52 -08:00
|
|
|
* max_low_pfn_mapped: highest direct mapped pfn under 4GB
|
|
|
|
|
* max_pfn_mapped: highest direct mapped pfn over 4GB
|
|
|
|
|
*
|
|
|
|
|
* The direct mapping only covers E820_RAM regions, so the ranges and gaps are
|
|
|
|
|
* represented by pfn_mapped
|
2009-04-28 16:00:49 +03:00
|
|
|
*/
|
|
|
|
|
unsigned long max_low_pfn_mapped;
|
|
|
|
|
unsigned long max_pfn_mapped;
|
|
|
|
|
|
2010-02-09 21:38:45 -02:00
|
|
|
#ifdef CONFIG_DMI
|
2009-03-12 16:09:49 -07:00
|
|
|
RESERVE_BRK(dmi_alloc, 65536);
|
2010-02-09 21:38:45 -02:00
|
|
|
#endif
|
2009-03-12 16:09:49 -07:00
|
|
|
|
2009-01-27 17:13:05 +01:00
|
|
|
|
2009-02-26 17:35:44 -08:00
|
|
|
static __initdata unsigned long _brk_start = (unsigned long)__brk_base;
|
|
|
|
|
unsigned long _brk_end = (unsigned long)__brk_base;
|
|
|
|
|
|
2009-01-27 17:13:05 +01:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
|
int default_cpu_present_to_apicid(int mps_cpu)
|
|
|
|
|
{
|
|
|
|
|
return __default_cpu_present_to_apicid(mps_cpu);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-31 15:18:40 +02:00
|
|
|
int default_check_phys_apicid_present(int phys_apicid)
|
2009-01-27 17:13:05 +01:00
|
|
|
{
|
2009-08-31 15:18:40 +02:00
|
|
|
return __default_check_phys_apicid_present(phys_apicid);
|
2009-01-27 17:13:05 +01:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-06-25 17:55:20 -07:00
|
|
|
struct boot_params boot_params;
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* Machine setup..
|
|
|
|
|
*/
|
2008-01-30 13:30:32 +01:00
|
|
|
static struct resource data_resource = {
|
|
|
|
|
.name = "Kernel data",
|
|
|
|
|
.start = 0,
|
|
|
|
|
.end = 0,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_MEM
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct resource code_resource = {
|
|
|
|
|
.name = "Kernel code",
|
|
|
|
|
.start = 0,
|
|
|
|
|
.end = 0,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_MEM
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct resource bss_resource = {
|
|
|
|
|
.name = "Kernel bss",
|
|
|
|
|
.start = 0,
|
|
|
|
|
.end = 0,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_MEM
|
|
|
|
|
};
|
|
|
|
|
|
2008-06-25 17:50:06 -07:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_32
|
2005-04-16 15:20:36 -07:00
|
|
|
/* cpu data as detected by the assembly code in head.S */
|
2013-06-18 18:23:59 -04:00
|
|
|
struct cpuinfo_x86 new_cpu_data = {
|
2013-03-03 00:14:42 +01:00
|
|
|
.wp_works_ok = -1,
|
|
|
|
|
};
|
2005-04-16 15:20:36 -07:00
|
|
|
/* common cpu data for all cpus */
|
2013-03-03 00:14:42 +01:00
|
|
|
struct cpuinfo_x86 boot_cpu_data __read_mostly = {
|
|
|
|
|
.wp_works_ok = -1,
|
|
|
|
|
};
|
2005-06-23 00:08:33 -07:00
|
|
|
EXPORT_SYMBOL(boot_cpu_data);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-03-27 23:55:04 +03:00
|
|
|
unsigned int def_to_bigsmp;
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/* for MCA, but anyone else can use it if they want */
|
|
|
|
|
unsigned int machine_id;
|
|
|
|
|
unsigned int machine_submodel_id;
|
|
|
|
|
unsigned int BIOS_revision;
|
|
|
|
|
|
2008-06-25 17:50:06 -07:00
|
|
|
struct apm_info apm_info;
|
|
|
|
|
EXPORT_SYMBOL(apm_info);
|
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
|
|
|
|
|
defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
|
|
|
|
|
struct ist_info ist_info;
|
|
|
|
|
EXPORT_SYMBOL(ist_info);
|
|
|
|
|
#else
|
|
|
|
|
struct ist_info ist_info;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#else
|
2009-03-04 16:16:51 -08:00
|
|
|
struct cpuinfo_x86 boot_cpu_data __read_mostly = {
|
|
|
|
|
.x86_phys_bits = MAX_PHYSMEM_BITS,
|
|
|
|
|
};
|
2008-06-25 17:50:06 -07:00
|
|
|
EXPORT_SYMBOL(boot_cpu_data);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
|
2013-08-05 15:02:43 -07:00
|
|
|
__visible unsigned long mmu_cr4_features;
|
2008-06-25 17:50:06 -07:00
|
|
|
#else
|
2013-08-05 15:02:43 -07:00
|
|
|
__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
|
2008-06-25 17:50:06 -07:00
|
|
|
#endif
|
|
|
|
|
|
2009-05-07 16:54:11 -07:00
|
|
|
/* Boot loader ID and version as integers, for the benefit of proc_dointvec */
|
|
|
|
|
int bootloader_type, bootloader_version;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Setup options
|
|
|
|
|
*/
|
|
|
|
|
struct screen_info screen_info;
|
2005-06-23 00:08:33 -07:00
|
|
|
EXPORT_SYMBOL(screen_info);
|
2005-04-16 15:20:36 -07:00
|
|
|
struct edid_info edid_info;
|
2005-09-09 13:04:34 -07:00
|
|
|
EXPORT_SYMBOL_GPL(edid_info);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
extern int root_mountflags;
|
|
|
|
|
|
2008-04-10 23:28:10 +02:00
|
|
|
unsigned long saved_video_mode;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-01-30 13:32:51 +01:00
|
|
|
#define RAMDISK_IMAGE_START_MASK 0x07FF
|
2005-04-16 15:20:36 -07:00
|
|
|
#define RAMDISK_PROMPT_FLAG 0x8000
|
2008-01-30 13:32:51 +01:00
|
|
|
#define RAMDISK_LOAD_FLAG 0x4000
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-02-12 00:54:11 -08:00
|
|
|
static char __initdata command_line[COMMAND_LINE_SIZE];
|
2008-08-12 12:52:36 -07:00
|
|
|
#ifdef CONFIG_CMDLINE_BOOL
|
|
|
|
|
static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
|
|
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
|
|
|
|
|
struct edd edd;
|
|
|
|
|
#ifdef CONFIG_EDD_MODULE
|
|
|
|
|
EXPORT_SYMBOL(edd);
|
|
|
|
|
#endif
|
|
|
|
|
/**
|
|
|
|
|
* copy_edd() - Copy the BIOS EDD information
|
|
|
|
|
* from boot_params into a safe place.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2009-11-30 18:33:51 +08:00
|
|
|
static inline void __init copy_edd(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-10-15 17:13:22 -07:00
|
|
|
memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
|
|
|
|
|
sizeof(edd.mbr_signature));
|
|
|
|
|
memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
|
|
|
|
|
edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
|
|
|
|
|
edd.edd_info_nr = boot_params.eddbuf_entries;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
#else
|
2009-11-30 18:33:51 +08:00
|
|
|
static inline void __init copy_edd(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-03-14 17:19:51 -07:00
|
|
|
void * __init extend_brk(size_t size, size_t align)
|
|
|
|
|
{
|
|
|
|
|
size_t mask = align - 1;
|
|
|
|
|
void *ret;
|
|
|
|
|
|
|
|
|
|
BUG_ON(_brk_start == 0);
|
|
|
|
|
BUG_ON(align & mask);
|
|
|
|
|
|
|
|
|
|
_brk_end = (_brk_end + mask) & ~mask;
|
|
|
|
|
BUG_ON((char *)(_brk_end + size) > __brk_limit);
|
|
|
|
|
|
|
|
|
|
ret = (void *)_brk_end;
|
|
|
|
|
_brk_end += size;
|
|
|
|
|
|
|
|
|
|
memset(ret, 0, size);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-16 19:39:08 -08:00
|
|
|
#ifdef CONFIG_X86_32
|
2011-02-18 11:30:30 +00:00
|
|
|
static void __init cleanup_highmap(void)
|
2010-12-27 16:48:32 -08:00
|
|
|
{
|
|
|
|
|
}
|
2009-06-22 17:39:41 +03:00
|
|
|
#endif
|
|
|
|
|
|
2009-03-14 17:19:51 -07:00
|
|
|
static void __init reserve_brk(void)
|
|
|
|
|
{
|
|
|
|
|
if (_brk_end > _brk_start)
|
2012-11-16 13:57:13 -08:00
|
|
|
memblock_reserve(__pa_symbol(_brk_start),
|
|
|
|
|
_brk_end - _brk_start);
|
2009-03-14 17:19:51 -07:00
|
|
|
|
|
|
|
|
/* Mark brk area as locked down and no longer taking any
|
|
|
|
|
new allocations */
|
|
|
|
|
_brk_start = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-04 20:50:42 +01:00
|
|
|
u64 relocated_ramdisk;
|
|
|
|
|
|
2008-01-30 13:32:51 +01:00
|
|
|
#ifdef CONFIG_BLK_DEV_INITRD
|
|
|
|
|
|
2013-01-24 12:19:56 -08:00
|
|
|
static u64 __init get_ramdisk_image(void)
|
|
|
|
|
{
|
|
|
|
|
u64 ramdisk_image = boot_params.hdr.ramdisk_image;
|
|
|
|
|
|
2013-01-28 20:16:44 -08:00
|
|
|
ramdisk_image |= (u64)boot_params.ext_ramdisk_image << 32;
|
|
|
|
|
|
2013-01-24 12:19:56 -08:00
|
|
|
return ramdisk_image;
|
|
|
|
|
}
|
|
|
|
|
static u64 __init get_ramdisk_size(void)
|
|
|
|
|
{
|
|
|
|
|
u64 ramdisk_size = boot_params.hdr.ramdisk_size;
|
|
|
|
|
|
2013-01-28 20:16:44 -08:00
|
|
|
ramdisk_size |= (u64)boot_params.ext_ramdisk_size << 32;
|
|
|
|
|
|
2013-01-24 12:19:56 -08:00
|
|
|
return ramdisk_size;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-25 17:49:26 -07:00
|
|
|
#define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT)
|
|
|
|
|
static void __init relocate_initrd(void)
|
2008-01-30 13:32:51 +01:00
|
|
|
{
|
2010-03-28 19:42:55 -07:00
|
|
|
/* Assume only end is not page aligned */
|
2013-01-24 12:19:56 -08:00
|
|
|
u64 ramdisk_image = get_ramdisk_image();
|
|
|
|
|
u64 ramdisk_size = get_ramdisk_size();
|
2010-03-28 19:42:55 -07:00
|
|
|
u64 area_size = PAGE_ALIGN(ramdisk_size);
|
2008-06-25 17:49:26 -07:00
|
|
|
unsigned long slop, clen, mapaddr;
|
|
|
|
|
char *p, *q;
|
2008-01-30 13:32:51 +01:00
|
|
|
|
2012-11-16 19:38:51 -08:00
|
|
|
/* We need to move the initrd down into directly mapped mem */
|
2013-12-04 20:50:42 +01:00
|
|
|
relocated_ramdisk = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
|
|
|
|
|
area_size, PAGE_SIZE);
|
2008-01-30 13:32:51 +01:00
|
|
|
|
2013-12-04 20:50:42 +01:00
|
|
|
if (!relocated_ramdisk)
|
2008-05-25 10:00:09 -07:00
|
|
|
panic("Cannot find place for new RAMDISK of size %lld\n",
|
2013-12-04 20:50:42 +01:00
|
|
|
ramdisk_size);
|
2008-05-25 10:00:09 -07:00
|
|
|
|
2012-11-16 19:38:51 -08:00
|
|
|
/* Note: this includes all the mem currently occupied by
|
2008-01-30 13:32:51 +01:00
|
|
|
the initrd, we rely on that fact to keep the data intact. */
|
2013-12-04 20:50:42 +01:00
|
|
|
memblock_reserve(relocated_ramdisk, area_size);
|
|
|
|
|
initrd_start = relocated_ramdisk + PAGE_OFFSET;
|
2008-01-30 13:32:51 +01:00
|
|
|
initrd_end = initrd_start + ramdisk_size;
|
2012-05-29 15:06:29 -07:00
|
|
|
printk(KERN_INFO "Allocated new RAMDISK: [mem %#010llx-%#010llx]\n",
|
2013-12-04 20:50:42 +01:00
|
|
|
relocated_ramdisk, relocated_ramdisk + ramdisk_size - 1);
|
2008-01-30 13:32:51 +01:00
|
|
|
|
|
|
|
|
q = (char *)initrd_start;
|
|
|
|
|
|
2012-11-16 19:38:51 -08:00
|
|
|
/* Copy the initrd */
|
2008-01-30 13:32:51 +01:00
|
|
|
while (ramdisk_size) {
|
|
|
|
|
slop = ramdisk_image & ~PAGE_MASK;
|
|
|
|
|
clen = ramdisk_size;
|
|
|
|
|
if (clen > MAX_MAP_CHUNK-slop)
|
|
|
|
|
clen = MAX_MAP_CHUNK-slop;
|
|
|
|
|
mapaddr = ramdisk_image & PAGE_MASK;
|
2008-09-07 15:21:16 -07:00
|
|
|
p = early_memremap(mapaddr, clen+slop);
|
2008-01-30 13:32:51 +01:00
|
|
|
memcpy(q, p+slop, clen);
|
2008-01-30 13:33:44 +01:00
|
|
|
early_iounmap(p, clen+slop);
|
2008-01-30 13:32:51 +01:00
|
|
|
q += clen;
|
|
|
|
|
ramdisk_image += clen;
|
|
|
|
|
ramdisk_size -= clen;
|
|
|
|
|
}
|
2012-11-16 19:38:51 -08:00
|
|
|
|
2013-01-24 12:19:56 -08:00
|
|
|
ramdisk_image = get_ramdisk_image();
|
|
|
|
|
ramdisk_size = get_ramdisk_size();
|
2012-05-29 15:06:29 -07:00
|
|
|
printk(KERN_INFO "Move RAMDISK from [mem %#010llx-%#010llx] to"
|
|
|
|
|
" [mem %#010llx-%#010llx]\n",
|
2008-05-21 18:40:18 -07:00
|
|
|
ramdisk_image, ramdisk_image + ramdisk_size - 1,
|
2013-12-04 20:50:42 +01:00
|
|
|
relocated_ramdisk, relocated_ramdisk + ramdisk_size - 1);
|
2008-06-25 17:49:26 -07:00
|
|
|
}
|
2008-06-13 20:07:03 -07:00
|
|
|
|
2013-01-24 12:19:55 -08:00
|
|
|
static void __init early_reserve_initrd(void)
|
|
|
|
|
{
|
|
|
|
|
/* Assume only end is not page aligned */
|
2013-01-24 12:19:56 -08:00
|
|
|
u64 ramdisk_image = get_ramdisk_image();
|
|
|
|
|
u64 ramdisk_size = get_ramdisk_size();
|
2013-01-24 12:19:55 -08:00
|
|
|
u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size);
|
|
|
|
|
|
|
|
|
|
if (!boot_params.hdr.type_of_loader ||
|
|
|
|
|
!ramdisk_image || !ramdisk_size)
|
|
|
|
|
return; /* No initrd provided by bootloader */
|
|
|
|
|
|
|
|
|
|
memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
|
|
|
|
|
}
|
2008-06-25 17:49:26 -07:00
|
|
|
static void __init reserve_initrd(void)
|
|
|
|
|
{
|
2010-03-28 19:42:55 -07:00
|
|
|
/* Assume only end is not page aligned */
|
2013-01-24 12:19:56 -08:00
|
|
|
u64 ramdisk_image = get_ramdisk_image();
|
|
|
|
|
u64 ramdisk_size = get_ramdisk_size();
|
2010-03-28 19:42:55 -07:00
|
|
|
u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size);
|
2012-11-16 19:38:51 -08:00
|
|
|
u64 mapped_size;
|
2008-06-25 17:49:26 -07:00
|
|
|
|
|
|
|
|
if (!boot_params.hdr.type_of_loader ||
|
|
|
|
|
!ramdisk_image || !ramdisk_size)
|
|
|
|
|
return; /* No initrd provided by bootloader */
|
|
|
|
|
|
|
|
|
|
initrd_start = 0;
|
|
|
|
|
|
2013-01-24 12:20:09 -08:00
|
|
|
mapped_size = memblock_mem_size(max_pfn_mapped);
|
2012-11-16 19:38:51 -08:00
|
|
|
if (ramdisk_size >= (mapped_size>>1))
|
2012-05-16 13:43:26 -04:00
|
|
|
panic("initrd too large to handle, "
|
|
|
|
|
"disabling initrd (%lld needed, %lld available)\n",
|
2012-11-16 19:38:51 -08:00
|
|
|
ramdisk_size, mapped_size>>1);
|
2008-06-25 17:49:26 -07:00
|
|
|
|
2012-05-29 15:06:29 -07:00
|
|
|
printk(KERN_INFO "RAMDISK: [mem %#010llx-%#010llx]\n", ramdisk_image,
|
|
|
|
|
ramdisk_end - 1);
|
2008-06-25 17:49:26 -07:00
|
|
|
|
2012-11-16 19:38:53 -08:00
|
|
|
if (pfn_range_is_mapped(PFN_DOWN(ramdisk_image),
|
2012-11-16 19:38:51 -08:00
|
|
|
PFN_DOWN(ramdisk_end))) {
|
|
|
|
|
/* All are mapped, easy case */
|
2008-06-25 17:49:26 -07:00
|
|
|
initrd_start = ramdisk_image + PAGE_OFFSET;
|
|
|
|
|
initrd_end = initrd_start + ramdisk_size;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
relocate_initrd();
|
2009-06-04 19:14:22 -07:00
|
|
|
|
2011-07-12 11:16:06 +02:00
|
|
|
memblock_free(ramdisk_image, ramdisk_end - ramdisk_image);
|
2008-01-30 13:32:51 +01:00
|
|
|
}
|
2008-06-22 02:46:58 -07:00
|
|
|
#else
|
2013-01-24 12:19:55 -08:00
|
|
|
static void __init early_reserve_initrd(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
2008-06-25 17:49:26 -07:00
|
|
|
static void __init reserve_initrd(void)
|
2008-06-22 02:46:58 -07:00
|
|
|
{
|
|
|
|
|
}
|
2008-01-30 13:32:51 +01:00
|
|
|
#endif /* CONFIG_BLK_DEV_INITRD */
|
|
|
|
|
|
2008-06-25 18:00:22 -07:00
|
|
|
static void __init parse_setup_data(void)
|
2008-06-25 17:56:22 -07:00
|
|
|
{
|
|
|
|
|
struct setup_data *data;
|
2013-08-13 15:46:41 -06:00
|
|
|
u64 pa_data, pa_next;
|
2008-06-25 17:56:22 -07:00
|
|
|
|
|
|
|
|
pa_data = boot_params.hdr.setup_data;
|
|
|
|
|
while (pa_data) {
|
2013-08-13 15:46:41 -06:00
|
|
|
u32 data_len, map_len, data_type;
|
2011-02-22 21:07:36 +01:00
|
|
|
|
|
|
|
|
map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
|
|
|
|
|
(u64)sizeof(struct setup_data));
|
|
|
|
|
data = early_memremap(pa_data, map_len);
|
|
|
|
|
data_len = data->len + sizeof(struct setup_data);
|
2013-08-13 15:46:41 -06:00
|
|
|
data_type = data->type;
|
|
|
|
|
pa_next = data->next;
|
|
|
|
|
early_iounmap(data, map_len);
|
2011-02-22 21:07:36 +01:00
|
|
|
|
2013-08-13 15:46:41 -06:00
|
|
|
switch (data_type) {
|
2008-06-25 17:56:22 -07:00
|
|
|
case SETUP_E820_EXT:
|
2013-08-13 15:46:41 -06:00
|
|
|
parse_e820_ext(pa_data, data_len);
|
2008-06-25 17:56:22 -07:00
|
|
|
break;
|
2011-02-22 21:07:37 +01:00
|
|
|
case SETUP_DTB:
|
|
|
|
|
add_dtb(pa_data);
|
2008-06-25 17:56:22 -07:00
|
|
|
break;
|
2013-12-20 18:02:19 +08:00
|
|
|
case SETUP_EFI:
|
|
|
|
|
parse_efi_setup(pa_data, data_len);
|
|
|
|
|
break;
|
2008-06-25 17:56:22 -07:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-08-13 15:46:41 -06:00
|
|
|
pa_data = pa_next;
|
2008-06-25 17:56:22 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-03 11:37:13 -07:00
|
|
|
static void __init e820_reserve_setup_data(void)
|
2008-06-30 16:20:54 -07:00
|
|
|
{
|
|
|
|
|
struct setup_data *data;
|
|
|
|
|
u64 pa_data;
|
2008-07-01 20:04:10 -07:00
|
|
|
int found = 0;
|
2008-06-30 16:20:54 -07:00
|
|
|
|
|
|
|
|
pa_data = boot_params.hdr.setup_data;
|
|
|
|
|
while (pa_data) {
|
2008-09-07 15:21:16 -07:00
|
|
|
data = early_memremap(pa_data, sizeof(*data));
|
2008-06-30 16:20:54 -07:00
|
|
|
e820_update_range(pa_data, sizeof(*data)+data->len,
|
|
|
|
|
E820_RAM, E820_RESERVED_KERN);
|
2008-07-01 20:04:10 -07:00
|
|
|
found = 1;
|
2008-06-30 16:20:54 -07:00
|
|
|
pa_data = data->next;
|
|
|
|
|
early_iounmap(data, sizeof(*data));
|
|
|
|
|
}
|
2008-07-01 20:04:10 -07:00
|
|
|
if (!found)
|
|
|
|
|
return;
|
|
|
|
|
|
2008-06-30 16:20:54 -07:00
|
|
|
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
|
2008-07-03 11:37:13 -07:00
|
|
|
memcpy(&e820_saved, &e820, sizeof(struct e820map));
|
2008-06-30 16:20:54 -07:00
|
|
|
printk(KERN_INFO "extended physical RAM map:\n");
|
|
|
|
|
e820_print_map("reserve setup_data");
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-25 13:39:17 -07:00
|
|
|
static void __init memblock_x86_reserve_range_setup_data(void)
|
2008-07-03 11:37:13 -07:00
|
|
|
{
|
|
|
|
|
struct setup_data *data;
|
|
|
|
|
u64 pa_data;
|
|
|
|
|
|
|
|
|
|
pa_data = boot_params.hdr.setup_data;
|
|
|
|
|
while (pa_data) {
|
2008-09-07 15:21:16 -07:00
|
|
|
data = early_memremap(pa_data, sizeof(*data));
|
2011-07-12 11:16:06 +02:00
|
|
|
memblock_reserve(pa_data, sizeof(*data) + data->len);
|
2008-07-03 11:37:13 -07:00
|
|
|
pa_data = data->next;
|
|
|
|
|
early_iounmap(data, sizeof(*data));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-25 17:57:13 -07:00
|
|
|
/*
|
|
|
|
|
* --------- Crashkernel reservation ------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_KEXEC
|
2008-06-26 21:54:08 +02:00
|
|
|
|
2010-12-16 19:20:41 -08:00
|
|
|
/*
|
|
|
|
|
* Keep the crash kernel below this limit. On 32 bits earlier kernels
|
|
|
|
|
* would limit the kernel to the low 512 MiB due to mapping restrictions.
|
2013-04-15 22:23:47 -07:00
|
|
|
* On 64bit, old kexec-tools need to under 896MiB.
|
2010-12-16 19:20:41 -08:00
|
|
|
*/
|
|
|
|
|
#ifdef CONFIG_X86_32
|
2013-04-15 22:23:47 -07:00
|
|
|
# define CRASH_KERNEL_ADDR_LOW_MAX (512 << 20)
|
|
|
|
|
# define CRASH_KERNEL_ADDR_HIGH_MAX (512 << 20)
|
2010-12-16 19:20:41 -08:00
|
|
|
#else
|
2013-04-15 22:23:47 -07:00
|
|
|
# define CRASH_KERNEL_ADDR_LOW_MAX (896UL<<20)
|
|
|
|
|
# define CRASH_KERNEL_ADDR_HIGH_MAX MAXMEM
|
2010-12-16 19:20:41 -08:00
|
|
|
#endif
|
|
|
|
|
|
2013-01-24 12:20:11 -08:00
|
|
|
static void __init reserve_crashkernel_low(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
|
const unsigned long long alignment = 16<<20; /* 16M */
|
|
|
|
|
unsigned long long low_base = 0, low_size = 0;
|
|
|
|
|
unsigned long total_low_mem;
|
|
|
|
|
unsigned long long base;
|
2013-04-15 22:23:45 -07:00
|
|
|
bool auto_set = false;
|
2013-01-24 12:20:11 -08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
total_low_mem = memblock_mem_size(1UL<<(32-PAGE_SHIFT));
|
2013-04-15 22:23:48 -07:00
|
|
|
/* crashkernel=Y,low */
|
2013-01-24 12:20:11 -08:00
|
|
|
ret = parse_crashkernel_low(boot_command_line, total_low_mem,
|
|
|
|
|
&low_size, &base);
|
2013-04-15 22:23:45 -07:00
|
|
|
if (ret != 0) {
|
|
|
|
|
/*
|
|
|
|
|
* two parts from lib/swiotlb.c:
|
|
|
|
|
* swiotlb size: user specified with swiotlb= or default.
|
|
|
|
|
* swiotlb overflow buffer: now is hardcoded to 32k.
|
|
|
|
|
* We round it to 8M for other buffers that
|
|
|
|
|
* may need to stay low too.
|
|
|
|
|
*/
|
|
|
|
|
low_size = swiotlb_size_or_default() + (8UL<<20);
|
|
|
|
|
auto_set = true;
|
|
|
|
|
} else {
|
2013-04-15 22:23:48 -07:00
|
|
|
/* passed with crashkernel=0,low ? */
|
2013-04-15 22:23:45 -07:00
|
|
|
if (!low_size)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-01-24 12:20:11 -08:00
|
|
|
|
|
|
|
|
low_base = memblock_find_in_range(low_size, (1ULL<<32),
|
|
|
|
|
low_size, alignment);
|
|
|
|
|
|
|
|
|
|
if (!low_base) {
|
2013-04-15 22:23:45 -07:00
|
|
|
if (!auto_set)
|
|
|
|
|
pr_info("crashkernel low reservation failed - No suitable area found.\n");
|
2013-01-24 12:20:11 -08:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memblock_reserve(low_base, low_size);
|
|
|
|
|
pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (System low RAM: %ldMB)\n",
|
|
|
|
|
(unsigned long)(low_size >> 20),
|
|
|
|
|
(unsigned long)(low_base >> 20),
|
|
|
|
|
(unsigned long)(total_low_mem >> 20));
|
|
|
|
|
crashk_low_res.start = low_base;
|
|
|
|
|
crashk_low_res.end = low_base + low_size - 1;
|
|
|
|
|
insert_resource(&iomem_resource, &crashk_low_res);
|
2010-12-16 19:20:41 -08:00
|
|
|
#endif
|
2013-01-24 12:20:11 -08:00
|
|
|
}
|
2010-12-16 19:20:41 -08:00
|
|
|
|
2008-06-25 18:00:22 -07:00
|
|
|
static void __init reserve_crashkernel(void)
|
2008-06-25 17:57:13 -07:00
|
|
|
{
|
2013-01-24 12:20:11 -08:00
|
|
|
const unsigned long long alignment = 16<<20; /* 16M */
|
2008-06-25 17:57:13 -07:00
|
|
|
unsigned long long total_mem;
|
|
|
|
|
unsigned long long crash_size, crash_base;
|
2013-04-15 22:23:47 -07:00
|
|
|
bool high = false;
|
2008-06-25 17:57:13 -07:00
|
|
|
int ret;
|
|
|
|
|
|
2012-03-28 14:42:47 -07:00
|
|
|
total_mem = memblock_phys_mem_size();
|
2008-06-25 17:57:13 -07:00
|
|
|
|
2013-04-15 22:23:47 -07:00
|
|
|
/* crashkernel=XM */
|
2008-06-25 17:57:13 -07:00
|
|
|
ret = parse_crashkernel(boot_command_line, total_mem,
|
|
|
|
|
&crash_size, &crash_base);
|
2013-04-15 22:23:47 -07:00
|
|
|
if (ret != 0 || crash_size <= 0) {
|
2013-04-15 22:23:48 -07:00
|
|
|
/* crashkernel=X,high */
|
2013-04-15 22:23:47 -07:00
|
|
|
ret = parse_crashkernel_high(boot_command_line, total_mem,
|
|
|
|
|
&crash_size, &crash_base);
|
|
|
|
|
if (ret != 0 || crash_size <= 0)
|
|
|
|
|
return;
|
|
|
|
|
high = true;
|
|
|
|
|
}
|
2008-06-26 21:54:08 +02:00
|
|
|
|
|
|
|
|
/* 0 means: find the address automatically */
|
|
|
|
|
if (crash_base <= 0) {
|
2010-10-05 16:05:14 -07:00
|
|
|
/*
|
2010-12-16 19:20:41 -08:00
|
|
|
* kexec want bzImage is below CRASH_KERNEL_ADDR_MAX
|
2010-10-05 16:05:14 -07:00
|
|
|
*/
|
|
|
|
|
crash_base = memblock_find_in_range(alignment,
|
2013-04-15 22:23:47 -07:00
|
|
|
high ? CRASH_KERNEL_ADDR_HIGH_MAX :
|
|
|
|
|
CRASH_KERNEL_ADDR_LOW_MAX,
|
|
|
|
|
crash_size, alignment);
|
2010-10-05 16:05:14 -07:00
|
|
|
|
2011-07-12 09:58:09 +02:00
|
|
|
if (!crash_base) {
|
2009-11-22 17:18:49 -08:00
|
|
|
pr_info("crashkernel reservation failed - No suitable area found.\n");
|
2008-06-25 17:57:13 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2013-01-24 12:20:11 -08:00
|
|
|
|
2008-06-26 21:54:08 +02:00
|
|
|
} else {
|
2009-11-22 17:18:49 -08:00
|
|
|
unsigned long long start;
|
|
|
|
|
|
2010-10-05 16:05:14 -07:00
|
|
|
start = memblock_find_in_range(crash_base,
|
|
|
|
|
crash_base + crash_size, crash_size, 1<<20);
|
2009-11-22 17:18:49 -08:00
|
|
|
if (start != crash_base) {
|
|
|
|
|
pr_info("crashkernel reservation failed - memory is in use.\n");
|
2008-06-25 17:57:13 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2008-06-26 21:54:08 +02:00
|
|
|
}
|
2011-07-12 11:16:06 +02:00
|
|
|
memblock_reserve(crash_base, crash_size);
|
2008-06-25 17:57:13 -07:00
|
|
|
|
2008-06-26 21:54:08 +02:00
|
|
|
printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
|
|
|
|
|
"for crashkernel (System RAM: %ldMB)\n",
|
|
|
|
|
(unsigned long)(crash_size >> 20),
|
|
|
|
|
(unsigned long)(crash_base >> 20),
|
|
|
|
|
(unsigned long)(total_mem >> 20));
|
2008-06-25 17:57:13 -07:00
|
|
|
|
2008-06-26 21:54:08 +02:00
|
|
|
crashk_res.start = crash_base;
|
|
|
|
|
crashk_res.end = crash_base + crash_size - 1;
|
|
|
|
|
insert_resource(&iomem_resource, &crashk_res);
|
2013-01-24 12:20:11 -08:00
|
|
|
|
|
|
|
|
if (crash_base >= (1ULL<<32))
|
|
|
|
|
reserve_crashkernel_low();
|
2008-06-25 17:57:13 -07:00
|
|
|
}
|
|
|
|
|
#else
|
2008-06-25 18:00:22 -07:00
|
|
|
static void __init reserve_crashkernel(void)
|
2008-06-25 17:57:13 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-06-25 17:58:02 -07:00
|
|
|
static struct resource standard_io_resources[] = {
|
|
|
|
|
{ .name = "dma1", .start = 0x00, .end = 0x1f,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "pic1", .start = 0x20, .end = 0x21,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "timer0", .start = 0x40, .end = 0x43,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "timer1", .start = 0x50, .end = 0x53,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "keyboard", .start = 0x60, .end = 0x60,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "keyboard", .start = 0x64, .end = 0x64,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "dma page reg", .start = 0x80, .end = 0x8f,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "pic2", .start = 0xa0, .end = 0xa1,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "dma2", .start = 0xc0, .end = 0xdf,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO },
|
|
|
|
|
{ .name = "fpu", .start = 0xf0, .end = 0xff,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_IO }
|
|
|
|
|
};
|
|
|
|
|
|
2009-08-19 14:55:50 +02:00
|
|
|
void __init reserve_standard_io_resources(void)
|
2008-06-25 17:58:02 -07:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* request I/O space for devices used on all i[345]86 PCs */
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
|
|
|
|
|
request_resource(&ioport_resource, &standard_io_resources[i]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-01 14:32:43 -07:00
|
|
|
static __init void reserve_ibft_region(void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long addr, size = 0;
|
|
|
|
|
|
|
|
|
|
addr = find_ibft_region(&size);
|
|
|
|
|
|
|
|
|
|
if (size)
|
2011-07-12 11:16:06 +02:00
|
|
|
memblock_reserve(addr, size);
|
2010-04-01 14:32:43 -07:00
|
|
|
}
|
|
|
|
|
|
2012-11-14 20:43:31 +00:00
|
|
|
static bool __init snb_gfx_workaround_needed(void)
|
|
|
|
|
{
|
2013-01-13 20:56:41 -08:00
|
|
|
#ifdef CONFIG_PCI
|
2012-11-14 20:43:31 +00:00
|
|
|
int i;
|
|
|
|
|
u16 vendor, devid;
|
2013-01-13 20:36:39 -08:00
|
|
|
static const __initconst u16 snb_ids[] = {
|
2012-11-14 20:43:31 +00:00
|
|
|
0x0102,
|
|
|
|
|
0x0112,
|
|
|
|
|
0x0122,
|
|
|
|
|
0x0106,
|
|
|
|
|
0x0116,
|
|
|
|
|
0x0126,
|
|
|
|
|
0x010a,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Assume no if something weird is going on with PCI */
|
|
|
|
|
if (!early_pci_allowed())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
vendor = read_pci_config_16(0, 2, 0, PCI_VENDOR_ID);
|
|
|
|
|
if (vendor != 0x8086)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
devid = read_pci_config_16(0, 2, 0, PCI_DEVICE_ID);
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(snb_ids); i++)
|
|
|
|
|
if (devid == snb_ids[i])
|
|
|
|
|
return true;
|
2013-01-13 20:56:41 -08:00
|
|
|
#endif
|
2012-11-14 20:43:31 +00:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Sandy Bridge graphics has trouble with certain ranges, exclude
|
|
|
|
|
* them from allocation.
|
|
|
|
|
*/
|
|
|
|
|
static void __init trim_snb_memory(void)
|
|
|
|
|
{
|
2013-01-13 20:36:39 -08:00
|
|
|
static const __initconst unsigned long bad_pages[] = {
|
2012-11-14 20:43:31 +00:00
|
|
|
0x20050000,
|
|
|
|
|
0x20110000,
|
|
|
|
|
0x20130000,
|
|
|
|
|
0x20138000,
|
|
|
|
|
0x40004000,
|
|
|
|
|
};
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!snb_gfx_workaround_needed())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
printk(KERN_DEBUG "reserving inaccessible SNB gfx pages\n");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Reserve all memory below the 1 MB mark that has not
|
|
|
|
|
* already been reserved.
|
|
|
|
|
*/
|
|
|
|
|
memblock_reserve(0, 1<<20);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(bad_pages); i++) {
|
|
|
|
|
if (memblock_reserve(bad_pages[i], PAGE_SIZE))
|
|
|
|
|
printk(KERN_WARNING "failed to reserve 0x%08lx\n",
|
|
|
|
|
bad_pages[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Here we put platform-specific memory range workarounds, i.e.
|
|
|
|
|
* memory known to be corrupt or otherwise in need to be reserved on
|
|
|
|
|
* specific platforms.
|
|
|
|
|
*
|
|
|
|
|
* If this gets used more widely it could use a real dispatch mechanism.
|
|
|
|
|
*/
|
|
|
|
|
static void __init trim_platform_memory_ranges(void)
|
|
|
|
|
{
|
|
|
|
|
trim_snb_memory();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-22 11:21:04 +08:00
|
|
|
static void __init trim_bios_range(void)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* A special case is the first 4Kb of memory;
|
|
|
|
|
* This is a BIOS owned area, not kernel ram, but generally
|
|
|
|
|
* not listed as such in the E820 table.
|
2010-08-24 17:32:04 -07:00
|
|
|
*
|
|
|
|
|
* This typically reserves additional memory (64KiB by default)
|
|
|
|
|
* since some BIOSes are known to corrupt low memory. See the
|
2010-08-25 16:38:20 -07:00
|
|
|
* Kconfig help text for X86_RESERVE_LOW.
|
2010-01-22 11:21:04 +08:00
|
|
|
*/
|
2013-02-14 14:02:52 -08:00
|
|
|
e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED);
|
2010-08-24 17:32:04 -07:00
|
|
|
|
2010-01-22 11:21:04 +08:00
|
|
|
/*
|
|
|
|
|
* special case: Some BIOSen report the PC BIOS
|
|
|
|
|
* area (640->1Mb) as ram even though it is not.
|
|
|
|
|
* take them out.
|
|
|
|
|
*/
|
|
|
|
|
e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
|
2012-11-14 20:43:31 +00:00
|
|
|
|
2010-01-22 11:21:04 +08:00
|
|
|
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-24 12:19:45 -08:00
|
|
|
/* called before trim_bios_range() to spare extra sanitize */
|
|
|
|
|
static void __init e820_add_kernel_range(void)
|
|
|
|
|
{
|
|
|
|
|
u64 start = __pa_symbol(_text);
|
|
|
|
|
u64 size = __pa_symbol(_end) - start;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Complain if .text .data and .bss are not marked as E820_RAM and
|
|
|
|
|
* attempt to fix it by adding the range. We may have a confused BIOS,
|
|
|
|
|
* or the user may have used memmap=exactmap or memmap=xxM$yyM to
|
|
|
|
|
* exclude kernel range. If we really are running on top non-RAM,
|
|
|
|
|
* we will crash later anyways.
|
|
|
|
|
*/
|
|
|
|
|
if (e820_all_mapped(start, start + size, E820_RAM))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pr_warn(".text .data .bss are not marked as E820_RAM!\n");
|
|
|
|
|
e820_remove_range(start, size, E820_RAM, 0);
|
|
|
|
|
e820_add_region(start, size, E820_RAM);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-14 14:02:52 -08:00
|
|
|
static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
|
|
|
|
|
|
2010-08-25 16:38:20 -07:00
|
|
|
static int __init parse_reservelow(char *p)
|
|
|
|
|
{
|
|
|
|
|
unsigned long long size;
|
|
|
|
|
|
|
|
|
|
if (!p)
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
size = memparse(p, &p);
|
|
|
|
|
|
|
|
|
|
if (size < 4096)
|
|
|
|
|
size = 4096;
|
|
|
|
|
|
|
|
|
|
if (size > 640*1024)
|
|
|
|
|
size = 640*1024;
|
|
|
|
|
|
|
|
|
|
reserve_low = size;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
early_param("reservelow", parse_reservelow);
|
|
|
|
|
|
2013-02-14 14:02:52 -08:00
|
|
|
static void __init trim_low_memory_range(void)
|
|
|
|
|
{
|
|
|
|
|
memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE));
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-10 17:18:17 -07:00
|
|
|
/*
|
|
|
|
|
* Dump out kernel offset information on panic.
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
|
|
|
|
|
{
|
|
|
|
|
pr_emerg("Kernel Offset: 0x%lx from 0x%lx "
|
|
|
|
|
"(relocation range: 0x%lx-0x%lx)\n",
|
|
|
|
|
(unsigned long)&_text - __START_KERNEL, __START_KERNEL,
|
|
|
|
|
__START_KERNEL_map, MODULES_VADDR-1);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
|
* Determine if we were loaded by an EFI loader. If so, then we have also been
|
|
|
|
|
* passed the efi memmap, systab, etc., so we should use these data structures
|
|
|
|
|
* for initialization. Note, the efi init code path is determined by the
|
|
|
|
|
* global efi_enabled. This allows the same kernel image to be used on existing
|
|
|
|
|
* systems (with a traditional BIOS) as well as on EFI systems.
|
|
|
|
|
*/
|
2008-06-25 17:52:35 -07:00
|
|
|
/*
|
|
|
|
|
* setup_arch - architecture-specific boot-time initializations
|
|
|
|
|
*
|
|
|
|
|
* Note: On x86_64, fixmaps are ready for use even before this is called.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
void __init setup_arch(char **cmdline_p)
|
|
|
|
|
{
|
2013-01-24 12:20:12 -08:00
|
|
|
memblock_reserve(__pa_symbol(_text),
|
|
|
|
|
(unsigned long)__bss_stop - (unsigned long)_text);
|
|
|
|
|
|
2013-01-24 12:19:55 -08:00
|
|
|
early_reserve_initrd();
|
|
|
|
|
|
2013-01-24 12:20:12 -08:00
|
|
|
/*
|
|
|
|
|
* At this point everything still needed from the boot loader
|
|
|
|
|
* or BIOS or kernel text should be early reserved or marked not
|
|
|
|
|
* RAM in e820. All other memory is free game.
|
|
|
|
|
*/
|
|
|
|
|
|
2008-06-25 17:52:35 -07:00
|
|
|
#ifdef CONFIG_X86_32
|
2005-04-16 15:20:36 -07:00
|
|
|
memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
|
2010-08-28 15:58:33 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* copy kernel address range established so far and switch
|
|
|
|
|
* to the proper swapper page table
|
|
|
|
|
*/
|
|
|
|
|
clone_pgd_range(swapper_pg_dir + KERNEL_PGD_BOUNDARY,
|
|
|
|
|
initial_page_table + KERNEL_PGD_BOUNDARY,
|
|
|
|
|
KERNEL_PGD_PTRS);
|
|
|
|
|
|
|
|
|
|
load_cr3(swapper_pg_dir);
|
2014-10-07 01:19:48 +01:00
|
|
|
/*
|
|
|
|
|
* Note: Quark X1000 CPUs advertise PGE incorrectly and require
|
|
|
|
|
* a cr3 based tlb flush, so the following __flush_tlb_all()
|
|
|
|
|
* will not flush anything because the cpu quirk which clears
|
|
|
|
|
* X86_FEATURE_PGE has not been invoked yet. Though due to the
|
|
|
|
|
* load_cr3() above the TLB has been flushed already. The
|
|
|
|
|
* quirk is invoked before subsequent calls to __flush_tlb_all()
|
|
|
|
|
* so proper operation is guaranteed.
|
|
|
|
|
*/
|
2010-08-28 15:58:33 +02:00
|
|
|
__flush_tlb_all();
|
2008-06-25 17:52:35 -07:00
|
|
|
#else
|
|
|
|
|
printk(KERN_INFO "Command line: %s\n", boot_command_line);
|
|
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-08-23 14:49:11 -07:00
|
|
|
/*
|
|
|
|
|
* If we have OLPC OFW, we might end up relocating the fixmap due to
|
|
|
|
|
* reserve_top(), so do this before touching the ioremap area.
|
|
|
|
|
*/
|
2010-06-18 17:46:53 -04:00
|
|
|
olpc_ofw_detect();
|
|
|
|
|
|
2010-05-20 21:04:29 -05:00
|
|
|
early_trap_init();
|
2008-07-21 16:49:54 -07:00
|
|
|
early_cpu_init();
|
2008-06-29 20:02:44 -07:00
|
|
|
early_ioremap_init();
|
|
|
|
|
|
2010-06-18 17:46:53 -04:00
|
|
|
setup_olpc_ofw_pgd();
|
|
|
|
|
|
2007-10-15 17:13:22 -07:00
|
|
|
ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
|
|
|
|
|
screen_info = boot_params.screen_info;
|
|
|
|
|
edid_info = boot_params.edid_info;
|
2008-06-25 17:52:35 -07:00
|
|
|
#ifdef CONFIG_X86_32
|
2007-10-15 17:13:22 -07:00
|
|
|
apm_info.bios = boot_params.apm_bios_info;
|
|
|
|
|
ist_info = boot_params.ist_info;
|
2008-06-25 17:52:35 -07:00
|
|
|
if (boot_params.sys_desc_table.length != 0) {
|
2007-10-15 17:13:22 -07:00
|
|
|
machine_id = boot_params.sys_desc_table.table[0];
|
|
|
|
|
machine_submodel_id = boot_params.sys_desc_table.table[1];
|
|
|
|
|
BIOS_revision = boot_params.sys_desc_table.table[2];
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2008-06-25 17:52:35 -07:00
|
|
|
#endif
|
|
|
|
|
saved_video_mode = boot_params.hdr.vid_mode;
|
2007-10-15 17:13:22 -07:00
|
|
|
bootloader_type = boot_params.hdr.type_of_loader;
|
2009-05-07 16:54:11 -07:00
|
|
|
if ((bootloader_type >> 4) == 0xe) {
|
|
|
|
|
bootloader_type &= 0xf;
|
|
|
|
|
bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
|
|
|
|
|
}
|
|
|
|
|
bootloader_version = bootloader_type & 0xf;
|
|
|
|
|
bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_BLK_DEV_RAM
|
2007-10-15 17:13:22 -07:00
|
|
|
rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
|
|
|
|
|
rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
|
|
|
|
|
rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|
2008-06-23 19:53:33 -07:00
|
|
|
#ifdef CONFIG_EFI
|
|
|
|
|
if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
|
2014-06-30 19:53:03 +02:00
|
|
|
EFI32_LOADER_SIGNATURE, 4)) {
|
2014-01-15 13:21:22 +00:00
|
|
|
set_bit(EFI_BOOT, &efi.flags);
|
2012-02-12 13:24:29 -08:00
|
|
|
} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
|
2014-06-30 19:53:03 +02:00
|
|
|
EFI64_LOADER_SIGNATURE, 4)) {
|
2014-01-15 13:21:22 +00:00
|
|
|
set_bit(EFI_BOOT, &efi.flags);
|
|
|
|
|
set_bit(EFI_64BIT, &efi.flags);
|
2008-06-23 19:53:33 -07:00
|
|
|
}
|
2012-11-14 09:42:35 +00:00
|
|
|
|
|
|
|
|
if (efi_enabled(EFI_BOOT))
|
|
|
|
|
efi_memblock_x86_reserve_range();
|
2008-06-23 19:53:33 -07:00
|
|
|
#endif
|
|
|
|
|
|
2009-08-20 13:04:10 +02:00
|
|
|
x86_init.oem.arch_setup();
|
2008-01-30 13:31:19 +01:00
|
|
|
|
2010-10-26 15:41:49 -06:00
|
|
|
iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
|
2008-04-23 15:09:05 +02:00
|
|
|
setup_memory_map();
|
2008-06-30 16:20:54 -07:00
|
|
|
parse_setup_data();
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
copy_edd();
|
|
|
|
|
|
2007-10-15 17:13:22 -07:00
|
|
|
if (!boot_params.hdr.root_flags)
|
2005-04-16 15:20:36 -07:00
|
|
|
root_mountflags &= ~MS_RDONLY;
|
|
|
|
|
init_mm.start_code = (unsigned long) _text;
|
|
|
|
|
init_mm.end_code = (unsigned long) _etext;
|
|
|
|
|
init_mm.end_data = (unsigned long) _edata;
|
2009-02-26 17:35:44 -08:00
|
|
|
init_mm.brk = _brk_end;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2012-11-16 13:57:13 -08:00
|
|
|
code_resource.start = __pa_symbol(_text);
|
|
|
|
|
code_resource.end = __pa_symbol(_etext)-1;
|
|
|
|
|
data_resource.start = __pa_symbol(_etext);
|
|
|
|
|
data_resource.end = __pa_symbol(_edata)-1;
|
|
|
|
|
bss_resource.start = __pa_symbol(__bss_start);
|
|
|
|
|
bss_resource.end = __pa_symbol(__bss_stop)-1;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-08-12 12:52:36 -07:00
|
|
|
#ifdef CONFIG_CMDLINE_BOOL
|
|
|
|
|
#ifdef CONFIG_CMDLINE_OVERRIDE
|
|
|
|
|
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
|
|
|
|
|
#else
|
|
|
|
|
if (builtin_cmdline[0]) {
|
|
|
|
|
/* append boot loader cmdline to builtin */
|
|
|
|
|
strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
|
|
|
|
|
strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
|
|
|
|
|
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-09-19 11:07:57 -07:00
|
|
|
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
|
|
|
|
|
*cmdline_p = command_line;
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-13 15:28:17 -08:00
|
|
|
* x86_configure_nx() is called before parse_early_param() to detect
|
|
|
|
|
* whether hardware doesn't support NX (so that the early EHCI debug
|
|
|
|
|
* console setup can safely call set_fixmap()). It may then be called
|
|
|
|
|
* again from within noexec_setup() during parsing early parameters
|
|
|
|
|
* to honor the respective command line option.
|
2009-09-19 11:07:57 -07:00
|
|
|
*/
|
2009-11-13 15:28:16 -08:00
|
|
|
x86_configure_nx();
|
2009-09-19 11:07:57 -07:00
|
|
|
|
|
|
|
|
parse_early_param();
|
|
|
|
|
|
2009-11-13 15:28:17 -08:00
|
|
|
x86_report_nx();
|
2008-09-11 16:42:00 -07:00
|
|
|
|
2008-06-30 16:20:54 -07:00
|
|
|
/* after early param, so could get panic from serial */
|
2010-08-25 13:39:17 -07:00
|
|
|
memblock_x86_reserve_range_setup_data();
|
2008-06-30 16:20:54 -07:00
|
|
|
|
2008-06-25 17:52:35 -07:00
|
|
|
if (acpi_mps_check()) {
|
2008-06-23 22:19:22 +02:00
|
|
|
#ifdef CONFIG_X86_LOCAL_APIC
|
2008-06-25 17:52:35 -07:00
|
|
|
disable_apic = 1;
|
2008-06-23 22:19:22 +02:00
|
|
|
#endif
|
2008-07-21 11:21:43 -07:00
|
|
|
setup_clear_cpu_cap(X86_FEATURE_APIC);
|
2008-06-20 16:11:20 -07:00
|
|
|
}
|
|
|
|
|
|
2008-07-16 17:25:46 -07:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
if (pci_early_dump_regs)
|
|
|
|
|
early_dump_pci_devices();
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-12-20 18:02:22 +08:00
|
|
|
/* update the e820_saved too */
|
|
|
|
|
e820_reserve_setup_data();
|
2008-04-23 15:09:05 +02:00
|
|
|
finish_e820_parsing();
|
2006-09-26 10:52:32 +02:00
|
|
|
|
2012-11-14 09:42:35 +00:00
|
|
|
if (efi_enabled(EFI_BOOT))
|
2009-03-03 21:55:31 -05:00
|
|
|
efi_init();
|
|
|
|
|
|
2008-09-22 02:52:26 -07:00
|
|
|
dmi_scan_machine();
|
2013-10-18 14:29:25 -07:00
|
|
|
dmi_memdev_walk();
|
2013-04-30 15:27:15 -07:00
|
|
|
dmi_set_dump_stack_arch_desc();
|
2008-09-22 02:52:26 -07:00
|
|
|
|
2008-10-27 10:41:46 -07:00
|
|
|
/*
|
|
|
|
|
* VMware detection requires dmi to be available, so this
|
|
|
|
|
* needs to be done after dmi_scan_machine, for the BP.
|
|
|
|
|
*/
|
2009-08-20 17:06:25 +02:00
|
|
|
init_hypervisor_platform();
|
2008-10-27 10:41:46 -07:00
|
|
|
|
2009-08-19 14:43:56 +02:00
|
|
|
x86_init.resources.probe_roms();
|
2008-06-16 13:03:31 -07:00
|
|
|
|
|
|
|
|
/* after parse_early_param, so could debug it */
|
|
|
|
|
insert_resource(&iomem_resource, &code_resource);
|
|
|
|
|
insert_resource(&iomem_resource, &data_resource);
|
|
|
|
|
insert_resource(&iomem_resource, &bss_resource);
|
|
|
|
|
|
2013-01-24 12:19:45 -08:00
|
|
|
e820_add_kernel_range();
|
2010-01-22 11:21:04 +08:00
|
|
|
trim_bios_range();
|
2008-06-25 17:52:35 -07:00
|
|
|
#ifdef CONFIG_X86_32
|
2008-06-16 16:11:08 -07:00
|
|
|
if (ppro_with_ram_bug()) {
|
|
|
|
|
e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
|
|
|
|
|
E820_RESERVED);
|
|
|
|
|
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
|
|
|
|
|
printk(KERN_INFO "fixed physical RAM map:\n");
|
|
|
|
|
e820_print_map("bad_ppro");
|
|
|
|
|
}
|
2008-06-25 17:52:35 -07:00
|
|
|
#else
|
|
|
|
|
early_gart_iommu_check();
|
|
|
|
|
#endif
|
2008-06-16 16:11:08 -07:00
|
|
|
|
2008-06-03 19:35:04 -07:00
|
|
|
/*
|
|
|
|
|
* partially used pages are not usable - thus
|
|
|
|
|
* we are rounding upwards:
|
|
|
|
|
*/
|
2008-07-10 20:38:26 -07:00
|
|
|
max_pfn = e820_end_of_ram_pfn();
|
2008-06-03 19:35:04 -07:00
|
|
|
|
2008-01-30 13:33:32 +01:00
|
|
|
/* update e820 for memory not covered by WB MTRRs */
|
|
|
|
|
mtrr_bp_init();
|
2008-07-08 18:56:38 -07:00
|
|
|
if (mtrr_trim_uncached_memory(max_pfn))
|
2008-07-10 20:38:26 -07:00
|
|
|
max_pfn = e820_end_of_ram_pfn();
|
2008-03-23 00:16:49 -07:00
|
|
|
|
2008-06-25 17:52:35 -07:00
|
|
|
#ifdef CONFIG_X86_32
|
2008-06-24 12:18:14 -07:00
|
|
|
/* max_low_pfn get updated here */
|
2008-06-23 03:05:30 -07:00
|
|
|
find_low_pfn_range();
|
2008-06-25 17:52:35 -07:00
|
|
|
#else
|
2009-02-16 17:29:58 -08:00
|
|
|
check_x2apic();
|
2008-06-25 17:52:35 -07:00
|
|
|
|
|
|
|
|
/* How many end-of-memory variables you have, grandma! */
|
|
|
|
|
/* need this before calling reserve_initrd */
|
2008-07-10 20:38:26 -07:00
|
|
|
if (max_pfn > (1UL<<(32 - PAGE_SHIFT)))
|
|
|
|
|
max_low_pfn = e820_end_of_low_ram_pfn();
|
|
|
|
|
else
|
|
|
|
|
max_low_pfn = max_pfn;
|
|
|
|
|
|
2008-06-25 17:52:35 -07:00
|
|
|
high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
|
2008-09-07 01:51:32 -07:00
|
|
|
#endif
|
|
|
|
|
|
2009-12-10 13:07:22 -08:00
|
|
|
/*
|
|
|
|
|
* Find and reserve possible boot-time SMP configuration:
|
|
|
|
|
*/
|
|
|
|
|
find_smp_config();
|
|
|
|
|
|
2010-04-01 14:32:43 -07:00
|
|
|
reserve_ibft_region();
|
|
|
|
|
|
2012-11-16 19:38:58 -08:00
|
|
|
early_alloc_pgt_buf();
|
|
|
|
|
|
2010-08-25 13:39:17 -07:00
|
|
|
/*
|
|
|
|
|
* Need to conclude brk, before memblock_x86_fill()
|
|
|
|
|
* it could use memblock_find_in_range, could overlap with
|
|
|
|
|
* brk area.
|
|
|
|
|
*/
|
|
|
|
|
reserve_brk();
|
|
|
|
|
|
2011-02-18 11:30:30 +00:00
|
|
|
cleanup_highmap();
|
|
|
|
|
|
2013-08-14 11:44:04 +08:00
|
|
|
memblock_set_current_limit(ISA_END_ADDRESS);
|
2010-08-25 13:39:17 -07:00
|
|
|
memblock_x86_fill();
|
|
|
|
|
|
2011-05-25 09:53:13 -04:00
|
|
|
/*
|
|
|
|
|
* The EFI specification says that boot service code won't be called
|
|
|
|
|
* after ExitBootServices(). This is, in fact, a lie.
|
|
|
|
|
*/
|
2012-11-14 09:42:35 +00:00
|
|
|
if (efi_enabled(EFI_MEMMAP))
|
2011-05-25 09:53:13 -04:00
|
|
|
efi_reserve_boot_services();
|
|
|
|
|
|
2010-08-25 13:39:17 -07:00
|
|
|
/* preallocate 4k for mptable mpc */
|
|
|
|
|
early_reserve_e820_mpc_new();
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
|
|
|
|
|
setup_bios_corruption_check();
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-24 12:19:54 -08:00
|
|
|
#ifdef CONFIG_X86_32
|
2012-05-29 15:06:29 -07:00
|
|
|
printk(KERN_DEBUG "initial memory mapped: [mem 0x00000000-%#010lx]\n",
|
|
|
|
|
(max_pfn_mapped<<PAGE_SHIFT) - 1);
|
2013-01-24 12:19:54 -08:00
|
|
|
#endif
|
2010-08-25 13:39:17 -07:00
|
|
|
|
2013-01-24 12:19:51 -08:00
|
|
|
reserve_real_mode();
|
2009-12-10 13:07:22 -08:00
|
|
|
|
2012-11-14 20:43:31 +00:00
|
|
|
trim_platform_memory_ranges();
|
2013-02-14 14:02:52 -08:00
|
|
|
trim_low_memory_range();
|
2012-11-14 20:43:31 +00:00
|
|
|
|
2012-11-16 19:38:41 -08:00
|
|
|
init_mem_mapping();
|
2011-10-20 16:15:26 -05:00
|
|
|
|
2013-01-24 12:19:52 -08:00
|
|
|
early_trap_pf_init();
|
2011-10-20 16:15:26 -05:00
|
|
|
|
2013-01-24 12:19:51 -08:00
|
|
|
setup_real_mode();
|
2011-10-20 16:15:26 -05:00
|
|
|
|
2014-01-27 17:06:50 -08:00
|
|
|
memblock_set_current_limit(get_max_mapped());
|
2014-06-04 16:06:54 -07:00
|
|
|
dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT);
|
2008-06-24 12:18:14 -07:00
|
|
|
|
2008-06-25 21:51:28 -07:00
|
|
|
/*
|
|
|
|
|
* NOTE: On x86-32, only from this point on, fixmaps are ready for use.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
|
|
|
|
|
if (init_ohci1394_dma_early)
|
|
|
|
|
init_ohci1394_dma_on_all_controllers();
|
|
|
|
|
#endif
|
2011-05-24 17:13:20 -07:00
|
|
|
/* Allocate bigger log buffer */
|
|
|
|
|
setup_log_buf(1);
|
2008-06-25 21:51:28 -07:00
|
|
|
|
2008-06-23 03:05:30 -07:00
|
|
|
reserve_initrd();
|
|
|
|
|
|
2012-10-01 20:38:47 -07:00
|
|
|
#if defined(CONFIG_ACPI) && defined(CONFIG_BLK_DEV_INITRD)
|
2012-10-01 00:23:54 +02:00
|
|
|
acpi_initrd_override((void *)initrd_start, initrd_end - initrd_start);
|
2012-10-01 20:38:47 -07:00
|
|
|
#endif
|
2012-10-01 00:23:54 +02:00
|
|
|
|
2008-06-25 17:52:35 -07:00
|
|
|
vsmp_init();
|
|
|
|
|
|
2008-06-17 15:41:45 -07:00
|
|
|
io_delay_init();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Parse the ACPI tables for possible boot-time SMP configuration.
|
|
|
|
|
*/
|
2013-03-01 14:51:27 -08:00
|
|
|
acpi_boot_table_init();
|
|
|
|
|
|
|
|
|
|
early_acpi_boot_init();
|
|
|
|
|
|
2011-02-16 12:13:06 +01:00
|
|
|
initmem_init();
|
2013-11-12 15:08:07 -08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Reserve memory for crash kernel after SRAT is parsed so that it
|
|
|
|
|
* won't consume hotpluggable memory.
|
|
|
|
|
*/
|
|
|
|
|
reserve_crashkernel();
|
|
|
|
|
|
2010-08-25 13:39:18 -07:00
|
|
|
memblock_find_dma_reserve();
|
2008-07-18 19:07:53 +02:00
|
|
|
|
2012-08-16 17:00:19 -03:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
2008-02-15 17:52:48 -02:00
|
|
|
kvmclock_init();
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-08-21 21:22:38 +01:00
|
|
|
x86_init.paging.pagetable_init();
|
2008-01-30 13:34:11 +01:00
|
|
|
|
2011-04-06 13:10:02 -07:00
|
|
|
if (boot_cpu_data.cpuid_level >= 0) {
|
|
|
|
|
/* A CPU has %cr4 if and only if it has CPUID */
|
|
|
|
|
mmu_cr4_features = read_cr4();
|
2012-05-08 21:22:46 +03:00
|
|
|
if (trampoline_cr4_features)
|
|
|
|
|
*trampoline_cr4_features = mmu_cr4_features;
|
2011-04-06 13:10:02 -07:00
|
|
|
}
|
|
|
|
|
|
2010-08-28 15:58:33 +02:00
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
|
/* sync back kernel address range */
|
|
|
|
|
clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
|
|
|
|
|
swapper_pg_dir + KERNEL_PGD_BOUNDARY,
|
|
|
|
|
KERNEL_PGD_PTRS);
|
|
|
|
|
#endif
|
2010-08-16 14:38:33 +02:00
|
|
|
|
2009-06-30 19:30:59 -07:00
|
|
|
tboot_probe();
|
|
|
|
|
|
2008-06-25 17:52:35 -07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
|
map_vsyscall();
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-09-26 10:52:32 +02:00
|
|
|
generic_apic_probe();
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-19 20:35:03 +02:00
|
|
|
early_quirks();
|
2006-06-08 00:43:38 -07:00
|
|
|
|
2008-06-23 19:55:05 -07:00
|
|
|
/*
|
|
|
|
|
* Read APIC and some other early information from ACPI tables.
|
|
|
|
|
*/
|
2005-04-16 15:20:36 -07:00
|
|
|
acpi_boot_init();
|
2009-08-14 15:23:29 -04:00
|
|
|
sfi_init();
|
2011-02-25 16:09:31 +01:00
|
|
|
x86_dtb_init();
|
2008-06-21 01:38:41 -07:00
|
|
|
|
2008-06-23 19:55:05 -07:00
|
|
|
/*
|
|
|
|
|
* get boot-time SMP configuration:
|
|
|
|
|
*/
|
2008-06-08 18:29:22 -07:00
|
|
|
if (smp_found_config)
|
|
|
|
|
get_smp_config();
|
2008-06-25 17:52:35 -07:00
|
|
|
|
2008-07-02 18:54:40 -07:00
|
|
|
prefill_possible_map();
|
2008-08-19 20:50:02 -07:00
|
|
|
|
2008-07-02 18:53:44 -07:00
|
|
|
init_cpu_to_node();
|
|
|
|
|
|
2008-06-25 17:52:35 -07:00
|
|
|
init_apic_mappings();
|
2012-05-07 19:19:56 +02:00
|
|
|
if (x86_io_apic_ops.init)
|
|
|
|
|
x86_io_apic_ops.init();
|
2008-08-19 20:50:52 -07:00
|
|
|
|
2008-06-23 19:55:05 -07:00
|
|
|
kvm_guest_init();
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-06-16 13:03:31 -07:00
|
|
|
e820_reserve_resources();
|
2008-05-20 20:10:58 -07:00
|
|
|
e820_mark_nosave_regions(max_low_pfn);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2009-08-19 14:55:50 +02:00
|
|
|
x86_init.resources.reserve_resources();
|
2008-06-16 13:03:31 -07:00
|
|
|
|
|
|
|
|
e820_setup_gap();
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#ifdef CONFIG_VT
|
|
|
|
|
#if defined(CONFIG_VGA_CONSOLE)
|
2012-11-14 09:42:35 +00:00
|
|
|
if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
|
2005-04-16 15:20:36 -07:00
|
|
|
conswitchp = &vga_con;
|
|
|
|
|
#elif defined(CONFIG_DUMMY_CONSOLE)
|
|
|
|
|
conswitchp = &dummy_con;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
2009-08-20 13:19:57 +02:00
|
|
|
x86_init.oem.banner();
|
2009-11-10 09:38:24 +08:00
|
|
|
|
2011-02-15 00:13:31 +08:00
|
|
|
x86_init.timers.wallclock_init();
|
|
|
|
|
|
2009-11-10 09:38:24 +08:00
|
|
|
mcheck_init();
|
2010-09-17 11:08:51 -04:00
|
|
|
|
2011-04-18 15:19:51 -07:00
|
|
|
arch_init_ideal_nops();
|
2012-09-04 12:42:27 -04:00
|
|
|
|
|
|
|
|
register_refined_jiffies(CLOCK_TICK_RATE);
|
2012-10-24 10:00:44 -07:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_EFI
|
2014-03-04 17:02:17 +01:00
|
|
|
if (efi_enabled(EFI_BOOT))
|
|
|
|
|
efi_apply_memmap_quirks();
|
2012-10-24 10:00:44 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2008-09-16 09:29:09 +02:00
|
|
|
|
2009-02-17 23:12:48 +01:00
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
|
|
2009-08-19 14:55:50 +02:00
|
|
|
static struct resource video_ram_resource = {
|
|
|
|
|
.name = "Video RAM area",
|
|
|
|
|
.start = 0xa0000,
|
|
|
|
|
.end = 0xbffff,
|
|
|
|
|
.flags = IORESOURCE_BUSY | IORESOURCE_MEM
|
2009-02-17 23:12:48 +01:00
|
|
|
};
|
|
|
|
|
|
2009-08-19 14:55:50 +02:00
|
|
|
void __init i386_reserve_resources(void)
|
2009-02-17 23:12:48 +01:00
|
|
|
{
|
2009-08-19 14:55:50 +02:00
|
|
|
request_resource(&iomem_resource, &video_ram_resource);
|
|
|
|
|
reserve_standard_io_resources();
|
2009-02-17 23:12:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* CONFIG_X86_32 */
|
2013-10-10 17:18:17 -07:00
|
|
|
|
|
|
|
|
static struct notifier_block kernel_offset_notifier = {
|
|
|
|
|
.notifier_call = dump_kernel_offset
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int __init register_kernel_offset_dumper(void)
|
|
|
|
|
{
|
|
|
|
|
atomic_notifier_chain_register(&panic_notifier_list,
|
|
|
|
|
&kernel_offset_notifier);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
__initcall(register_kernel_offset_dumper);
|