-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtc.js
More file actions
46 lines (34 loc) · 899 Bytes
/
Copy pathrtc.js
File metadata and controls
46 lines (34 loc) · 899 Bytes
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
const {
dll
} = require('./loader');
function RTC(cpu) {
this.cpu = cpu;
cpu.io.register_read(0x70, this, dll.cmos_readb_70);
cpu.io.register_read(0x71, this, function() {
if (dll.cmos_should_lower())
this.cpu.device_lower_irq(8);
return dll.cmos_readb_71();
});
cpu.io.register_write(0x70, this, dll.cmos_writeb_70);
cpu.io.register_write(0x71, this, dll.cmos_writeb_71);
dll.cmos_init(0);
}
RTC.prototype.get_state = function() {
// TODO
var state = [];
return state;
};
RTC.prototype.set_state = function(state) {
// TODO
};
RTC.prototype.timer = function(time, legacy_mode) {
const result = dll.cmos_next(dll.cmos_get_now());
const to_raise = dll.cmos_get_raise();
if (to_raise) {
this.cpu.device_raise_irq(8);
}
return result;
};
RTC.prototype.cmos_read = dll.cmos_get;
RTC.prototype.cmos_write = dll.cmos_set;
exports.RTC = RTC;