📄 acpi.c
字号:
/* * acpi.c - Architecture-Specific Low-Level ACPI Support * * Copyright (C) 1999 VA Linux Systems * Copyright (C) 1999,2000 Walt Drummond <drummond@valinux.com> * Copyright (C) 2000, 2002-2003 Hewlett-Packard Co. * David Mosberger-Tang <davidm@hpl.hp.com> * Copyright (C) 2000 Intel Corp. * Copyright (C) 2000,2001 J.I. Lee <jung-ik.lee@intel.com> * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001 Jenna Hall <jenna.s.hall@intel.com> * Copyright (C) 2001 Takayoshi Kochi <t-kochi@bq.jp.nec.com> * Copyright (C) 2002 Erich Focht <efocht@ess.nec.de> * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */#include <linux/config.h>#include <linux/module.h>#include <linux/init.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/smp.h>#include <linux/string.h>#include <linux/types.h>#include <linux/irq.h>#include <linux/acpi.h>#include <linux/efi.h>#include <linux/mmzone.h>#include <asm/io.h>#include <asm/iosapic.h>#include <asm/machvec.h>#include <asm/page.h>#include <asm/system.h>#include <asm/numa.h>#include <asm/sal.h>#include <asm/hw_irq.h>#ifdef XEN#include <xen/errno.h>#include <xen/nodemask.h>#endif#define BAD_MADT_ENTRY(entry, end) ( \ (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ ((acpi_table_entry_header *)entry)->length != sizeof(*entry))#define PREFIX "ACPI: "void (*pm_idle) (void);EXPORT_SYMBOL(pm_idle);void (*pm_power_off) (void);unsigned char acpi_kbd_controller_present = 1;unsigned char acpi_legacy_devices;const char *acpi_get_sysname (void){/* #ifdef CONFIG_IA64_GENERIC */ unsigned long rsdp_phys; struct acpi20_table_rsdp *rsdp; struct acpi_table_xsdt *xsdt; struct acpi_table_header *hdr; rsdp_phys = acpi_find_rsdp(); if (!rsdp_phys) { printk(KERN_ERR "ACPI 2.0 RSDP not found, default to \"dig\"\n"); return "dig"; } rsdp = (struct acpi20_table_rsdp *) __va(rsdp_phys); if (strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1)) { printk(KERN_ERR "ACPI 2.0 RSDP signature incorrect, default to \"dig\"\n"); return "dig"; } xsdt = (struct acpi_table_xsdt *) __va(rsdp->xsdt_address); hdr = &xsdt->header; if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1)) { printk(KERN_ERR "ACPI 2.0 XSDT signature incorrect, default to \"dig\"\n"); return "dig"; } if (!strcmp(hdr->oem_id, "HP")) { return "hpzx1"; } else if (!strcmp(hdr->oem_id, "SGI")) { return "sn2"; } return "dig";/*#else# if defined (CONFIG_IA64_HP_SIM) return "hpsim";# elif defined (CONFIG_IA64_HP_ZX1) return "hpzx1";# elif defined (CONFIG_IA64_SGI_SN2) return "sn2";# elif defined (CONFIG_IA64_DIG) return "dig";# else# error Unknown platform. Fix acpi.c.# endif#endif*/}#ifdef CONFIG_ACPI_BOOT#define ACPI_MAX_PLATFORM_INTERRUPTS 256/* Array to record platform interrupt vectors for generic interrupt routing. */int platform_intr_list[ACPI_MAX_PLATFORM_INTERRUPTS] = { [0 ... ACPI_MAX_PLATFORM_INTERRUPTS - 1] = -1};enum acpi_irq_model_id acpi_irq_model = ACPI_IRQ_MODEL_IOSAPIC;/* * Interrupt routing API for device drivers. Provides interrupt vector for * a generic platform event. Currently only CPEI is implemented. */intacpi_request_vector (u32 int_type){ int vector = -1; if (int_type < ACPI_MAX_PLATFORM_INTERRUPTS) { /* corrected platform error interrupt */ vector = platform_intr_list[int_type]; } else printk(KERN_ERR "acpi_request_vector(): invalid interrupt type\n"); return vector;}char *__acpi_map_table (unsigned long phys_addr, unsigned long size){ return __va(phys_addr);}/* -------------------------------------------------------------------------- Boot-time Table Parsing -------------------------------------------------------------------------- */static int total_cpus __initdata;static int available_cpus __initdata;struct acpi_table_madt * acpi_madt __initdata;static u8 has_8259;static int __initacpi_parse_lapic_addr_ovr ( acpi_table_entry_header *header, const unsigned long end){ struct acpi_table_lapic_addr_ovr *lapic; lapic = (struct acpi_table_lapic_addr_ovr *) header; if (BAD_MADT_ENTRY(lapic, end)) return -EINVAL; acpi_table_print_madt_entry(header); if (lapic->address) { iounmap((void *) ipi_base_addr); ipi_base_addr = (void __iomem *) ioremap(lapic->address, 0); } return 0;}static int __initacpi_parse_lsapic (acpi_table_entry_header *header, const unsigned long end){ struct acpi_table_lsapic *lsapic; lsapic = (struct acpi_table_lsapic *) header; if (BAD_MADT_ENTRY(lsapic, end)) return -EINVAL; acpi_table_print_madt_entry(header); printk(KERN_INFO "CPU %d (0x%04x)", total_cpus, (lsapic->id << 8) | lsapic->eid); if (!lsapic->flags.enabled) printk(" disabled"); else { printk(" enabled");#ifdef CONFIG_SMP if (available_cpus < NR_CPUS) { smp_boot_data.cpu_phys_id[available_cpus] = (lsapic->id << 8) | lsapic->eid; if (hard_smp_processor_id() == (unsigned int) smp_boot_data.cpu_phys_id[available_cpus]) printk(" (BSP)"); ++available_cpus; } else { printk(" - however, ignored..."); }#else ++available_cpus;#endif } printk("\n"); total_cpus++; return 0;}static int __initacpi_parse_lapic_nmi (acpi_table_entry_header *header, const unsigned long end){ struct acpi_table_lapic_nmi *lacpi_nmi; lacpi_nmi = (struct acpi_table_lapic_nmi*) header; if (BAD_MADT_ENTRY(lacpi_nmi, end)) return -EINVAL; acpi_table_print_madt_entry(header); /* TBD: Support lapic_nmi entries */ return 0;}static int __initacpi_parse_iosapic (acpi_table_entry_header *header, const unsigned long end){ struct acpi_table_iosapic *iosapic; iosapic = (struct acpi_table_iosapic *) header; if (BAD_MADT_ENTRY(iosapic, end)) return -EINVAL; acpi_table_print_madt_entry(header); iosapic_init(iosapic->address, iosapic->global_irq_base); return 0;}static int __initacpi_parse_plat_int_src ( acpi_table_entry_header *header, const unsigned long end){ struct acpi_table_plat_int_src *plintsrc; int vector; plintsrc = (struct acpi_table_plat_int_src *) header; if (BAD_MADT_ENTRY(plintsrc, end)) return -EINVAL; acpi_table_print_madt_entry(header); /* * Get vector assignment for this interrupt, set attributes, * and program the IOSAPIC routing table. */ vector = iosapic_register_platform_intr(plintsrc->type, plintsrc->global_irq, plintsrc->iosapic_vector, plintsrc->eid, plintsrc->id, (plintsrc->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, (plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); platform_intr_list[plintsrc->type] = vector; return 0;}static int __initacpi_parse_int_src_ovr ( acpi_table_entry_header *header, const unsigned long end){ struct acpi_table_int_src_ovr *p; p = (struct acpi_table_int_src_ovr *) header; if (BAD_MADT_ENTRY(p, end)) return -EINVAL; acpi_table_print_madt_entry(header); iosapic_override_isa_irq(p->bus_irq, p->global_irq, (p->flags.polarity == 1) ? IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, (p->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL); return 0;}static int __initacpi_parse_nmi_src (acpi_table_entry_header *header, const unsigned long end){ struct acpi_table_nmi_src *nmi_src; nmi_src = (struct acpi_table_nmi_src*) header; if (BAD_MADT_ENTRY(nmi_src, end)) return -EINVAL; acpi_table_print_madt_entry(header); /* TBD: Support nimsrc entries */ return 0;}/* Hook from generic ACPI tables.c */void __init acpi_madt_oem_check(char *oem_id, char *oem_table_id){ if (!strncmp(oem_id, "IBM", 3) && (!strncmp(oem_table_id, "SERMOW", 6))){ /* Unfortunatly ITC_DRIFT is not yet part of the * official SAL spec, so the ITC_DRIFT bit is not * set by the BIOS on this hardware. */ sal_platform_features |= IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT;#if 0 /*Start cyclone clock*/ cyclone_setup(0);#endif }}static int __initacpi_parse_madt (unsigned long phys_addr, unsigned long size){ if (!phys_addr || !size) return -EINVAL; acpi_madt = (struct acpi_table_madt *) __va(phys_addr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -