-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhardware.cpp
More file actions
43 lines (35 loc) · 750 Bytes
/
hardware.cpp
File metadata and controls
43 lines (35 loc) · 750 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
#include "hardware.h"
#include <SPI.h>
#include "memory.h"
#include "CPU.h"
Memory memory;
static CPU *_cpu;
bool hardware_reset() {
bool success = true;
_cpu->reset();
return success;
}
void hardware_init(CPU &cpu) {
_cpu = &cpu;
memory.begin();
}
#if !defined(NO_CHECKPOINT)
void hardware_checkpoint(Stream &s) {
unsigned ds = 0;
for (unsigned i = 0; i < 0x10000; i += ds) {
Memory::Device *dev = memory.get(i);
dev->checkpoint(s);
ds = dev->pages() * Memory::page_size;
}
_cpu->checkpoint(s);
}
void hardware_restore(Stream &s) {
unsigned ds = 0;
for (unsigned i = 0; i < 0x10000; i += ds) {
Memory::Device *dev = memory.get(i);
dev->restore(s);
ds = dev->pages() * Memory::page_size;
}
_cpu->restore(s);
}
#endif