/* The generic i8259_irq() make the kernel hang on booting. Since we cannot get the irq via the IRR directly, we access the ISR instead.  */
int mach_i8259_irq(void)
/* The generic i8259_irq() make the kernel hang on booting. Since we cannot get the irq via the IRR directly, we access the ISR instead.  */
int mach_i8259_irq(void)
{
	int irq, isr;
	irq = -1;
	if ((LOONGSON_INTISR & LOONGSON_INTEN) & LOONGSON_INT_BIT_INT0) {
		spin_lock(&i8259A_lock);
		isr = inb(PIC_MASTER_CMD) &
			~inb(PIC_MASTER_IMR) & ~(1 << PIC_CASCADE_IR);
		if (!isr)
			isr = (inb(PIC_SLAVE_CMD) & ~inb(PIC_SLAVE_IMR)) << 8;
		irq = ffs(isr) - 1;
		if (unlikely(irq == 7)) {
			outb(0x0B, PIC_MASTER_ISR);
			if (~inb(PIC_MASTER_ISR) & 0x80)
				irq = -1;
		}
		spin_unlock(&i8259A_lock);
	}
	return irq;
}