Exemplo n.º 1
0
int
acpi_map_lsapic(acpi_handle handle, int *pcpu)
{
	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
	union acpi_object *obj;
	struct acpi_table_lsapic *lsapic;
	cpumask_t tmp_map;
	long 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(*lsapic)) {
		acpi_os_free(buffer.pointer);
		return -EINVAL;
	}

	lsapic = (struct acpi_table_lsapic *)obj->buffer.pointer;

	if ((lsapic->header.type != ACPI_MADT_LSAPIC) ||
	    (!lsapic->flags.enabled)) {
		acpi_os_free(buffer.pointer);
		return -EINVAL;
	}

	physid = ((lsapic->id <<8) | (lsapic->eid));

	acpi_os_free(buffer.pointer);
	buffer.length = ACPI_ALLOCATE_BUFFER;
	buffer.pointer = NULL;

	cpus_complement(tmp_map, cpu_present_map);
	cpu = first_cpu(tmp_map);
	if(cpu >= NR_CPUS)
		return -EINVAL;

	acpi_map_cpu2node(handle, cpu, physid);

 	cpu_set(cpu, cpu_present_map);
	ia64_cpu_to_sapicid[cpu] = physid;
	ia64_acpiid_to_sapicid[lsapic->acpi_id] = ia64_cpu_to_sapicid[cpu];

	*pcpu = cpu;
	return(0);
}
Exemplo n.º 2
0
static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
{
	int cpu;
	cpumask_t tmp_map;
	char *bootup_cpu = "";

	if (!(m->mpc_cpuflag & CPU_ENABLED)) {
		disabled_cpus++;
		return;
	}
	if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
		bootup_cpu = " (Bootup-CPU)";
		boot_cpu_id = m->mpc_apicid;
	}

	printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu);

	if (num_processors >= NR_CPUS) {
		printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
			" Processor ignored.\n", NR_CPUS);
		return;
	}

	num_processors++;
	cpus_complement(tmp_map, cpu_present_map);
	cpu = first_cpu(tmp_map);

	physid_set(m->mpc_apicid, phys_cpu_present_map);
 	if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
 		/*
		 * x86_bios_cpu_apicid is required to have processors listed
 		 * in same order as logical cpu numbers. Hence the first
 		 * entry is BSP, and so on.
 		 */
		cpu = 0;
 	}
	/* are we being called early in kernel startup? */
	if (x86_cpu_to_apicid_early_ptr) {
		u16 *cpu_to_apicid = x86_cpu_to_apicid_early_ptr;
		u16 *bios_cpu_apicid = x86_bios_cpu_apicid_early_ptr;

		cpu_to_apicid[cpu] = m->mpc_apicid;
		bios_cpu_apicid[cpu] = m->mpc_apicid;
	} else {
		per_cpu(x86_cpu_to_apicid, cpu) = m->mpc_apicid;
		per_cpu(x86_bios_cpu_apicid, cpu) = m->mpc_apicid;
	}

	cpu_set(cpu, cpu_possible_map);
	cpu_set(cpu, cpu_present_map);
}
Exemplo n.º 3
0
int acpi_map_lsapic(acpi_handle handle, int *pcpu)
{
	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
	union acpi_object *obj;
	struct acpi_madt_local_sapic *lsapic;
	cpumask_t tmp_map;
	long 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)
	{
		kfree(buffer.pointer);
		return -EINVAL;
	}

	lsapic = (struct acpi_madt_local_sapic *)obj->buffer.pointer;

	if ((lsapic->header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) ||
	    (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))) {
		kfree(buffer.pointer);
		return -EINVAL;
	}

	physid = ((lsapic->id << 8) | (lsapic->eid));

	kfree(buffer.pointer);
	buffer.length = ACPI_ALLOCATE_BUFFER;
	buffer.pointer = NULL;

	cpus_complement(tmp_map, cpu_present_map);
	cpu = first_cpu(tmp_map);
	if (cpu >= NR_CPUS)
		return -EINVAL;

	acpi_map_cpu2node(handle, cpu, physid);

	cpu_set(cpu, cpu_present_map);
	ia64_cpu_to_sapicid[cpu] = physid;

	*pcpu = cpu;
	return (0);
}
Exemplo n.º 4
0
void __cpuinit generic_processor_info(int apicid, int version)
{
    int cpu;
    cpumask_t tmp_map;

    if (num_processors >= NR_CPUS) {
        printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
               " Processor ignored.\n", NR_CPUS);
        return;
    }

    num_processors++;
    cpus_complement(tmp_map, cpu_present_map);
    cpu = first_cpu(tmp_map);

    physid_set(apicid, phys_cpu_present_map);
    if (apicid == boot_cpu_physical_apicid) {
        /*
         * x86_bios_cpu_apicid is required to have processors listed
         * in same order as logical cpu numbers. Hence the first
         * entry is BSP, and so on.
         */
        cpu = 0;
    }
    if (apicid > max_physical_apicid)
        max_physical_apicid = apicid;

    /* are we being called early in kernel startup? */
    if (early_per_cpu_ptr(x86_cpu_to_apicid)) {
        u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid);
        u16 *bios_cpu_apicid = early_per_cpu_ptr(x86_bios_cpu_apicid);

        cpu_to_apicid[cpu] = apicid;
        bios_cpu_apicid[cpu] = apicid;
    } else {
        per_cpu(x86_cpu_to_apicid, cpu) = apicid;
        per_cpu(x86_bios_cpu_apicid, cpu) = apicid;
    }

    cpu_set(cpu, cpu_possible_map);
    cpu_set(cpu, cpu_present_map);
}
Exemplo n.º 5
0
static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
{
	int cpu;
	unsigned char ver;
	cpumask_t tmp_map;

	if (!(m->mpc_cpuflag & CPU_ENABLED)) {
		disabled_cpus++;
		return;
	}

	printk(KERN_INFO "Processor #%d %d:%d APIC version %d\n",
		m->mpc_apicid,
	       (m->mpc_cpufeature & CPU_FAMILY_MASK)>>8,
	       (m->mpc_cpufeature & CPU_MODEL_MASK)>>4,
		m->mpc_apicver);

	if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
		Dprintk("    Bootup CPU\n");
		boot_cpu_id = m->mpc_apicid;
	}
	if (num_processors >= NR_CPUS) {
		printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
			" Processor ignored.\n", NR_CPUS);
		return;
	}

	num_processors++;
	cpus_complement(tmp_map, cpu_present_map);
	cpu = first_cpu(tmp_map);

#if MAX_APICS < 255	
	if ((int)m->mpc_apicid > MAX_APICS) {
		printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n",
			m->mpc_apicid, MAX_APICS);
		return;
	}
#endif
	ver = m->mpc_apicver;

	physid_set(m->mpc_apicid, phys_cpu_present_map);
	/*
	 * Validate version
	 */
	if (ver == 0x0) {
		printk(KERN_ERR "BIOS bug, APIC version is 0 for CPU#%d! fixing up to 0x10. (tell your hw vendor)\n", m->mpc_apicid);
		ver = 0x10;
	}
	apic_version[m->mpc_apicid] = ver;
 	if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
 		/*
 		 * bios_cpu_apicid is required to have processors listed
 		 * in same order as logical cpu numbers. Hence the first
 		 * entry is BSP, and so on.
 		 */
		cpu = 0;
 	}
	bios_cpu_apicid[cpu] = m->mpc_apicid;
	x86_cpu_to_apicid[cpu] = m->mpc_apicid;

	cpu_set(cpu, cpu_possible_map);
	cpu_set(cpu, cpu_present_map);
}
Exemplo n.º 6
0
/**
 * Parses an MP table CPU entry.
 */
static void __init
MP_processor_info(struct mpc_config_processor *m)
{
    int cpu;
    int is_bp;
    unsigned char ver;
    cpumask_t tmp_map;

    if (!(m->mpc_cpuflag & CPU_ENABLED)) {
        printk(KERN_WARNING "A disabled CPU was encountered\n");
        return;
    }

    /* Count the new CPU */
    if (++num_cpus > NR_CPUS)
        panic("NR_CPUS limit of %i reached.\n", NR_CPUS);

    /*
     * Determine if this is the bootstrap processor...
     * the one responsible for booting the other CPUs.
     */
    is_bp = (m->mpc_cpuflag & CPU_BOOTPROCESSOR);

    /*
     * Assign a logical CPU ID.
     * The bootstrap CPU is always assigned logical ID 0.
     * All other CPUs are assigned the lowest ID available.
     */
    if (is_bp) {
        cpu = 0;
    } else {
        cpus_complement(tmp_map, cpu_present_map);
        cpu = first_cpu(tmp_map);
    }

    /* Validate APIC version, fixing up if necessary. */
    ver = m->mpc_apicver;
    if (ver == 0x0) {
        printk(KERN_ERR "BIOS bug, APIC version is 0 for PhysCPU#%d! "
               "fixing up to 0x10. (tell your hw vendor)\n",
               m->mpc_apicid);
        ver = 0x10;
    }

    /* Remember the APIC's version */
    apic_version[m->mpc_apicid] = ver;

    /* Add the CPU to the map of physical CPU IDs present. */
    physid_set(m->mpc_apicid, phys_cpu_present_map);

    /* Remember the physical CPU ID of the bootstrap CPU. */
    if (is_bp)
        boot_phys_cpu_id = m->mpc_apicid;

    /* Add the CPU to the map of logical CPU IDs present. */
    cpu_set(cpu, cpu_present_map);

    /* Store ID information. */
    cpu_info[cpu].logical_id   = cpu;
    cpu_info[cpu].physical_id  = m->mpc_apicid;
    cpu_info[cpu].arch.apic_id = m->mpc_apicid;

    printk(KERN_DEBUG
           "Physical CPU #%d -> Logical CPU #%d, %d:%d APIC version %d%s\n",
           m->mpc_apicid,
           cpu,
           (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
           (m->mpc_cpufeature & CPU_MODEL_MASK)  >> 4,
           ver,
           is_bp ? " (Bootstrap CPU)" : "");
}