Commit Graph

86 Commits

Author SHA1 Message Date
lif 17fc254342 Add "JitKvm" (copy of Cached Interpreter for now) 2020-02-15 21:07:42 -08:00
CrystalGamma b00a7045aa PowerPC: Thread state through float helpers 2019-04-02 19:59:29 +02:00
CrystalGamma e3075f3834 PowerPC: Factor out CR helpers into POD class 2019-03-08 20:42:09 +01:00
Lioncash 244d083f0e PowerPC: Remove separate macros for paired singles
Previously, PowerPC.h had four macros in it like so:

\#define rPS0(i) (*(double*)(&PowerPC::ppcState.ps[i][0]))
\#define rPS1(i) (*(double*)(&PowerPC::ppcState.ps[i][1]))

\#define riPS0(i) (*(u64*)(&PowerPC::ppcState.ps[i][0]))
\#define riPS1(i) (*(u64*)(&PowerPC::ppcState.ps[i][1]))

Casting between object representations like this is undefined behavior.
Given this is used heavily with the interpreter (that is, the most
accurate, but slowest CPU backend), we don't exactly want to allow
undefined behavior to creep into it.

Instead, this adds a helper struct for operating with the paired singles,
and replaces the four macros with a single macro for accessing the
paired-singles/floating-point registers.

This way, it's left up to the caller to explicitly decide how it wants to interpret
the data (and makes it more obvious where different interpretations of
the same data are occurring at, as there'll be a call to one of the
[x]AsDouble() functions).
2018-12-25 10:35:09 -05:00
Lioncash 562d2a700b PowerPC: Add functions to read/write the full timebase value
Allows us to get rid of a silly pointer cast and deduplicate some code
from the front-end when it comes to reading the value.
2018-06-19 13:26:08 -04:00
Lioncash 6f473b96d0 PowerPC: Convert CPUCore enum into an enum class
Makes the enum values strongly-typed and prevents the identifiers from
polluting the PowerPC namespace. This also cleans up the parameters of
some functions where we were accepting an ambiguous int type and
expecting the correct values to be passed in.

Now those parameters accept a PowerPC::CPUCore type only, making it
immediately obvious which values should be passed in. It also turns out
we were storing these core types into other structures as plain ints,
which have also been corrected.

As this type is used directly with the configuration code, we need to
provide our own overloaded insertion (<<) and extraction (>>) operators
in order to make it compatible with it. These are fairly trivial to
implement, so there's no issue here.

A minor adjustment to TryParse() was required, as our generic function
was doing the following:

N tmp = 0;

which is problematic, as custom types may not be able to have that
assignment performed (e.g. strongly-typed enums), so we change this to:

N tmp;

which is sufficient, as the value is attempted to be initialized
immediately under that statement.
2018-06-15 10:27:59 -04:00
Lioncash 06056d4f45 Gekko: Make register constructors explicit where applicable
Prevents implicit conversions to types and requires explicitly
specifying them in order to construct instances of them. Given these are
used within emulation code directly, being explicit is always better
than implicit.
2018-06-03 12:37:17 -04:00
Lioncash b9aad3310e PowerPC: Move MMU-specifics from PowerPC.h to MMU.h
PowerPC.h at this point is pretty much a general glob of stuff, and it's
unfortunate, since it means pulling in a lot of unrelated header
dependencies and a bunch of other things that don't need to be seen by
things that just want to read memory.

Breaking this out into its own header keeps all the MMU-related stuff
together and also limits the amount of header dependencies being
included (the primary motivation for this being the former reason).
2018-05-17 19:18:55 -04:00
Lioncash ddbe292d54 PowerPC: Parenthesize GQR macro argument
Ideally none of these macros would exist (long-term goal), however in
the meantime at least make sure expressions always evaluate correctly
(thankfully no current usages rely on this).
2018-05-17 04:48:29 -04:00
Lioncash 3f19aa6469 PowerPC/Interpreter: Avoid sign conversion with utility functions
Given we're operating with flags and bit representations, lets avoid
signed values here. It lessens the amount of sign conversion warnings
and lessens the amount of things to think about screwing you over when
making changes to the interpreter among other things.
2018-05-16 22:21:26 -04:00
Lioncash cb5926c1ca PowerPC: Make the PowerPCState's fpscr member variable a UReg_FPSCR instance
Gets rid of the need to cast the actual member to access information without bit shifts and masking.
2018-05-06 18:46:52 -04:00
Léo Lam 76b031184c
Merge pull request #6341 from sepalani/debug-watches
DebugInterface: Watches methods added
2018-05-06 13:25:26 +02:00
Lioncash ffcf107dd2 PowerPC: Make the PowerPCState's msr member variable a UReg_MSR instance
Gets rid of the need to construct UReg_MSR values around the the actual
member in order to query information from it (without using shifts and
masks). This makes it more concise in some areas, while helping with
readability in some other places (such as copying the ILE bit to the LE
bit in the exception checking functions).
2018-05-05 17:59:30 -04:00
Sepalani 74d4a4478f DebugInterface: Watches methods added
Move Watches to Common
2018-04-28 17:46:51 +04:00
Sepalani 048513183e PowerPC: HostR/W float/double added 2018-04-17 08:29:47 +04:00
Lioncash 4c97deb364 PowerPC: Namespace all header contents for PowerPC.h
Puts everything under the same namespace. Previously the header was only
partially namespaced, which is inconsistent.
2018-03-22 19:01:47 -04:00
Lioncash e53fffeb90 PowerPC: Properly unset the overflow bit
The OV bit is non-sticky. Therefore, after an overflow-enabled
instruction executes, if an overflow does *not* occur, then OV is
cleared. SO is sticky however, so it staying set in this case is
correct.
2018-03-21 23:59:15 -04:00
Lioncash f129c936e7 PowerPC: Add functions for getting and setting the XER OV bit
While we're at it, change GetXER_SO's return value to u32
to prevent potential sign bit wonkyness given we're performing bit arithmetic.
2018-03-19 11:51:04 -04:00
degasus 6ad63c1b35 Jit64: Inline GP fast check in Cleanup. 2017-11-18 17:43:38 +01:00
degasus 4feddd7748 PowerPC: Include the gather pipe pointer in the ppc state. 2017-11-18 14:14:45 +01:00
Shawn Hoffman ef9090d7da powerpc: silence an int->u32 init warning 2017-06-07 20:09:43 -07:00
JosJuice 256a0cf4db Remove JITIL 2017-05-19 22:21:07 +02:00
JosJuice 9cd9ae902a x86-64 support on Android
We can do this now that the x86-64 JIT supports PIE.

JITIL is deliberately excluded from the GUI because it
doesn't support PIE yet. (JITIL will be used if it's
set in the INI, though.)
2017-04-16 11:53:33 +02:00
Lioncash 8d98ac6509 CPU: Convert state enum to an enum class
Gets enum constants out of the immediate namespace. Also makes it
strongly typed like the other state enums.
2017-03-28 11:48:28 -04:00
degasus 5152c997a4 MMU: Create constants for our BAT flags.
This avoids a few hard-coded constants in several files.
2017-03-15 09:20:40 +01:00
Lioncash 4d1a4ba759 PowerPC: Remove unnecessary const on function declaration parameters 2017-03-06 14:10:33 -05:00
Léo Lam fdfe57a49b IOS: Implement MIOS functionality
This implements MIOS's PPC bootstrapping functionality, which enables
users to start a GameCube game from the Wii System Menu.

Because we aren't doing Starlet LLE (and don't have a boot1), we can
just jump to MIOS when the emulated software does an ES_LAUNCH or uses
ioctlv 0x25 to launch BC.

Note that the process is more complex on a real Wii and goes through
several more steps before getting to MIOS:

* The System Menu detects a GameCube disc and launches BC (1-100)
  instead of the game. [Dolphin does this too.]

* BC, which is reportedly very similar to boot1, lowers the Hollywood
  clock speed to the Flipper's and then launches boot2.

* boot2 sees the lowered clock speed and launches MIOS (1-101) instead
  of the System Menu.

MIOS runs instead of IOS in GC mode and has an embedded GC IPL (which
is the code actually responsible for loading the disc game) and a PPC
bootstrap code. To get things working properly, we simply need to load
both to memory, then jump to the bootstrap code at 0x3400.

Obviously, because of the way this works, a real MIOS is required.
2017-02-08 15:07:34 +01:00
Lioncash 13f70d4597 PowerPC: Convert #defines into typed constants 2017-02-07 20:17:15 -05:00
Lioncash e07383a783 Core: Convert State enum into an enum class 2017-02-05 08:32:23 -05:00
Matthew Parlane 4df22e03ca Merge pull request #4823 from lioncash/tlb
PowerPC: Rename tlb_entry struct to TLBEntry
2017-02-06 00:59:39 +13:00
Lioncash f7b9db9846 PowerPC: Convert CoreMode enum into an enum class
Prevents constants from polluting the namespace.
2017-02-04 19:34:56 -05:00
Lioncash 52b45a3933 PowerPC: Rename tlb_entry struct to TLBEntry
Makes it consistent with our naming style.
2017-02-04 18:58:45 -05:00
Lioncash c67d095787 PowerPC: Move page #define constants to MMU.cpp
These are only ever used here.

This also converts them into typed constants.
2017-02-03 11:48:42 -05:00
degasus 384efb0cb2 JitArm64: Initial implementation of the BLR optimization. 2017-02-02 09:06:34 +01:00
EmptyChaos 49873b1287 MMU/PatchEngine: Fix potential crash during stack probe
TryReadInstruction doesn't validate the address it resolves, that
can result in Memory::GetPointer failing and returning nullptr
which then leads to a nullptr dereference and a crash.

Created PowerPC::HostIsInstructionRAMAddress which works the same
way as PowerPC::HostIsRAMAddress for the IBAT.
2017-01-24 08:05:11 +11:00
degasus 70caf447b9 JitCache: Get physical addresses from PPCAnalyst.
So we support all kind of degenerated blocks now, not just range+length based ones.
2017-01-23 20:33:44 +01:00
Lioncash c761f98ede PowerPC: Simplify TLB resetting
Member initializers and std::array make this trivial for fixed value initialization.
2017-01-18 19:31:04 -05:00
Lioncash 6c61021eb1 PPCTables: Use std::array instead of raw C arrays 2017-01-18 03:03:00 -05:00
Lioncash ea8fc594a5 Common: Move BreakPoints into Core
BreakPoints utilizes the jit global variable, so this was making Core and
Common cyclical dependencies on one another.
2017-01-10 05:24:44 -05:00
EmptyChaos 83407263e5 HLE/GeckoCode: Add new HLE hook exit trampoline
Dolphin emulates GeckoCodes by fiddling with the CPU state when a
VI Interrupt occurs. The problem with this is that we don't know
where the PC is so it's non-deterministic and not necessarily
suitable for use with the codehandler.

There are two options: Patch the game like Gecko OS either directly
or using HLE::Patch, or use a trampoline so we can branch from any
PC even if it would otherwise not be valid. The problem with Gecko OS
patches is there are 10 of them and they have to be configured
manually (i.e. Game INIs to would need to have a [Core]GeckoHookType
property).

HLE_Misc::GeckoReturnTrampoline enables the Code Handler to be
entered from anywhere, the trampoline restores all the registers that
had to be secretly saved to the stack.
2016-10-03 16:27:42 +11:00
degasus a4d72ac6e3 MMU: Add small BAT comment. 2016-09-06 08:43:31 +02:00
degasus 6493ea1eb9 MMU: Coding style fixes. 2016-09-06 08:43:31 +02:00
magumagu d557310371 Support for dynamic BAT modification (dynamic-bat).
Fundamentally, all this does is enforce the invariant that we always
translate effective addresses based on the current BAT registers and
page table before we do anything else with them.

This change can be logically divided into three parts.  The first part is
creating a table to represent the current BAT state, and keeping it up to
date (PowerPC::IBATUpdated, PowerPC::DBATUpdated, etc.).  This does
nothing by itself, but it's necessary for the other parts.

The second part (mostly in MMU.cpp) is simply removing all the hardcoded
checks for specific untranslated addresses, and consistently translating
addresses using the current BAT configuration. Very straightforward, but a
lot of code changes because we hardcoded assumptions all over the place.

The third part (mostly in Memmap.cpp) is making the fastmem arena reflect
the current BAT configuration.  We do this by redoing the mapping (calling
memmap()) based on the BAT table whenever it changes.

One additional minor change is that translation can fail in two ways:
either the segment is a direct store segment, or page table lookup failed.
The difference doesn't usually matter, but the difference affects cache
instructions, like dcbz.
2016-09-06 08:43:22 +02:00
aldelaro5 47d1b07abb Add a thread safe variant of invalidating the icache
This is used by the next commit.
2016-08-23 07:37:41 -04:00
magumagu 758e6406cd JIT: fix handling of PC in dispatcher/block cache.
Specifically, don't make any assumptions about what effective addresses
are used for code, and correctly handle changes to MSR.DR/MSR.IR.

(Split off from dynamic-bat.)
2016-08-06 11:41:39 +02:00
Scott Mansell 6834b4cb27 Revert "JitCache: Support for VMEM + MSR bits" 2016-07-27 11:15:25 +12:00
magumagu b81d008f92 JIT: fix handling of PC in dispatcher/block cache.
Specifically, don't make any assumptions about what effective addresses
are used for code, and correctly handle changes to MSR.DR/MSR.IR.

(Split off from dynamic-bat.)
2016-07-16 09:24:05 +02:00
Pierre Bourdon 3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
EmptyChaos c1922783f8 Core: Threadsafety Synchronization Fixes (Frame Advance / FifoPlayer)
Fix Frame Advance and FifoPlayer pause/unpause/stop.

CPU::EnableStepping is not atomic but is called from multiple threads
which races and leaves the system in a random state; also instruction
stepping was unstable, m_StepEvent had an almost random value because
of the dual purpose it served which could cause races where CPU::Run
would SingleStep when it was supposed to be sleeping.

FifoPlayer never FinishStateMove()d which was causing it to deadlock.
Rather than partially reimplementing CPU::Run, just use CPUCoreBase
and then call CPU::Run(). More DRY and less likely to have weird bugs
specific to the player (i.e the previous freezing on pause/stop).

Refactor PowerPC::state into CPU since it manages the state of the
CPU Thread which is controlled by CPU, not PowerPC. This simplifies
the architecture somewhat and eliminates races that can be caused by
calling PowerPC state functions directly instead of using CPU's
(because they bypassed the EnableStepping lock).
2016-05-13 09:23:44 +10:00
Chris Burgener 3140f9b226 Change GetStatePtr() Return to const 2016-04-05 12:45:48 -04:00