⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boot.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	outb(new >> 8, 0x4d1);}int acpi_gsi_to_irq(u32 gsi, unsigned int *irq){	*irq = gsi;	return 0;}/* * success: return IRQ number (>=0) * failure: return < 0 */int acpi_register_gsi(u32 gsi, int triggering, int polarity){	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 (triggering == 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, triggering, polarity);	}#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_CPUint acpi_map_lsapic(acpi_handle handle, int *pcpu){	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };	union acpi_object *obj;	struct acpi_madt_local_apic *lapic;	cpumask_t tmp_map, new_map;	u8 physid;	int cpu;	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))		return -EINVAL;	if (!buffer.length || !buffer.pointer)		return -EINVAL;	obj = buffer.pointer;	if (obj->type != ACPI_TYPE_BUFFER ||	    obj->buffer.length < sizeof(*lapic)) {		kfree(buffer.pointer);		return -EINVAL;	}	lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;	if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||	    !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {		kfree(buffer.pointer);		return -EINVAL;	}	physid = lapic->id;	kfree(buffer.pointer);	buffer.length = ACPI_ALLOCATE_BUFFER;	buffer.pointer = NULL;	tmp_map = cpu_present_map;	mp_register_lapic(physid, lapic->lapic_flags & ACPI_MADT_ENABLED);	/*	 * If mp_register_lapic successfully generates a new logical cpu	 * number, then the following will get us exactly what was mapped	 */	cpus_andnot(new_map, cpu_present_map, tmp_map);	if (cpus_empty(new_map)) {		printk ("Unable to map lapic to logical cpu number\n");		return -EINVAL;	}	cpu = first_cpu(new_map);	*pcpu = cpu;	return 0;}EXPORT_SYMBOL(acpi_map_lsapic);int acpi_unmap_lsapic(int cpu){	per_cpu(x86_cpu_to_apicid, cpu) = -1;	cpu_clear(cpu, cpu_present_map);	num_processors--;	return (0);}EXPORT_SYMBOL(acpi_unmap_lsapic);#endif				/* CONFIG_ACPI_HOTPLUG_CPU */int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base){	/* TBD */	return -EINVAL;}EXPORT_SYMBOL(acpi_register_ioapic);int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base){	/* TBD */	return -EINVAL;}EXPORT_SYMBOL(acpi_unregister_ioapic);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 *)(phys_to_virt(start) + offset), "RSD PTR ", sig_len))			continue;		return (start + offset);	}	return 0;}static int __init acpi_parse_sbf(struct acpi_table_header *table){	struct acpi_table_boot *sb;	sb = (struct acpi_table_boot *)table;	if (!sb) {		printk(KERN_WARNING PREFIX "Unable to map SBF\n");		return -ENODEV;	}	sbf_port = sb->cmos_index;	/* Save CMOS port */	return 0;}#ifdef CONFIG_HPET_TIMER#include <asm/hpet.h>static struct __initdata resource *hpet_res;static int __init acpi_parse_hpet(struct acpi_table_header *table){	struct acpi_table_hpet *hpet_tbl;	hpet_tbl = (struct acpi_table_hpet *)table;	if (!hpet_tbl) {		printk(KERN_WARNING PREFIX "Unable to map HPET\n");		return -ENODEV;	}	if (hpet_tbl->address.space_id != ACPI_SPACE_MEM) {		printk(KERN_WARNING PREFIX "HPET timers must be located in "		       "memory.\n");		return -1;	}	hpet_address = hpet_tbl->address.address;	/*	 * Some broken BIOSes advertise HPET at 0x0. We really do not	 * want to allocate a resource there.	 */	if (!hpet_address) {		printk(KERN_WARNING PREFIX		       "HPET id: %#x base: %#lx is invalid\n",		       hpet_tbl->id, hpet_address);		return 0;	}#ifdef CONFIG_X86_64	/*	 * Some even more broken BIOSes advertise HPET at	 * 0xfed0000000000000 instead of 0xfed00000. Fix it up and add	 * some noise:	 */	if (hpet_address == 0xfed0000000000000UL) {		if (!hpet_force_user) {			printk(KERN_WARNING PREFIX "HPET id: %#x "			       "base: 0xfed0000000000000 is bogus\n "			       "try hpet=force on the kernel command line to "			       "fix it up to 0xfed00000.\n", hpet_tbl->id);			hpet_address = 0;			return 0;		}		printk(KERN_WARNING PREFIX		       "HPET id: %#x base: 0xfed0000000000000 fixed up "		       "to 0xfed00000.\n", hpet_tbl->id);		hpet_address >>= 32;	}#endif	printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",	       hpet_tbl->id, hpet_address);	/*	 * Allocate and initialize the HPET firmware resource for adding into	 * the resource tree during the lateinit timeframe.	 */#define HPET_RESOURCE_NAME_SIZE 9	hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);	if (!hpet_res)		return 0;	memset(hpet_res, 0, sizeof(*hpet_res));	hpet_res->name = (void *)&hpet_res[1];	hpet_res->flags = IORESOURCE_MEM;	snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",		 hpet_tbl->sequence);	hpet_res->start = hpet_address;	hpet_res->end = hpet_address + (1 * 1024) - 1;	return 0;}/* * hpet_insert_resource inserts the HPET resources used into the resource * tree. */static __init int hpet_insert_resource(void){	if (!hpet_res)		return 1;	return insert_resource(&iomem_resource, hpet_res);}late_initcall(hpet_insert_resource);#else#define	acpi_parse_hpet	NULL#endifstatic int __init acpi_parse_fadt(struct acpi_table_header *table){#ifdef CONFIG_X86_PM_TIMER	/* detect the location of the ACPI PM Timer */	if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) {		/* FADT rev. 2 */		if (acpi_gbl_FADT.xpm_timer_block.space_id !=		    ACPI_ADR_SPACE_SYSTEM_IO)			return 0;		pmtmr_ioport = acpi_gbl_FADT.xpm_timer_block.address;		/*		 * "X" fields are optional extensions to the original V1.0		 * fields, so we must selectively expand V1.0 fields if the		 * corresponding X field is zero.	 	 */		if (!pmtmr_ioport)			pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;	} else {		/* FADT rev. 1 */		pmtmr_ioport = acpi_gbl_FADT.pm_timer_block;	}	if (pmtmr_ioport)		printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n",		       pmtmr_ioport);#endif	return 0;}unsigned long __init acpi_find_rsdp(void){	unsigned long rsdp_phys = 0;	if (efi_enabled) {		if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)			return efi.acpi20;		else if (efi.acpi != EFI_INVALID_TABLE_ADDR)			return 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, 0x20000);	return rsdp_phys;}#ifdef	CONFIG_X86_LOCAL_APIC/* * Parse LAPIC entries in MADT * returns 0 on success, < 0 on error */static int __init acpi_parse_madt_lapic_entries(void){	int count;	if (!cpu_has_apic)		return -ENODEV;	/*	 * 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_TYPE_LOCAL_APIC_OVERRIDE,				  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_TYPE_LOCAL_APIC, 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_TYPE_LOCAL_APIC_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 */#ifdef	CONFIG_X86_IO_APIC/* * Parse IOAPIC related entries in MADT * returns 0 on success, < 0 on error */static int __init acpi_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 (!cpu_has_apic)		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_TYPE_IO_APIC, 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_TYPE_INTERRUPT_OVERRIDE, 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_gbl_FADT.sci_interrupt, 0, 0);	/* Fill in identity legacy mapings where no override */	mp_config_acpi_legacy_irqs();	count =	    acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE, 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 */static void __init acpi_process_madt(void){#ifdef CONFIG_X86_LOCAL_APIC	int error;	if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) {		/*		 * Parse MADT LAPIC entries		 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -