mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 20:29:46 +00:00
Add AddressMap class for defining physical maps.
This commit is contained in:
parent
a469bcf900
commit
aec95254a8
36
addressmap.cpp
Normal file
36
addressmap.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include "addressmap.h"
|
||||||
|
|
||||||
|
AddressMap::AddressMap()
|
||||||
|
{
|
||||||
|
this->address_map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddressMap::~AddressMap()
|
||||||
|
{
|
||||||
|
for (auto &entry : address_map) {
|
||||||
|
if (entry.devobj)
|
||||||
|
delete(entry.devobj);
|
||||||
|
}
|
||||||
|
this->address_map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddressMap::add(AddressMapEntry &entry)
|
||||||
|
{
|
||||||
|
if (entry.type & RT_ROM) {
|
||||||
|
printf("ROM entry added.\n");
|
||||||
|
printf("entry.mem_ptr = %llx\n", (uint64_t)entry.mem_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
address_map.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddressMapEntry *AddressMap::get_range(uint32_t addr)
|
||||||
|
{
|
||||||
|
for (auto &entry : address_map) {
|
||||||
|
if (addr >= entry.start && addr <= entry.end)
|
||||||
|
return &entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
39
addressmap.h
Normal file
39
addressmap.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef ADDRESS_MAP_H
|
||||||
|
#define ADDRESS_MAP_H
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <vector>
|
||||||
|
#include "mmiodevice.h"
|
||||||
|
|
||||||
|
typedef uint32_t (*DevRead) (uint32_t offset, int size);
|
||||||
|
typedef void (*DevWrite)(uint32_t offset, uint32_t value, int size);
|
||||||
|
|
||||||
|
enum RangeType {
|
||||||
|
RT_ROM = 1,
|
||||||
|
RT_RAM = 2,
|
||||||
|
RT_MMIO = 4, /* memory mapped I/O */
|
||||||
|
RT_MIRROR = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct AddressMapEntry {
|
||||||
|
uint32_t start; /* first address of the corresponding range */
|
||||||
|
uint32_t end; /* last address of the corresponding range */
|
||||||
|
uint32_t mirror; /* mirror address for RT_MIRROR */
|
||||||
|
uint32_t type; /* range type */
|
||||||
|
MMIODevice *devobj; /* pointer to device object */
|
||||||
|
unsigned char *mem_ptr; /* direct pointer to data for memory objects */
|
||||||
|
} AddressMapEntry;
|
||||||
|
|
||||||
|
|
||||||
|
class AddressMap {
|
||||||
|
public:
|
||||||
|
AddressMap();
|
||||||
|
~AddressMap();
|
||||||
|
void add(AddressMapEntry &entry);
|
||||||
|
AddressMapEntry *get_range(uint32_t addr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<AddressMapEntry> address_map;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* ADDRESS_MAP_H_ */
|
14
makefile
14
makefile
@ -1,6 +1,11 @@
|
|||||||
OBJS = main.o macioserial.o macscsi.o macswim3.o mpc106.o openpic.o poweropcodes.o ppcfpopcodes.o ppcgekkoopcodes.o ppcmemory.o ppcopcodes.o viacuda.o davbus.o debugger.o
|
OBJS = main.o macioserial.o macscsi.o macswim3.o mpc106.o openpic.o poweropcodes.o \
|
||||||
SOURCE = main.cpp macioserial.cpp macscsi.cpp macswim3.cpp mpc106.cpp openpic.cpp poweropcodes.cpp ppcfpopcodes.cpp ppcgekkoopcodes.cpp ppcmemory.cpp ppcopcodes.cpp viacuda.cpp davbus.cpp debugger.cpp
|
ppcfpopcodes.o ppcgekkoopcodes.o ppcmemory.o ppcopcodes.o viacuda.o davbus.o \
|
||||||
HEADER = macioserial.h macscsi.h macswim3.h mpc106.h openpic.h ppcemumain.h ppcmemory.h viacuda.h debugger.h
|
debugger.o addressmap.o
|
||||||
|
SOURCE = main.cpp macioserial.cpp macscsi.cpp macswim3.cpp mpc106.cpp openpic.cpp \
|
||||||
|
poweropcodes.cpp ppcfpopcodes.cpp ppcgekkoopcodes.cpp ppcmemory.cpp \
|
||||||
|
ppcopcodes.cpp viacuda.cpp davbus.cpp debugger.cpp addressmap.cpp
|
||||||
|
HEADER = macioserial.h macscsi.h macswim3.h mpc106.h openpic.h ppcemumain.h ppcmemory.h \
|
||||||
|
viacuda.h debugger.h addressmap.h
|
||||||
OUT = dingusppc
|
OUT = dingusppc
|
||||||
CC = g++
|
CC = g++
|
||||||
FLAGS = -g -c -Wall -std=c++11
|
FLAGS = -g -c -Wall -std=c++11
|
||||||
@ -51,5 +56,8 @@ davbus.o: davbus.cpp
|
|||||||
debugger.o: debugger.cpp
|
debugger.o: debugger.cpp
|
||||||
$(CC) $(FLAGS) debugger.cpp
|
$(CC) $(FLAGS) debugger.cpp
|
||||||
|
|
||||||
|
addressmap.o: addressmap.cpp
|
||||||
|
$(CC) $(FLAGS) addressmap.cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJS) $(OUT)
|
rm -f $(OBJS) $(OUT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user