~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/i8259.c

Tags: upstream-0.9.0+20070816
ImportĀ upstreamĀ versionĀ 0.9.0+20070816

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    uint8_t rotate_on_auto_eoi;
45
45
    uint8_t special_fully_nested_mode;
46
46
    uint8_t init4; /* true if 4 byte init */
 
47
    uint8_t single_mode; /* true if slave pic is not initialized */
47
48
    uint8_t elcr; /* PIIX edge/trigger selection*/
48
49
    uint8_t elcr_mask;
49
50
    PicState2 *pics_state;
53
54
    /* 0 is master pic, 1 is slave pic */
54
55
    /* XXX: better separation between the two pics */
55
56
    PicState pics[2];
56
 
    IRQRequestFunc *irq_request;
 
57
    qemu_irq parent_irq;
57
58
    void *irq_request_opaque;
58
59
    /* IOAPIC callback support */
59
60
    SetIRQFunc *alt_irq_func;
159
160
        }
160
161
        printf("pic: cpu_interrupt\n");
161
162
#endif
162
 
        s->irq_request(s->irq_request_opaque, 1);
 
163
        qemu_irq_raise(s->parent_irq);
163
164
    }
164
165
 
165
166
/* all targets should do this rather than acking the IRQ in the cpu */
166
167
#if defined(TARGET_MIPS)
167
168
    else {
168
 
        s->irq_request(s->irq_request_opaque, 0);
 
169
        qemu_irq_lower(s->parent_irq);
169
170
    }
170
171
#endif
171
172
}
174
175
int64_t irq_time[16];
175
176
#endif
176
177
 
177
 
void pic_set_irq_new(void *opaque, int irq, int level)
 
178
void i8259_set_irq(void *opaque, int irq, int level)
178
179
{
179
180
    PicState2 *s = opaque;
180
181
 
181
182
#if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT)
182
183
    if (level != irq_level[irq]) {
183
184
#if defined(DEBUG_PIC)
184
 
        printf("pic_set_irq: irq=%d level=%d\n", irq, level);
 
185
        printf("i8259_set_irq: irq=%d level=%d\n", irq, level);
185
186
#endif
186
187
        irq_level[irq] = level;
187
188
#ifdef DEBUG_IRQ_COUNT
202
203
    pic_update_irq(s);
203
204
}
204
205
 
205
 
/* obsolete function */
206
 
void pic_set_irq(int irq, int level)
207
 
{
208
 
    pic_set_irq_new(isa_pic, irq, level);
209
 
}
210
 
 
211
206
/* acknowledge interrupt 'irq' */
212
207
static inline void pic_intack(PicState *s, int irq)
213
208
{
278
273
    s->rotate_on_auto_eoi = 0;
279
274
    s->special_fully_nested_mode = 0;
280
275
    s->init4 = 0;
 
276
    s->single_mode = 0;
281
277
    /* Note: ELCR is not reset */
282
278
}
283
279
 
295
291
            /* init */
296
292
            pic_reset(s);
297
293
            /* deassert a pending interrupt */
298
 
            s->pics_state->irq_request(s->pics_state->irq_request_opaque, 0);
 
294
            qemu_irq_lower(s->pics_state->parent_irq);
299
295
            s->init_state = 1;
300
296
            s->init4 = val & 1;
301
 
            if (val & 0x02)
302
 
                hw_error("single mode not supported");
 
297
            s->single_mode = val & 2;
303
298
            if (val & 0x08)
304
299
                hw_error("level sensitive irq not supported");
305
300
        } else if (val & 0x08) {
356
351
            break;
357
352
        case 1:
358
353
            s->irq_base = val & 0xf8;
359
 
            s->init_state = 2;
 
354
            s->init_state = s->single_mode ? (s->init4 ? 3 : 0) : 2;
360
355
            break;
361
356
        case 2:
362
357
            if (s->init4) {
468
463
    qemu_put_8s(f, &s->rotate_on_auto_eoi);
469
464
    qemu_put_8s(f, &s->special_fully_nested_mode);
470
465
    qemu_put_8s(f, &s->init4);
 
466
    qemu_put_8s(f, &s->single_mode);
471
467
    qemu_put_8s(f, &s->elcr);
472
468
}
473
469
 
492
488
    qemu_get_8s(f, &s->rotate_on_auto_eoi);
493
489
    qemu_get_8s(f, &s->special_fully_nested_mode);
494
490
    qemu_get_8s(f, &s->init4);
 
491
    qemu_get_8s(f, &s->single_mode);
495
492
    qemu_get_8s(f, &s->elcr);
496
493
    return 0;
497
494
}
543
540
#endif
544
541
}
545
542
 
546
 
PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque)
 
543
qemu_irq *i8259_init(qemu_irq parent_irq)
547
544
{
548
545
    PicState2 *s;
 
546
 
549
547
    s = qemu_mallocz(sizeof(PicState2));
550
548
    if (!s)
551
549
        return NULL;
553
551
    pic_init1(0xa0, 0x4d1, &s->pics[1]);
554
552
    s->pics[0].elcr_mask = 0xf8;
555
553
    s->pics[1].elcr_mask = 0xde;
556
 
    s->irq_request = irq_request;
557
 
    s->irq_request_opaque = irq_request_opaque;
 
554
    s->parent_irq = parent_irq;
558
555
    s->pics[0].pics_state = s;
559
556
    s->pics[1].pics_state = s;
560
 
    return s;
 
557
    isa_pic = s;
 
558
    return qemu_allocate_irqs(i8259_set_irq, s, 16);
561
559
}
562
560
 
563
561
void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,