-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacpi.js
More file actions
111 lines (98 loc) · 2.85 KB
/
Copy pathacpi.js
File metadata and controls
111 lines (98 loc) · 2.85 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const {
dll
} = require('./loader');
function ACPI(cpu) {
this.cpu = cpu;
var io = cpu.io;
var acpi = {
pci_id: 0x07 << 3,
pci_space: [
0x86, 0x80, 0x13, 0x71, 0x07, 0x00, 0x80, 0x02, 0x08, 0x00, 0x80, 0x06, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00,
],
pci_bars: [],
name: "acpi",
};
cpu.devices.pci.register_device(acpi);
io.register_read(0xB000, this, undefined, function() {
return dll.acpi_read16(0xB000);
});
io.register_read(0xB002, this, undefined, function() {
return dll.acpi_read16(0xB002);
});
io.register_read(0xB004, this, undefined, function() {
return dll.acpi_read16(0xB004);
});
io.register_write(0xB000, this, undefined, function(value) {
dll.acpi_write16(0xB000, value);
});
io.register_write(0xB002, this, undefined, function(value) {
dll.acpi_write16(0xB002, value);
});
io.register_write(0xB004, this, undefined, function(value) {
dll.acpi_write16(0xB004, value);
});
io.register_read(0xAFE0, this, function() {
return dll.acpi_read8(0xAFE0);
});
io.register_read(0xAFE1, this, function() {
return dll.acpi_read8(0xAFE1);
});
io.register_read(0xAFE2, this, function() {
return dll.acpi_read8(0xAFE2);
});
io.register_read(0xAFE3, this, function() {
return dll.acpi_read8(0xAFE3);
});
io.register_write(0xAFE0, this, function(value) {
dll.acpi_write8(0xAFE0, value);
});
io.register_write(0xAFE1, this, function(value) {
dll.acpi_write8(0xAFE1, value);
});
io.register_write(0xAFE2, this, function(value) {
dll.acpi_write8(0xAFE2, value);
});
io.register_write(0xAFE3, this, function(value) {
dll.acpi_write8(0xAFE3, value);
});
io.register_read(0xB008, this, undefined, undefined, function() {
return dll.acpi_read32(0xB008);
});
}
ACPI.prototype.timer = function(now) {
if (dll.acpi_timer(now))
this.cpu.device_lower_irq(9)
else
this.cpu.device_raise_irq(9);
return dll.acpi_get_result();
};
ACPI.prototype.get_timer = dll.acpi_get_timer;
ACPI.prototype.get_state = function() {
const dll_state = dll.acpi_get_state();
return [
dll_state[0],
dll_state[1],
dll_state[2],
[
dll_state[3],
dll_state[4],
dll_state[5],
dll_state[6],
]
];
};
ACPI.prototype.set_state = function(state) {
var dll_state = new Uint16Array(7);
dll_state[0] = state[0];
dll_state[1] = state[1];
dll_state[2] = state[2];
dll_state[3] = state[3][0];
dll_state[4] = state[3][1];
dll_state[5] = state[3][2];
dll_state[6] = state[3][3];
dll.acpi_set_state(dll_state);
};
exports.ACPI = ACPI;