📄 boot.c
字号:
*irq = gsi; return 0;}unsigned int acpi_register_gsi(u32 gsi, int edge_level, int active_high_low){ unsigned int irq; unsigned int plat_gsi = gsi;#ifdef CONFIG_PCI /* * Make sure all (legacy) PCI IRQs are set as level-triggered. */ if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { extern void eisa_set_level_irq(unsigned int irq); if (edge_level == ACPI_LEVEL_SENSITIVE) eisa_set_level_irq(gsi); }#endif#ifdef CONFIG_X86_IO_APIC if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) { plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low); }#endif acpi_gsi_to_irq(plat_gsi, &irq); return irq;}EXPORT_SYMBOL(acpi_register_gsi);/* * ACPI based hotplug support for CPU */#ifdef CONFIG_ACPI_HOTPLUG_CPUintacpi_map_lsapic(acpi_handle handle, int *pcpu){ /* TBD */ return -EINVAL;}EXPORT_SYMBOL(acpi_map_lsapic);intacpi_unmap_lsapic(int cpu){ /* TBD */ return -EINVAL;}EXPORT_SYMBOL(acpi_unmap_lsapic);#endif /* CONFIG_ACPI_HOTPLUG_CPU */static unsigned long __initacpi_scan_rsdp ( unsigned long start, unsigned long length){ unsigned long offset = 0; unsigned long sig_len = sizeof("RSD PTR ") - 1; /* * Scan all 16-byte boundaries of the physical memory region for the * RSDP signature. */ for (offset = 0; offset < length; offset += 16) { if (strncmp((char *) (start + offset), "RSD PTR ", sig_len)) continue; return (start + offset); } return 0;}static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size){ struct acpi_table_sbf *sb; if (!phys_addr || !size) return -EINVAL; sb = (struct acpi_table_sbf *) __acpi_map_table(phys_addr, size); if (!sb) { printk(KERN_WARNING PREFIX "Unable to map SBF\n"); return -ENODEV; } sbf_port = sb->sbf_cmos; /* Save CMOS port */ return 0;}#ifdef CONFIG_HPET_TIMERstatic int __init acpi_parse_hpet(unsigned long phys, unsigned long size){ struct acpi_table_hpet *hpet_tbl; if (!phys || !size) return -EINVAL; hpet_tbl = (struct acpi_table_hpet *) __acpi_map_table(phys, size); if (!hpet_tbl) { printk(KERN_WARNING PREFIX "Unable to map HPET\n"); return -ENODEV; } if (hpet_tbl->addr.space_id != ACPI_SPACE_MEM) { printk(KERN_WARNING PREFIX "HPET timers must be located in " "memory.\n"); return -1; }#ifdef CONFIG_X86_64 vxtime.hpet_address = hpet_tbl->addr.addrl | ((long) hpet_tbl->addr.addrh << 32); printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", hpet_tbl->id, vxtime.hpet_address);#else /* X86 */ { extern unsigned long hpet_address; hpet_address = hpet_tbl->addr.addrl; printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", hpet_tbl->id, hpet_address); }#endif /* X86 */ return 0;}#else#define acpi_parse_hpet NULL#endif#ifdef CONFIG_X86_PM_TIMERextern u32 pmtmr_ioport;#endifstatic int __init acpi_parse_fadt(unsigned long phys, unsigned long size){ struct fadt_descriptor_rev2 *fadt = NULL; fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size); if(!fadt) { printk(KERN_WARNING PREFIX "Unable to map FADT\n"); return 0; }#ifdef CONFIG_ACPI_INTERPRETER /* initialize sci_int early for INT_SRC_OVR MADT parsing */ acpi_fadt.sci_int = fadt->sci_int;#endif#ifdef CONFIG_X86_PM_TIMER /* detect the location of the ACPI PM Timer */ if (fadt->revision >= FADT2_REVISION_ID) { /* FADT rev. 2 */ if (fadt->xpm_tmr_blk.address_space_id != ACPI_ADR_SPACE_SYSTEM_IO) return 0; pmtmr_ioport = fadt->xpm_tmr_blk.address; } else { /* FADT rev. 1 */ pmtmr_ioport = fadt->V1_pm_tmr_blk; } if (pmtmr_ioport) printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", pmtmr_ioport);#endif return 0;}unsigned long __initacpi_find_rsdp (void){ unsigned long rsdp_phys = 0; if (efi_enabled) { if (efi.acpi20) return __pa(efi.acpi20); else if (efi.acpi) return __pa(efi.acpi); } /* * Scan memory looking for the RSDP signature. First search EBDA (low * memory) paragraphs and then search upper memory (E0000-FFFFF). */ rsdp_phys = acpi_scan_rsdp (0, 0x400); if (!rsdp_phys) rsdp_phys = acpi_scan_rsdp (0xE0000, 0xFFFFF); return rsdp_phys;}#ifdef CONFIG_X86_LOCAL_APIC/* * Parse LAPIC entries in MADT * returns 0 on success, < 0 on error */static int __initacpi_parse_madt_lapic_entries(void){ int count; /* * Note that the LAPIC address is obtained from the MADT (32-bit value) * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). */ count = acpi_table_parse_madt(ACPI_MADT_LAPIC_ADDR_OVR, acpi_parse_lapic_addr_ovr, 0); if (count < 0) { printk(KERN_ERR PREFIX "Error parsing LAPIC address override entry\n"); return count; } mp_register_lapic_address(acpi_lapic_addr); count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic, MAX_APICS); if (!count) { printk(KERN_ERR PREFIX "No LAPIC entries present\n"); /* TBD: Cleanup to allow fallback to MPS */ return -ENODEV; } else if (count < 0) { printk(KERN_ERR PREFIX "Error parsing LAPIC entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } count = acpi_table_parse_madt(ACPI_MADT_LAPIC_NMI, acpi_parse_lapic_nmi, 0); if (count < 0) { printk(KERN_ERR PREFIX "Error parsing LAPIC NMI entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } return 0;}#endif /* CONFIG_X86_LOCAL_APIC */#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI_INTERPRETER)/* * Parse IOAPIC related entries in MADT * returns 0 on success, < 0 on error */static int __initacpi_parse_madt_ioapic_entries(void){ int count; /* * ACPI interpreter is required to complete interrupt setup, * so if it is off, don't enumerate the io-apics with ACPI. * If MPS is present, it will handle them, * otherwise the system will stay in PIC mode */ if (acpi_disabled || acpi_noirq) { return -ENODEV; } /* * if "noapic" boot option, don't look for IO-APICs */ if (skip_ioapic_setup) { printk(KERN_INFO PREFIX "Skipping IOAPIC probe " "due to 'noapic' option.\n"); return -ENODEV; } count = acpi_table_parse_madt(ACPI_MADT_IOAPIC, acpi_parse_ioapic, MAX_IO_APICS); if (!count) { printk(KERN_ERR PREFIX "No IOAPIC entries present\n"); return -ENODEV; } else if (count < 0) { printk(KERN_ERR PREFIX "Error parsing IOAPIC entry\n"); return count; } count = acpi_table_parse_madt(ACPI_MADT_INT_SRC_OVR, acpi_parse_int_src_ovr, NR_IRQ_VECTORS); if (count < 0) { printk(KERN_ERR PREFIX "Error parsing interrupt source overrides entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } /* * If BIOS did not supply an INT_SRC_OVR for the SCI * pretend we got one so we can set the SCI flags. */ if (!acpi_sci_override_gsi) acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0); /* Fill in identity legacy mapings where no override */ mp_config_acpi_legacy_irqs(); count = acpi_table_parse_madt(ACPI_MADT_NMI_SRC, acpi_parse_nmi_src, NR_IRQ_VECTORS); if (count < 0) { printk(KERN_ERR PREFIX "Error parsing NMI SRC entry\n"); /* TBD: Cleanup to allow fallback to MPS */ return count; } return 0;}#elsestatic inline int acpi_parse_madt_ioapic_entries(void){ return -1;}#endif /* !(CONFIG_X86_IO_APIC && CONFIG_ACPI_INTERPRETER) */static void __initacpi_process_madt(void){#ifdef CONFIG_X86_LOCAL_APIC int count, error; count = acpi_table_parse(ACPI_APIC, acpi_parse_madt); if (count >= 1) { /* * Parse MADT LAPIC entries */ error = acpi_parse_madt_lapic_entries(); if (!error) { acpi_lapic = 1; /* * Parse MADT IO-APIC entries */ error = acpi_parse_madt_ioapic_entries(); if (!error) { acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; acpi_irq_balance_set(NULL); acpi_ioapic = 1; smp_found_config = 1; clustered_apic_check(); } } if (error == -EINVAL) { /* * Dell Precision Workstation 410, 610 come here. */ printk(KERN_ERR PREFIX "Invalid BIOS MADT, disabling ACPI\n"); disable_acpi(); } }#endif return;}/* * acpi_boot_table_init() and acpi_boot_init() * called from setup_arch(), always. * 1. checksums all tables * 2. enumerates lapics * 3. enumerates io-apics * * acpi_table_init() is separate to allow reading SRAT without * other side effects. * * side effects of acpi_boot_init: * acpi_lapic = 1 if LAPIC found * acpi_ioapic = 1 if IOAPIC found * if (acpi_lapic && acpi_ioapic) smp_found_config = 1; * if acpi_blacklisted() acpi_disabled = 1; * acpi_irq_model=... * ... * * return value: (currently ignored) * 0: success * !0: failure */int __initacpi_boot_table_init(void){ int error; /* * If acpi_disabled, bail out * One exception: acpi=ht continues far enough to enumerate LAPICs */ if (acpi_disabled && !acpi_ht) return 1; /* * Initialize the ACPI boot-time table parser. */ error = acpi_table_init(); if (error) { disable_acpi(); return error; }#ifdef __i386__ check_acpi_pci();#endif acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); /* * blacklist may disable ACPI entirely */ error = acpi_blacklisted(); if (error) { extern int acpi_force; if (acpi_force) { printk(KERN_WARNING PREFIX "acpi=force override\n"); } else { printk(KERN_WARNING PREFIX "Disabling ACPI support\n"); disable_acpi(); return error; } } return 0;}int __init acpi_boot_init(void){ /* * If acpi_disabled, bail out * One exception: acpi=ht continues far enough to enumerate LAPICs */ if (acpi_disabled && !acpi_ht) return 1; acpi_table_parse(ACPI_BOOT, acpi_parse_sbf); /* * set sci_int and PM timer address */ acpi_table_parse(ACPI_FADT, acpi_parse_fadt); /* * Process the Multiple APIC Description Table (MADT), if present */ acpi_process_madt(); acpi_table_parse(ACPI_HPET, acpi_parse_hpet); acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -