--- trunk/src/devices/dev_mc146818.c 2007/10/08 16:18:31 11 +++ trunk/src/devices/dev_mc146818.c 2007/10/08 16:18:38 12 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: dev_mc146818.c,v 1.69 2005/05/20 07:42:12 debug Exp $ + * $Id: dev_mc146818.c,v 1.72 2005/08/02 07:56:37 debug Exp $ * * MC146818 real-time clock, used by many different machines types. * (DS1687 as used in some SGI machines is similar to MC146818.) @@ -56,7 +56,7 @@ /* #define MC146818_DEBUG */ -#define TICK_STEPS_SHIFT 14 +#define TICK_SHIFT 14 /* 256 on DECstation, SGI uses reg at 72*4 as the Century */ @@ -140,8 +140,7 @@ if ((d->reg[MC_REGB * 4] & MC_REGB_PIE) && d->interrupt_every_x_cycles > 0) { - d->cycles_left_until_interrupt -= - (1 << TICK_STEPS_SHIFT); + d->cycles_left_until_interrupt -= (1 << TICK_SHIFT); if (d->cycles_left_until_interrupt < 0 || d->cycles_left_until_interrupt >= @@ -366,25 +365,20 @@ #endif /* - * For some reason, Linux/sgimips relies on the UIP bit to go - * on and off. Without this code, booting Linux takes forever: - */ - d->reg[MC_REGA * 4] &= ~MC_REGA_UIP; -#if 1 - /* TODO: solve this more nicely */ - if ((random() & 0xff) == 0) - d->reg[MC_REGA * 4] ^= MC_REGA_UIP; -#endif - - /* - * Sprite seens to wants UF interrupt status, once every second, or + * Sprite seems to wants UF interrupt status, once every second, or * it hangs forever during bootup. (These do not cause interrupts, * but it is good enough... Sprite polls this, iirc.) + * + * Linux on at least sgimips and evbmips (Malta) wants the UIP bit + * in REGA to be updated once a second. */ timet = time(NULL); tmp = gmtime(&timet); d->reg[MC_REGC * 4] &= ~MC_REGC_UF; + if (tmp->tm_sec != d->previous_second) { + d->reg[MC_REGA * 4] &= ~MC_REGA_UIP; + d->reg[MC_REGC * 4] |= MC_REGC_UF; d->reg[MC_REGC * 4] |= MC_REGC_IRQF; d->previous_second = tmp->tm_sec; @@ -393,14 +387,14 @@ the PF (periodic flag) bit set, even though interrupts are not enabled? */ d->reg[MC_REGC * 4] |= MC_REGC_PF; - } + } else + d->reg[MC_REGA * 4] |= MC_REGA_UIP; /* RTC data is in either BCD format or binary: */ - if (d->use_bcd) { + if (d->use_bcd) d->reg[MC_REGB * 4] &= ~(1 << 2); - } else { + else d->reg[MC_REGB * 4] |= (1 << 2); - } /* RTC date/time is always Valid: */ d->reg[MC_REGD * 4] |= MC_REGD_VRT; @@ -649,7 +643,6 @@ mc146818_update_time(d); - machine_add_tickfunction(machine, dev_mc146818_tick, - d, TICK_STEPS_SHIFT); + machine_add_tickfunction(machine, dev_mc146818_tick, d, TICK_SHIFT); }