/* Don't check I/O APIC IDs for some xAPIC systems.  They have * no meaning without the serial APIC bus. */ if (NO_IOAPIC_CHECK) continue; 
static void __init setup_ioapic_ids_from_mpc(void){	union IO_APIC_reg_00 reg_00;	physid_mask_t phys_id_present_map;	int apic;	int i;	unsigned char old_id;	unsigned long flags;	/*	 * This is broken; anything with a real cpu count has to	 * circumvent this idiocy regardless.	 */	phys_id_present_map = ioapic_phys_id_map(phys_cpu_present_map);	/*	 * Set the IOAPIC ID to the value stored in the MPC table.	 */	for (apic = 0; apic < nr_ioapics; apic++) {		/* Read the register 0 value */		spin_lock_irqsave(&ioapic_lock, flags);		reg_00.raw = io_apic_read(apic, 0);		spin_unlock_irqrestore(&ioapic_lock, flags);				old_id = mp_ioapics[apic].mpc_apicid;		if (mp_ioapics[apic].mpc_apicid >= get_physical_broadcast()) {			printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n",				apic, mp_ioapics[apic].mpc_apicid);			printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",				reg_00.bits.ID);			mp_ioapics[apic].mpc_apicid = reg_00.bits.ID;		}		/* Don't check I/O APIC IDs for some xAPIC systems.  They have		 * no meaning without the serial APIC bus. */		if (NO_IOAPIC_CHECK)			continue;		/*		 * Sanity check, is the ID really free? Every APIC in a		 * system must have a unique ID or we get lots of nice		 * 'stuck on smp_invalidate_needed IPI wait' messages.		 */		if (check_apicid_used(phys_id_present_map,					mp_ioapics[apic].mpc_apicid)) {			printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",				apic, mp_ioapics[apic].mpc_apicid);			for (i = 0; i < get_physical_broadcast(); i++)				if (!physid_isset(i, phys_id_present_map))					break;			if (i >= get_physical_broadcast())				panic("Max APIC ID exceeded!\n");			printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",				i);			physid_set(i, phys_id_present_map);			mp_ioapics[apic].mpc_apicid = i;		} else {			physid_mask_t tmp;			tmp = apicid_to_cpu_present(mp_ioapics[apic].mpc_apicid);			apic_printk(APIC_VERBOSE, "Setting %d in the "					"phys_id_present_map\n",					mp_ioapics[apic].mpc_apicid);			physids_or(phys_id_present_map, phys_id_present_map, tmp);		}		/*		 * We need to adjust the IRQ routing table		 * if the ID changed.		 */		if (old_id != mp_ioapics[apic].mpc_apicid)			for (i = 0; i < mp_irq_entries; i++)				if (mp_irqs[i].mpc_dstapic == old_id)					mp_irqs[i].mpc_dstapic						= mp_ioapics[apic].mpc_apicid;		/*		 * Read the right value from the MPC table and		 * write it into the ID register.	 	 */		apic_printk(APIC_VERBOSE, KERN_INFO			"...changing IO-APIC physical APIC ID to %d ...",			mp_ioapics[apic].mpc_apicid);		reg_00.bits.ID = mp_ioapics[apic].mpc_apicid;		spin_lock_irqsave(&ioapic_lock, flags);		io_apic_write(apic, 0, reg_00.raw);		spin_unlock_irqrestore(&ioapic_lock, flags);		/*		 * Sanity check		 */		spin_lock_irqsave(&ioapic_lock, flags);		reg_00.raw = io_apic_read(apic, 0);		spin_unlock_irqrestore(&ioapic_lock, flags);		if (reg_00.bits.ID != mp_ioapics[apic].mpc_apicid)			printk("could not set ID!\n");		else			apic_printk(APIC_VERBOSE, " ok.\n");	}}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ca05fea6db5259c6d62e517c41d448a4249175f4/io_apic.c/buggy/arch/i386/kernel/io_apic.c