Update to v087r08 release.
byuu says:
Added some more ARM opcodes, hooked up MMIO. Bind it with mmio[(addr
000-3ff)] = this; inside CPU/PPU/APU, goes to read(), write().
Also moved the Hitachi HG51B core to processor/, and split it apart from
the snes/chip/hitachidsp implementation.
This one actually worked really well. Very clean split between MMIO/DMA
and the processor core. I may move a more generic DMA function inside
the core, not sure yet.
I still believe the HG51B169 to be a variant of the HG51BS family, but
given they're meant to be incredibly flexible microcontrollers, it's
possible that each variant gets its own instruction set.
So, who knows. We'll worry about it if we ever find another HG51B DSP,
I guess.
GBA BIOS is constantly reading from 04000300, but it never writes. If
I return prng()&1, I can get it to proceed until it hits a bad opcode
(stc opcode, which the GBA lacks a coprocessor so ... bad codepath.)
Without it, it just reads that register forever and keeps resetting the
system, or something ...
I guess we're going to have to try and get ARMwrestler working, because
the BIOS seems to need too much emulation code to do anything at all.
2012-03-24 07:52:36 +00:00
|
|
|
#include <processor/processor.hpp>
|
|
|
|
#include "hg51b.hpp"
|
|
|
|
|
|
|
|
namespace Processor {
|
|
|
|
|
|
|
|
#include "registers.cpp"
|
2018-09-10 02:11:19 +00:00
|
|
|
#include "instruction.cpp"
|
Update to v087r08 release.
byuu says:
Added some more ARM opcodes, hooked up MMIO. Bind it with mmio[(addr
000-3ff)] = this; inside CPU/PPU/APU, goes to read(), write().
Also moved the Hitachi HG51B core to processor/, and split it apart from
the snes/chip/hitachidsp implementation.
This one actually worked really well. Very clean split between MMIO/DMA
and the processor core. I may move a more generic DMA function inside
the core, not sure yet.
I still believe the HG51B169 to be a variant of the HG51BS family, but
given they're meant to be incredibly flexible microcontrollers, it's
possible that each variant gets its own instruction set.
So, who knows. We'll worry about it if we ever find another HG51B DSP,
I guess.
GBA BIOS is constantly reading from 04000300, but it never writes. If
I return prng()&1, I can get it to proceed until it hits a bad opcode
(stc opcode, which the GBA lacks a coprocessor so ... bad codepath.)
Without it, it just reads that register forever and keeps resetting the
system, or something ...
I guess we're going to have to try and get ARMwrestler working, because
the BIOS seems to need too much emulation code to do anything at all.
2012-03-24 07:52:36 +00:00
|
|
|
#include "instructions.cpp"
|
|
|
|
#include "serialization.cpp"
|
|
|
|
|
2018-09-04 05:44:35 +00:00
|
|
|
auto HG51B::lock() -> void {
|
|
|
|
io.lock = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::halt() -> void {
|
|
|
|
io.halt = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::wait(uint24 address) -> uint {
|
|
|
|
if(isROM(address)) return 1 + io.wait.rom;
|
|
|
|
if(isRAM(address)) return 1 + io.wait.ram;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::main() -> void {
|
|
|
|
if(io.lock) return step(1);
|
|
|
|
if(io.suspend.enable) return suspend();
|
2018-09-10 02:11:19 +00:00
|
|
|
if(io.cache.enable) return cache(), void();
|
2018-09-04 05:44:35 +00:00
|
|
|
if(io.dma.enable) return dma();
|
|
|
|
if(io.halt) return step(1);
|
|
|
|
return execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::step(uint clocks) -> void {
|
|
|
|
if(io.bus.enable) {
|
|
|
|
if(io.bus.pending > clocks) {
|
|
|
|
io.bus.pending -= clocks;
|
|
|
|
} else {
|
|
|
|
io.bus.enable = 0;
|
|
|
|
io.bus.pending = 0;
|
2018-09-10 02:11:19 +00:00
|
|
|
if(io.bus.reading) io.bus.reading = 0, r.mdr = read(io.bus.address);
|
|
|
|
if(io.bus.writing) io.bus.writing = 0, write(io.bus.address, r.mdr);
|
2018-09-04 05:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::execute() -> void {
|
2018-09-10 02:11:19 +00:00
|
|
|
if(!cache()) return halt();
|
|
|
|
auto opcode = programRAM[io.cache.page][r.pc];
|
2018-09-04 05:44:35 +00:00
|
|
|
advance();
|
|
|
|
step(1);
|
2018-09-10 02:11:19 +00:00
|
|
|
instructionTable[opcode]();
|
Update to v087r08 release.
byuu says:
Added some more ARM opcodes, hooked up MMIO. Bind it with mmio[(addr
000-3ff)] = this; inside CPU/PPU/APU, goes to read(), write().
Also moved the Hitachi HG51B core to processor/, and split it apart from
the snes/chip/hitachidsp implementation.
This one actually worked really well. Very clean split between MMIO/DMA
and the processor core. I may move a more generic DMA function inside
the core, not sure yet.
I still believe the HG51B169 to be a variant of the HG51BS family, but
given they're meant to be incredibly flexible microcontrollers, it's
possible that each variant gets its own instruction set.
So, who knows. We'll worry about it if we ever find another HG51B DSP,
I guess.
GBA BIOS is constantly reading from 04000300, but it never writes. If
I return prng()&1, I can get it to proceed until it hits a bad opcode
(stc opcode, which the GBA lacks a coprocessor so ... bad codepath.)
Without it, it just reads that register forever and keeps resetting the
system, or something ...
I guess we're going to have to try and get ARMwrestler working, because
the BIOS seems to need too much emulation code to do anything at all.
2012-03-24 07:52:36 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 05:44:35 +00:00
|
|
|
auto HG51B::advance() -> void {
|
|
|
|
if(++r.pc == 0) {
|
|
|
|
if(io.cache.page == 1) return halt();
|
|
|
|
io.cache.page = 1;
|
2018-09-10 02:11:19 +00:00
|
|
|
if(io.cache.lock[io.cache.page]) return halt();
|
2018-09-04 05:44:35 +00:00
|
|
|
r.pb = r.p;
|
2018-09-10 02:11:19 +00:00
|
|
|
if(!cache()) return halt();
|
2018-09-04 05:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
Update to v087r08 release.
byuu says:
Added some more ARM opcodes, hooked up MMIO. Bind it with mmio[(addr
000-3ff)] = this; inside CPU/PPU/APU, goes to read(), write().
Also moved the Hitachi HG51B core to processor/, and split it apart from
the snes/chip/hitachidsp implementation.
This one actually worked really well. Very clean split between MMIO/DMA
and the processor core. I may move a more generic DMA function inside
the core, not sure yet.
I still believe the HG51B169 to be a variant of the HG51BS family, but
given they're meant to be incredibly flexible microcontrollers, it's
possible that each variant gets its own instruction set.
So, who knows. We'll worry about it if we ever find another HG51B DSP,
I guess.
GBA BIOS is constantly reading from 04000300, but it never writes. If
I return prng()&1, I can get it to proceed until it hits a bad opcode
(stc opcode, which the GBA lacks a coprocessor so ... bad codepath.)
Without it, it just reads that register forever and keeps resetting the
system, or something ...
I guess we're going to have to try and get ARMwrestler working, because
the BIOS seems to need too much emulation code to do anything at all.
2012-03-24 07:52:36 +00:00
|
|
|
|
2018-09-04 05:44:35 +00:00
|
|
|
auto HG51B::suspend() -> void {
|
|
|
|
if(!io.suspend.duration) return step(1); //indefinite
|
|
|
|
step(io.suspend.duration);
|
|
|
|
io.suspend.duration = 0;
|
2018-09-10 02:11:19 +00:00
|
|
|
io.suspend.enable = 0;
|
2018-09-04 05:44:35 +00:00
|
|
|
}
|
|
|
|
|
2018-09-10 02:11:19 +00:00
|
|
|
auto HG51B::cache() -> bool {
|
2018-09-04 05:44:35 +00:00
|
|
|
uint24 address = io.cache.base + r.pb * 512;
|
2018-09-10 02:11:19 +00:00
|
|
|
|
|
|
|
//try to use the current page ...
|
|
|
|
if(io.cache.address[io.cache.page] == address) return io.cache.enable = 0, true;
|
|
|
|
//if it's not valid, try to use the other page ...
|
|
|
|
io.cache.page ^= 1;
|
|
|
|
if(io.cache.address[io.cache.page] == address) return io.cache.enable = 0, true;
|
|
|
|
//if it's not valid, try to load into the other page ...
|
|
|
|
if(io.cache.lock[io.cache.page]) io.cache.page ^= 1;
|
|
|
|
//if it's locked, try to load into the first page ...
|
|
|
|
if(io.cache.lock[io.cache.page]) return io.cache.enable = 0, false;
|
|
|
|
|
2018-09-04 05:44:35 +00:00
|
|
|
io.cache.address[io.cache.page] = address;
|
|
|
|
for(uint offset : range(256)) {
|
|
|
|
step(wait(address)); programRAM[io.cache.page][offset].byte(0) = read(address++);
|
|
|
|
step(wait(address)); programRAM[io.cache.page][offset].byte(1) = read(address++);
|
|
|
|
}
|
2018-09-10 02:11:19 +00:00
|
|
|
return io.cache.enable = 0, true;
|
2018-09-04 05:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::dma() -> void {
|
|
|
|
for(uint offset : range(io.dma.length)) {
|
|
|
|
uint24 source = io.dma.source + offset;
|
|
|
|
uint24 target = io.dma.target + offset;
|
|
|
|
|
|
|
|
if(isROM(source) && isROM(target)) return lock();
|
|
|
|
if(isRAM(source) && isRAM(target)) return lock();
|
|
|
|
|
|
|
|
step(wait(source));
|
|
|
|
auto data = read(source);
|
|
|
|
|
|
|
|
step(wait(target));
|
|
|
|
write(target, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
io.dma.enable = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::running() const -> bool {
|
|
|
|
return io.cache.enable || io.dma.enable || io.bus.pending || !io.halt;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::busy() const -> bool {
|
|
|
|
return io.cache.enable || io.dma.enable || io.bus.pending;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto HG51B::power() -> void {
|
|
|
|
r = {};
|
|
|
|
io = {};
|
Update to v087r08 release.
byuu says:
Added some more ARM opcodes, hooked up MMIO. Bind it with mmio[(addr
000-3ff)] = this; inside CPU/PPU/APU, goes to read(), write().
Also moved the Hitachi HG51B core to processor/, and split it apart from
the snes/chip/hitachidsp implementation.
This one actually worked really well. Very clean split between MMIO/DMA
and the processor core. I may move a more generic DMA function inside
the core, not sure yet.
I still believe the HG51B169 to be a variant of the HG51BS family, but
given they're meant to be incredibly flexible microcontrollers, it's
possible that each variant gets its own instruction set.
So, who knows. We'll worry about it if we ever find another HG51B DSP,
I guess.
GBA BIOS is constantly reading from 04000300, but it never writes. If
I return prng()&1, I can get it to proceed until it hits a bad opcode
(stc opcode, which the GBA lacks a coprocessor so ... bad codepath.)
Without it, it just reads that register forever and keeps resetting the
system, or something ...
I guess we're going to have to try and get ARMwrestler working, because
the BIOS seems to need too much emulation code to do anything at all.
2012-03-24 07:52:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|