25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_dreamcast_rtc.c,v 1.3 2007/02/03 20:14:23 debug Exp $ |
* $Id: dev_dreamcast_rtc.c,v 1.4 2007/06/15 19:11:15 debug Exp $ |
29 |
* |
* |
30 |
* Dreamcast Real-Time Clock. |
* COMMENT: Dreamcast Real-Time Clock |
31 |
* |
* |
32 |
* Pretty basic; two 32-bit words at physical addresses 0x00710000 and |
* Pretty basic; two 32-bit words at physical addresses 0x00710000 and |
33 |
* 0x00710004 hold the high and low 16-bit parts, respectively, of the |
* 0x00710004 hold the high and low 16-bit parts, respectively, of the |
58 |
|
|
59 |
DEVICE_ACCESS(dreamcast_rtc) |
DEVICE_ACCESS(dreamcast_rtc) |
60 |
{ |
{ |
61 |
/* struct dreamcast_rtc_data *d = |
/* struct dreamcast_rtc_data *d = extra; */ |
|
(struct dreamcast_rtc_data *) extra; */ |
|
62 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
63 |
struct timeval tv; |
struct timeval tv; |
64 |
|
|
84 |
odata &= 0xffff; |
odata &= 0xffff; |
85 |
break; |
break; |
86 |
|
|
87 |
default:if (writeflag == MEM_READ) { |
default: |
88 |
|
if (writeflag == MEM_READ) { |
89 |
fatal("[ dreamcast_rtc: read from addr 0x%x ]\n", |
fatal("[ dreamcast_rtc: read from addr 0x%x ]\n", |
90 |
(int)relative_addr); |
(int)relative_addr); |
91 |
} else { |
} else { |
103 |
|
|
104 |
DEVINIT(dreamcast_rtc) |
DEVINIT(dreamcast_rtc) |
105 |
{ |
{ |
106 |
struct machine *machine = devinit->machine; |
struct dreamcast_rtc_data *d; |
107 |
struct dreamcast_rtc_data *d = |
|
108 |
malloc(sizeof(struct dreamcast_rtc_data)); |
CHECK_ALLOCATION(d = malloc(sizeof(struct dreamcast_rtc_data))); |
|
if (d == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
109 |
memset(d, 0, sizeof(struct dreamcast_rtc_data)); |
memset(d, 0, sizeof(struct dreamcast_rtc_data)); |
110 |
|
|
111 |
memory_device_register(machine->memory, devinit->name, |
memory_device_register(devinit->machine->memory, devinit->name, |
112 |
0x00710000, 0x100, dev_dreamcast_rtc_access, d, DM_DEFAULT, NULL); |
0x00710000, 0x100, dev_dreamcast_rtc_access, d, DM_DEFAULT, NULL); |
113 |
|
|
114 |
return 1; |
return 1; |