memory: remove unused functions
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -17,12 +17,6 @@ class Memory {
|
|||||||
uint8_t read(size_t address) const;
|
uint8_t read(size_t address) const;
|
||||||
void write(size_t address, uint8_t byte);
|
void write(size_t address, uint8_t byte);
|
||||||
|
|
||||||
uint16_t read_halfword(size_t address) const;
|
|
||||||
void write_halfword(size_t address, uint16_t halfword);
|
|
||||||
|
|
||||||
uint32_t read_word(size_t address) const;
|
|
||||||
void write_word(size_t address, uint32_t word);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#define MEMORY_REGION(name, start, end) \
|
#define MEMORY_REGION(name, start, end) \
|
||||||
static constexpr size_t name##_START = start; \
|
static constexpr size_t name##_START = start; \
|
||||||
|
26
src/bus.cc
26
src/bus.cc
@@ -1,4 +1,5 @@
|
|||||||
#include "bus.hh"
|
#include "bus.hh"
|
||||||
|
#include "util/log.hh"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace matar {
|
namespace matar {
|
||||||
@@ -17,21 +18,38 @@ Bus::write_byte(size_t address, uint8_t byte) {
|
|||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
Bus::read_halfword(size_t address) {
|
Bus::read_halfword(size_t address) {
|
||||||
return memory->read_halfword(address);
|
if (address & 0b01)
|
||||||
|
glogger.warn("Reading a non aligned halfword address");
|
||||||
|
|
||||||
|
return memory->read(address) | memory->read(address + 1) << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Bus::write_halfword(size_t address, uint16_t halfword) {
|
Bus::write_halfword(size_t address, uint16_t halfword) {
|
||||||
memory->write_halfword(address, halfword);
|
if (address & 0b01)
|
||||||
|
glogger.warn("Writing to a non aligned halfword address");
|
||||||
|
|
||||||
|
memory->write(address, halfword & 0xFF);
|
||||||
|
memory->write(address + 1, halfword >> 8 & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
Bus::read_word(size_t address) {
|
Bus::read_word(size_t address) {
|
||||||
return memory->read_word(address);
|
if (address & 0b11)
|
||||||
|
glogger.warn("Reading a non aligned word address");
|
||||||
|
|
||||||
|
return memory->read(address) | memory->read(address + 1) << 8 |
|
||||||
|
memory->read(address + 2) << 16 | memory->read(address + 3) << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Bus::write_word(size_t address, uint32_t word) {
|
Bus::write_word(size_t address, uint32_t word) {
|
||||||
memory->write_word(address, word);
|
if (address & 0b11)
|
||||||
|
glogger.warn("Writing to a non aligned word address");
|
||||||
|
|
||||||
|
memory->write(address, word & 0xFF);
|
||||||
|
memory->write(address + 1, word >> 8 & 0xFF);
|
||||||
|
memory->write(address + 2, word >> 16 & 0xFF);
|
||||||
|
memory->write(address + 3, word >> 24 & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -89,43 +89,6 @@ Memory::write(size_t address, uint8_t byte) {
|
|||||||
|
|
||||||
#undef MATCHES
|
#undef MATCHES
|
||||||
|
|
||||||
uint16_t
|
|
||||||
Memory::read_halfword(size_t address) const {
|
|
||||||
if (address & 0b01)
|
|
||||||
glogger.warn("Reading a non aligned halfword address");
|
|
||||||
|
|
||||||
return read(address) | read(address + 1) << 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Memory::write_halfword(size_t address, uint16_t halfword) {
|
|
||||||
if (address & 0b01)
|
|
||||||
glogger.warn("Writing to a non aligned halfword address");
|
|
||||||
|
|
||||||
write(address, halfword & 0xFF);
|
|
||||||
write(address + 1, halfword >> 8 & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
Memory::read_word(size_t address) const {
|
|
||||||
if (address & 0b11)
|
|
||||||
glogger.warn("Reading a non aligned word address");
|
|
||||||
|
|
||||||
return read(address) | read(address + 1) << 8 | read(address + 2) << 16 |
|
|
||||||
read(address + 3) << 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Memory::write_word(size_t address, uint32_t word) {
|
|
||||||
if (address & 0b11)
|
|
||||||
glogger.warn("Writing to a non aligned word address");
|
|
||||||
|
|
||||||
write(address, word & 0xFF);
|
|
||||||
write(address + 1, word >> 8 & 0xFF);
|
|
||||||
write(address + 2, word >> 16 & 0xFF);
|
|
||||||
write(address + 3, word >> 24 & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Memory::parse_header() {
|
Memory::parse_header() {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user