summaryrefslogtreecommitdiff
path: root/emu/bus.h
blob: c1866cb239daf96379014ad7b04d6c536efc8ee5 (plain)
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
#ifndef BUS_H
#define BUS_H

#include "device.h"

enum {
	MAX_NOF_DEVICES = 5
};

typedef struct registered_device_t {
	device_t *device;
	uint16_t from;
	uint16_t to;
} registered_device_t;

typedef struct bus_t {
	device_t base;
	int nof_devices;
	registered_device_t devices[MAX_NOF_DEVICES];
} bus_t;

void bus_init( bus_t *bus );
void bus_register( bus_t *bus, device_t *device, uint16_t from, uint16_t to );

uint8_t bus_read( void *obj, uint16_t addr );
void bus_write( void *obj, uint16_t addr, uint8_t data );
void bus_deinit( void *obj );

#endif