Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2009 Thomas Gleixner <tglx@linutronix.de>
0003  *
0004  *  For licencing details see kernel-base/COPYING
0005  */
0006 #include <linux/init.h>
0007 #include <linux/ioport.h>
0008 #include <linux/export.h>
0009 #include <linux/pci.h>
0010 
0011 #include <asm/acpi.h>
0012 #include <asm/bios_ebda.h>
0013 #include <asm/paravirt.h>
0014 #include <asm/pci_x86.h>
0015 #include <asm/mpspec.h>
0016 #include <asm/setup.h>
0017 #include <asm/apic.h>
0018 #include <asm/e820/api.h>
0019 #include <asm/time.h>
0020 #include <asm/irq.h>
0021 #include <asm/io_apic.h>
0022 #include <asm/hpet.h>
0023 #include <asm/memtype.h>
0024 #include <asm/tsc.h>
0025 #include <asm/iommu.h>
0026 #include <asm/mach_traps.h>
0027 #include <asm/irqdomain.h>
0028 
0029 void x86_init_noop(void) { }
0030 void __init x86_init_uint_noop(unsigned int unused) { }
0031 static int __init iommu_init_noop(void) { return 0; }
0032 static void iommu_shutdown_noop(void) { }
0033 bool __init bool_x86_init_noop(void) { return false; }
0034 void x86_op_int_noop(int cpu) { }
0035 static __init int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
0036 static __init void get_rtc_noop(struct timespec64 *now) { }
0037 
0038 static __initconst const struct of_device_id of_cmos_match[] = {
0039     { .compatible = "motorola,mc146818" },
0040     {}
0041 };
0042 
0043 /*
0044  * Allow devicetree configured systems to disable the RTC by setting the
0045  * corresponding DT node's status property to disabled. Code is optimized
0046  * out for CONFIG_OF=n builds.
0047  */
0048 static __init void x86_wallclock_init(void)
0049 {
0050     struct device_node *node = of_find_matching_node(NULL, of_cmos_match);
0051 
0052     if (node && !of_device_is_available(node)) {
0053         x86_platform.get_wallclock = get_rtc_noop;
0054         x86_platform.set_wallclock = set_rtc_noop;
0055     }
0056 }
0057 
0058 /*
0059  * The platform setup functions are preset with the default functions
0060  * for standard PC hardware.
0061  */
0062 struct x86_init_ops x86_init __initdata = {
0063 
0064     .resources = {
0065         .probe_roms     = probe_roms,
0066         .reserve_resources  = reserve_standard_io_resources,
0067         .memory_setup       = e820__memory_setup_default,
0068     },
0069 
0070     .mpparse = {
0071         .setup_ioapic_ids   = x86_init_noop,
0072         .find_smp_config    = default_find_smp_config,
0073         .get_smp_config     = default_get_smp_config,
0074     },
0075 
0076     .irqs = {
0077         .pre_vector_init    = init_ISA_irqs,
0078         .intr_init      = native_init_IRQ,
0079         .intr_mode_select   = apic_intr_mode_select,
0080         .intr_mode_init     = apic_intr_mode_init,
0081         .create_pci_msi_domain  = native_create_pci_msi_domain,
0082     },
0083 
0084     .oem = {
0085         .arch_setup     = x86_init_noop,
0086         .banner         = default_banner,
0087     },
0088 
0089     .paging = {
0090         .pagetable_init     = native_pagetable_init,
0091     },
0092 
0093     .timers = {
0094         .setup_percpu_clockev   = setup_boot_APIC_clock,
0095         .timer_init     = hpet_time_init,
0096         .wallclock_init     = x86_wallclock_init,
0097     },
0098 
0099     .iommu = {
0100         .iommu_init     = iommu_init_noop,
0101     },
0102 
0103     .pci = {
0104         .init           = x86_default_pci_init,
0105         .init_irq       = x86_default_pci_init_irq,
0106         .fixup_irqs     = x86_default_pci_fixup_irqs,
0107     },
0108 
0109     .hyper = {
0110         .init_platform      = x86_init_noop,
0111         .guest_late_init    = x86_init_noop,
0112         .x2apic_available   = bool_x86_init_noop,
0113         .msi_ext_dest_id    = bool_x86_init_noop,
0114         .init_mem_mapping   = x86_init_noop,
0115         .init_after_bootmem = x86_init_noop,
0116     },
0117 
0118     .acpi = {
0119         .set_root_pointer   = x86_default_set_root_pointer,
0120         .get_root_pointer   = x86_default_get_root_pointer,
0121         .reduced_hw_early_init  = acpi_generic_reduced_hw_init,
0122     },
0123 };
0124 
0125 struct x86_cpuinit_ops x86_cpuinit = {
0126     .early_percpu_clock_init    = x86_init_noop,
0127     .setup_percpu_clockev       = setup_secondary_APIC_clock,
0128 };
0129 
0130 static void default_nmi_init(void) { };
0131 
0132 static void enc_status_change_prepare_noop(unsigned long vaddr, int npages, bool enc) { }
0133 static bool enc_status_change_finish_noop(unsigned long vaddr, int npages, bool enc) { return false; }
0134 static bool enc_tlb_flush_required_noop(bool enc) { return false; }
0135 static bool enc_cache_flush_required_noop(void) { return false; }
0136 
0137 struct x86_platform_ops x86_platform __ro_after_init = {
0138     .calibrate_cpu          = native_calibrate_cpu_early,
0139     .calibrate_tsc          = native_calibrate_tsc,
0140     .get_wallclock          = mach_get_cmos_time,
0141     .set_wallclock          = mach_set_rtc_mmss,
0142     .iommu_shutdown         = iommu_shutdown_noop,
0143     .is_untracked_pat_range     = is_ISA_range,
0144     .nmi_init           = default_nmi_init,
0145     .get_nmi_reason         = default_get_nmi_reason,
0146     .save_sched_clock_state     = tsc_save_sched_clock_state,
0147     .restore_sched_clock_state  = tsc_restore_sched_clock_state,
0148     .hyper.pin_vcpu         = x86_op_int_noop,
0149 
0150     .guest = {
0151         .enc_status_change_prepare = enc_status_change_prepare_noop,
0152         .enc_status_change_finish  = enc_status_change_finish_noop,
0153         .enc_tlb_flush_required    = enc_tlb_flush_required_noop,
0154         .enc_cache_flush_required  = enc_cache_flush_required_noop,
0155     },
0156 };
0157 
0158 EXPORT_SYMBOL_GPL(x86_platform);
0159 
0160 struct x86_apic_ops x86_apic_ops __ro_after_init = {
0161     .io_apic_read   = native_io_apic_read,
0162     .restore    = native_restore_boot_irq_mode,
0163 };