Commit Graph

80 Commits

Author SHA1 Message Date
DesperateProgrammer 06ea3f68ec Cleaned up and fastened up 2024-01-31 12:20:41 +01:00
DesperateProgrammer 1dc15a0d07 Simplified set selection adjustment for the cache lock down 2024-01-26 10:09:10 +01:00
DesperateProgrammer caa90dd5ac Changed DCache Random Cache-Line selection to a double Galoise LFSR 2024-01-26 09:21:08 +01:00
DesperateProgrammer a0f4eb691b Fixed Typo and missing file on the cache type constants 2024-01-25 12:12:31 +01:00
DesperateProgrammer cd60c13ea1 Replaced Magic numbers in CP15 cache type register 2024-01-25 12:09:17 +01:00
DesperateProgrammer 6959d6f2b0 Added privilege checks for reading & writing CP15 cache registers 2024-01-25 11:52:37 +01:00
DesperateProgrammer 8a0ad8ac3f Added permission checks to CP15 Cache register write operations 2024-01-25 11:44:26 +01:00
DesperateProgrammer 3c94802704 Removed magic number from Cache Fill timings. 2024-01-25 11:05:58 +01:00
DesperateProgrammer bf0767b4f3 Added CP15 prefetch routine 2024-01-25 10:48:04 +01:00
DesperateProgrammer 9d2e515947 Implemented CacheLockDown 2024-01-25 10:08:57 +01:00
DesperateProgrammer 7b8327d3a4 Disabled Caches, when JIT is enabled 2024-01-25 09:05:51 +01:00
DesperateProgrammer 71b5c829aa Fixed unaligned access to data cache 2024-01-24 14:53:55 +01:00
DesperateProgrammer b23cb819bb Changed write to cached data from invalidating to updating the cached data to get nearer to hw timings 2024-01-24 11:57:57 +01:00
DesperateProgrammer f67e93918c Fixed data cache using only 1 cycle on miss. 2024-01-24 11:02:34 +01:00
DesperateProgrammer a46f972c21 Added Cache Data Write and Read via CP15 2024-01-24 10:37:17 +01:00
DesperateProgrammer 0a07661b57 Implemented DCache and several CP15 registers 2024-01-24 09:51:56 +01:00
DesperateProgrammer b6b0197dd3 Implemented "weird" instruction cache invalidation by Set/Way 2024-01-19 10:38:07 +01:00
DesperateProgrammer d9fcc2ec2c Replaced more CP15 magic values with named constants 2024-01-19 10:24:02 +01:00
DesperateProgrammer 434c234098 Enable instruction cache routines. Fixed typos in constants. 2024-01-19 10:00:02 +01:00
DesperateProgrammer 1019afee92 Cleaned up magic numbers and simplified (not yet used) ICache functions
Marked reading CP15 Cache Dirty Bit as not present
2024-01-19 08:30:38 +01:00
DesperateProgrammer 716b4af815 Added ICacheLockDown and DCacheLockDown to CP15 savestate 2024-01-18 14:35:03 +01:00
DesperateProgrammer a2f711c048 Added CP15 Data and Instruction Cache Lockdown Register 2024-01-18 09:39:33 +01:00
Jesse Talavera 9bfc9c08ff
Sprinkle `const` around where appropriate (#1909)
* Sprinkle `const` around where appropriate

- This will make it easier to use `NDS` objects in `const` contexts (e.g. `const` parameters or methods)

* Remove the `const` qualifier on `DSi_DSP::DSPRead16`

- MMIO reads can be non-pure, so this may not be `const` in the future
2023-12-12 11:07:22 +01:00
Jesse Talavera-Greenberg e973236203
Refactor `NDS` and `DSi` to be objects (#1893)
* First crack at refactoring NDS and DSi into objects

- Remove all global/`static` variables in `NDS` and related classes
- Rely more on virtual dispatch when we need to pick methods at runtime
- Pass `NDS&` or `DSi&` to its constituent components where necessary
- Introduce some headers or move some definitions to break `#include` cycles

* Refactor the frontend to accommodate the core's changes

* Move up `SchedList`'s declaration

- Move it to before the components are initialized so the `map`s inside are initialized
- Fields in C++ are initialized in the order they're declared

* Fix a crash when allocating memory

* Fix JIT-free builds

* Fix GDB-free builds

* Fix Linux builds

- Explicitly qualify some member types in NDS, since they share the same name as their classes

* Remove an unnecessary template argument

- This was causing the build to fail on macOS

* Fix ARM and Android builds

* Rename `Constants.h` to `MemConstants.h`

* Add `NDS::IsRunning()`

* Use an `#include` guard instead of `#pragma once`
2023-11-28 23:16:41 +01:00
Jesse Talavera-Greenberg 346dd4006e
Move all core types into namespaces (#1886)
* Reorganize namespaces

- Most types are now moved into the `melonDS` namespace
- Only good chance to do this for a while, since a big refactor is next

* Fix the build
2023-11-25 18:32:09 +01:00
Jesse Talavera-Greenberg 544fefa27f
Refactor the JIT to be object-oriented (#1879)
* Move TinyVector to a new file

- So it's less sensitive to #include ordering

* Forgot to include assert.h

* Refactor ARMJIT_Memory into an object

* Oops, forgot a declaration

* Refactor ARMJIT to be contained in an object

* Remove an unused function declaration

* Add a missing #include

* Remove a now-unused global

* Use ARMJIT_Memory's own memory access functions

* Fix some omissions in the ARM JIT

* Move libandroid to be a member of ARMJIT_Memory instead of a global

* Default-initialize most fields in ARMJIT_Compiler.h

* Define NOOP_IF_NO_JIT

* Finish refactoring the JIT to be object-oriented
2023-11-18 16:40:54 +01:00
Arisotura ac38faef14 update copyright years 2023-11-04 00:21:46 +01:00
Jesse Talavera-Greenberg ee55677086
Assorted portability enhancements (#1800)
* Introduce some Platform calls for managing dynamic libraries

* Add Platform::WriteFATSectors

* Introduce some Platform calls for managing dynamic libraries

* Add Platform::WriteFATSectors

* Change includes of "../types.h" to "types.h"

- Makes it easier to directly include these headers in downstream projects

* Change an include of "../Wifi.h" to "Wifi.h"

* Allow CommonFuncs.cpp to compile on Android

* Tidy up some logging calls

- Use Platform::Log in LAN_Socket.cpp
- Soften some warnings to Debug logs (since they don't necessarily represent problems)

* Add Platform::EnterGBAMode

- Gracefully stop the emulator if trying to enter GBA mode

* Soften some logs that most players won't care about

* Soften some more logs

* Introduce Platform wrappers for file operations

* Fix pointer spacing

* Fix more style nits

* Log the errno when ftruncate fails

* Fix FileSeek offset argument

- With an s32 offset, we couldn't access files larger than 2GB

* Revise Platform::StopEmu to address feedback

- Remove Platform::EnterGBAMode in favor of adding a reason to Platform::StopEmu
- Also rename Platform::StopEmu to Platform::SignalStop
- Add an optional argument to NDS::Stop
- Use the new argument everywhere that the console stops itself

* Rename FileGetString to FileReadLine

- It conveys the meaning better

* Rename FileSeekOrigin::Set to Start

- It conveys the meaning better

* Change definition of FileGetString to FileReadLine

- Oops, almost forgot it

* Rename FlushFile to FileFlush

- To remain consistent with the other File functions

* Add a FileType usage

* Fix line break in FileSeekOrigin

* Document Platform::DeInit

* Clarify that StopReason::Unknown doesn't always mean an error

* Move and document FileType::HostFile

* Remove Platform::OpenDataFile

- Nothing currently uses it

* Refactor Platform::OpenFile and Platform::OpenLocalFile to accept a FileMode enum instead of a string

- The enum is converted to fopen flags under the hood
- The file type is used to decide whether to add the "b" flag
- Some helper functions are exposed for the benefit of consistent behavior among frontends
- Equivalent behavior is maintained

* Fix a tab that should be spaces

* Use Windows' 64-bit implementations of fseek/ftell

* Move Platform::IsBinaryFile to Platform.cpp

- It could vary by frontend

* Remove an unused FileType

* Rename an enum constant

* Document various Platform items

* Use Platform::DynamicLibrary to load libandroid

- And clean it up at the end

* Fix a typo

* Pass the correct filetype to FATStorage

- Since it can be used for DSI NAND images or for SD cards

* Remove Platform::FileType
2023-08-18 22:50:57 +02:00
Jesse Talavera-Greenberg 79dfb8dc8f
Introduce `Platform::Log` (#1640)
* Add Platform::Log and Platform::LogLevel

* Replace most printf calls with Platform::Log calls

* Move a brace down

* Move some log entries to one Log call

- Some implementations of Log may assume a full line

* Log the MAC address as LogLevel::Info
2023-03-23 18:04:38 +01:00
RSDuck 32609bbc98 invalidate JIT blocks in ARM7 WVRAM when it's remapped 2022-08-22 00:39:08 +02:00
Arisotura 35cc79787d update copyright headers 2022-01-09 02:15:50 +01:00
RSDuck 6c2ea93173 get rid of DTCMSize 2021-10-29 01:35:47 +02:00
Arisotura cca5615748 add the PU checks. bahahahah 2021-10-29 00:36:55 +02:00
Arisotura c532059cd3 oops! 2021-10-28 22:45:23 +02:00
Arisotura 15a66b1be1 more accurate DTCM check 2021-10-28 22:41:42 +02:00
Arisotura d20543c119
DMA timing renovation (#1207)
* make timers usable for measurement shito without being assfuckingly unreliable

* bürp

* Arisotura can you ever clean up your goddamn code

also regroup the timer code instead of having it split weirdly

* make the set-timing functions a tad less hacky

* congrats Arisotura you made an ass-enum

* add timing region tables, and separate timings for ARM9 DMA (exempt of 3c penalty)

* temp work on DMA timings, not finished

also, did you know? 'increment/reload' is also a thing for the source address

* begin work

* add some of the GBA slot/wifi timings

* complete it, I guess

* make some progress

* getting somewhere

* sdsdfs

* see, Arisotura, was it that hard? blarg.
2021-08-31 02:28:34 +02:00
RSDuck 436b3c4c1d update copyright year and add missing GPL headers 2021-03-12 20:07:40 +01:00
Arisotura ba373ca72a DSi: make ARM9-clock-selector actually work 2020-08-17 19:15:45 +02:00
Nadia Holmquist Pedersen b4ad35948d Merge remote-tracking branch 'upstream/slirp' into slirp-merge 2020-07-26 21:41:09 +02:00
RSDuck 8a96dfce18 fix build with JIT disabled
fixes #675 and #674
2020-07-25 20:59:53 +02:00
RSDuck c5381d2911 reconcile DSi and JIT, fastmem for x64 and Windows 2020-06-30 23:50:41 +02:00
RSDuck e335a8ca76 first steps in bringing over the JIT refactor/fastmem 2020-06-16 12:11:19 +02:00
RSDuck 052ff73672 rewrite JIT memory emulation 2020-06-16 12:01:08 +02:00
RSDuck 6d217e1010 fix build with JIT disabled and set default JIT maxblock size to 32 2020-06-16 11:59:09 +02:00
RSDuck 1ad90cb334 include more information in DataRegion 2020-06-16 11:58:46 +02:00
RSDuck 40b88ab05a new block cache and much more...
- more reliable code invalidation detection
- blocks aren't stopped at any branch, but are being followed
if possible to get larger blocks
- idle loop recognition
- optimised literal loads, load/store cycle counting
 and loads/stores from constant addresses
2020-06-16 11:56:36 +02:00
RSDuck 0d786573ab remove debug printf 2020-06-16 11:54:48 +02:00
RSDuck 00cd9af033 fix uninitialised memory mapping 2020-06-16 11:54:47 +02:00
RSDuck 86f2be7260 jit: add compile option 2020-06-16 11:54:03 +02:00
RSDuck c692287eba JIT: base
all instructions are interpreted
2020-06-16 11:53:05 +02:00