Revision ba3c64fb hw/slavio_serial.c
b/hw/slavio_serial.c | ||
---|---|---|
45 | 45 |
#ifdef DEBUG_SERIAL |
46 | 46 |
#define SER_DPRINTF(fmt, args...) \ |
47 | 47 |
do { printf("SER: " fmt , ##args); } while (0) |
48 |
#define pic_set_irq(irq, level) \ |
|
49 |
do { printf("SER: set_irq(%d): %d\n", (irq), (level)); pic_set_irq((irq),(level));} while (0) |
|
48 | 50 |
#else |
49 | 51 |
#define SER_DPRINTF(fmt, args...) |
50 | 52 |
#endif |
... | ... | |
174 | 176 |
slavio_serial_reset_chn(&s->chn[1]); |
175 | 177 |
} |
176 | 178 |
|
179 |
static inline void clr_rxint(ChannelState *s) |
|
180 |
{ |
|
181 |
s->rxint = 0; |
|
182 |
if (s->chn == 0) |
|
183 |
s->rregs[3] &= ~0x20; |
|
184 |
else { |
|
185 |
s->otherchn->rregs[3] &= ~4; |
|
186 |
} |
|
187 |
slavio_serial_update_irq(s); |
|
188 |
} |
|
189 |
|
|
190 |
static inline void set_rxint(ChannelState *s) |
|
191 |
{ |
|
192 |
s->rxint = 1; |
|
193 |
if (s->chn == 0) |
|
194 |
s->rregs[3] |= 0x20; |
|
195 |
else { |
|
196 |
s->otherchn->rregs[3] |= 4; |
|
197 |
} |
|
198 |
slavio_serial_update_irq(s); |
|
199 |
} |
|
200 |
|
|
201 |
static inline void clr_txint(ChannelState *s) |
|
202 |
{ |
|
203 |
s->txint = 0; |
|
204 |
if (s->chn == 0) |
|
205 |
s->rregs[3] &= ~0x10; |
|
206 |
else { |
|
207 |
s->otherchn->rregs[3] &= ~2; |
|
208 |
} |
|
209 |
slavio_serial_update_irq(s); |
|
210 |
} |
|
211 |
|
|
212 |
static inline void set_txint(ChannelState *s) |
|
213 |
{ |
|
214 |
s->txint = 1; |
|
215 |
if (s->chn == 0) |
|
216 |
s->rregs[3] |= 0x10; |
|
217 |
else { |
|
218 |
s->otherchn->rregs[3] |= 2; |
|
219 |
} |
|
220 |
slavio_serial_update_irq(s); |
|
221 |
} |
|
222 |
|
|
177 | 223 |
static void slavio_serial_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) |
178 | 224 |
{ |
179 | 225 |
SerialState *ser = opaque; |
... | ... | |
198 | 244 |
newreg |= 0x8; |
199 | 245 |
break; |
200 | 246 |
case 0x20: |
201 |
s->rxint = 0;
|
|
247 |
clr_rxint(s);
|
|
202 | 248 |
break; |
203 | 249 |
case 0x28: |
204 |
s->txint = 0; |
|
250 |
clr_txint(s); |
|
251 |
break; |
|
252 |
case 0x38: |
|
253 |
clr_rxint(s); |
|
254 |
clr_txint(s); |
|
205 | 255 |
break; |
206 | 256 |
default: |
207 | 257 |
break; |
... | ... | |
247 | 297 |
s->txint = 1; |
248 | 298 |
s->rregs[0] |= 4; // Tx buffer empty |
249 | 299 |
s->rregs[1] |= 1; // All sent |
250 |
// Interrupts reported only on channel A |
|
251 |
if (s->chn == 0) |
|
252 |
s->rregs[3] |= 0x10; |
|
253 |
else { |
|
254 |
s->otherchn->rregs[3] |= 2; |
|
255 |
} |
|
300 |
set_txint(s); |
|
256 | 301 |
slavio_serial_update_irq(s); |
257 | 302 |
} |
258 | 303 |
break; |
... | ... | |
280 | 325 |
return ret; |
281 | 326 |
case 1: |
282 | 327 |
s->rregs[0] &= ~1; |
328 |
clr_rxint(s); |
|
283 | 329 |
if (s->type == kbd) |
284 | 330 |
ret = get_queue(s); |
285 | 331 |
else |
... | ... | |
304 | 350 |
|
305 | 351 |
static void serial_receive_byte(ChannelState *s, int ch) |
306 | 352 |
{ |
353 |
SER_DPRINTF("put ch %d\n", ch); |
|
307 | 354 |
s->rregs[0] |= 1; |
308 |
// Interrupts reported only on channel A |
|
309 |
if (s->chn == 0) |
|
310 |
s->rregs[3] |= 0x20; |
|
311 |
else { |
|
312 |
s->otherchn->rregs[3] |= 4; |
|
313 |
} |
|
314 | 355 |
s->rx = ch; |
315 |
s->rxint = 1; |
|
316 |
slavio_serial_update_irq(s); |
|
356 |
set_rxint(s); |
|
317 | 357 |
} |
318 | 358 |
|
319 | 359 |
static void serial_receive_break(ChannelState *s) |
Also available in: Unified diff