2012-03-23 10:43:39 +00:00
|
|
|
#ifndef PROCESSOR_ARM_HPP
|
|
|
|
#define PROCESSOR_ARM_HPP
|
|
|
|
|
|
|
|
namespace Processor {
|
|
|
|
|
2015-06-24 13:21:24 +00:00
|
|
|
//Supported Models:
|
2015-07-01 10:58:42 +00:00
|
|
|
//* ARMv3 (ARM60)
|
|
|
|
//* ARMv4T (ARM7TDMI)
|
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
|
|
|
|
2012-03-23 10:43:39 +00:00
|
|
|
struct ARM {
|
2015-07-01 10:58:42 +00:00
|
|
|
enum : unsigned { //mode flags for bus_read, bus_write:
|
|
|
|
Nonsequential = 1, //N cycle
|
|
|
|
Sequential = 2, //S cycle
|
|
|
|
Prefetch = 4, //instruction fetch (eligible for prefetch)
|
|
|
|
Byte = 8, //8-bit access
|
|
|
|
Half = 16, //16-bit access
|
|
|
|
Word = 32, //32-bit access
|
|
|
|
Load = 64, //load operation
|
|
|
|
Store = 128, //store operation
|
Update to v095r03 release and icarus 20151107.
byuu says:
Note: you will need the new icarus (and please use the "no manifest"
system) to run GBA games with this WIP.
Changelog:
- fixed caching of r(d) to pass armwrestler tests [Jonas Quinn]
- DMA to/from GBA BIOS should fail [Cydrak]
- fixed sign-extend and rotate on ldrs instructions [Cydrak]
- fixed 8-bit SRAM reading/writing [byuu]
- refactored GBA/cartridge
- cartridge/rom,ram.type is now cartridge/mrom,sram,eeprom,flash
- things won't crash horribly if you specify a RAM size larger than
the largest legal size in the manifest
- specialized MROM / SRAM classes replace all the shared read/write
functions that didn't work right anyway
- there's a new ruby/video.glx2 driver, which is not enabled by default
- use this if you are running Linux/BSD, but don't have OpenGL 3.2 yet
- I'm not going to support OpenGL2 on Windows/OS X, because these OSes
don't ship ancient video card drivers
- probably more. What am I, clairvoyant? :P
For endrift's tests, this gets us to 1348/1552 memory and 1016/1260
timing. Overall, this puts us back in second place. Only no$ is ahead
on memory, but bgba is even more ahead on timing.
2015-11-08 09:09:18 +00:00
|
|
|
Signed = 256, //sign extend
|
2015-07-01 10:58:42 +00:00
|
|
|
};
|
2015-06-24 13:21:24 +00:00
|
|
|
|
2012-03-23 10:43:39 +00:00
|
|
|
#include "registers.hpp"
|
|
|
|
#include "instructions-arm.hpp"
|
|
|
|
#include "instructions-thumb.hpp"
|
|
|
|
#include "disassembler.hpp"
|
2015-06-24 13:21:24 +00:00
|
|
|
|
|
|
|
virtual auto step(unsigned clocks) -> void = 0;
|
2015-07-01 10:58:42 +00:00
|
|
|
virtual auto bus_idle() -> void = 0;
|
|
|
|
virtual auto bus_read(unsigned mode, uint32 addr) -> uint32 = 0;
|
|
|
|
virtual auto bus_write(unsigned mode, uint32 addr, uint32 word) -> void = 0;
|
2015-06-24 13:21:24 +00:00
|
|
|
|
|
|
|
//arm.cpp
|
|
|
|
auto power() -> void;
|
|
|
|
auto exec() -> void;
|
|
|
|
auto idle() -> void;
|
2015-07-01 10:58:42 +00:00
|
|
|
auto read(unsigned mode, uint32 addr) -> uint32;
|
|
|
|
auto load(unsigned mode, uint32 addr) -> uint32;
|
|
|
|
auto write(unsigned mode, uint32 addr, uint32 word) -> void;
|
|
|
|
auto store(unsigned mode, uint32 addr, uint32 word) -> void;
|
2015-06-24 13:21:24 +00:00
|
|
|
auto vector(uint32 addr, Processor::Mode mode) -> void;
|
|
|
|
|
|
|
|
//algorithms.cpp
|
|
|
|
auto condition(uint4 condition) -> bool;
|
|
|
|
auto bit(uint32 result) -> uint32;
|
|
|
|
auto add(uint32 source, uint32 modify, bool carry) -> uint32;
|
|
|
|
auto sub(uint32 source, uint32 modify, bool carry) -> uint32;
|
|
|
|
auto mul(uint32 product, uint32 multiplicand, uint32 multiplier) -> uint32;
|
|
|
|
auto lsl(uint32 source, uint8 shift) -> uint32;
|
|
|
|
auto lsr(uint32 source, uint8 shift) -> uint32;
|
|
|
|
auto asr(uint32 source, uint8 shift) -> uint32;
|
|
|
|
auto ror(uint32 source, uint8 shift) -> uint32;
|
|
|
|
auto rrx(uint32 source) -> uint32;
|
|
|
|
|
|
|
|
//step.cpp
|
2015-07-01 10:58:42 +00:00
|
|
|
auto pipeline_step() -> void;
|
2015-06-24 13:21:24 +00:00
|
|
|
auto arm_step() -> void;
|
|
|
|
auto thumb_step() -> void;
|
|
|
|
|
|
|
|
//serialization.cpp
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
2015-07-01 10:58:42 +00:00
|
|
|
bool trace = false;
|
|
|
|
uintmax_t instructions = 0;
|
2012-03-23 10:43:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|