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
|
#ifndef DEV_H_
#define DEV_H_
#include "devices/system.h"
#include "devices/memory.h"
#include "devices/math.h"
#include "devices/clock.h"
#include "devices/input.h"
#include "devices/screen.h"
#include "devices/stream.h"
#include "devices/file.h"
// Signals that can be emitted by a device.
typedef enum {
SIG_NONE = 0,
SIG_HALT,
SIG_DB1,
SIG_DB2,
SIG_DB3,
SIG_DB4,
SIG_DB5,
SIG_DB6,
SIG_SLEEP,
SIG_RESET,
SIG_FORK,
} Signal;
// Bedrock device bus.
typedef struct {
SystemDevice system;
MemoryDevice memory;
MathDevice math;
ClockDevice clock;
InputDevice input;
ScreenDevice screen;
StreamDevice stream;
FileDevice file;
} DeviceBus;
// Methods.
void dev_reset(DeviceBus *d);
u8 dev_read(DeviceBus *d, u8 port);
Signal dev_write(DeviceBus *d, u8 port, u8 v);
// Duplicate declarations from main.
void open_keyboard(void);
void close_keyboard(void);
#endif
|