mirror of
https://github.com/rkujawa/rk65c02.git
synced 2024-12-11 18:49:16 +00:00
Make bus read/writes possible to devices mapped anywhere, not only 0.
This commit is contained in:
parent
7ab946c5df
commit
dcf275939b
58
src/bus.c
58
src/bus.c
@ -47,44 +47,54 @@ uint8_t
|
|||||||
bus_read_1(bus_t *t, uint16_t addr)
|
bus_read_1(bus_t *t, uint16_t addr)
|
||||||
{
|
{
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
|
uint16_t doff;
|
||||||
device_mapping_t *dm;
|
device_mapping_t *dm;
|
||||||
device_t *d;
|
device_t *dtmp, *d;
|
||||||
|
|
||||||
|
d = NULL;
|
||||||
|
|
||||||
LL_FOREACH(t->dm_head, dm) {
|
LL_FOREACH(t->dm_head, dm) {
|
||||||
d = dm->dev;
|
dtmp = dm->dev;
|
||||||
|
if ( (addr >= dm->addr) && (addr < (dm->addr + dtmp->size)) ) {
|
||||||
if (dm->addr == 0)
|
d = dtmp;
|
||||||
val = d->read_1(d, addr);
|
doff = dm->addr;
|
||||||
/*
|
}
|
||||||
* else
|
|
||||||
* Check if address is inside of given device range, calculate
|
|
||||||
* offset.
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// printf("bus READ @ %x value %x\n", addr, val);
|
|
||||||
|
if (d == NULL) {
|
||||||
|
fprintf(stderr, "Hitting unmapped bus space @ %x!", addr);
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = d->read_1(d, addr - doff);
|
||||||
|
|
||||||
|
printf("bus READ @ %x (off %x) value %x\n", addr, addr - doff, val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bus_write_1(bus_t *t, uint16_t addr, uint8_t val)
|
bus_write_1(bus_t *t, uint16_t addr, uint8_t val)
|
||||||
{
|
{
|
||||||
|
uint16_t doff;
|
||||||
device_mapping_t *dm;
|
device_mapping_t *dm;
|
||||||
device_t *d;
|
device_t *dtmp, *d;
|
||||||
|
|
||||||
|
d = NULL;
|
||||||
|
|
||||||
LL_FOREACH(t->dm_head, dm) {
|
LL_FOREACH(t->dm_head, dm) {
|
||||||
d = dm->dev;
|
dtmp = dm->dev;
|
||||||
|
if ( (addr >= dm->addr) && (addr < (dm->addr + dtmp->size)) ) {
|
||||||
if (dm->addr == 0)
|
d = dtmp;
|
||||||
d->write_1(d, addr, val);
|
doff = dm->addr;
|
||||||
/*
|
}
|
||||||
* else
|
|
||||||
* Check if address is inside of given device range, calculate
|
|
||||||
* offset.
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// printf("bus WRITE @ %x value %x\n", addr, val);
|
|
||||||
|
if (d == NULL) {
|
||||||
|
fprintf(stderr, "Hitting unmapped bus space @ %x!", addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("bus WRITE @ %x (off %x) value %x\n", addr, addr - doff, val);
|
||||||
|
d->write_1(d, addr, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bus_t
|
bus_t
|
||||||
|
Loading…
Reference in New Issue
Block a user