/* set irq level. If an edge is detected, then the IRR is set to 1  */
static int pic_set_irq1(struct kvm_kpic_state *s, int irq, int level)
/* set irq level. If an edge is detected, then the IRR is set to 1  */
static int pic_set_irq1(struct kvm_kpic_state *s, int irq, int level)
{
	int mask, ret = 1;
	mask = 1 << irq;
	if (s->elcr & mask)
		if (level) {
			ret = !(s->irr & mask);
			s->irr |= mask;
			s->last_irr |= mask;
		} else {
			s->irr &= ~mask;
			s->last_irr &= ~mask;
		}
	else
		if (level) {
			if ((s->last_irr & mask) == 0) {
				ret = !(s->irr & mask);
				s->irr |= mask;
			}
			s->last_irr |= mask;
		} else
			s->last_irr &= ~mask;
	return (s->imr & mask) ? -1 : ret;
}