1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_mc146818.c,v 1.80 2005/11/20 11:28:45 debug Exp $ |
* $Id: dev_mc146818.c,v 1.86 2006/06/22 13:22:41 debug Exp $ |
29 |
* |
* |
30 |
* MC146818 real-time clock, used by many different machines types. |
* MC146818 real-time clock, used by many different machines types. |
31 |
* (DS1687 as used in some other machines is also similar to the MC146818.) |
* (DS1687 as used in some other machines is also similar to the MC146818.) |
137 |
#endif |
#endif |
138 |
|
|
139 |
if (d->interrupt_hz > 0) |
if (d->interrupt_hz > 0) |
140 |
d->interrupt_every_x_cycles = |
d->interrupt_every_x_cycles = emulated_hz / d->interrupt_hz; |
|
emulated_hz / d->interrupt_hz; |
|
141 |
else |
else |
142 |
d->interrupt_every_x_cycles = 0; |
d->interrupt_every_x_cycles = 0; |
143 |
} |
} |
159 |
if (d->cycles_left_until_interrupt < 0 || |
if (d->cycles_left_until_interrupt < 0 || |
160 |
d->cycles_left_until_interrupt >= |
d->cycles_left_until_interrupt >= |
161 |
d->interrupt_every_x_cycles) { |
d->interrupt_every_x_cycles) { |
162 |
/* debug("[ rtc interrupt (every %i cycles) ]\n", |
/* fatal("[ rtc interrupt (every %i cycles) ]\n", |
163 |
d->interrupt_every_x_cycles); */ |
d->interrupt_every_x_cycles); */ |
164 |
cpu_interrupt(cpu, d->irq_nr); |
cpu_interrupt(cpu, d->irq_nr); |
165 |
|
|
318 |
struct tm *tmp; |
struct tm *tmp; |
319 |
time_t timet; |
time_t timet; |
320 |
struct mc_data *d = extra; |
struct mc_data *d = extra; |
321 |
int i, relative_addr = r; |
int relative_addr = r; |
322 |
|
size_t i; |
323 |
|
|
324 |
relative_addr /= d->addrdiv; |
relative_addr /= d->addrdiv; |
325 |
|
|
506 |
case 0x128: |
case 0x128: |
507 |
d->reg[relative_addr] = data[0]; |
d->reg[relative_addr] = data[0]; |
508 |
if (data[0] & 8) { |
if (data[0] & 8) { |
509 |
|
int j; |
510 |
|
|
511 |
/* Used on SGI to power off the machine. */ |
/* Used on SGI to power off the machine. */ |
512 |
fatal("[ md146818: power off ]\n"); |
fatal("[ md146818: power off ]\n"); |
513 |
for (i=0; i<cpu->machine->ncpus; i++) |
for (j=0; j<cpu->machine->ncpus; j++) |
514 |
cpu->machine->cpus[i]->running = 0; |
cpu->machine->cpus[j]->running = 0; |
515 |
cpu->machine-> |
cpu->machine-> |
516 |
exit_without_entering_debugger = 1; |
exit_without_entering_debugger = 1; |
517 |
} |
} |
641 |
|
|
642 |
if (machine->machine_type != MACHINE_PREP) { |
if (machine->machine_type != MACHINE_PREP) { |
643 |
/* NetBSD/prep has a really ugly clock detection code; |
/* NetBSD/prep has a really ugly clock detection code; |
644 |
all other machines/OSes don't need this. */ |
no other machines/OSes don't need this. */ |
645 |
d->ugly_netbsd_prep_hack_done = NETBSD_HACK_DONE; |
d->ugly_netbsd_prep_hack_done = NETBSD_HACK_DONE; |
646 |
} |
} |
647 |
|
|
692 |
* TODO: Find out if this messes up Sprite emulation; if so, then |
* TODO: Find out if this messes up Sprite emulation; if so, then |
693 |
* this hack has to be removed. |
* this hack has to be removed. |
694 |
*/ |
*/ |
695 |
d->uip_threshold = 5; |
d->uip_threshold = 8; |
696 |
|
|
697 |
if (access_style == MC146818_ARC_JAZZ) |
if (access_style == MC146818_ARC_JAZZ) |
698 |
memory_device_register(mem, "mc146818_jazz", 0x90000070ULL, |
memory_device_register(mem, "mc146818_jazz", 0x90000070ULL, |
714 |
|
|
715 |
mc146818_update_time(d); |
mc146818_update_time(d); |
716 |
|
|
717 |
machine_add_tickfunction(machine, dev_mc146818_tick, d, TICK_SHIFT); |
machine_add_tickfunction(machine, dev_mc146818_tick, d, |
718 |
|
TICK_SHIFT, 0.0); |
719 |
} |
} |
720 |
|
|