Revision 3cbee15b hw/heathrow_pic.c
b/hw/heathrow_pic.c | ||
---|---|---|
1 | 1 |
/* |
2 |
* Heathrow PIC support (standard PowerMac PIC)
|
|
2 |
* Heathrow PIC support (OldWorld PowerMac)
|
|
3 | 3 |
* |
4 |
* Copyright (c) 2005 Fabrice Bellard |
|
4 |
* Copyright (c) 2005-2007 Fabrice Bellard |
|
5 |
* Copyright (c) 2007 Jocelyn Mayer |
|
5 | 6 |
* |
6 | 7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | 8 |
* of this software and associated documentation files (the "Software"), to deal |
... | ... | |
22 | 23 |
* THE SOFTWARE. |
23 | 24 |
*/ |
24 | 25 |
#include "vl.h" |
26 |
#include "ppc_mac.h" |
|
25 | 27 |
|
26 | 28 |
//#define DEBUG |
27 | 29 |
|
... | ... | |
34 | 36 |
|
35 | 37 |
typedef struct HeathrowPICS { |
36 | 38 |
HeathrowPIC pics[2]; |
39 |
qemu_irq *irqs; |
|
37 | 40 |
} HeathrowPICS; |
38 | 41 |
|
39 | 42 |
static inline int check_irq(HeathrowPIC *pic) |
... | ... | |
45 | 48 |
static void heathrow_pic_update(HeathrowPICS *s) |
46 | 49 |
{ |
47 | 50 |
if (check_irq(&s->pics[0]) || check_irq(&s->pics[1])) { |
48 |
cpu_interrupt(first_cpu, CPU_INTERRUPT_HARD);
|
|
51 |
qemu_irq_raise(s->irqs[0]);
|
|
49 | 52 |
} else { |
50 |
cpu_reset_interrupt(first_cpu, CPU_INTERRUPT_HARD);
|
|
53 |
qemu_irq_lower(s->irqs[0]);
|
|
51 | 54 |
} |
52 | 55 |
} |
53 | 56 |
|
... | ... | |
57 | 60 |
HeathrowPIC *pic; |
58 | 61 |
unsigned int n; |
59 | 62 |
|
63 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
60 | 64 |
value = bswap32(value); |
61 |
#ifdef DEBUG |
|
62 |
printf("pic_writel: %08x: %08x\n", |
|
63 |
addr, value); |
|
64 | 65 |
#endif |
65 | 66 |
n = ((addr & 0xfff) - 0x10) >> 4; |
67 |
#ifdef DEBUG |
|
68 |
printf("pic_writel: " PADDRX " %u: %08x\n", addr, n, value); |
|
69 |
#endif |
|
66 | 70 |
if (n >= 2) |
67 | 71 |
return; |
68 | 72 |
pic = &s->pics[n]; |
... | ... | |
110 | 114 |
} |
111 | 115 |
} |
112 | 116 |
#ifdef DEBUG |
113 |
printf("pic_readl: %08x: %08x\n", |
|
114 |
addr, value); |
|
117 |
printf("pic_readl: " PADDRX " %u: %08x\n", addr, n, value); |
|
115 | 118 |
#endif |
119 |
#ifdef TARGET_WORDS_BIGENDIAN |
|
116 | 120 |
value = bswap32(value); |
121 |
#endif |
|
117 | 122 |
return value; |
118 | 123 |
} |
119 | 124 |
|
... | ... | |
156 | 161 |
heathrow_pic_update(s); |
157 | 162 |
} |
158 | 163 |
|
159 |
qemu_irq *heathrow_pic_init(int *pmem_index) |
|
164 |
qemu_irq *heathrow_pic_init(int *pmem_index, |
|
165 |
int nb_cpus, qemu_irq **irqs) |
|
160 | 166 |
{ |
161 | 167 |
HeathrowPICS *s; |
162 | 168 |
|
163 | 169 |
s = qemu_mallocz(sizeof(HeathrowPICS)); |
164 | 170 |
s->pics[0].level_triggered = 0; |
165 | 171 |
s->pics[1].level_triggered = 0x1ff00000; |
172 |
/* only 1 CPU */ |
|
173 |
s->irqs = irqs[0]; |
|
166 | 174 |
*pmem_index = cpu_register_io_memory(0, pic_read, pic_write, s); |
175 |
|
|
167 | 176 |
return qemu_allocate_irqs(heathrow_pic_set_irq, s, 64); |
168 | 177 |
} |
Also available in: Unified diff