FreeBSD/sys/x86/x86/mp_x86.c
/*
 * Assign logical CPU IDs to local APICs.
 */
Assign logical CPU IDs to local APICs.
Assign logical CPU IDs to local APICs .
void
assign_cpu_ids(void)
{
	struct topo_node *node;
	u_int smt_mask;
	smt_mask = (1u << core_id_shift) - 1;
	mp_ncpus = 0;
	TOPO_FOREACH(node, &topo_root) {
		if (node->type != TOPO_TYPE_PU)
			continue;
		if ((node->hwid & smt_mask) != (boot_cpu_id & smt_mask))
			cpu_info[node->hwid].cpu_hyperthread = 1;
		if (resource_disabled("lapic", node->hwid)) {
			if (node->hwid != boot_cpu_id)
				cpu_info[node->hwid].cpu_disabled = 1;
			else
				printf("Cannot disable BSP, APIC ID = %d\n",
				    node->hwid);
		}
		if (!hyperthreading_allowed &&
		    cpu_info[node->hwid].cpu_hyperthread)
			cpu_info[node->hwid].cpu_disabled = 1;
		if (mp_ncpus >= MAXCPU)
			cpu_info[node->hwid].cpu_disabled = 1;
		if (cpu_info[node->hwid].cpu_disabled) {
			disabled_cpus++;
			continue;
		}
		cpu_apic_ids[mp_ncpus] = node->hwid;
		apic_cpuids[node->hwid] = mp_ncpus;
		topo_set_pu_id(node, mp_ncpus);
		mp_ncpus++;
	}
	KASSERT(mp_maxid >= mp_ncpus - 1,
	    ("%s: counters out of sync: max %d, count %d", __func__, mp_maxid,
	    mp_ncpus));
}
void assign_cpu_ids ( void ) { struct topo_node * node ; u_int smt_mask ; smt_mask = ( 1u << core_id_shift ) - 1 ; mp_ncpus = 0 ; TOPO_FOREACH ( node , & topo_root ) { if ( node -> type != TOPO_TYPE_PU ) continue ; if ( ( node -> hwid & smt_mask ) != ( boot_cpu_id & smt_mask ) ) cpu_info [ node -> hwid ] . cpu_hyperthread = 1 ; if ( resource_disabled ( " " , node -> hwid ) ) { if ( node -> hwid != boot_cpu_id ) cpu_info [ node -> hwid ] . cpu_disabled = 1 ; else printf ( " \n " , node -> hwid ) ; } if ( ! hyperthreading_allowed && cpu_info [ node -> hwid ] . cpu_hyperthread ) cpu_info [ node -> hwid ] . cpu_disabled = 1 ; if ( mp_ncpus >= MAXCPU ) cpu_info [ node -> hwid ] . cpu_disabled = 1 ; if ( cpu_info [ node -> hwid ] . cpu_disabled ) { disabled_cpus ++ ; continue ; } cpu_apic_ids [ mp_ncpus ] = node -> hwid ; apic_cpuids [ node -> hwid ] = mp_ncpus ; topo_set_pu_id ( node , mp_ncpus ) ; mp_ncpus ++ ; } KASSERT ( mp_maxid >= mp_ncpus - 1 , ( " " , __func__ , mp_maxid , mp_ncpus ) ) ; }
Assign logical CPU IDs to local APICs.
Assign logical CPU IDs to local APICs .
/*
	 * Assign CPU IDs to local APIC IDs and disable any CPUs
	 * beyond MAXCPU.  CPU 0 is always assigned to the BSP.
	 */