Commit Graph

86 Commits

Author SHA1 Message Date
Arisotura
8fc403cdad update copyright headers 2024-06-15 17:01:19 +02: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
53e5aa6298 Exclude JIT-related declarations more aggressively 2023-12-08 17:19:00 +01:00
Jesse Talavera
090627b3c1
Remove the last ConfigEntry state (#1902)
* Get rid of `ConfigEntry::ExternalBIOSEnable`

- Now the BIOS files themselves are checked
- The frontend's `Config::ExternalBIOSEnable` is not affected

* Add `JITArgs`

* Pass the JIT status to the `ARM` constructors

* Encapsulate `NDS::EnableJIT`

* Pass `JITArgs` to `ARMJIT`'s constructor

* Remove the `JIT_*` `ConfigEntry`s in favor of members

- Allow all the JIT args to be set with `NDS::SetJITArgs`
- Encapsulate the JIT-related parameters in `ARMJIT` so they can reset the block cache if changed
- Update the active (or newly-created) console in the frontend with adjusted JIT args

* Make audio bit depth and interpolation configurable in `NDSArgs`

- Define enums for both
- Give those settings default values in `NDSArgs`
- Remove `ConfigEntry::AudioBitDepth`
- Initialize these settings in the relevant SPU constructors

* Move the last DSi-specific logic in `Reset` to its own subclass

* Remove `ConfigEntry::DSi_FullBIOSBoot`

- Add members to `DSi` instead for getting and setting this
- Update the frontend to accommodate these changes

* Oops, missed a spot

* Remove `ConfigEntry::Firm_MAC` and `Platform::GetConfigArray`

- Also move the MAC parsing code to `ROMManager`

* Remove the last `ConfigEntry` state

- Make GDB support configurable via members

* Add some `#ifdef`s that I'd almost forgotten
2023-12-05 16:47:16 +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
PoroCYon
3ab752b8ca
GDB stub (#1583)
* gdbstub beginnings

* gdbstub: finish gdb impl things, next up is integration with melonDS

* holy fuck the gdbstub works

* gdb breakpoints work, but there's a mysterious crash on continue

* fix memory corruption that sometimes happened, and make resetting the console thru gdb work

* remove some gdb debug printing

* fix things in gdbstub

* separate option for enabling gdbstub

* add mode-dependent CPU registers

* C++ize the GDBstub code

* add gdbstub config in emu settings dialog

* make sure gdb is disabled when jit is enabled

* Remove unnecessary compiler flags, mark ARMJIT assembly code as no-execute-stack

This hardens the binary a little bit against common exploitation methods

* add option to wait for debugger attach on startup

* only insert GNU stack notes on linux

* disable gdbstub enable checkbox when jit is enabled

* fix non-linux incompatibilities

* enable gdbstub by default

* fix issues with gdbstub settings disable stuff

* format stuff

* update gdb test code

* Fix segfault when calling StubCallbacks->GetCPU()

C++ overrides are hard. Please I'm just a lowly C programmer.

* fix packet size not being sent correctly

Thanks to @GlowingUmbreon on Github for troubleshooting this

* fix select(2) calls (i should read docs more properly)

* fix GDB command sequencing/parsing issue (hopefully)

* [GDB] implement no-ack mode

* fix sending ack on handshake

* get lldb to work
2023-10-22 15:35:31 +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
Arisotura
9394dde67a fix copyright headers 2022-03-07 21:08:54 +01:00
Arisotura
35cc79787d update copyright headers 2022-01-09 02:15:50 +01:00
Arisotura
19ddaee13b finally decouple Config from the core. baahhahahahah 2021-11-18 01:17:51 +01:00
Arisotura
c1dcd585be decouple JIT from Config. bahahahahah 2021-11-17 18:15:50 +01:00
RSDuck
55ec724fee more fixes for literal invalidation 2021-08-31 08:13:22 +02:00
RSDuck
8d2746e517 fix #1187
how could this go on unnoticed for so long?
2021-08-31 04:53:25 +02:00
RSDuck
9ee2017443 don't add constant cycles if they're 0 2021-07-24 17:07:08 +02:00
RSDuck
6944fdbe78 add support for JIT profiling with VTune 2021-07-24 16:20:03 +02:00
RSDuck
c2152c8f74 JIT: fix ldm with writeback loading rn 2021-07-24 04:35:45 +02:00
RSDuck
aa430608e7 support allocating more registers for aarch64 JIT
also some minor fixes for the x64 JIT as well
2021-06-29 22:25:43 +02:00
RSDuck
f060162dac attempt at fixing #1037 2021-03-17 16:44:54 +01:00
RSDuck
436b3c4c1d update copyright year and add missing GPL headers 2021-03-12 20:07:40 +01:00
WaluigiWare64
43348210f9 Fix some compiler warnings 2021-01-25 14:12:13 +00:00
RSDuck
771dfaca2e JIT: handle STR post with rd == rn
fixes Zelda Four Swords
2021-01-19 23:50:08 +01:00
RSDuck
5865b4438e fix JIT block hash after a merged thumb BL
fixes #928
2021-01-05 22:38:29 +01:00
webgeek1234
298b958e2a
Rename jit linkage asm files (#836)
An extension of lower case s indicates to not run the
preprocessor while upper case S does. These files have defines.
2020-12-01 19:48:46 +01:00
WaluigiWare64
7da4550eea
Add support for macOS (#771)
* use shm_open() instead of memfd_create() on macOS

malloc.h isn't a header on macOS

* Change OpenGL headers + create ifdef for DO_PROCLIST

macOS seems to already have the OpenGL functions defined, without the ifdef, it gives "ambiguous references" errors.

* macOS doesn't have ->gregs in uc_mcontext

and it doesn't have REG_RIP either
https://github.com/gperftools/gperftools/blob/master/m4/pc_from_ucontext.m4

* use getpid() to make memory file name unique

* #ifndef __APPLE__ for AF_PACKET and linux/if_packet.h

* Add include and link directories for macOS and link the OpenGL framework

* Add macOS CI

* Use newly added libslirp package from Homebrew

https://github.com/Homebrew/homebrew-core/pull/63412

* Use Apple's Clang instead of GNU GCC on macOS

* Add macOS build instructions to README

* Try to fix macOS undefined symbol

* snprintf doesn't take null terminator into account

* Map new memory on macOS for JIT

* Only use gcc-ar if using GNU Compiler

* re-add fastmem code - whoops!

* Fix style issue - use camelCase not snake_case

* Set Minimum macOS version

* Switch Minimum OS X version to 10.9

* Add macOS libpcap library name

* fix memory leak

* Fix binding keys in macOS

* Allow getting MAC address on macOS

melonDS on Linux uses AF_PACKET, which doesn't exist on macOS. Instead, this commit uses AF_LINK on macOS to get the MAC address.

* Remove unneeded macOS CI dependencies

* Build melonDS app bundle on macOS

Now it is no longer required to install the libraries on macOS, they come with the app bundle.

* fix macOS CI not being able to find macdeployqt

* copy melonDS.app with recursive because it's a folder

* Disable fastmem checkbox on macOS

* Disable fastmem by default in config

* forgot a semicolon

* Don't bundle libraries, causes issues on macOS <10.15

* Update README + allow finding version in Finder on macOS

* Make sure fastmem checkbox stays uncheckable
2020-11-29 17:11:33 +01:00
RSDuck
78839f862e JIT fixes
- fix fastmem problems on linux
- small fix memory leak
- SlowWrite functions always take in a 32-bit variable so that the C compiler knows that the values aren't necessary zero extended
- a few other stylistic things
- handle SIGBUS as well (for macos)
2020-11-09 20:43:31 +01:00
Filippo Scognamiglio
fbca47381b
Fix a couple of wrong cpp function pointers. (#785) 2020-10-31 17:53:01 +01:00
Filippo Scognamiglio
45ea1fa990
Fix compilation issues on pedantic cpp compilers. (#783)
* Fix compilation issues on pedantic cpp compilers.

* Avoid using fullblown static function.
2020-10-31 17:40:05 +01:00
Valeri
0d845c9e69
Random minor fixes (#757)
* Fix incorrect/questionable assert() usage

Originally reported by https://lgtm.com/projects/g/Arisotura/melonDS/?mode=tree&ruleFocus=2159000700,
but also includes a bunch of other fixes.

* Fix some `printf` warnings

Rule https://lgtm.com/projects/g/Arisotura/melonDS/?mode=tree&ruleFocus=2160310550

* Remove useless check

It is never passed thanks to `if (num_in < 1) {...; return}` before
Rule https://lgtm.com/projects/g/Arisotura/melonDS/?mode=tree&ruleFocus=2154840804

* Add missing header guard, rename other to avoid conflicts

Rule https://lgtm.com/projects/g/Arisotura/melonDS/?mode=tree&ruleFocus=2163210746

* Make DSi_SDDevice destructor virtual

Rule https://lgtm.com/projects/g/Arisotura/melonDS/?mode=tree&ruleFocus=2158670642

* Use thread-safe localtime_r, assign `time` result directly

Rule https://lgtm.com/projects/g/Arisotura/melonDS/?mode=tree&ruleFocus=2154840805

* Fix MinGW build

It needs _POSIX_THREAD_SAFE_FUNCTIONS to export `localtime_r`
2020-10-01 13:44:09 +02:00
RSDuck
9772201345 remove some UB
- savestates used to read a four bytes from a single byte value
- a few unassigned variables
- some other things
- also make the ROR macro an inline function
2020-09-04 20:37:14 +02:00
RSDuck
5903b11bda subtract cycles after checking IRQ and Halt
also switch back to adding to ARM::Cycles instead of subtracting from them
2020-07-27 23:14:39 +02:00
RSDuck
17ce4d2a73 x64 JIT: remove unecessary MOV 2020-07-27 13:49:13 +02:00
RSDuck
0e7df468c7 x64 JIT: generate patch trunk for RSCRATCH4
I thought I already fixed this?
2020-07-25 22:21:26 +02:00
RSDuck
887ad27ed8 implement carry setting ALU op with imm 2020-07-25 22:08:43 +02:00
RSDuck
8f5d8d1e12 fix for fastmem when pc is used as immediate
and (hopefully) make SIGSEGV handler work for aarch64 linux
2020-07-08 23:47:24 +02:00
RSDuck
3786660099 misc JIT changes 2020-07-08 23:08:25 +02:00
RSDuck
778623a8b7 make linux work and fix a few bugs 2020-07-04 18:58:00 +02:00
RSDuck
c5381d2911 reconcile DSi and JIT, fastmem for x64 and Windows 2020-06-30 23:50:41 +02:00
RSDuck
ea6d03581b make literal optimisation work again
enable single register block load/store optimisations for x64 aswell
2020-06-16 12:11:20 +02:00
RSDuck
e335a8ca76 first steps in bringing over the JIT refactor/fastmem 2020-06-16 12:11:19 +02:00
RSDuck
fea9f95bba fix inlined IO register access 2020-06-16 12:06:43 +02:00
RSDuck
4cff4b5228 allow allocating caller saved regs on windows 2020-05-09 15:39:39 +02:00
RSDuck
5a0b568647 allow allocating caller saved registers
currently system-v only
2020-05-09 14:34:52 +02:00
RSDuck
0f53a34551 rewrite JIT memory emulation 2020-05-09 00:45:05 +02:00
RSDuck
bcc4b5c8dd fix regression from last commit
also a small mistake with msr
2020-04-26 23:25:32 +02:00
RSDuck
b0b9ec42e4 don't use param registers for ReadBanked/WriteBanked
should fix linux build
2020-04-26 20:47:36 +02:00
RSDuck
59c8d39765 hopefully fix stack handling for linux 2020-04-26 16:17:16 +02:00
RSDuck
a9dd6e30ad implement msr and mrs for the x64 JIT 2020-04-26 13:05:18 +02:00