1670 Commits

Author SHA1 Message Date
TuxSH
5cdbfab54b Add build options to Makefile
For stuff like testing PASLR, *hax2x, khc3ds, etc.

Also fix a corner-case bug when changing the 3dsx app from itself to
itself, if its TID corresponds to the default.
2023-01-07 15:38:36 +00:00
TuxSH
da0b1a1389 Revert force-setting SysNAND when launching TWL Mode
This being said, neither legacy FIRM nor DSiWare actually support
EmuNAND; installing the same TWL title on both SysNAND and EmuNAND and
then launch it from EmuNAND will work though.

It is only when exiting AGB firm that we want to boot SysNAND no matter
what, because the save file has been written on a partition in SysNAND.

This is mainly to ensure we reboot to the proper NAND in case we reboot.
2023-01-03 21:31:37 +01:00
TuxSH
fe4bb0857b Implement autobooting into homebrew (3DS and DSi modes)
Add config option to autoboot into 3DS and DSi homebrew menu, without
going through Home Menu (nor launching it).

For 3DS homebrew, this requires homebrew built with libctru v2.0.0 or
later (v2.0.0 was released 2.5y ago).

We simulate a "reboot into title" to achieve this. This being said, when
launching stuff like Pokemon US/UM on O3DS, Home Menu reboots into
itself and not the game directly. This will cause Home Menu to crash if
you use this feature and configure it to use a non-default memory layout
(but if you don't, Home Menu will work just fine).
2023-01-03 15:30:07 +01:00
TuxSH
0a6b6865ca loader: always reload ExHeader for hb, after all
Caching exheader for applications launched through Home Menu has very
little benefit, as UnregisterProgram is called a lot, and, for 3DSX,
boot.3dsx/target 3DSX can be changed at any time.
2022-12-29 18:47:43 +01:00
TuxSH
ffbd8554d5 loader: implement PASLR (disabled by default)
Faithfully implement the PASLR algorithm official Loader
uses (it's not very good). Physical address space layout
randomization means that the layout of the pages in physical
memory are randomized, but doens't randomize the virtual addresses.

Also refactor some parts of our Loader impl a little more.
2022-12-29 00:23:45 +01:00
TuxSH
7074ac1166 Move hb:ldr from Rosalina to Loader
Let's not pretend in 2022 that it needed things from rosalina sysmodule
- it did not.

This moves 3DSX loading from Rosalina to Loader, and also removes all
the dependencies Loader had to other Luma3DS components (if kernel ext.
is missing, a default config will be used). This means that, as long as
you replace Loader to the one in here, you will be able to properly load
3DSX files.

Changes:
- hb:ldr is now hosted in loader
- hb:ldr LoadProcess, PatchExHeaderInfo, DebugNextApplicationByForce:
  all removed
- fix a bug where some malformed 3DSX files were not rejected
- grant access to CONFIG11 registers to 3DSX homebrew
- move dirty homebrew chainload (when HM. isn't loaded nor loadable) to
  pm
- pm:dbg (ext.) PrepareToChainloadHomebrew: removed
2022-12-25 23:27:48 +01:00
TuxSH
6fa80c959d Update FatFS from R0.13c to R0.15 2022-12-23 19:25:23 +01:00
TuxSH
a7b840e531 Fix upgrade process possibly copying non-Luma firms
Upgrade process always copied sdmc:/boot.firm to nand:/boot.firm even if
Luma3DS was chainloaded from another path.

Fix this by copying from argv[0], if Luma3DS was launched from the SD
card.

Also use "sdmc:" and "nand:" instead of "0:" and "1:" when using FatFS.

Closes #1776.
2022-12-23 14:48:35 +01:00
TuxSH
fcd08d6614 Patch kernel11 to remove checks on core2/3 thread creation
This stubs checks in SvcCreateThread and SvcSetProcessIdealProcessor
that applied when creating threads on core2 and core3. This allows
non-sysmodules to create threads on core3.

Please note, core2 access was already being automatically granted to
3dsx apps for a long time (this is controlled through a kernel flag),
and other apps that needed it had that flag too.
This commit thus changes nothing for all these applications.

Do not create threads on core3 unless you know exactly what you're doing.
On N3DS, gsp (GPU sysmodule) depends on qtm (head-tracking sysmodule) which
runs many threads at very high priority on core3. Running code that needs the
GPU (including printf) on core3 can thus result in thread starvation /
deadlock.

If you just need an extra application core, just use core2 as it is intended
for that exact purpose and is by default completely idle.

Closes #1668
2022-12-17 23:47:19 +01:00
PabloMK7
71cf677b00 config: Ignore rest of pressed buttons (fixes #1769) 2022-09-25 23:01:21 +01:00
Bent
0c3f51815e Rosalina: Fix crash for external PMDBG_DebugNextApplicationByForce 2022-09-25 22:59:02 +01:00
TuxSH
80aee6fdc1 Fix mcu firmware version check (byte order was inverted) 2022-06-10 22:55:18 +01:00
TuxSH
2c184cf7a3 Update chainloader version number 2022-06-04 22:27:31 +01:00
TuxSH
3227b2ea4b Fix battery voltage calculation (thanks nocash) 2022-06-03 23:53:07 +01:00
TuxSH
e5e09c1e13 gdb: use 'swbreak' for bkpt too 2022-06-03 22:18:10 +01:00
TuxSH
4de0375bde kext: fix bug in rosalinaThreadLockPredicate (thanks @hax0kartik) 2022-05-21 20:19:36 +01:00
TuxSH
ea8f9f4667 loader: refactor part around HIO 2022-05-06 19:53:27 +01:00
TuxSH
6573fc4247 k11ext: fix wrong condition bug 2022-05-02 15:57:59 +01:00
TuxSH
65825020ab bootdiag: add process list dumping 2022-04-23 23:55:48 +02:00
TuxSH
e17ff09713 rosalina: Add define to print process creation time 2022-04-23 13:03:30 +02:00
TuxSH
b79717e848 ruh roh 2022-04-16 00:02:04 +01:00
TuxSH
c0eaf1ea3c Add option to toggle power to card slot.
Fixes #1202. This option is meant to be used when you have something like e.g. a flashcard that is misbehaving.
2022-04-15 21:41:23 +01:00
TuxSH
0e16e4c5fc config init: disable patch games by default; alter system settings version string by default 2022-04-13 21:56:07 +01:00
TuxSH
32d13dc117 Add boot9/boot11 dumping 2022-04-13 21:56:02 +01:00
TuxSH
d957494d45 kext: even more perf improvements
Turns out the undef handler path is quite hot, as only one thread per core can have VFP enabled at a time.
2022-04-12 23:55:08 +01:00
TuxSH
1e95344588 bootdiag: forgot #else 2022-04-11 13:36:14 +01:00
TuxSH
cb398f1e4a ldr => ldrb 2022-04-11 01:06:59 +01:00
TuxSH
ef842dda2a Fix extremely obnoxious race-cond+uninit handle bug
This is mostly a libctru bug (well, sort of).

This can only happen to built-in sysmodules, and to
processes waiting for err:f, that fail to obtain
handles through svcConnectToPort first try; and only
prior to 11.0.

Prior to fw 11.0, kernel didn't zero-initialize output
handles, and thus the output handle gets filled with
junk (leaked kernel stack data) in case of failure.
Libctru does not account for this, and closes such
handles anyway (in srvInit, errfInit, and possibly
more).

The problem is that, in our case, that garbage was
equal to 0x8000, actually a valid handle, in fact
the first handle to be created (and not closed) in
a process... a handle to KAddressArbiter.

Accidentally closing this handle resulted in one or
more KIPs spin-waiting and starving core1, resulting
in an inability to boot.

We fix this simply by replicating what recent k11 does,
in kext (for svcConnectToPort). For srvGetServiceHandle,
add two layers of safety.
2022-04-10 22:19:32 +01:00
TuxSH
56be46b4bd rosalina: introduce bootdiag, tool to dump state of a process in early init 2022-04-10 21:43:19 +01:00
TuxSH
f32f3a4854 Fix config yet again 2022-04-10 01:31:56 +01:00
TuxSH
859b11a27d Fix k11ext regression 2022-04-10 00:05:36 +01:00
TuxSH
97ec1298e3 derp 2022-04-09 23:26:28 +01:00
TuxSH
188d86cb7f gdb: always pass current thread ID when stopping 2022-04-09 21:26:47 +01:00
TuxSH
01ebbf114c Restore extended-remote support & map <GDB PID>-><1 + 3DS PID> (breaking change)
Once more, the "official" gdb client is the one than is the least compliant to its very own stub specs (compared to, say, IDA)
2022-04-09 19:28:33 +01:00
TuxSH
2b5da40a1d arm9: util: make chrono non-static 2022-04-06 02:03:04 +01:00
TuxSH
c64f94bc82 kernel ext: perf improvements 2022-04-05 22:23:09 +01:00
TuxSH
3463effeae rosalina: add "time to boot to HM" in debug menu 2022-04-05 18:33:12 +01:00
TuxSH
c71474a668 Fix #1737 (screen filters CCT was OOB) 2022-03-31 01:16:02 +01:00
TuxSH
90d6420f38 Fix typo in swapFramebuffer, closes #1726 2022-03-28 21:21:41 +01:00
TuxSH
676bbf0d88 Moved config file to INI, and more
- Add support for saving screen filters color temperature and NTP timezone offset (you still need to go to misc->save config)
- some advanced options moved to "in ini file only"; "patch games" is now enabled by default
- ntp: fix support for UTC+12 to +14
- remove deprecated custom svc 0x2e
2022-03-28 20:30:02 +01:00
TuxSH
d798ff0efc Move bootconfig to mcu free regs & copy boot.firm to NAND with each upgrade 2022-03-27 21:04:23 +01:00
TuxSH
fcdb6a7ab5 Add code to backup essential files 2022-03-26 23:09:55 +00:00
TuxSH
bc6e14ada7 ntp: more precise & also set system time
System time is what System Settings (only) changes; user time seems to be set periodically by HM.
2022-03-16 22:19:49 +00:00
TuxSH
44c1711805 Update copyright years 2022-03-13 18:00:00 +00:00
aspargas2
ee16c0b104 fix reading emunand sector 0 2022-03-13 16:26:08 +00:00
TuxSH
26ea031f0e
Merge pull request #1623 from s5bug/master
Fix various things about the cheat system
2022-03-08 23:50:20 +00:00
TuxSH
8c3ae4a2fe Wait for B release before exiting rosalina menu
Closes #1701
2022-03-08 23:42:52 +00:00
Margen67
8cfc0bc709 Makefile: curl improvements
-f: Doesn't output a file on error.
-O: Gets filename from URL.
2022-03-07 22:22:14 +00:00
Gabe Cook
fd4d54a2cc Allow patches in the home menu 2022-03-07 22:19:43 +00:00
George-lewis
e9b8b0daef
Add ASCII View to Rosalina Process List (#1703) 2022-03-07 20:47:06 +00:00