--- trunk/src/devices/dev_mc146818.c 2007/10/08 16:21:06 33 +++ trunk/src/devices/dev_mc146818.c 2007/10/08 16:21:17 34 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2006 Anders Gavare. All rights reserved. + * Copyright (C) 2003-2007 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_mc146818.c,v 1.91 2006/10/07 03:20:19 debug Exp $ + * $Id: dev_mc146818.c,v 1.95 2007/02/03 16:55:55 debug Exp $ * * MC146818 real-time clock, used by many different machines types. * (DS1687 as used in some other machines is also similar to the MC146818.) @@ -76,7 +76,7 @@ int timebase_hz; int interrupt_hz; int old_interrupt_hz; - int irq_nr; + struct interrupt irq; struct timer *timer; volatile int pending_timer_interrupts; @@ -120,7 +120,7 @@ if ((d->reg[MC_REGB * 4] & MC_REGB_PIE) && pti > 0) { static int warned = 0; - if (pti > 800 && !warned) { + if (pti > 1500 && !warned) { warned = 1; fatal("[ WARNING: MC146818 interrupts lost, " "host too slow? ]\n"); @@ -139,7 +139,7 @@ } #endif - cpu_interrupt(cpu, d->irq_nr); + INTERRUPT_ASSERT(d->irq); d->reg[MC_REGC * 4] |= MC_REGC_PF; } @@ -472,7 +472,7 @@ case MC_REGB*4: d->reg[MC_REGB*4] = data[0]; if (!(data[0] & MC_REGB_PIE)) { - cpu_interrupt_ack(cpu, d->irq_nr); + INTERRUPT_DEASSERT(d->irq); } /* debug("[ mc146818: write to MC_REGB, data[0] " @@ -566,13 +566,14 @@ data[0] = d->reg[relative_addr]; if (relative_addr == MC_REGC*4) { - cpu_interrupt_ack(cpu, d->irq_nr); + INTERRUPT_DEASSERT(d->irq); /* * Acknowledging an interrupt decreases the * number of pending "real world" timer ticks. */ - if (d->reg[MC_REGC * 4] & MC_REGC_PF) + if (d->reg[MC_REGC * 4] & MC_REGC_PF && + d->pending_timer_interrupts > 0) d->pending_timer_interrupts --; d->reg[MC_REGC * 4] = 0x00; @@ -600,7 +601,7 @@ * so it contains both rtc related stuff and the station's Ethernet address. */ void dev_mc146818_init(struct machine *machine, struct memory *mem, - uint64_t baseaddr, int irq_nr, int access_style, int addrdiv) + uint64_t baseaddr, char *irq_path, int access_style, int addrdiv) { unsigned char ether_address[6]; int i, dev_len; @@ -613,10 +614,12 @@ } memset(d, 0, sizeof(struct mc_data)); - d->irq_nr = irq_nr; + d->access_style = access_style; d->addrdiv = addrdiv; + INTERRUPT_CONNECT(irq_path, d->irq); + d->use_bcd = 0; switch (access_style) { case MC146818_SGI: