-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrtc.c
65 lines (51 loc) · 1.11 KB
/
rtc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "mmu.h"
#include "state.h"
#include "diag.h"
#define RTCSIZE 0x40
#define RTCBASE 0xfffc20
HANDLE_DIAGNOSTICS(rtc)
static BYTE rtc_read_byte(LONG addr)
{
return 0;
}
static WORD rtc_read_word(LONG addr)
{
return (rtc_read_byte(addr)<<8)|rtc_read_byte(addr+1);
}
static void rtc_write_byte(LONG addr, BYTE data)
{
}
static void rtc_write_word(LONG addr, WORD data)
{
rtc_write_byte(addr, (data&0xff00)>>8);
rtc_write_byte(addr+1, (data&0xff));
}
static int rtc_state_collect(struct mmu_state *state)
{
state->size = 0;
return STATE_VALID;
}
static void rtc_state_restore(struct mmu_state *state)
{
}
void rtc_init()
{
struct mmu *rtc;
rtc = mmu_create("RTC0", "Real-Time Clock");
if(!rtc) {
return;
}
rtc->start = RTCBASE;
rtc->size = RTCSIZE;
rtc->read_byte = rtc_read_byte;
rtc->read_word = rtc_read_word;
rtc->write_byte = rtc_write_byte;
rtc->write_word = rtc_write_word;
rtc->state_collect = rtc_state_collect;
rtc->state_restore = rtc_state_restore;
rtc->diagnostics = rtc_diagnostics;
mmu_register(rtc);
}