Compare commits

..

1039 Commits

Author SHA1 Message Date
Aurora 1182d3a627 Fix #1050 2018-03-23 02:49:16 +01:00
TuxSH 938cb6492f Revert "Revert "Switched from mapping target process memory to svcReadProcessMemory & svcWriteProcessMemory functions.""
This reverts commit 1fd689f5da.
2018-03-20 01:11:49 +01:00
TuxSH fed62855cb Merge pull request #1000 from duckbill007/master
Gateshark cheats support
2018-03-20 01:00:25 +01:00
Mikaela Szekely 4f54596658 Implement #940 (#1043)
Thanks @Qyriad ^^
2018-03-04 00:45:47 +01:00
Aurora Wright 0b41ed04d5 Simplify loadNintendoFirm after the previous commit 2018-02-09 05:09:43 +01:00
Aurora Wright 9509a86998 Force using the external FIRM if CTRNAND couldn't be mounted or the CTRNAND FIRM has issues 2018-02-05 03:47:43 +01:00
Duckbill 6d4d80a798 Merge remote-tracking branch 'upstream/master' 2018-01-19 17:38:57 +03:00
TuxSH 76d274cfe2 getmemregions: userland never exceeds 0x40000000 2018-01-19 01:42:53 +01:00
TuxSH ccf13be964 Merge pull request #1010 from Nanquitas/input-redirection-sockupdate
InputRedirection: check service existence instead of using OpenProcessByName
2018-01-19 01:30:15 +01:00
TuxSH e36b27ccf0 Merge pull request #1012 from Nanquitas/rosalina-freeze-fix
Rosalina: fix freeze when attempting to open Rosalina before the syst…
2018-01-19 01:29:58 +01:00
TuxSH 34c80ad476 Merge pull request #1009 from Nanquitas/gdb-list-memregion
gdb: new getmemregions command
2018-01-19 01:28:53 +01:00
TuxSH 97ae106d8e Merge pull request #1011 from Nanquitas/patch-2
sock_util: remove unneeded check
2018-01-19 01:28:08 +01:00
Nanquitas 7cb74b74d7 Rosalina: fix freeze when attempting to open Rosalina before the system finished to boot 2018-01-18 23:39:47 +01:00
Nanquitas 337205eb08 sock_util: remove unneeded check
We loop while (server_sockfd == -1) so it's safe to assume that (server_sockfd != -1) once out of the loop.
2018-01-18 22:57:46 +01:00
Nanquitas f36977017b InputRedirection: check service existence instead of using OpenProcessByName 2018-01-18 20:44:54 +01:00
Nanquitas e40b547bb6 gdb: new getmemregions command 2018-01-18 17:23:43 +01:00
Duckbill 1fd689f5da Revert "Switched from mapping target process memory to svcReadProcessMemory & svcWriteProcessMemory functions."
This reverts commit c5c8dca14c.
2018-01-16 09:54:55 +03:00
Duckbill c5c8dca14c Switched from mapping target process memory to svcReadProcessMemory & svcWriteProcessMemory functions. 2018-01-15 21:29:05 +03:00
TuxSH 11f820efa7 Check service existence before GetServiceHandle 2018-01-15 02:52:50 +01:00
TuxSH 9074688491 Make srvGetServiceHandle non-blocking if service port is full in all cases 2018-01-15 02:27:07 +01:00
Duckbill 1de27c54f1 Fix range checks 2018-01-13 16:02:54 +03:00
Duckbill 3e67e64faa Fixes after review on github 2018-01-13 13:51:28 +03:00
TuxSH 553f8d2533 Remove lto for sysmodules 2018-01-12 11:20:17 +01:00
Duckbill ec7ae35da1 Fixes for masked 16-bit cheat opcodes, based on existing cheats. 2018-01-12 10:46:50 +03:00
Duckbill 7e8da0d236 Possible out of bounds fix 2018-01-10 09:53:36 +03:00
Duckbill b3e6561072 Merge remote-tracking branch 'upstream/master' 2018-01-06 12:29:08 +03:00
Aurora Wright 41f32ed983 Remove the need for hardcoding the horizontal positions for the "x"s in multiple choice options 2018-01-05 19:38:58 +01:00
TuxSH bbadf840ef struct fb shouldn't be packed 2018-01-04 22:12:31 +01:00
TuxSH acc50aae46 Merge branch 'master' of github.com:AuroraWright/Luma3DS 2018-01-04 18:41:14 +01:00
TuxSH 6a68a77973 Rewrite the ARM9 exception handlers, ...
- Fix patchArm9ExceptionHandlersInstall for older versions

- Fix some bugs in the ARM11 exception handlers

- Other, minor, changes
2018-01-04 18:40:11 +01:00
Duckbill 0f4d66dd61 Try to load cheats if there aren't any on every open of cheats menu. 2018-01-03 11:48:10 +03:00
Duckbill d28642d2c3 More range checks and separate code and heap allocation 2018-01-03 00:27:44 +03:00
Duckbill ca4685cc42 Range checks added 2018-01-02 14:23:45 +03:00
Aurora 522f10582d Merge pull request #995 from joel16/master
Update MCU::HWC functions with latest changes from ctrulib
2018-01-01 18:07:32 +01:00
Joel16 239d113177 Update mcu functions with changes from ctrulib 2018-01-01 11:05:22 -06:00
Duckbill fd80294bf2 Fix buffer overflow in case of very long cheats.txt file 2017-12-31 11:26:18 +03:00
Duckbill b379d83469 Merge remote-tracking branch 'upstream/master' 2017-12-31 11:16:44 +03:00
Aurora 27f352fdf1 Merge pull request #991 from Qyriad/master
Implement #989: Add configurable splash duration
2017-12-29 05:08:22 +01:00
Mikaela RJ Szekely bfec874a7c Add colon in option that I forgot 2017-12-28 22:02:06 -05:00
Mikaela RJ Szekely 93561003e8 Implement #989: Add configurable splash duration 2017-12-28 21:50:06 -05:00
TuxSH 1572bfd989 [sm] Fix process unregistering logic bug (fixes #984)
In this case pm+sm were supposed to automatically unregister ro's services (the kernel can close a dying process's handle automatically). Not doing this apparently induced a reference leak of DevMenu's as a process, preventing it to be destroyed and the memory allocation reslimit counter to be updated by KProcess's destructor accordingly.
2017-12-27 19:30:57 +01:00
Duckbill cb945612a3 Remove ast empty cheat from list 2017-12-25 14:16:57 +03:00
Duckbill 1b440f7f3b Skip empty cheats 2017-12-25 13:57:20 +03:00
Duckbill 78791f7b66 Paging fixes 2017-12-25 13:45:09 +03:00
Duckbill 5def0c18e2 Cheat file format changed from binary to plaintext 2017-12-22 14:46:46 +03:00
Duckbill 0e67b0f026 Moved key combo calculation to loading cheat phase 2017-12-22 12:39:09 +03:00
Duckbill 8052946517 Cheats array repleced by continous buffer 2017-12-22 12:17:45 +03:00
Duckbill b6d6cc9750 Cheat implementations 2017-12-21 20:14:04 +03:00
TuxSH 2a840f2c79 Minor date/time conversion loop style fixes 2017-12-19 02:32:51 +01:00
TuxSH 4eaf791849 Merge pull request #937 from Hayleia/timestamped-screenshots
screenshots use timestamps as name
2017-12-19 02:15:07 +01:00
Aurora Wright be0f50b19c Disable poweroff when shell closed on NTRboothax altogether to prevent issues with unstable magnets 2017-12-18 21:02:41 +01:00
Aurora Wright f30b7b9fb3 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-12-18 20:56:45 +01:00
Aurora Wright 6a0f332e3c Shutdown when waiting for button presses if the shell is closed, except when coming from a NTRboothax boot 2017-12-18 20:56:32 +01:00
TuxSH 16530d3a52 Merge pull request #972 from LiquidFenrir/ramviewer-fix
fix mistake, processes viewed were attached even if debugger was off
2017-12-18 07:13:13 +01:00
Aurora Wright 20af9c6750 Fix issue reported in
https://github.com/AuroraWright/Luma3DS/commit/f27cdb4543fe63b6b05d8f1950967999c3bdaa44\#commitcomment-24611141, simplify https://github.com/AuroraWright/Luma3DS/commit/56e54cd110e8f1065522c6d6ff5e9411fa9ebd69
2017-12-18 04:27:11 +01:00
LiquidFenrir fee9f6b427 forgot to return, made processes viewed attached even though the debugger wasnt enabled 2017-12-17 19:31:05 +01:00
TuxSH 57d03d6333 Merge pull request #916 from LiquidFenrir/ramviewer-fix
Several ramviewer improvements
2017-12-17 03:31:36 +01:00
LiquidFenrir 0075fe2aa0 work with processes with code starting at 0x14000000 2017-12-16 19:26:55 +01:00
LiquidFenrir d54417ac0a explicit casting 2017-12-16 19:26:27 +01:00
LiquidFenrir 648801d432 make pressing X accidentally twice less punitive 2017-12-16 04:30:40 +01:00
LiquidFenrir 2be2826b0b detect jumping address and change mode accordingly 2017-12-16 04:14:21 +01:00
LiquidFenrir 37a9fa1bf4 work again with heapless processes, and show wether you're currently viewing heap or code on screen (apart from the address) 2017-12-14 17:03:13 +01:00
LiquidFenrir 65af93c8ce other display for entering goto 2017-12-07 22:07:53 +01:00
LiquidFenrir 8353b84944 fix dump filename 2017-12-07 20:07:44 +01:00
LiquidFenrir d6a89db495 make use of values defined in draw.h 2017-12-07 19:56:36 +01:00
LiquidFenrir f156aa8cdb add dumper
mostly a copy of the screenshotting function/from #937
2017-12-07 19:53:44 +01:00
LiquidFenrir f9adbcc9d9 fix same-name variables 2017-12-07 18:23:29 +01:00
TuxSH cf8696ac70 Disable non-process memory access by default (see below), remove IDA 6.8 support...
The physical memory access "bit31" mapping (0--0x30000000 => 0x80000000--0xB0000000) as well as privileged (kernel) mappings confuse debugger clients like IDA's which interpret the value of the registers.
Access to those mappings can be toggled using "monitor toggleextmemaccess" instead (issue reported by @Nanquitas). Closes #943.

Additionally, support for the buggy IDA 6.8's buggy gdb client was removed. Please use IDA 7.0 or higher.

P.S: IDA 7.0 added client support for no-ack mode (Debugging options > Set specific options), which should be enabled to make debugging twice as smooth. "Use stepping support" should be unchecked.
2017-11-26 02:18:59 +01:00
Yuuki Hikari 9c5766f649 Merge pull request #945 from astronautlevel2/master
Switch to APT_ResetHardwareAsync() for reboot (Closes #831), fix #831
2017-11-23 20:46:01 -05:00
Alex Taber c9701f93b9 Switch to APT_ResetHardwareAsync() for reboot (Closes #831) 2017-11-23 20:32:26 -05:00
Aurora Wright 56e54cd110 Fix https://github.com/AuroraWright/Luma3DS/issues/921 2017-11-22 19:03:39 +01:00
TuxSH 55836b48af Merge pull request #942 from Nanquitas/watchpoint-fix
Fix the impossibility to set a second watchpoint
2017-11-22 16:17:53 +01:00
Asuka Amari 09bfdb9ee1 removed unused variable 2017-11-22 07:03:00 +01:00
Nanquitas 1c2e8dec11 Fix the impossibility to set a second watchpoint 2017-11-22 03:37:23 +01:00
TuxSH 506b16db37 Fix watchpoints handling (huge thanks to @Nanquitas) 2017-11-22 01:24:35 +01:00
Asuka Amari 8f03234e58 screenshots now use timestamps as name
Instead of being called top_XXXX.bmp where XXXX means nothing,
screenshots are now called YYYY-MM-DD_HH-MM-SS.mmm_top.bmp (and same
idea for bot and top_right).

First obvious consequence, this is easier to manage in a file browser.
Now you have screenshots grouped by time, and you also have the 2 or 3
related screenshots (top, bot, top_right) close one to another.

Another consequence is that there is no need to go through existing
screenshots to find an unused number. Now osGetTime takes care of
everything. And going through files was a very time consuming process.
Now screenshots only need 4 (or 6 if 3D) seconds to be saved (instead of
40 seconds if you had 200 screenshots in your directory already).

Conflicts may happen when people change the date and time on their 3DS,
but that's why I even included milliseconds in the timestamp. People
don't set date and time everyday and they'd be unlucky to take a
screenshot at the exact time, milliseconds included, as another
screenshot right after setting the time one hour earlier...

Source for converting seconds since 1970 (or 1900...) to date and time:
https://stackoverflow.com/questions/21593692/
2017-11-18 16:37:35 +01:00
TuxSH 44b5e10323 Fix N3DS menu entry 2017-11-10 20:51:52 +01:00
LiquidFenrir 48303604b0 show address instead of offset when jumping 2017-11-05 06:56:54 +01:00
LiquidFenrir ab2ddbc2ee fix visible blank
if jumping too close to the end, the cursor won't be at the top to avoid the blank
2017-11-05 06:48:56 +01:00
LiquidFenrir 9495bf30bf make jumping put the cursor at the top row
downside: when jumping near the end, a blank is visible
2017-11-05 06:30:41 +01:00
TuxSH a4899a1bec Remove redundant variables in Makefile 2017-11-03 19:03:17 +01:00
LiquidFenrir 882c6cf0d4 show the "main" address to distinguish between heap and code 2017-11-03 02:19:15 +01:00
LiquidFenrir a5e18c82d1 reset scrolling when changing modes to avoid problems when the sizes dont match 2017-11-03 02:15:28 +01:00
TuxSH 22a8661fe1 Always patch FS and P9, remove SM service checks 2017-11-02 21:52:14 +01:00
TuxSH 8258a98647 Integrate 3ds_pxi and 3ds_sm 2017-11-02 15:11:55 +01:00
LiquidFenrir 76dde0e6db Add ram viewer/editor (#877)
Huge thanks to @LiquidFenrir
2017-10-24 18:35:15 +02:00
Ian Burgwin 1a39cb27e4 fix discord invite link 2017-10-14 10:10:03 -07:00
Aurora Wright 95d2d0a6bd Update makefile 2017-10-12 20:56:47 +02:00
Aurora Wright 98d4345858 Remove unneeded check 2017-10-07 23:04:55 +02:00
Aurora Wright 1e4431dcc9 Fix ARM9 exceptions displaying ARM11-specific info 2017-10-07 20:59:21 +02:00
Aurora Wright 348b175994 Fix some fault statuses overlapping to a new line 2017-10-05 19:55:21 +02:00
Aurora Wright 76f057dafb Remove friends patch as it's useless 2017-10-05 18:45:06 +02:00
Aurora Wright 188400c5a9 Use ctrulib functions for mcu/battery level 2017-10-05 18:41:11 +02:00
Aurora a74d9c6d3e Merge pull request #878 from Margen67/master
Update README.md
2017-10-03 01:19:26 +02:00
Margen67 f8bcfb2f58 Update README.md
Add armips buildbot link.
Other minor changes.
2017-09-26 14:44:14 -07:00
TuxSH d63fc2bc82 Fix latest commit 2017-09-24 19:31:38 +02:00
TuxSH 8e31784996 Fix thumb breakpoint handling 2017-09-24 17:58:23 +02:00
Aurora Wright f27cdb4543 Also fix RBGA4 (untested) 2017-09-23 22:34:28 +02:00
Aurora a39adc8ac1 Merge pull request #869 from Streetwalrus/pxfmt
Fix RGB5_A1 conversion
2017-09-23 22:27:24 +02:00
Dan Elkouby 97bef66018 Fix RGB5_A1 conversion 2017-09-23 15:01:11 +03:00
Aurora Wright bb5518b0f6 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-09-22 18:05:10 +02:00
Aurora Wright ac73a96ce2 Set default firmSource for CTRNAND mounting in crypto.c, move CTRNAND mounting for SD mode to firm.c 2017-09-22 18:05:03 +02:00
Ian Burgwin 7075004e58 Merge pull request #866 from Margen67/master
Update ISSUE_TEMPLATE.md
2017-09-21 14:04:38 -07:00
Margen67 ddf8ba5116 Update ISSUE_TEMPLATE.md 2017-09-21 14:02:09 -07:00
Aurora Wright f46773ba64 Stub isTitleAllowed 2017-09-20 01:36:02 +02:00
Aurora Wright f67d333457 Update fpdver 2017-09-19 14:46:42 +02:00
Aurora Wright 4116c1e00f Update FIRM loading magic, only deinit LCDs if they are inited, fix ntrboot naming 2017-09-07 05:24:43 +02:00
Aurora Wright bc1aa15dd7 Add more checks, make the emuNAND SD check only occur when emuNAND is being booted 2017-08-28 14:46:18 +02:00
Aurora Wright ecd27f7eaa Fix diskio indentation 2017-08-28 02:54:56 +02:00
Aurora Wright 618ce671ac Fix previous commit, deinit screens on ARM9 exception, add check for write protect switch on writing operations 2017-08-28 02:43:12 +02:00
Hikari-chin 2a6a655804 Error if emuNAND is booted while the SD card is write protected 2017-08-27 16:20:17 -04:00
Aurora Wright 33436ae2a6 Fix derp with previous commit 2017-08-27 16:24:04 +02:00
Aurora Wright 9f2b66ac51 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-08-27 16:20:52 +02:00
Aurora Wright df93e4797e Refactor boot mode/firmlaunch detection, fix firmlaunch from FIRM boots 2017-08-27 16:20:41 +02:00
Aurora Wright 538d1dec77 Minor style stuff 2017-08-21 19:33:31 +02:00
TuxSH 2492c8273a Fix exception display 2017-08-21 19:26:17 +02:00
Aurora Wright d358df48a6 Wait for ntrboot buttons not to be held 2017-08-20 18:23:50 +02:00
Aurora Wright f619dafff1 Added displaying boot source and loader on the bottom screen in the config 2017-08-20 17:00:47 +02:00
Aurora Wright 0419fc4e30 Reinstate ntrboot display in config 2017-08-20 16:16:20 +02:00
Aurora Wright 13317b9548 Change ntrboot behavior, turn Luma into a chainloader when used as ntrboot FIRM as it can not be functional, disable FIRM protection when ran from ntrboot B9S 2017-08-20 16:08:54 +02:00
Aurora Wright 18db70a669 Minor style stuff 2017-08-19 02:54:38 +02:00
TuxSH f79923814d Detect NTRCARD and FIRM1 boot sources properly...
Always display the configuration menu if booted from NTRCARD (because it's painful to get to otherwise -- even if b9s has a 2s delay), with the mention "Booted from NTRCARD" in the title.
2017-08-19 01:40:55 +02:00
Aurora Wright c92de03a5f Always erase exception dump in memory 2017-08-17 17:38:42 +02:00
Aurora Wright 3f356da879 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-08-17 17:33:37 +02:00
Aurora Wright 9efac01c86 Fix derp 2017-08-17 17:33:18 +02:00
TuxSH ca2622af7c Fix #778 2017-08-16 23:46:36 +02:00
Aurora Wright aa8e0bda8c Update FatFs to R0.13 2017-08-16 19:37:39 +02:00
TuxSH c79f11ee99 Change exception dump parser directory structure 2017-08-16 19:23:04 +02:00
Aurora Wright 04d0770b90 Add missing info for data aborts in the exception parser and turn it into a pip module 2017-08-16 18:59:12 +02:00
Aurora Wright fbf8a1b6d9 Minor code syntax stuff 2017-08-16 18:04:22 +02:00
Aurora Wright a3cb6a622d Merge https://github.com/AuroraWright/Luma3DS/pull/793 , clarify the exception dumps' paths 2017-08-16 16:55:07 +02:00
Aurora Wright 0790a3ceb3 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-08-16 15:50:06 +02:00
Aurora Wright 4fa12f90fc Fix derp 2017-08-16 15:49:57 +02:00
TuxSH d5d56e7634 Merge pull request #790 from WinterMute/windows-path-fix
Don't fix already transformed $DEVKITARM variable
2017-08-15 15:20:27 +02:00
TuxSH a964089df4 Merge pull request #792 from Nanquitas/master
Exceptions: display more infos on screen (status, far, access type)
2017-08-15 15:20:17 +02:00
Dave Murphy 5fd5b4da89 Don't fix already transformed $DEVKITARM variable 2017-08-15 14:15:34 +01:00
Hikari-chin 322a7050aa Fix #791 2017-08-15 09:01:48 -04:00
Nanquitas b7f4ac02c8 Exceptions: display more infos on screen (status, far, access type) 2017-08-15 14:09:14 +02:00
TuxSH 009f61a8b6 Merge pull request #787 from Nanquitas/master
exception_parser.py: display the fault status source
2017-08-15 02:44:18 +02:00
Nanquitas 26d0cafb39 exception_parser.py: display the fault status source 2017-08-15 00:51:20 +02:00
TuxSH bd1d4a77fe Merge pull request #783 from Nanquitas/patch-1
Watchpoints: fix read DSCR to enable MonitorMode
2017-08-14 19:04:15 +02:00
Nanquitas f235bc83a8 Watchpoints: fix read DSCR to enable MonitorMode 2017-08-14 16:10:50 +02:00
Aurora Wright 9c6b540905 Do not hardcode FBs in ARM11, do not set FBs twice on screen init 2017-08-13 17:36:31 +02:00
TuxSH d2e911a58e Merge pull request #781 from profi200/master
Revert 9273a88d and make it not freeze the GPU/LCD hardware.
2017-08-13 16:00:45 +02:00
TuxSH 9344a7b434 Fix default FB addresses 2017-08-13 16:00:35 +02:00
profi200 cd194fa5b2 Revert 9273a88d and make it not freeze the GPU/LCD hardware. 2017-08-13 14:50:14 +02:00
Aurora Wright 49c0ab65df Check r0 and r1 too for firm0 detection 2017-08-11 23:54:28 +02:00
Aurora Wright 8f9c1305e4 Reinstate unsupported loader error 2017-08-11 23:48:32 +02:00
TuxSH d4193ec11d Attempt to detect booting from firm 2017-08-11 23:33:21 +02:00
TuxSH 6b9b0472bc Merge pull request #775 from LiquidFenrir/nwmcheck
Add a warning when nwm isn't running
2017-08-11 23:00:07 +02:00
LiquidFenrir 7e74258363 check if nwm is running to fix https://github.com/AuroraWright/Luma3DS/issues/774 2017-08-11 04:29:38 +02:00
Aurora Wright f6483ec602 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-08-07 21:20:18 +02:00
Aurora Wright 36c1da1d61 Add mention of exheaders in the Enable game patching description 2017-08-07 21:20:08 +02:00
Stary 2001 6bcb1f8679 Merge pull request #763 from Streetwalrus/ir-title
Fix input redirection title index in the menu
2017-08-06 22:15:21 +01:00
Dan Elkouby 62932a9639 Fix input redirection title index in the menu
This option is the third, not the fourth, and toggling it will override
the "save settings" option's title instead.
2017-08-06 23:56:00 +03:00
Hikari-chin a4629e4b65 Cleaned up and rearranged the Rosalina menu in preparation for future features 2017-08-01 17:38:48 +02:00
Aurora Wright a0c2b43b34 Implement loading of exheaders from SD/CTRNAND (must be called luma/titles/TITLEID/exheader.bin), thanks to @HiddenRambler! 2017-08-01 17:38:23 +02:00
TuxSH 3907c46980 Follow ARM's documentation on hw watchpoints to the letter 2017-07-20 00:56:08 +02:00
TuxSH 7e7ab124a3 Log "logged" errdisp messages in /luma/errdisp.txt, fixes #707 2017-07-19 00:59:47 +02:00
TuxSH cfc6cf24bf Some kext refactoring 2017-07-16 18:58:20 +02:00
TuxSH 46e9cb6b23 Fix fallthrough bug 2017-07-16 13:29:02 +02:00
TuxSH ba14efe1f4 Suppress future -Wimplicit-fallthrough=3 warnings 2017-07-15 00:41:42 +02:00
TuxSH 3d8f62d38f Fix MaxCpuTime for 3dsx 2017-07-09 22:14:00 +02:00
Hikari-chin 3edaf0af64 Whoops 2017-07-09 14:36:06 -04:00
Aurora Wright 9273a88db7 It seems FB setup needs to be done first 2017-07-09 19:21:12 +02:00
Aurora Wright 37ba2c15de Reinstate framebuffer setup on initScreens to allow old Luma to be chainloaded if FB address changes in b9s/new Luma, remove useless clearScreens for the alternate FBs after the first init 2017-07-09 19:06:42 +02:00
Aurora Wright 557f2057f7 Fix spacing 2017-07-06 18:09:18 +02:00
Aurora Wright 6b5cc93780 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-07-06 17:29:43 +02:00
Aurora Wright 9760191af8 Fix conflict between emunand selection and payload booting when "Autoboot EmuNAND" is checked, you now need to press L + DPad to boot payloads if that option is checked 2017-07-06 17:29:38 +02:00
TuxSH 8845e4dd20 Merge pull request #704 from Hikari-chin/master
LED toggle switch in Rosalina's misc menu + updated README
2017-07-05 19:26:56 +02:00
Yuuki Hikari 8cf823f548 Update README.md 2017-07-05 02:13:03 -04:00
Hikari-chin 2538769f3a Added LED toggling from the Rosalina misc. menu 2017-07-04 23:50:40 -04:00
Aurora Wright 89fca38807 Merge master into local branch 2017-07-05 01:37:36 +02:00
Aurora Wright dcc0eed69c Fix LayeredFS for games like Pokemon Art Academy which mistakenly use two forward slashes after the mountpoint 2017-07-05 01:31:04 +02:00
Yuuki Hikari 817475257e Merge pull request #700 from LiquidFenrir/wifi-toggle
Add wireless toggling in rosalina
2017-07-04 15:09:16 -04:00
LiquidFenrir f2861058ba add wireless toggling in rosalina
https://github.com/AuroraWright/Luma3DS/issues/619#issuecomment-309239178

ligne 353: CFG11_WIFICNT, nothing includes it in rosalina so I hardcoded it here
ligne 363: could also use svc 0x5A (SetWifiEnabled) but not sure how
2017-07-04 18:35:55 +02:00
TuxSH 5d2a7315d5 Fix SetWifiEnabled 2017-07-03 19:28:34 +02:00
TuxSH 1520ab7555 Update ISSUE_TEMPLATE.md
7.1 => 8.1
2017-07-02 22:52:49 +02:00
Aurora Wright d4d0fbd73b Re-add dir_build variable 2017-07-02 00:46:57 +02:00
Aurora Wright ddb8e98e95 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-07-02 00:44:29 +02:00
Aurora Wright fd69b4169f Use GNU/BSD agnostic syntax instead of detecting the OS (thanks @smartperson) 2017-07-02 00:44:14 +02:00
TuxSH b48e0b5c5b Update ISSUE_TEMPLATE.md 2017-06-30 23:52:44 +02:00
TuxSH 31e2243c5c Update description for "enable game patching" 2017-06-28 21:59:57 +02:00
Aurora Wright da0ee2e442 Fix external 3.x and 4.x FIRMs, fix 1.x and 2.x booting on dev units 2017-06-28 20:28:14 +02:00
Aurora Wright b88dc9ac6a Only check in .text 2017-06-28 18:14:05 +02:00
Aurora Wright 9f78d7f62b Add region-free manuals patch 2017-06-28 17:37:12 +02:00
Aurora Wright e67c6ed3ee Change pattern 2017-06-26 23:42:41 +02:00
Aurora Wright 2e111ca91b Revert "Revert "Merge pull request #662 from MerryMage/dsp-sig""
This reverts commit 62d51fd99d.
2017-06-26 23:39:28 +02:00
Aurora Wright 62d51fd99d Revert "Merge pull request #662 from MerryMage/dsp-sig"
This reverts commit a9289b1f21, reversing
changes made to d42e938232.
2017-06-26 22:06:10 +02:00
TuxSH a9289b1f21 Merge pull request #662 from MerryMage/dsp-sig
Add a patch to disable DSP firmware signature check
2017-06-26 20:51:16 +02:00
Aurora Wright d42e938232 Restore 7.1 max module size for NATIVE_FIRM 2017-06-26 19:03:57 +02:00
MerryMage 3d3dcb1f28 Add DSP signature check patch 2017-06-26 17:34:43 +01:00
Aurora Wright 82143212ce Remove the need for Homebrew and GNU tools on macOS 2017-06-26 18:32:33 +02:00
TuxSH 7246a2664e Move section0 to second quarter of VRAM 2017-06-26 17:41:40 +02:00
Aurora Wright 1291f2520a Fix derp 2017-06-26 17:11:00 +02:00
TuxSH 042ecf5343 Fix write-only hw watchpoint handling 2017-06-26 16:57:25 +02:00
Aurora Wright 6e54dcc24c Add macOS building support (you need to install coreutils and gnu-sed with homebrew) 2017-06-26 16:29:04 +02:00
TuxSH 91378ef3c1 Fix menu display bugs 2017-06-25 00:14:07 +02:00
Aurora Wright 0377cbd2b4 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-06-22 15:49:31 +02:00
Aurora Wright 786ecf4fe4 Remove some configbit math 2017-06-22 15:49:23 +02:00
TuxSH 0fbdee313f Merge branch 'master' of github.com:AuroraWright/Luma3DS 2017-06-20 21:24:52 +02:00
Aurora Wright 9b8e2b933d Add missing checks in getFreeK9Space 2017-06-20 19:56:34 +02:00
TuxSH cc64ef9670 Take fb stride into account 2017-06-20 18:29:30 +02:00
TuxSH 31ff6a1da8 Clarify option 2017-06-20 17:39:11 +02:00
TuxSH 94532e9cea Halve the time necessary to take a screenshot 2017-06-20 16:14:36 +02:00
Aurora Wright 3f93bc5988 Support 3.x+ EmuNANDs and 3.x SysNANDs (partially), external FIRMs coming soonŧ 2017-06-19 18:13:59 +02:00
TuxSH 39ca23d609 Add qGetTLSAddr 2017-06-19 16:04:19 +02:00
TuxSH 47a9c1b576 Fix FS patch for 4.x 2017-06-19 15:34:51 +02:00
TuxSH d819cfd58f Remove useless files 2017-06-19 15:21:15 +02:00
TuxSH 17828273a5 Revamp config format, add saving of Rosalina opt.
(menu combo & 3dsx title ID)
2017-06-18 22:31:21 +02:00
TuxSH 2363817265 Fix grey strides issue (maybe) 2017-06-17 01:52:08 +02:00
TuxSH b31018ab17 Lower the priority of the Rosalina menu 2017-06-17 00:15:36 +02:00
TuxSH c610ec3319 Virtually full support for 4.x sysNAND
(see also: previous commit)
2017-06-16 22:37:04 +02:00
TuxSH b71dedccfc Full support for fw >= 6.x (tested)
Virtually full support for 5.x except that svcUnmapProcessMemoryEx will be forwarded to svcUnmapProcessMemory (both are equivalent for up to 64MB chunks)
2017-06-16 04:21:48 +02:00
TuxSH 9ccfacd06d Display IP in menus when either gdb/inputredir is enabled 2017-06-15 17:38:45 +02:00
TuxSH 12b561a27d Remove unused variables 2017-06-15 01:57:57 +02:00
TuxSH cc41003e1c Fix exheader.h 2017-06-15 01:53:34 +02:00
TuxSH 3d534c9a81 Unschedule threads properly...
...instead of using a shitty yield when opening the Rosalina menu
2017-06-14 19:35:03 +02:00
TuxSH 24de7c5272 Fix indentation of gdb.c 2017-06-14 10:04:09 +02:00
TuxSH a1b2ea2c5b Fix firmlaunch payload path bug 2017-06-14 02:05:32 +02:00
TuxSH 19d68b6df4 Adjust config mem values 2017-06-14 01:29:55 +02:00
TuxSH 2ab41dbd01 Fix firmlaunch bug 2017-06-13 23:08:32 +02:00
TuxSH da30c0b0f0 Fix dfsr being displayed instead of fpexc 2017-06-13 02:53:53 +02:00
TuxSH 005684d865 Fix loader bugs
new-hbmenu now works with H&S, etc.
2017-06-13 02:37:27 +02:00
TuxSH da1eff82ba Remove debugging line 2017-06-13 02:29:01 +02:00
TuxSH a17311c955 Merge branch 'memregion-test' 2017-06-13 02:28:38 +02:00
TuxSH e1d0602f25 Move the kext outside Rosalina
- Stability (tm)
- Boots 1s faster on N3DS
- (∩ ͡° ͜ʖ ͡°)⊃━☆゚
2017-06-13 02:00:41 +02:00
TuxSH 2ff9718510 Merge pull request #595 from Hikari-chin/master
Fix #593
2017-06-12 18:00:22 +02:00
Hikari-chin 33af9cfe09 Fix #593 2017-06-12 01:45:38 +00:00
Aurora 79709a7ae7 Merge pull request #594 from Margen67/master
Update issue template
2017-06-11 21:01:48 +02:00
Margen67 a796a70d01 Update issue template 2017-06-11 12:00:06 -07:00
TuxSH 53e2ef24f1 Refactor pattern for ir hook 2017-06-11 17:16:14 +01:00
Ezekiel Bethel c0059c83ac inputredirection hook in ir:user cpp emulation => c-stick works in games now, also hook refactoring 2017-06-11 17:16:13 +01:00
Ezekiel Bethel 37eb21d297 poweroff/reboot for Rosalina misc. menu 2017-06-11 17:06:43 +01:00
Aurora Wright 52a18831a7 Minor style changes (2) 2017-06-10 03:06:16 +02:00
Aurora Wright 0d7cca7b20 Minor style changes 2017-06-10 02:55:55 +02:00
Aurora Wright bea73c51ae Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-06-10 02:39:08 +02:00
Aurora Wright 0c68750056 Refactor payload loading, fix messy externs, add safety checks to Nintendo FIRMs, fix some Nintendo FIRMs not being loaded as payloads 2017-06-10 02:39:00 +02:00
TuxSH ae8ea7da16 Revert PR due to breakage for a totally unrelated reason
(will be added back later)
2017-06-10 01:39:11 +02:00
TuxSH 69762c5dce Revert "Attempt fixing svcConnectToPortInitHook.s again"
This reverts commit 901d4992c0.
2017-06-09 20:48:01 +02:00
TuxSH 901d4992c0 Attempt fixing svcConnectToPortInitHook.s again 2017-06-09 18:10:02 +02:00
Aurora Wright 4d47d891d1 Fix max module size check, static-ify more strings 2017-06-09 17:29:26 +02:00
TuxSH a7046909ec Use static const when appropriate 2017-06-09 14:26:51 +02:00
Aurora Wright 4bc95979de Revert #949d219c726e41cca84c873e7e200be14af13f63 (breaks building on *nix) 2017-06-09 13:44:04 +02:00
TuxSH 949d219c72 lolwut this fixes building on WSL
maybe memsearch is flasky on unaligned patterns, dunno
2017-06-09 05:00:38 +02:00
TuxSH 9a3d9aed30 Always enable ARM9 exceptions, update .gitignore 2017-06-09 02:31:14 +02:00
TuxSH 4d99143da0 Merge pull request #561 from SciresM/master
Add config option to disable exception vectors.
2017-06-09 00:17:14 +02:00
TuxSH 461035b212 Fix bug(s), refactor svcConnectToPortInitHook.s, cleanup 2017-06-08 21:35:41 +02:00
Michael Scire 0694ea8367 Add config option to disable exception vectors. 2017-06-07 17:48:30 -07:00
TuxSH 427a05997d Revert "Refactor fatalExceptionHandlers.s a bit"
This reverts commit 84d736c2eb.
2017-06-08 02:02:49 +02:00
TuxSH 84d736c2eb Refactor fatalExceptionHandlers.s a bit 2017-06-07 23:58:29 +02:00
TuxSH a16d1ebe33 Refactor k11 main hook
Much less error-prone now.
2017-06-07 22:13:05 +02:00
Aurora Wright 43f3c84316 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-06-07 19:16:13 +02:00
Aurora Wright 44cafe3f46 Fix mismerges 2017-06-07 19:15:51 +02:00
TuxSH 76d7a035bd Fix country/state id spoofing 2017-06-07 01:06:39 +02:00
TuxSH a5b638ae7b Fix uninitialized variable bugs 2017-06-06 21:04:13 +02:00
TuxSH 174089e4f3 Fix langemu bugs 2017-06-06 19:37:16 +02:00
TuxSH 4d219813fe Merge pull request #519 from sora10pls/master
Reference release notes in README.md
2017-06-06 02:52:32 +02:00
Aurora Wright a798f453d2 Update gitignore 2017-06-06 02:17:58 +02:00
Aurora Wright 6ec21611c0 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-06-06 02:13:02 +02:00
Aurora Wright 31f4419eec Refactor screen functions, completely fix config not saving bug 2017-06-06 02:12:18 +02:00
Aurora Wright 60d136f9b5 Fix #491 2017-06-06 01:22:17 +02:00
TuxSH 0ba7f9dba0 Fix chainloader 2017-06-05 21:24:18 +02:00
TuxSH 0ac6db006a Work around a GDB bug (w/r/t packet size) 2017-06-05 21:23:17 +02:00
TuxSH 26dd61e4e6 Fix (work around) Nintendo own HM bug, GG Ninty 2017-06-05 20:28:44 +02:00
TuxSH dda11206db Fix bug in fatalExceptionHandlers.s 2017-06-05 19:32:37 +02:00
Matt e8565d30a9 Reference release notes in README.md 2017-06-05 10:15:49 -04:00
TuxSH 2d4c103854 Merge pull request #510 from T3CHNOLOG1C/master
fix typo in readme
2017-06-05 14:46:21 +02:00
T3CHNOLOG1C d0b9e36908 fix typo in readme 2017-06-05 06:58:19 -04:00
TuxSH 21db0d45bd Added Rosalina, see details
- see release notes
- ( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)
- (∩ ͡° ͜ʖ ͡°)⊃━☆゚
- ( ͡ᵔ ͜ʖ ͡ᵔ) ♫┌( ͡° ͜ʖ ͡°)┘♪ ♫└( ͡° ͜ʖ ͡°)┐♪
2017-06-05 02:02:04 +02:00
Aurora Wright 4429cb2095 Refactor chronometer functions 2017-06-04 18:56:44 +02:00
Aurora Wright cab54d1b31 Move i2c delay to i2c.c 2017-06-04 18:32:09 +02:00
TuxSH 1d2909ea03 Fix ISSDMODE usage 2017-06-03 03:59:18 +02:00
Aurora Wright d802e5329c Fix overlap check 2017-06-03 01:02:52 +02:00
TuxSH 118f81d347 0xBEEF -> 0x1BEEF 2017-06-02 20:36:58 +02:00
Aurora Wright ba3740a77a Return if the FIRM payloads filesize is different than expected 2017-06-02 19:35:14 +02:00
Aurora Wright 47369c8f5e Should use the function here too 2017-06-02 19:35:13 +02:00
Aurora Wright 7a05dee453 Rework whitelist check patch 2017-06-02 19:35:12 +02:00
Aurora Wright 9e47369365 Add DS cart whitelist patch for home menu (both versions of the func should be supported) 2017-06-02 19:35:10 +02:00
Aurora Wright 5379c05001 Update gitignore, Minor style changes 2017-06-02 19:35:09 +02:00
TuxSH 5b34b2d114 Change directory structure 2017-06-02 19:35:08 +02:00
TuxSH 3ea8734fdd More complete TWL key init 2017-06-02 19:35:07 +02:00
Aurora Wright 8e22080e05 Backport FIRM whitelist from b9s 2017-06-02 19:35:05 +02:00
TuxSH 692a94fe5e Fix call to patchK11ModuleLoading 2017-06-02 19:35:04 +02:00
Aurora Wright 01c760ab88 Not needed/usable 2017-06-02 19:35:03 +02:00
Aurora Wright 28e5d8107f Remove hardcoded CTRNAND FAT offsets, calculate them from parsing NCSD + CTR MBR 2017-06-02 19:35:02 +02:00
Aurora Wright 710d8cd15c Fix DTCM 2017-06-02 19:35:00 +02:00
TuxSH 8395540288 Refine the N3DS check 2017-06-02 19:34:59 +02:00
TuxSH d57d8aaae7 Use DTCM for ctrNandWrite's buffer, crt0 changes, reboot patch changes 2017-06-02 19:34:58 +02:00
Aurora Wright 10f555b6fb Fix payload size check 2017-06-02 19:34:57 +02:00
Aurora Wright 9f30244bfb Refactoring, fix bugs, move loader to itcm (without overwriting exception handlers), support for running Luma standalone 2017-06-02 19:34:55 +02:00
TuxSH 0b65fcbdd7 Add -S nand-retail to be sure 2017-06-02 19:34:54 +02:00
TuxSH 067e217909 Add proper arm11 crt0 and fix race condition 2017-06-02 19:34:53 +02:00
TuxSH d6c6c421e9 Allow empty sections at any place in FIRMs 2017-06-02 19:34:52 +02:00
TuxSH 90b54581b0 Fix two bugs 2017-06-02 19:34:51 +02:00
TuxSH 68d9674ca3 Refactor error 2017-06-02 19:34:49 +02:00
TuxSH a9a8edeaf4 Handle arguments in a better way 2017-06-02 19:34:48 +02:00
TuxSH dd21a3930d Adapt changes from b9s/next 2017-06-02 19:34:47 +02:00
TuxSH 53209b9be0 Begin turning Luma3DS into a proper firm
Unfinished work
2017-06-02 19:34:46 +02:00
TuxSH 8308e1a8b8 Merge pull request #479 from Margen67/master
Update ISSUE_TEMPLATE.md (..again)
2017-05-31 21:07:39 +02:00
Margen67 986a2fb5d8 Update ISSUE_TEMPLATE.md (..again) 2017-05-31 10:57:05 -07:00
TuxSH 9570e6cbec Merge pull request #472 from gnmmarechal/master
Updated README.md
2017-05-31 18:46:30 +02:00
Gnm Software 2012 93a08c5ef9 Updated README.md 2017-05-29 16:41:17 +01:00
TuxSH a187c0c7ce Update README.md w/r/t firmtool 2017-05-23 17:41:19 +02:00
Aurora Wright 43f4475272 Move sdmmc init to a more proper place 2017-05-22 04:00:10 +02:00
Aurora Wright a7ed32e206 Consistency 2017-05-21 19:59:02 +02:00
Aurora Wright 6eadac23b3 Not needed 2017-05-21 19:38:58 +02:00
Aurora 1c7eb8f97a Merge pull request #454 from Margen67/master
Fix typo
2017-05-21 17:57:02 +02:00
Aurora Wright a71c5f42fc Not needed 2017-05-20 15:30:18 +02:00
Aurora Wright de0f1dc156 Use arm11 entry define for screen.c, fix isFirmlaunch not being always defined 2017-05-20 13:52:47 +02:00
Margen67 bb05961f70 Fix typo 2017-05-19 20:42:15 -07:00
Aurora Wright 57900e91ba Minor stuff 2017-05-20 05:26:01 +02:00
Aurora Wright 98f650a5de Make loader recognize SD/CTRNAND modes and only look in the appropriate one 2017-05-20 05:09:48 +02:00
Aurora Wright 55b2db4a8d Minor cleanup 2017-05-20 04:43:04 +02:00
Aurora Wright fbe3088744 No longer needed 2017-05-20 03:53:36 +02:00
Aurora Wright 336ab6a64c Minor reboot patch changes 2017-05-20 03:49:03 +02:00
TuxSH c73fec46e6 Fix memcmp u"nand" in fs.c 2017-05-20 02:44:28 +02:00
Aurora Wright b493e2bd5f Fix minor firmlaunch patch bug 2017-05-20 02:29:26 +02:00
Aurora Wright 78a7d6c5af General cleanup/refactoring 2017-05-20 02:08:25 +02:00
TuxSH a8b2e9a50c Update config.c 2017-05-20 01:05:33 +02:00
TuxSH 2d7c1e42d8 Fix loader, other fixes 2017-05-20 01:04:32 +02:00
Aurora Wright 64ebec3ea4 Fix chainloading bugs/refactoring 2017-05-20 00:45:05 +02:00
TuxSH 252d32aafe So glad not having to deal with Brahma shit anymore 2017-05-20 00:23:43 +02:00
TuxSH 2349370960 Fix reboot patch and argument handling 2017-05-20 00:18:41 +02:00
TuxSH 6ccc0f0538 Add memset 2017-05-19 22:45:00 +02:00
TuxSH 9f12a47cfc Fix string handling bugs 2017-05-19 22:40:07 +02:00
TuxSH ee880802c8 Fix crt0 & include missing files 2017-05-19 22:07:12 +02:00
TuxSH ab14e77b50 Remove A9LH & Brahma support altogether, use FIRM format instead 2017-05-19 22:06:49 +02:00
TuxSH 1d4245e582 Set 0x18..0x1F only on O3DS 2017-05-18 01:24:35 +02:00
TuxSH 8636a74ba4 Revert "Minor stuff"
This reverts commit ba88ec25f6.

Conflicts:
	source/firm.c
2017-05-18 01:07:29 +02:00
TuxSH 3b766de306 Fix derp in loader 2017-05-17 22:11:09 +02:00
TuxSH 1f300e1b75 Update Makefile 2017-05-17 20:30:20 +02:00
TuxSH 56efe6035f Finally fix Makefiles 2017-05-17 20:28:46 +02:00
TuxSH 73e363d159 Fix derp 2017-05-17 17:24:48 +02:00
TuxSH 3ac134bc16 Fix screen issue, etc. 2017-05-17 17:16:16 +02:00
Aurora Wright c7bb1f9655 Unbreak loader 2017-05-17 16:15:32 +02:00
Aurora Wright 7847646b3e Not needed 2017-05-17 16:06:40 +02:00
Aurora Wright ec6e9f73bb Minor wording fix 2017-05-17 15:16:01 +02:00
Aurora Wright bd62f033ab Drop pre-A9LH support 2017-05-17 14:53:29 +02:00
Aurora Wright ba88ec25f6 Minor stuff 2017-05-17 13:36:18 +02:00
TuxSH b9bc41a772 Groundwork
Change the payload loader location
Always set keys 0x18..0x1F
Set arm11 entrypoint correctly
2017-05-17 13:02:01 +02:00
TuxSH e029458b09 Merge pull request #450 from Margen67/patch-1
Update issue template
2017-05-12 18:59:43 +02:00
Margen67 b3ecf1776b Update ISSUE_TEMPLATE.md 2017-05-12 08:56:03 -07:00
Aurora Wright 5fe83588eb If only one payload exists, START directly boots it 2017-05-10 15:18:01 +02:00
Aurora Wright 18b8eaabae Attempt to fix false positives when looking for update RomFSes 2017-05-08 21:35:46 +02:00
Aurora Wright e11695c2f0 Minor stuff 2017-05-08 15:16:16 +02:00
Aurora Wright 91edbf71c8 Fix derp 2017-05-08 05:33:01 +02:00
Aurora Wright 5b9b22021b Fix bugs in processNumber() 2017-05-08 05:14:42 +02:00
Aurora Wright 033d90b866 Minor stuff/fixes 2017-05-08 01:13:29 +02:00
Aurora Wright 540c0df918 Consistency 2017-05-07 23:49:49 +02:00
Aurora Wright 6de167467f Merge master into local branch 2017-05-07 23:20:25 +02:00
Aurora Wright c746326eb3 Cleanup 2017-05-07 23:18:26 +02:00
TuxSH 0fbd384a73 Remove unused code and comments 2017-05-07 18:53:08 +02:00
TuxSH e8d4a98c7b Refactor string handling 2017-05-07 17:58:44 +02:00
Aurora Wright f5aa63936c Fix derp 2017-05-06 15:48:38 +02:00
Aurora Wright 62a57d0f47 Minor stuff 2017-05-06 04:43:07 +02:00
Aurora Wright 958fb4c739 Merge master into local branch 2017-05-05 20:20:07 +02:00
Aurora Wright e231275cbe Rewrite the LayeredFS code to check the mount name properly and use ro/data padding for the custom path 2017-05-05 20:16:44 +02:00
TuxSH 5a404c3a35 Remove titleID restriction for code loading 2017-05-01 18:21:18 +02:00
Aurora Wright b1c07c6204 Try to mitigate https://github.com/AuroraWright/Luma3DS/issues/433 2017-04-29 19:15:41 +02:00
Aurora Wright 60f158d488 This is unused now 2017-04-29 18:12:14 +02:00
Aurora Wright 1887c6fae3 Revert db33c315f2 2017-04-29 18:07:43 +02:00
Aurora Wright 725a825762 Update FatFs 2017-04-28 23:38:15 +02:00
Aurora Wright b81f59d5ae Rewrite the LayeredFS pattern searching, small cleanup 2017-04-28 23:09:33 +02:00
Aurora Wright 39c2b8927b Fix mistake 2017-04-28 19:16:57 +02:00
Aurora Wright 89dfdac7bf This always fails 2017-04-28 12:43:56 +02:00
Aurora Wright c087edf2ba Minor cleanup 2017-04-28 12:40:07 +02:00
Aurora Wright db33c315f2 Instead of filtering mountpoints in the LayeredFS payload by their first letters, change known mountpoints not starting with "r" to start with "r" throughout the code 2017-04-28 00:33:30 +02:00
Aurora Wright c7e7dd8248 Minor stuff 2017-04-27 22:32:46 +02:00
Aurora Wright b10d82a883 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-04-27 22:17:43 +02:00
Aurora Wright e151b3d4ef Add displaying title IDs for ARM11 exceptions 2017-04-27 22:17:19 +02:00
ihaveamac 5ccf4a45c1 update ISSUE_TEMPLATE 2017-04-26 17:10:59 -07:00
Aurora Wright c5369a5cad Minor stuff 2017-04-26 18:04:02 +02:00
Aurora Wright b5eba765a5 Fix update RomFSes mounted as "ext:" (such as Taiko no Tatsujin: Don Don! Mystery Adventure) 2017-04-26 17:26:39 +02:00
Aurora Wright a5ddc38477 Minor stuff 2017-04-23 19:22:38 +02:00
Aurora Wright 8d102256a2 Improve fsTryOpenFile pattern (fixes Zelda Triforce Heroes) 2017-04-23 18:44:46 +02:00
Aurora Wright 2e561f7ea9 Cleanup 2017-04-23 05:40:22 +02:00
Aurora Wright 9656fe1b6f Change variable names for consistency 2017-04-23 03:13:38 +02:00
Aurora Wright 48c23f2a43 Attempt to fix NSMB2 by changing archive name 2017-04-23 03:11:02 +02:00
TuxSH 6d82649c3c Update config.c 2017-04-17 12:24:58 +02:00
Aurora Wright 81dea35754 Minor stuff 2017-04-17 03:59:45 +02:00
Aurora Wright fdbe43421b Fix diffs offsets 2017-04-17 02:31:04 +02:00
Aurora Wright 0d71560785 Minor stuff (2) 2017-04-17 02:18:34 +02:00
Aurora Wright 108e8a0cd4 Make loader search for patterns in just the appropriate code.bin segment, tentatively fix compatibility with Daigasso updates 2017-04-17 02:14:17 +02:00
Aurora Wright 653e81c48e Minor stuff 2017-04-17 01:01:03 +02:00
Aurora Wright 0dc0783094 Update submodules 2017-04-17 00:48:54 +02:00
Aurora 13ef1bf6be Merge pull request #408 from svanheulen/master
Use .text segment padding for LayeredFS payload
2017-04-17 00:40:20 +02:00
Seth VanHeulen 7ea80353f6 Use .text segment padding for LayeredFS payload 2017-04-16 17:59:20 -04:00
TuxSH 07bbff7d11 Fix patchSvcBreak11 2017-04-15 23:11:53 +02:00
Aurora Wright 2ff4fc3cdd Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2017-04-15 22:36:42 +02:00
Aurora Wright c9456055ea Minor stuff 2017-04-15 22:36:34 +02:00
TuxSH 2900f2d67b Update linker.ld 2017-04-15 21:17:50 +02:00
TuxSH 93c8c90804 Fix linker scripts 2017-04-15 17:11:36 +02:00
Aurora Wright 36e54642d2 Remove unused code, fix bug 2017-04-15 15:58:07 +02:00
Aurora Wright e04cb28711 Update credits, remove useless DLP version check 2017-04-15 15:47:10 +02:00
Aurora Wright ad1dc51e06 Mention IPS patches too 2017-04-14 18:14:46 +02:00
Aurora Wright 5b6bab7a58 Change Custom RomFS -> LayeredFS 2017-04-14 17:58:24 +02:00
Aurora Wright 9bd2fc659d Remove layeredFS debugging 2017-04-14 17:44:18 +02:00
Aurora Wright f18633f65f Fix injector derp 2017-04-14 17:42:17 +02:00
Aurora Wright 1026bc7b4f Update FatFs 2017-04-14 17:31:34 +02:00
Aurora Wright f1dee68142 Complete kernel9Loader 2017-04-14 17:07:41 +02:00
Aurora Wright f7cc2d295c Fix config derp (2) 2017-04-14 14:54:31 +02:00
Aurora Wright a6f254b5cf Fix config derp 2017-04-14 14:42:42 +02:00
Aurora Wright 00dbbe1b28 Not needed to save the whole struct 2017-04-14 05:02:45 +02:00
Aurora Wright 7f33309903 Fixed config bug, minor stuff 2017-04-14 04:48:03 +02:00
Aurora Wright c95808fa2d CTRNAND for LayeredFS and small changes 2017-04-13 02:49:19 +02:00
Aurora Wright 5b6bd048a9 LayeredFS 2017-04-13 01:03:57 +02:00
TuxSH 28e6ad3372 Remove the 11.3 patch that caused bugs...
...since Nintendo fixed the underlying issue on 11.4 anyways
2017-04-11 16:37:24 +02:00
TuxSH 9b128ebba5 Update most recent fpdver 2017-04-11 16:33:40 +02:00
TuxSH 71f49180c3 Fix firmlaunch patch (it was broken on 11.4) 2017-04-11 15:31:48 +02:00
TuxSH 4a042241a8 Update Makefile 2017-04-11 14:45:17 +02:00
TuxSH 0eab9127e3 Pretend nothing happened... 2017-03-19 21:29:58 +01:00
TuxSH 9f11991410 Merge pull request #383 from Margen67/master
Create ISSUE_TEMPLATE.md
2017-03-17 21:31:01 +01:00
Margen67 fec0b95098 Create ISSUE_TEMPLATE.md
Hopefully people will finally stop posting invalid issues..
2017-03-17 10:22:36 -07:00
TuxSH 5081439f53 Update config.c 2017-03-05 14:12:49 +01:00
TuxSH c44aebee4d Forgot that 2017-03-05 14:03:15 +01:00
TuxSH 706cd50f25 Always hide PIN, rework dev. options, fix bug 2017-03-05 01:56:24 +01:00
TuxSH b1b81c87f2 Fix linker scripts 2017-02-23 19:30:09 +01:00
TuxSH bf7e30539e Fix parallel builds for a9lh target
Cakes* builds are still broken, not sure it's our fault
2017-02-23 19:07:53 +01:00
TuxSH 5f8a61201b Apparently this halves the amount of stuttering with some games, on 11.3 2017-02-19 03:42:17 +01:00
TuxSH ed8aee8b8c Remove custom 3dsx.ld dependency
Thanks to @WinterMute
2017-02-13 01:20:44 +01:00
TuxSH 92ec2af587 Update crypto.c 2017-02-09 22:48:11 +01:00
TuxSH 7960c87579 Implement aes_setkey for TWL keyslots + TWL console info/crypto init 2017-02-09 20:35:39 +01:00
TuxSH 700d572732 Stub svc 0x59 2017-02-08 23:18:08 +01:00
TuxSH 014a0d86f1 "Fix" the kernel9loader function and always set >= 9.6 keys, separately 2017-02-08 12:34:07 +01:00
TuxSH 88db59405f Update patcher.c 2017-02-07 02:15:34 +01:00
TuxSH ef2e008700 Set the stub back to AXIWRAM again 2017-01-24 23:35:23 +01:00
TuxSH 07101c053a Fix boot issue (2) 2017-01-24 23:20:47 +01:00
TuxSH 6c5f6ac475 Attempt to fix the boot issue 2017-01-24 21:59:02 +01:00
TuxSH 61ecd9a617 Update screen.c 2017-01-24 09:22:31 +01:00
TuxSH 6f56a9bfe9 Update config.h 2017-01-24 02:22:38 +01:00
TuxSH 416875ee46 Merge pull request #343 from HighMans/master
Update config.c
2017-01-24 00:37:33 +01:00
HighMans c875b506ea Update config.c 2017-01-21 15:20:48 -05:00
TuxSH ff4517e583 Merge pull request #337 from arbingordon/master
Add pin hiding option
2017-01-20 00:29:59 +01:00
John Kearney 92cc989dc9 Add pin hiding option 2017-01-19 17:24:06 -05:00
TuxSH 6e5987e3ca Update submodules 2017-01-18 00:18:22 +01:00
TuxSH f03e232b90 Update screen.c 2017-01-15 22:23:20 +01:00
TuxSH 1eb18c1790 Fix sigpatch bug on N3DS safe_firm
Thanks @SciresM for noticing it
2017-01-08 18:29:26 +01:00
TuxSH 3076d56973 Merge pull request #317 from SciresM/master
Add signature patches for old firmwares.
2017-01-07 23:47:19 +01:00
Michael Scire b35707edf9 Signature patches for factory/1.x/2.x 2017-01-07 14:32:02 -08:00
TuxSH dfbd0dc9e7 Merge pull request #309 from maorninja/master
Update link to Plailects Guide
2017-01-03 20:25:00 +01:00
maorninja 620ad7ba71 Update link to Plailects Guide 2017-01-02 21:28:04 -08:00
TuxSH 5e4fd53243 Merge pull request #305 from adibsurani/master
Added a patch to disable DLP region check
2016-12-23 21:22:27 +01:00
TuxSH 0ba7630354 Fix ldrt/sdrt handling. 2016-12-22 23:11:15 +01:00
Adib Surani 028d0ec0d5 Whitespace 2016-12-23 03:53:31 +11:00
Adib Surani 751fa05fcd DLP region patch 2016-12-23 03:51:17 +11:00
Aurora f89845257e Minor stuff 2016-12-11 20:10:51 +01:00
Aurora 2f274e2f47 Consistency 2016-12-11 19:51:11 +01:00
Aurora 38088e80e1 Switch to static arrays 2016-12-11 19:30:54 +01:00
Aurora 14162828ea Fix custom paths shorter than the original one 2016-12-11 19:25:12 +01:00
Aurora ab8507e09d Makefile cleanup 2016-12-03 23:22:48 +01:00
Aurora 0d25c07333 Payload menu fixes 2016-12-01 00:51:07 +01:00
Aurora bfc8ba8447 Minor cleanup 2016-11-29 20:11:30 +01:00
Aurora a45f8293d9 Fix small derp 2016-11-29 19:51:07 +01:00
Aurora f29b9d14d7 Minor stuff 2016-11-26 22:46:46 +01:00
Aurora 9c9fd2deef Include base_tools instead of specifying binaries manually 2016-11-26 18:00:17 +01:00
Aurora 3bb01ffd68 Remove useless makefile rules 2016-11-26 17:48:57 +01:00
Aurora bc6d9994dc Patches fail on applets 2016-11-26 15:01:07 +01:00
Aurora e177f9e0fe Minor stuff 2016-11-26 14:07:48 +01:00
TuxSH c5d75d2de9 Update exceptions.c 2016-11-24 07:12:28 +01:00
Aurora cc0cade4d2 Implemented ips patcher for code.bin, extended patching to applets 2016-11-19 15:44:10 +01:00
Aurora 1e3362250f Cleanup, fixed exceptions derp, support RomFS from CTRNAND, patching features for NAND titles 2016-11-17 15:46:57 +01:00
Aurora db16e8d602 Little fixes (2) 2016-11-16 20:29:19 +01:00
Aurora 2a563eddd0 Little fixes 2016-11-16 14:52:50 +01:00
Aurora 6b8474b7b9 Minor stuff 2016-11-16 04:02:39 +01:00
Aurora b5336c81cc Added RomFS redirection courtesy of @delebile, changed structure for game patches: language emulation txts now go to /luma/titles/<titleid>/locale.txt, code.bins go to /luma/titles/<titleid>/code.bin, RomFSes go to /luma/titles/<titleid>/romfs 2016-11-16 03:41:59 +01:00
Aurora 1fcab825bf Fix derp (3) 2016-11-15 20:34:11 +01:00
Aurora 0306556032 Fix derp (2) 2016-11-15 19:45:27 +01:00
Aurora b093578046 Fix derps 2016-11-15 19:35:57 +01:00
Aurora 9332b9eb33 Refactor the codebase to limit nested if/elses 2016-11-15 19:29:48 +01:00
Aurora 141c7817a0 Cleanup 2016-11-15 14:08:58 +01:00
Aurora f155026d8f Fix derp 2016-11-14 20:49:59 +01:00
Aurora 37e467ba60 Cleanup, add possibility to clear the inserted PIN by pressing SELECT 2016-11-14 15:42:26 +01:00
Aurora 3572b835b5 Some consoles seem to need 3ms 2016-11-14 02:11:12 +01:00
Aurora da4f3a72af Re-add the power button support with a temporary (?) bugfix 2016-11-14 01:56:52 +01:00
Aurora 2938bbd11f This function appears to be borked on New 3DS 2016-11-14 01:03:11 +01:00
Aurora abf3017eb2 Fix epic fail 2016-11-14 00:08:41 +01:00
Aurora 5c855ea52f Better this way 2016-11-13 22:36:13 +01:00
Aurora c83edea7ad Improved the waitInput function basing on code from @d0k3, added support for the power button, added possibiity to quit the payload loader menu with START 2016-11-13 22:15:03 +01:00
Aurora 6d3113c8c3 Hide payload extension 2016-11-13 19:30:30 +01:00
Aurora 48c48c7bbc Fix max payload filename size 2016-11-13 18:50:01 +01:00
Aurora e4093ed988 Minor stuff 2016-11-13 18:40:33 +01:00
Aurora c79af52720 Save 2 characters for payload names 2016-11-13 18:30:34 +01:00
Aurora 61eeaca6d5 Move START here 2016-11-13 18:17:02 +01:00
Aurora 320a79ba72 Fix derp 2016-11-13 18:13:12 +01:00
Aurora 2e1b943805 Implement chainloader selector menu (can be called with START, the START payload can now be booted with L+START 2016-11-13 18:10:59 +01:00
Aurora bc167dde2d Reword the developer options decription 2016-11-13 13:56:29 +01:00
Aurora 7d9a8b4211 Fix derp 2016-11-12 22:27:03 +01:00
Aurora 0b16d88756 Minor stuff 2016-11-12 14:17:42 +01:00
TuxSH 796cb31ed7 Update exceptions.c 2016-11-12 13:18:24 +01:00
Aurora d7fd2f26c1 Revert "Add support for installing retail 0x3D[0] key-encrypted CIAs on dev units"
This reverts commit 5adb8749de.
2016-11-12 02:52:54 +01:00
TuxSH 5adb8749de Add support for installing retail 0x3D[0] key-encrypted CIAs on dev units
When "UNITINFO" is enabled
2016-11-12 02:14:35 +01:00
Aurora 3474faa4a2 Added support for dev units sysupdater FIRM (untested but should work) 2016-11-12 01:50:43 +01:00
Aurora acd9c04ff6 Minor stuff 2016-11-11 18:31:38 +01:00
Aurora 833c9406b0 Make it possible to use the reboot patch with the payload on CTRNAND and no SD 2016-11-11 16:31:17 +01:00
Aurora 2f1253e27f Merge pull request #276 from SciresM/patch-1
Add devkit keys.
2016-11-11 15:56:57 +01:00
SciresM 53b847e31c Add devkit keys. 2016-11-11 06:55:29 -08:00
Aurora 7efa33dd7f It seems some games check just for the language 2016-11-11 04:04:12 +01:00
Aurora 4011970a57 Fix derp 2016-11-11 02:16:33 +01:00
TuxSH a2cfa2be16 Fix same handling bug on arm9 2016-11-11 00:30:49 +01:00
Aurora c4b691d688 Add another check 2016-11-10 22:41:51 +01:00
Aurora 72a7a8eee5 Minor stuff 2016-11-10 13:17:58 +01:00
Aurora 52d352385f Move dev common key patch to UNITINFO since it breaks SD retail encrypted CIAs 2016-11-10 13:10:02 +01:00
Aurora c1f85650bd Minor stuff 2016-11-09 22:52:29 +01:00
Aurora b830909504 Optimize function 2016-11-09 17:01:56 +01:00
Aurora 4ad6b1c220 Attempt to increase the compatibility of language emulation with some rare games, add checks for the functions 2016-11-09 16:33:54 +01:00
Aurora 429488a4ba Fixed New 3DS CPU patch overriding the CPU mode of N3DS exclusives/enhanced titles 2016-11-08 17:52:02 +01:00
Aurora 40c6cc11a5 Minor stuff 2016-11-06 14:52:10 +01:00
Aurora 594881c6ce Do things properly 2016-11-06 14:45:45 +01:00
Aurora 1cc64a0fbc Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2016-11-06 01:10:18 +01:00
Aurora f492318e3c The cart update pattern is only present once on NS up to 8.0 2016-11-06 01:09:44 +01:00
TuxSH 4b06bb7795 Fix svcBreak handling bug 2016-11-06 00:05:12 +01:00
Aurora f7e570383a Add dev unit check 2016-11-05 17:46:47 +01:00
Aurora 896a088199 Fix comment 2016-11-04 22:31:43 +01:00
Aurora f3322bd003 Fix config derp, remove 0key encryption/nand ncch encryption/CIA dev common key checks on retail consoles 2016-11-04 22:28:33 +01:00
Aurora cef947d67d Fix NS version 2016-11-03 19:36:08 +01:00
Aurora b6640d118d Fix derp 2016-11-03 19:29:28 +01:00
Aurora 273d0b2ce9 Minor stuff 2016-11-03 19:02:38 +01:00
Aurora 9b724d776e Add title version support to loader, only apply userland patches to suitable title versions, report used console and safe mode boots to loader separately from the config, remove eShop update check patch as older eShop version would fail anyway and it causes issues with background updates 2016-11-03 18:56:32 +01:00
Aurora 3eaa706ccf Minor stuff (2) 2016-11-02 15:36:20 +01:00
Aurora b4c854dfe8 Minor stuff 2016-11-01 20:52:04 +01:00
Aurora 9cdadbe834 Cleanup some userland patches, add/cleanup credits for patches 2016-11-01 19:07:53 +01:00
TuxSH b3f38a8764 Update cache.s
Comments
2016-10-31 14:18:29 +01:00
Aurora 5d868284c6 Fix 11.2 FIRM support 2016-10-25 15:47:04 +02:00
Aurora 035751980d Minor stuff 2016-10-23 18:44:26 +02:00
Aurora 6b80bc08d5 Simplify some patches 2016-10-23 15:54:03 +02:00
Aurora 2089959d1b Minor stuff 2016-10-23 04:03:41 +02:00
Aurora 67b00ec28d Not needed 2016-10-23 03:56:55 +02:00
Aurora 127ae6b945 Minor stuff 2016-10-23 03:50:38 +02:00
Aurora 4f53b3ce35 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2016-10-23 03:44:12 +02:00
Aurora c3092b482a This is actually Thumb code 2016-10-23 03:42:52 +02:00
TuxSH 080219f88d Update reboot.s 2016-10-22 23:38:26 +02:00
Aurora 3fd783cd01 Cleanup 2016-10-22 18:00:58 +02:00
Aurora 211cd964d7 Move hexAtoi to strings.c, add bound check to decAtoi 2016-10-22 16:57:18 +02:00
Aurora 04f42f0be4 Fix derp 2016-10-22 16:31:31 +02:00
Aurora e00ef893d0 Introduce a decimal itoa, fixed findDumpFile not working properly with more than 100 dumps 2016-10-22 16:25:27 +02:00
Aurora 858efa604e Minor stuff (2) 2016-10-17 23:39:13 +02:00
Aurora b63b17c54f Minor stuff 2016-10-17 18:27:48 +02:00
Aurora f0e111c20e It seems we don't need it anymore after all 2016-10-17 01:21:12 +02:00
Aurora 7339f57138 Minor stuff (2) 2016-10-16 23:35:30 +02:00
Aurora 1e39c999f9 Minor stuff 2016-10-16 04:03:00 +02:00
Aurora 62f7a06192 Add safety checks for loaded FIRM modules 2016-10-16 02:47:53 +02:00
Aurora a0531b7930 Fix FIRM size check 2016-10-16 00:21:18 +02:00
Aurora 0619d04939 Divide Process9 and Kernel9 patches on non-NATIVE FIRMs too 2016-10-15 19:22:32 +02:00
Aurora cd76476d26 Fix derp 2016-10-15 18:05:46 +02:00
Aurora 53b6c17e33 Fix UNITINFO patch, limit kernel9 pattern searches to kernel9 2016-10-15 16:16:53 +02:00
Aurora 3b7b66b272 Fix fs patch to work on old FIRMs 2016-10-15 15:04:48 +02:00
Aurora a795a45c34 Cleanup the modules patch (makes it considerably smaller too 2016-10-15 05:00:09 +02:00
Aurora b58cbd228c We don't really need two sets of blank spaces 2016-10-15 00:32:00 +02:00
Aurora fc994285f9 Do the same with the reboot patch 2016-10-14 19:14:46 +02:00
Aurora d5e74b91c7 Make loader read from CTRNAND just if SD is not mounted 2016-10-14 18:03:17 +02:00
Aurora c5eb2e1070 Not needed 2016-10-14 02:06:01 +02:00
Aurora d613cb057e Minor stuff 2016-10-13 18:45:38 +02:00
Aurora 121792bebe Fix A9LH patches not being applied after firmlaunch 2016-10-13 15:19:37 +02:00
Aurora e07c230106 Simplify the main logic, remove assumption that if not using A9LH, SysNAND can't have a newer FIRM than EmuNAND, fix derp 2016-10-13 15:08:30 +02:00
Aurora d5ce3044c8 Figured I might as well do this 2016-10-13 00:52:18 +02:00
Aurora 98ff43b4d2 Minor stuff (2) 2016-10-12 23:05:26 +02:00
Aurora 1704fbcd62 Minor stuff 2016-10-12 05:08:30 +02:00
Aurora 014ac1cf72 Fix derp 2016-10-12 02:45:49 +02:00
Aurora b499c7ee75 Use f_chdir and relative paths 2016-10-12 02:32:36 +02:00
Aurora 2e069e326c Not needed anymore 2016-10-11 17:16:59 +02:00
Aurora e47d42da22 Rename vars 2016-10-11 16:59:55 +02:00
Aurora 615e5dfaa7 Fixed CTRNAND writing leaving encrypted data (thanks to d0k3), added path.txt support for CTRNAND, have the firmlaunch patch panic if both payloads cannot be found 2016-10-11 16:55:37 +02:00
Aurora fde2c371ef Minor stuff 2016-10-11 02:44:17 +02:00
Aurora a0b4e7fd5d Fix other derps 2016-10-11 00:41:58 +02:00
Aurora 45c36bbcae Fix derp 2016-10-10 23:46:25 +02:00
Aurora 66c041ad93 Minor stuff 2016-10-10 18:56:19 +02:00
Aurora 32d5c52b5f Reinstate this check 2016-10-10 18:31:56 +02:00
Aurora 9cf5b01633 Minor stuff 2016-10-10 17:30:53 +02:00
Aurora d4cf22d370 Display the number of failed patches, make loader svcBreak on failed patch, minor cleanup 2016-10-10 16:27:21 +02:00
Aurora 973640f023 Remove assumptions 2016-10-10 13:29:34 +02:00
Aurora 248ea82f76 One more check, fix non-unique pattern 2016-10-10 13:27:19 +02:00
Aurora a868079a93 Don't close the directory if not already opened 2016-10-10 03:50:24 +02:00
Aurora d270d5b9ca This can be here 2016-10-10 03:39:23 +02:00
Aurora e9692a438b More sanity checks 2016-10-10 03:10:53 +02:00
Aurora 06ea123dbd Minor stuff 2016-10-10 02:51:44 +02:00
Aurora 85141d5eda Fix another derp 2016-10-10 02:39:19 +02:00
Aurora fa13b8fbd0 Fix derp 2016-10-10 02:19:15 +02:00
Aurora 5b4712644a Lots of refactoring, main() has its own file yet again, properly handle failed patches/decryption steps, support TWL and AGB FIRM since 3.0 2016-10-10 02:10:47 +02:00
Aurora aa422914bd Does not seem to work 2016-10-08 14:46:57 +02:00
Aurora 22c453e297 Fix derp 2016-10-08 14:44:25 +02:00
Aurora e5f40cec5a This is a char 2016-10-08 14:27:36 +02:00
Aurora 50b24bf6c2 Switch to structs where possible 2016-10-08 14:23:08 +02:00
Aurora b575ee9e28 Minor stuff 2016-10-08 01:58:58 +02:00
Aurora 37030621ac Revamp CTRNAND support, add proper support for hiding options in config menu 2016-10-08 01:47:39 +02:00
Aurora f005da4d12 Prevent reading FIRM files if SD is not mounted 2016-10-07 16:25:41 +02:00
Aurora 6295559d9c Change SAFE_MODE detection for <= 2.1 2016-10-07 16:14:16 +02:00
Aurora f36ff303d9 Fix diskio.c stuff 2016-10-07 14:51:32 +02:00
Aurora 1a62e91c01 Minor stuff 2016-10-07 14:31:15 +02:00
Aurora 7f314dfe11 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2016-10-07 14:27:54 +02:00
Aurora 0caf9f4214 Add safety checks, support booting from CTRNAND 2016-10-07 14:27:30 +02:00
TuxSH 1ad600c81a Make the exception dump parser output the disassembly of the dumped code (when it's possible) 2016-10-06 00:16:21 +02:00
TuxSH bd6c7b7fdb Fix the arm11 exception handlers on < 7.x 2016-09-30 22:46:48 +02:00
Aurora 5f93724845 Fix some unrelated files being detected as FIRMs due to uncleared FatFs strings 2016-09-28 15:37:58 +02:00
Aurora ad60eac6ef Avoid overwriting the fb struct 2016-09-28 15:01:38 +02:00
Aurora b3e3a2937a Fix CakeBrah error displaying the .dat file 2016-09-26 21:42:27 +02:00
Aurora d010038228 Minor config descriptions changes 2016-09-26 16:00:10 +02:00
Aurora c28eada93e Minor makefile stuff 2016-09-26 14:23:35 +02:00
Aurora 9d84a92b1f Minor stuff 2016-09-26 13:53:58 +02:00
Aurora 7884be106d Fix closing the directory object if the directory does not exist in findDumpFile 2016-09-26 13:24:37 +02:00
Aurora 5fe7c7e7e1 Up the maximum custom path size to 55 characters from 37 2016-09-26 13:03:39 +02:00
Aurora f244b95aad Replace CakesROP's default top screen image 2016-09-25 18:06:38 +02:00
Aurora 3b5a5759b8 Forgot this 2016-09-25 15:22:07 +02:00
Aurora 528e7ee33b Git reset CakeBrah on clean for good measure 2016-09-25 15:14:07 +02:00
Aurora c1f55735fc Reintroduce the CakeBrah patch to avoid having the Luma3DS.dat file on *hax/menuhax 2016-09-25 15:10:44 +02:00
Aurora 185ea86284 Fix derp 2016-09-23 21:52:42 +02:00
Aurora 618262f015 Reorganize output structure 2016-09-23 20:18:29 +02:00
Aurora c0f41ac10e Shutdown on error 2016-09-23 19:43:09 +02:00
Aurora 3010699f20 Fix derps 2016-09-23 19:20:42 +02:00
Aurora fb274538e1 Minor stuff 2016-09-23 19:03:59 +02:00
Aurora 1a5d953a98 Not needed 2016-09-23 18:49:27 +02:00
Aurora 2dd1baebb3 Other minor makefile stuff 2016-09-23 18:45:59 +02:00
Aurora d46beac22a Pass name variable along 2016-09-23 18:37:46 +02:00
Aurora 6ed8741006 Minor stuff 2016-09-23 18:26:39 +02:00
Aurora 6845e42f2c Forgot this 2016-09-23 18:10:24 +02:00
Aurora 5196869634 Bring our own chainloader for *hax 2016-09-23 18:07:45 +02:00
Aurora 083806bfc9 Fix decrypted ARM9bin support for LGY FIRMs 2016-09-23 14:51:34 +02:00
Aurora 11d29368ce Minor stuff (2), update readme 2016-09-23 14:06:03 +02:00
Aurora 100c3d9e36 Minor stuff 2016-09-23 02:25:37 +02:00
Aurora 01fbf8c3a5 Forgot this 2016-09-23 02:13:12 +02:00
Aurora a36556d7e4 Got rid of the bin2c dependency 2016-09-23 02:06:04 +02:00
Aurora 4f11162fae Allow for separate custom versions for each NAND 2016-09-23 00:08:15 +02:00
Aurora 2cbaf39fd5 Make error() reboot if in a firmlaunch environment, improve errors 2016-09-22 22:51:52 +02:00
Aurora 2cc46c618b Better to make extra sure here 2016-09-22 22:27:46 +02:00
Aurora a0325e91f9 This can't happen 2016-09-22 22:19:27 +02:00
Aurora e11edd5dee Ensure the booted EmuNAND can actually exist before the FAT partition 2016-09-22 20:00:48 +02:00
Aurora 5e8990f571 Fix derp 2016-09-22 15:44:25 +02:00
Aurora a3fd55036a Minor stuff 2016-09-22 15:22:43 +02:00
Aurora 7a3d15c48b Got rid of CakeHax, patched CakeBrah to load arm9loaderhax.bin directly (lifting size restrictions in the process), got rid of the pathchanger (to have a custom path you can now enable the option and write it in a /luma/path.txt file, it must start with a / (this path is also picked up by the patched CakeBrah loader), fixed loading SafeA9LHInstaller and other payloads which need the OTP hash if having a PIN, fixed writing a file smaller than the existing one not removing the extra size, slightly changed the PIN format, added support for the alternate framebuffer and made the splash screen use it (it is now displayed all at once), fixed screen issues from CakeBrah 2016-09-22 14:54:55 +02:00
TuxSH a5b52a2470 Fix latest commit 2016-09-21 11:25:44 +02:00
Aurora a8cd14dafd Minor stuff 2016-09-21 00:16:27 +02:00
Aurora 2b249bd496 Also support DOS newlines, and break on newline in custom version 2016-09-20 16:16:18 +02:00
Aurora c8586cfe26 Account for trailing newlines in .txts 2016-09-20 15:35:51 +02:00
Aurora f228cb241f Minor stuff 2016-09-20 14:39:06 +02:00
Aurora fd33ef8496 Const-ify 2016-09-20 14:21:21 +02:00
Aurora ba1cf6473a Rewording of config decriptions 2016-09-19 19:04:22 +02:00
Aurora f418dcdb7b Minor stuff 2016-09-19 18:21:28 +02:00
Aurora f91c26d752 Forgot this 2016-09-19 18:06:46 +02:00
Aurora f7156f2ff2 Fix rebooting on firmlaunch 2016-09-19 17:54:11 +02:00
Aurora e444b587cf Fix derp 2016-09-19 17:07:56 +02:00
Aurora a7fcc6a5cf Add note to the access patches description 2016-09-19 16:51:17 +02:00
Aurora 872b1ccbb6 Refactor arm9Loader(), fix decrypted-arm9bin FIRM support 2016-09-19 16:33:15 +02:00
Aurora b7b3400296 Minor stuff 2016-09-19 14:57:36 +02:00
Aurora 420ccdcb82 Merge master and dev builds 2016-09-19 14:05:56 +02:00
Aurora eaa4d6323e Minor stuff 2016-09-19 00:38:49 +02:00
Aurora 4e7ac41a6c Add NUS-encrypted FIRM support (thanks to CakesFW) 2016-09-18 23:56:10 +02:00
Aurora 92f3a736a7 Support already decrypted N3DS firmware.bins in dev 2016-09-18 20:10:24 +02:00
Aurora 5a30b2b298 If the custom version is larger than 5 but smaller than 19 characters, truncate it 2016-09-18 18:32:25 +02:00
Aurora 85aaae67bf Minor wording stuff 2016-09-18 18:05:51 +02:00
TuxSH efe66bc72e Make option descriptions more readable, fix bug in draw.c 2016-09-18 17:40:00 +02:00
Aurora d7bdf3fc19 Finally fix GW downgraded NANDs (thanks GW for the easily recognizable junk) 2016-09-18 13:29:23 +02:00
Aurora c4e5f4410c Minor stuff 2016-09-17 14:52:50 +02:00
Aurora f5039dca56 Fix UTF-8 BOM (Windows Notepad seems to like it) being parsed as a regular character 2016-09-17 00:12:09 +02:00
Aurora de6f9789cb Reduce max file size 2016-09-16 13:30:16 +02:00
Aurora 4376a1093f Ninty doesn't support 4-byte UTF16 2016-09-16 12:59:32 +02:00
Aurora a413ed01f3 Fix derp 2016-09-16 03:39:12 +02:00
Aurora 05bb831321 Add UTF-8 support to customversion.txt 2016-09-16 03:14:37 +02:00
Aurora 6e0f1e5235 If 'Autoboot SysNAND' is unchecked, it's impossible to select the EmuNAND if having a corrisponding directional pad payload. Skip the payload launching if 'A' is held to make this possible 2016-09-15 23:57:55 +02:00
Aurora 2f915401dd Minor stuff 2016-09-15 20:15:20 +02:00
Aurora 14152b3072 Minor config wording stuff 2016-09-15 03:39:03 +02:00
Aurora 8f3cba37b3 Minor stuff 2016-09-14 22:48:46 +02:00
Aurora 0853f6f7ad Automate building the menuhax 3dsx and copying the pathchanger stuff 2016-09-14 19:14:45 +02:00
Aurora ae7a7ba365 Minsize GW EmuNANDs don't exist 2016-09-14 12:01:39 +02:00
Aurora 724af0fdc4 Forgot this 2016-09-14 00:07:33 +02:00
Aurora 550ea2116e Implement custom "Ver." string, must be in a textfile named "customversion.txt" in /luma, with base format Ver. %d.%d.%d-%d%ls, implemented descriptions for the options on the bottom screen, you can now boot SysNAND with an EmuNAND FIRM other than the first one, cleanup 2016-09-13 23:16:23 +02:00
Aurora 7952271d61 Get rid of selectScreen, allow clearing the screens separately, implement a PIN message function on the bottom screen (you can place a textfile named pinmessage.txt in /luma, with 800 characters max) 2016-09-13 16:22:26 +02:00
Aurora ffaa5790c2 Cleanup, add boundary checks for files loaded from SD 2016-09-13 15:07:07 +02:00
Aurora 934c4bed0b Minor stuff (2) 2016-09-13 02:50:05 +02:00
Aurora 6f040caa98 Minor stuff 2016-09-13 01:43:44 +02:00
TuxSH 50e5c29b1c Display the stack dump partially on the bottom screen when handling an exception 2016-09-13 00:52:15 +02:00
Aurora e0b5539b91 Minor stuff again 2016-09-12 19:20:31 +02:00
Aurora 050f58a3bb Don't init screens if the PIN file does not exist or is invalid 2016-09-12 19:03:31 +02:00
Aurora c739ed8e48 Added visual indication of the PIN digits in the input screens 2016-09-12 18:47:47 +02:00
Aurora a09fc6ebcb Minor stuff 2016-09-12 18:14:03 +02:00
Aurora 4367ea6afa Forgot about this 2016-09-12 15:35:55 +02:00
Aurora da0adeb39e Switch to enums for the options 2016-09-11 19:17:56 +02:00
Aurora 63160a22a6 Hide N3DS CPU setting on O3DS 2016-09-11 18:45:53 +02:00
Aurora 2bc1927ebd Let's change it here as well 2016-09-11 16:33:20 +02:00
Aurora 66e0cfc185 memsearch() replaced with a Boyer-Moore Horspool implementation due to Quick Search being buggy in some rare cases 2016-09-11 16:23:59 +02:00
Aurora 7bd0e4f5b4 Revert "Remove some ifdefs"
This reverts commit 7271850df2.
2016-09-11 03:29:39 +02:00
TuxSH 7271850df2 Remove some ifdefs 2016-09-11 01:33:51 +02:00
Aurora 8c79285774 Redundancy 2016-09-11 01:28:57 +02:00
Aurora 56a77ceac1 Update readme 2016-09-11 01:18:44 +02:00
Aurora 3034420ac2 Merge changes, also change the dev build variable to DEV, which must have a value of TRUE 2016-09-11 00:58:34 +02:00
Aurora 99a157649d Minor stuff 2016-09-11 00:37:56 +02:00
TuxSH e6645554f0 Merge branch 'master' into developer
Conflicts:
	source/firm.c
	source/patches.c
	source/patches.h
2016-09-10 21:35:23 +02:00
TuxSH 0f83d1ffaa Fix broken assumptions and bugs 2016-09-10 21:12:53 +02:00
Aurora 2286eb21a7 Minor stuff 2016-09-08 23:21:40 +02:00
Aurora 64c81aa5f8 Revert "Save 4 bytes as we are space constrained on N3DS"
This reverts commit eba56d0f64.
2016-09-08 23:17:54 +02:00
Aurora 29dcfca608 Copyright stuff 2016-09-08 23:07:03 +02:00
Aurora f1cb9630ec Improve readability 2016-09-08 22:33:25 +02:00
Aurora ebbea57400 Add -dev archive generation 2016-09-08 19:28:17 +02:00
Aurora 6016dc14f8 Forgot this 2016-09-08 18:53:21 +02:00
Aurora dc8e4e5f14 Merged the two branches 2016-09-08 18:50:17 +02:00
Aurora 72c8212a0e Merge branch 'master' into developer 2016-09-08 16:11:56 +02:00
Aurora 2cd2a081d6 Update FatFs to 0.12b 2016-09-08 16:11:34 +02:00
Aurora b44ec544f4 Merge branch 'master' into developer 2016-09-08 13:51:03 +02:00
Aurora 063eae7e95 Fix another derp 2016-09-08 13:50:41 +02:00
Aurora 2552572904 Merge master into developer 2016-09-08 13:39:38 +02:00
Aurora b74dda42a2 Fix config derp, change the logic of the NIM update patch to only be applied when booting with R 2016-09-08 13:38:01 +02:00
Aurora 6e178e2069 Merge branch 'master' into developer 2016-09-08 03:11:06 +02:00
Aurora 277d723992 Minor stuff (2) 2016-09-08 02:51:51 +02:00
Aurora 2f6afe9932 Minor stuff 2016-09-08 01:50:02 +02:00
Aurora edcc617780 Merge master into developer 2016-09-08 01:43:36 +02:00
Aurora 5d39242b83 Added support for up to 4 emuNANDs (the "second emuNAND as default" toggle is now a multi option, and you can choose the emuNAND on startup by holding Up (1)/Right (2)/Down (3)/Left (4) when EmuNAND is being booted), added a B payload as the B button was freed 2016-09-08 00:49:55 +02:00
Aurora ddbe5fd27b Round NAND size to 4MB for the default layout 2016-09-07 22:22:31 +02:00
Aurora deb91d1d02 Refactor the emuNAND code 2016-09-07 18:05:43 +02:00
Aurora 63073ea07f Merge pull request #202 from DarkMatterCore/master
Support additional EmuNAND layouts.
2016-09-07 18:03:12 +02:00
Pablo Curiel a331fcd873 Add minimum NAND size exception for 2DS. 2016-09-07 11:33:05 -04:00
Pablo Curiel 99654bd5b2 Fix compatibility with 2DS.
Adds a check to determine if the NAND size is greater than the size of
an Old 3DS Toshiba NAND.
2016-09-07 11:25:20 -04:00
Aurora f10427287f Update sdmmc (thanks @gemarcano) 2016-09-07 14:26:01 +02:00
Pablo Curiel 5b6318ee3a Support additional EmuNAND layouts.
Fixes compatibility with a second EmuNAND placed after an EmuNAND
created with either the 'default' or 'minimum' setup sizes with EmuNAND9
/ 3DS Multi EmuNAND Creator.
2016-09-06 22:26:48 -04:00
Aurora 98cdbe0784 Minor stuff 2016-09-06 22:27:23 +02:00
Aurora e4eb3ae38d Minor stuff 2016-09-06 22:23:28 +02:00
Aurora 6686e4add7 Minor cleanup, added error when writing an exception dump fails 2016-09-06 19:33:50 +02:00
Aurora 96a274bf7d Merge branch 'master' into developer 2016-09-06 18:09:58 +02:00
Aurora add17a7994 Not needed 2016-09-06 18:08:54 +02:00
Aurora 26e404c6a2 Update readme 2016-09-06 17:09:27 +02:00
Aurora 144de8b328 Update readme 2016-09-06 17:07:55 +02:00
Aurora c0226e6fd9 Merge branch 'master' into developer 2016-09-06 16:53:25 +02:00
Aurora 57d728a9be Update readme 2016-09-06 16:51:01 +02:00
Aurora b2e9f5377b Merge branch 'master' into developer 2016-09-06 15:52:59 +02:00
Aurora d3d315784c Fix derp 2016-09-06 15:52:08 +02:00
Aurora 942a371b6a Fix patchKernel9Panic() pattern (fix crashes on certain O3DS FIRMs) 2016-09-06 15:41:11 +02:00
Aurora 66ffc78f60 Merge branch 'master' into developer 2016-09-06 14:42:35 +02:00
Aurora a9570cef14 Minor stuff 2016-09-06 14:15:32 +02:00
Aurora 16bc08f046 Minor stuff 2016-09-06 14:09:29 +02:00
Aurora 024335e5cd We do not use this 2016-09-06 13:47:04 +02:00
Aurora 8f32048774 Spaces, spaces everywhere 2016-09-06 13:43:00 +02:00
Aurora 33d3dd256d Merge branch 'master' into developer 2016-09-04 14:06:37 +02:00
Aurora fc151f7595 Consistency 2016-09-04 14:05:29 +02:00
Aurora 9152884815 Merge master into developer 2016-09-04 13:55:31 +02:00
Aurora 2b4e97bec5 Get rid of the PIN on/off toggle and add an Off status to the multi option, change the config layout to allow for more multi options, add macros for all options 2016-09-04 13:45:03 +02:00
Aurora a63393504f Merge branch 'master' into developer 2016-09-04 00:55:42 +02:00
Aurora 97ae8d2d44 Forgot this 2016-09-04 00:55:20 +02:00
Aurora 6c59728516 Merge master into developer 2016-09-04 00:48:09 +02:00
Aurora 201fe05a06 Implement selectable PIN size, added support for the directional pad in PINs 2016-09-04 00:38:17 +02:00
Aurora a78889523f Merge branch 'master' into developer 2016-09-03 23:08:27 +02:00
Aurora 5cd1a207c9 Forgot an instance where the PIN path is used 2016-09-03 23:07:51 +02:00
Aurora 423f0ca631 Merge branch 'master' into developer 2016-09-03 22:01:12 +02:00
Aurora 7612e38d41 Increase the config minor version 2016-09-03 22:00:49 +02:00
Aurora bf234950cb Merge master into developer 2016-09-03 21:55:37 +02:00
Aurora bd992fca15 Remove the TWL dev launcher patch as it became unnecessary 2016-09-03 19:11:44 +02:00
Aurora 45fee57abd Merge master into developer 2016-09-03 18:19:02 +02:00
Aurora a2bca96d47 Cleanup, use sizeof() for pattern memsearches 2016-09-03 18:15:00 +02:00
Aurora 9862256ca7 Do not hardcode the FIRM version check for the module patch, check for the free space to be enough 2016-09-03 18:01:56 +02:00
Aurora 6afc8b3b5c Merge master into developer 2016-09-03 17:49:54 +02:00
Aurora 9b4b4ec543 Cleanup, use sizeof() for pattern memsearches 2016-09-03 15:36:35 +02:00
Aurora d412711868 More cleanup, ARM9 exceptions for Luma and payloads are always enabled (FIRM ARM9 and ARM11 exceptions need Dev. options not to be "none") 2016-09-03 02:25:09 +02:00
Aurora 0b33551d94 Clarify option 2016-09-02 23:23:46 +02:00
Aurora 9c1b585054 Merge branch 'master' into developer 2016-09-02 22:57:23 +02:00
Aurora fc3a69d9ca Small cleanup 2016-09-02 22:56:57 +02:00
Aurora cce4a6d07f Cleanup, re-enabled module patch on N3DS on 8.1, 9.0 and >= 11.0 FIRMs 2016-09-02 22:51:11 +02:00
Aurora b16539408b Merge branch 'master' into developer 2016-09-02 15:48:02 +02:00
Aurora eba56d0f64 Save 4 bytes as we are space constrained on N3DS 2016-09-02 15:40:28 +02:00
Aurora f2181b1d3e Fix comments 2016-09-02 15:20:42 +02:00
Aurora c93a97f8d7 mcuReboot now checks for isFirmlaunch 2016-09-02 15:19:14 +02:00
Aurora 8fd2525cd1 Make the correct FIRM type always be set and fix loading old NATIVE_FIRMs from SD 2016-09-02 15:07:03 +02:00
Aurora 62a70cfdac Old NATIVE_FIRMs do not have injectable modules 2016-09-02 14:47:20 +02:00
Aurora ca0a79fc89 Merge branch 'master' into developer 2016-09-02 14:28:47 +02:00
Aurora 104b8e859f mcuReboot now checks for isFirmlaunch 2016-09-02 14:27:56 +02:00
Aurora a99b26ff8c Merge master into developer 2016-09-02 14:24:24 +02:00
Aurora 9bc62ec12d Move config and PIN paths to the respective headers 2016-09-02 14:14:19 +02:00
Aurora 84a6bb772f Merge master into developer 2016-09-02 13:44:07 +02:00
Aurora 263a5eda56 Update to latest FatFs patch 2016-09-02 13:40:20 +02:00
Aurora 7fb17ce52f Remove exceptions folder from Luma-dev when cleaning 2016-09-01 18:01:21 +02:00
Aurora 631fad24c0 Make firmware.bin check more readable 2016-09-01 17:56:33 +02:00
Aurora f1d77fa62a Add checks for the FIRM bin files to be correct for the console 2016-09-01 17:51:03 +02:00
TuxSH 3bc247b43b Update firm.c 2016-09-01 17:09:58 +02:00
Aurora 3608799dff Merge master into developer 2016-08-31 19:54:12 +02:00
Aurora c0f042bc2a Can not support safe_firm firmlaunches without 3ds_injector at the moment 2016-08-31 19:50:37 +02:00
TuxSH 8982ff259a Add support for 1.x NATIVE_FIRM (on sysNAND) and the O3DS v0 SAFE_FIRM 2016-08-31 19:30:45 +02:00
Aurora 726b06b748 Merge master into developer 2016-08-31 16:14:20 +02:00
Aurora 0057ab9c5a Fix config not being written in a rare circumstance 2016-08-31 16:11:44 +02:00
Aurora 048bf0ee4d Cleanup 2016-08-31 13:49:10 +02:00
Aurora 4da0708b51 Merge branch 'developer' of https://github.com/AuroraWright/Luma3DS into developer 2016-08-31 13:48:28 +02:00
Aurora 4c529e3145 Cleanup 2016-08-31 13:47:49 +02:00
TuxSH 8ceeca372f Fix build issue 2016-08-31 13:24:29 +02:00
TuxSH 4326ac9be1 Merge branch 'developer' of https://github.com/AuroraWright/Luma3DS into developer
Conflicts:
	source/patches.c
2016-08-31 13:14:12 +02:00
TuxSH 697c64abe4 Fix and restrain module access checks 2016-08-31 13:11:41 +02:00
Aurora 7e8cf84c42 Fix yet another derp 2016-08-30 22:51:15 +02:00
Aurora b6d91375a5 Minor cleanup 2016-08-30 21:56:27 +02:00
Aurora 61305688fd Move the itoa function to strings.c 2016-08-30 21:34:03 +02:00
Aurora 492ae4139f Merge branch 'master' into developer 2016-08-30 21:32:48 +02:00
Aurora a84f393bd5 Move the itoa function to strings.c 2016-08-30 21:32:15 +02:00
Aurora 5de54d6f9f Fix derp 2016-08-30 21:11:11 +02:00
Aurora 8fc797120f Merge master into developer, use the new string functions 2016-08-30 21:02:45 +02:00
Aurora 5406d648bc Fix derp 2016-08-30 20:01:45 +02:00
Aurora a2003fba95 Add -O3 optimization for the string functions 2016-08-30 19:48:21 +02:00
Aurora a76c15d018 Introduce a strcat replacement 2016-08-30 17:48:41 +02:00
Aurora ae8caf3d3a Merge master into developer, remove createDirectory calls 2016-08-30 17:09:29 +02:00
Aurora f221915a95 Get rid of createDirectory and make fileWrite handle directory tree creation 2016-08-30 17:04:29 +02:00
Aurora 7f93733107 Rewrite the module copying function 2016-08-30 02:18:32 +02:00
Aurora e8b9e49f57 Fix derps (thanks to @Mrrraou), general cleaup, rewrite of the modules copying function 2016-08-30 02:08:07 +02:00
TuxSH cb9576b10e Merge branch 'master' into developer
Conflicts:
	source/firm.c
	source/firm.h
	source/patches.c
	source/patches.h
2016-08-29 20:12:23 +02:00
TuxSH 06fe06f9f1 Update CFWInfo.h 2016-08-29 18:23:06 +02:00
Aurora abf7c8e565 Replace pinKeyToLetter with a C implementation, minor cleanup 2016-08-29 18:11:59 +02:00
TuxSH 46227e6763 Fix build issues on some environments. 2016-08-29 17:51:03 +02:00
Aurora 2ffe4a5451 Revert "Skip PIN verification after a MCU reboot on A9LH"
This reverts commit 18bd4bbcf6.
2016-08-29 16:04:17 +02:00
Aurora 18bd4bbcf6 Skip PIN verification after a MCU reboot on A9LH 2016-08-29 15:57:32 +02:00
Aurora 8209433696 Cleanup and refactoring 2016-08-29 15:42:54 +02:00
Aurora ad9e00acaa Add delay if a PIN was just verified and SAFE_MODE is being booted 2016-08-29 13:56:23 +02:00
Aurora c96f96258f Only patch 2.x NATIVE_FIRM on A9LH 2016-08-29 01:58:01 +02:00
Aurora 82699f3e00 Merge readPin and verifyPin 2016-08-28 23:41:41 +02:00
Aurora e2d828a4a2 Fixed derp 2016-08-28 15:58:10 +02:00
Aurora 92328c6a7e Made it easier to change your PIN, added PIN file deletion when needed 2016-08-28 15:51:54 +02:00
Aurora 3f8ad17e86 Minor PIN cleanup and UI changes 2016-08-28 14:59:33 +02:00
Aurora 52999db43a Readability stuff 2016-08-28 14:41:18 +02:00
Aurora 760aa99709 Revert "Add back reboot patch on 2.x"
This reverts commit 51c514de84.
2016-08-28 12:33:00 +02:00
TuxSH 51c514de84 Add back reboot patch on 2.x 2016-08-28 11:48:35 +02:00
Aurora 317899b4bf Fix another derp 2016-08-28 02:56:46 +02:00
Aurora 4c93d2b1f9 Better to put this here 2016-08-28 02:49:53 +02:00
Aurora 71c5404bfe Fix derp 2016-08-28 02:41:00 +02:00
Aurora 9c5248b87a Cleanup previous commit 2016-08-28 02:38:52 +02:00
TuxSH 83a0293af4 Add support (firmprot and firmlaunch patches) for 2.x on sysNAND 2016-08-28 00:32:47 +02:00
TuxSH 84f3eddaf8 Merge branch 'master' into developer
Conflicts:
	source/config.c
	source/config.h
2016-08-27 19:31:42 +02:00
TuxSH a5c6b908b6 Fix reboot patch for 5.x/6.x 2016-08-27 18:10:51 +02:00
Aurora 94f0d873df Cleanup 2016-08-27 17:34:37 +02:00
Aurora d6f66d24fa Consistency 2016-08-27 16:11:37 +02:00
Aurora 31458e9938 Implement a new config file format which allows invalidating the config with new releases, fix config-related bugs, cleanup 2016-08-27 16:00:15 +02:00
TuxSH dca612ffd7 Update firm.c 2016-08-27 13:13:43 +02:00
TuxSH 5177308d48 Update firm.c 2016-08-27 13:11:55 +02:00
TuxSH 59ab44a8c7 Merge branch 'master' into developer
Conflicts:
	source/firm.c
2016-08-27 00:44:31 +02:00
Aurora c711ed6253 Added a different error for < 3.x NANDs as they can not be booted currently 2016-08-27 00:34:25 +02:00
TuxSH 58c6be17eb Merge branch 'master' into developer 2016-08-27 00:11:34 +02:00
TuxSH 259bcc686c Merge branch 'master' into developer
Conflicts:
	source/config.c
	source/firm.c
2016-08-26 23:28:31 +02:00
Aurora 356268eae5 Welcome back to the 1,25s speed boost 2016-08-26 22:24:23 +02:00
Aurora 2dd64b8a92 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2016-08-26 21:38:36 +02:00
Aurora b5cddedb7d Fix config derp 2016-08-26 21:38:03 +02:00
TuxSH 7afdc2b3b5 "Fix" the twlbg patches and make them optional 2016-08-26 19:09:14 +02:00
Aurora 60c4956290 Fix wrong bootconfig being picked up by 3ds_injector, cleanup 2016-08-26 18:44:39 +02:00
TuxSH 4c6a2f7ab1 Fix bug in svcBreak handling. 2016-08-26 11:38:50 +02:00
TuxSH 76cee0d95b Merge branch 'master' into developer 2016-08-25 21:22:32 +02:00
TuxSH 7331a919e4 Fix bug. 2016-08-25 18:53:37 +02:00
TuxSH 27ea6b96c4 Merge branch 'master' into developer
Conflicts:
	Makefile
	source/firm.c
	source/patches.c
2016-08-25 18:49:00 +02:00
TuxSH 33238cee54 Remove loading of /luma/TwlBg.cxi, fix bugs. 2016-08-25 16:39:43 +02:00
TuxSH 384dd2ad81 Implement on-the-fly patching of TwlBg
(and port the patches from https://github.com/ahezard/twl_firm_patcher; big thanks to ahezard and people mentioned in this page; also to Subv for the original patching idea (for NATIVE_FIRM))
2016-08-25 00:13:43 +02:00
TuxSH 4885e0b8d8 On second thought... 2016-08-23 20:51:48 +02:00
TuxSH 2a84911d3b Setting "Dev. options" to "None" now disables the exception handlers and related patches (again)
Port the UNITINFO patch to TWL/AGB (although it doesn't make debugging information display on fatal errors) and SAFE firms.
On dev units this patch will set it to its "retail" value (i.e. 0)
2016-08-23 20:39:42 +02:00
TuxSH 7f672fb417 Fix an off-by-one error in the exception handlers 2016-08-22 01:21:29 +02:00
TuxSH a13fdeecf6 Merge branch 'master' into developer
Conflicts:
	source/firm.c
	source/patches.c
	source/patches.h
2016-08-21 22:31:39 +02:00
TuxSH 74ac76ba84 Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2016-08-21 22:09:47 +02:00
TuxSH 253e031f83 Add support for loading /luma/TwlBg.cxi (on dev branch this will take precedence) 2016-08-21 22:09:27 +02:00
TuxSH ef1ecf859c Update draw.c 2016-08-20 19:59:25 +02:00
TuxSH a302ad3bea R.I.P boot speed boost (for now) 2016-08-20 18:45:56 +02:00
TuxSH 0951260df7 Merge branch 'master' into developer
Conflicts:
	source/patches.c
2016-08-18 00:39:21 +02:00
TuxSH b87dadbb72 Update patches.c 2016-08-18 00:36:28 +02:00
TuxSH 1dd6a9821a Merge branch 'master' into developer
Conflicts:
	Makefile
	source/patches.c
2016-08-18 00:35:20 +02:00
TuxSH 50a2424001 Implement svcGetCFWInfo in place of svc 0x2e (which is stubbed). Luma3DS now boots ca. 1.5s faster
Fix bug in pin.c where the START button wasn't recognized as well.
2016-08-17 23:47:30 +02:00
TuxSH 61e5a4444f Fix derp. 2016-08-17 16:03:49 +02:00
Aurora de3eb6ccd7 Merge branch 'master' into developer 2016-08-16 23:10:25 +02:00
Aurora 4f8c66b2b7 There would not be an use for this 2016-08-16 22:59:25 +02:00
Aurora 4d9cbc4e19 Fix fail 2016-08-16 22:46:41 +02:00
Aurora 40369d44df Pin cleanup 2016-08-16 22:39:02 +02:00
Aurora ee3720f0b7 Make loader more readable, use an array instead of a fixed location for the emuNAND test sector 2016-08-16 18:47:27 +02:00
Aurora e5dcca1c2b Update gitignore 2016-08-16 01:59:23 +02:00
Aurora ef8438a214 Update gitignore 2016-08-16 01:58:34 +02:00
TuxSH dfd699c16b Merge branch 'master' into developer
Conflicts:
	source/config.c
2016-08-15 22:08:45 +02:00
TuxSH a381c2a811 Update config.c 2016-08-15 21:37:25 +02:00
TuxSH e4c87a59d0 Merge branch 'master' into developer
Conflicts:
	source/config.c
2016-08-15 21:29:17 +02:00
TuxSH eef30ceb3c Make the multi-choice options look cleaner 2016-08-15 21:25:06 +02:00
TuxSH 76411387ba Revert most of latest commit 2016-08-15 21:20:31 +02:00
TuxSH 8d5d8d2100 Fix and rewrite parts of k11modules.s 2016-08-15 21:07:06 +02:00
TuxSH 802bce12a7 Merge branch 'master' into developer 2016-08-15 17:23:53 +02:00
TuxSH a1024c288e Update pin.c 2016-08-15 17:15:16 +02:00
TuxSH a4531b01d5 Merge branch 'master' into developer 2016-08-15 16:51:36 +02:00
TuxSH d445b20e90 Fix bugs 2016-08-15 16:50:58 +02:00
TuxSH 24ddf5ca3d Merge branch 'master' into developer
Conflicts:
	source/config.c
	source/fs.h
	source/patches.c
2016-08-15 16:29:48 +02:00
Aurora bb117d3d74 Clear screens before turning on the backlight to mitigate previous FB contents persisting 2016-08-15 15:25:44 +02:00
Aurora c101653077 Clear screens before a power off/reboot 2016-08-15 14:46:33 +02:00
Aurora 5248b96f8a No need for this 2016-08-15 13:41:52 +02:00
Aurora 7ab59e420a Fix comment 2016-08-15 13:28:43 +02:00
Aurora 83a849126a Move stuff from firm.c (2) 2016-08-15 13:23:27 +02:00
Aurora c9c373f607 Move stuff from firm.c 2016-08-15 13:11:27 +02:00
Aurora aa7c2c0009 Various changes/cleanups, removed useless code, simplified chronometer functions 2016-08-15 03:51:48 +02:00
TuxSH 57fc4df86f Merge branch 'master' into developer 2016-08-14 23:42:33 +02:00
TuxSH 75acdc8a98 Fix setRSAMod0DerivedKeys 2016-08-14 23:32:56 +02:00
TuxSH 070f7fcc68 Fix exception dump folder creation 2016-08-14 13:47:12 +02:00
TuxSH 4d48238fb1 Merge branch 'master' into developer
Conflicts:
	source/start.s
2016-08-14 12:42:13 +02:00
TuxSH 9b304404f7 Enable access to the ITCM (older k9lh payloads disabled access to it).
Thanks @Normmatt for reporting that bug.
2016-08-14 12:30:12 +02:00
TuxSH 8e5ced8e3c Merge branch 'master' into developer 2016-08-13 23:56:49 +02:00
TuxSH 95ef379ac5 Remove the empty "luma" folder from the output folder since it will be created automatically when running Luma3DS. 2016-08-13 23:56:07 +02:00
TuxSH 915f9ccb0d Create /luma/dumps/arm9 and /luma/dumps/arm11 automatically when needed. 2016-08-13 23:43:34 +02:00
TuxSH 3709ac301a Merge branch 'master' into developer
Conflicts:
	source/config.c
	source/fs.c
	source/fs.h
2016-08-13 23:04:41 +02:00
TuxSH 3bc966f84e Replace "Enable splash screen with no screen-init" by "Display splash screen before payloads".
The screens will be initied if and only if there are splash files to display.
2016-08-13 22:23:14 +02:00
TuxSH 457b4cec13 Disable interrupts and do some refactoring. 2016-08-13 20:49:40 +02:00
TuxSH 88891ef6cd Setting "Dev. Options" to "None" no longer disable exception handling and related patches.
Removed the patch that disables execution protection on the global kernel FCRAM and VRAM mapping as it was unused, worthless, and caused bugs in the past.
2016-08-13 15:31:08 +02:00
TuxSH 25811e2b52 Remove handling of kernel panics for SAFE_FIRM k9, fix it for LGY FIRMs. 2016-08-13 11:47:10 +02:00
TuxSH f81c92e35b The user-mode context is now dumped (instead of the supervisor-mode context) on a svcBreak call.
Kernel panics are now handled by the exception handlers as well.
2016-08-12 15:17:19 +02:00
TuxSH 39b2aff627 Merge branch 'master' into developer 2016-08-06 22:38:54 +02:00
TuxSH 905777466d Don't set retail keys on dev units. 2016-08-06 22:38:06 +02:00
TuxSH 4e21cf4f1c Add an option to disable access checks (svc, service and arm9 flag checks) (thanks to @Subv for the most part) 2016-08-04 20:10:31 +02:00
TuxSH eccf9eab93 Enable reading TwlBg and AgbBg as well as TWL_FIRM, AGB_FIRM and SAFE_FIRM from SD card.
It's up to the user to provide supported versions of these firmware binaries (>= 5.x for NATIVE_FIRM, latest versions for the other firmwares) when using this feature.
2016-08-04 13:44:51 +02:00
TuxSH c36ad54bcb Always load firmware.bin when it exists. 2016-08-04 11:16:28 +02:00
TuxSH 81e2b7c11c Merge branch 'master' into developer
Conflicts:
	source/patches.c
2016-08-04 00:18:53 +02:00
TuxSH 18b5cdcddf Don't make any assumption regarding version when loading an external firmware file. 2016-08-04 00:05:01 +02:00
TuxSH fe31114779 Fix build issue 2016-08-03 23:27:58 +02:00
TuxSH df30a2a320 Fix bug regarding Arm9 exceptions 2016-08-03 23:15:45 +02:00
TuxSH cf7fa8ecbd Merge branch 'master' into developer
Conflicts:
	source/config.c
	source/firm.c
	source/fs.c
	source/fs.h
	source/patches.c
	source/patches.h
	source/utils.h
2016-08-03 22:52:51 +02:00
TuxSH 389a169443 pin.c cleanup 2016-08-03 20:49:10 +02:00
TuxSH e01802e299 Check the PIN before loading a payload.
Also fix some bugs.
2016-08-03 16:58:03 +02:00
TuxSH 709aefba5d Implement a PIN-checking system.
Idea and original code by @reworks
2016-08-03 14:13:26 +02:00
Aurora e4ed713fce Update FatFs to 0.12a 2016-07-20 15:07:13 +02:00
Aurora d3c507b0d4 Minor stuff 2016-07-20 00:11:59 +02:00
Aurora a68e14def3 Added error screen when booting an unsupported NAND with no firmware.bin or writing to the config fails, added code for creating the "luma" directory if it is missing 2016-07-18 23:07:28 +02:00
Aurora 8175642a2a Fix changing the brightness
Needs to be static for some reason
2016-07-18 21:57:31 +02:00
Aurora 8d1befea9e Rename "Updated SysNAND" to reflect its only new purpose 2016-07-18 19:10:41 +02:00
Aurora e7b8a0ef39 Force A9LH detection is not needed anymore 2016-07-18 18:53:23 +02:00
Aurora be6ee894f9 Fix firmware.bin loading 2016-07-18 17:28:04 +02:00
Aurora e0e8ed2113 Hardcode 9.6 FIRM version for firmware.bin 2016-07-18 17:13:46 +02:00
Aurora c63e46b1a9 Added FIRM version detection, removed firmware.bin loading unless an unsupported O3DS NATIVE_FIRM (pre-5.0) is being loaded, skip patching old unsupported O3DS AGB/TWL FIRMs, only apply 11.0 patches with 11.0 or greater 2016-07-18 16:58:29 +02:00
Aurora eb9c74a1ed Bool-ify 2016-07-18 15:46:29 +02:00
Aurora efd83e063e Remove code to skip the rbeoot patch on 9.0 as it is not needed anymore with A9LH and constitutes a brick risk 2016-07-18 15:40:31 +02:00
Aurora ae23a1c84d Fixed Luma allowing users to go to the configuration after AGB_FIRM quits 2016-07-18 15:09:04 +02:00
TuxSH fd1253caac Merge branch 'master' into developer 2016-07-14 21:21:55 +02:00
TuxSH a0e8bc1de3 Add support for launching >= 6.x/7.x emuNANDs properly when the sysNAND is on a lower firmware version
To launch 3.x - 4.x emuNANDs, you'll need to use an external firmware file (10.x or so should do the trick)
2016-07-14 21:20:45 +02:00
TuxSH 004f0652c9 Prevent double faults when either PC or SP is invalid 2016-07-14 20:08:31 +02:00
TuxSH d5190cd788 Minor stuff (2) 2016-07-05 16:24:00 +02:00
TuxSH 2412faf033 Merge branch 'master' into developer 2016-07-05 16:11:58 +02:00
TuxSH 72caad86cc Minor stuff 2016-07-05 16:05:53 +02:00
TuxSH 7df9917a00 Merge branch 'master' into developer 2016-07-03 20:54:14 +02:00
TuxSH 575adcbb9d Revert part of 136e0d89 (due to cache issues) 2016-07-03 20:53:13 +02:00
TuxSH 2d6debddb9 Merge branch 'master' into developer
Conflicts:
	source/firm.h
	source/fs.h
	source/patches.h
2016-07-02 17:44:08 +02:00
TuxSH 53d2aac2ae Update CakeBrah 2016-07-02 17:38:33 +02:00
TuxSH 96211813e3 Use bool instead of u32 where it's relevant 2016-07-02 14:44:01 +02:00
TuxSH 153bbd6242 Merge branch 'master' into developer
Conflicts:
	source/config.c
2016-07-02 12:48:08 +02:00
TuxSH 730e716f0f Update CakeBrah 2016-07-02 12:32:39 +02:00
TuxSH 2238293c0f Fix indentation 2016-07-02 10:59:21 +02:00
Aurora 29d8e637d8 One-liners ftw 2016-07-01 20:36:43 +02:00
Aurora 136e0d8974 Cleanup 2016-07-01 20:27:28 +02:00
TuxSH 0eb87df84f Enable support for reading FIRM system modules from SD card (in /luma/sysmodules) 2016-06-27 13:21:08 +02:00
TuxSH a9db998d84 Fix potential bugs in the exception handlers 2016-06-18 13:10:07 +02:00
TuxSH fcb8edffdf Merge branch 'master' into developer 2016-06-14 19:51:49 +02:00
TuxSH 61684ecb68 We need to clean and flush caches before jumping to payloads, actually. 2016-06-14 19:50:38 +02:00
TuxSH 0ced86b55f Merge branch 'master' into developer
Conflicts:
	source/firm.c
	source/patches.h
2016-06-13 23:16:33 +02:00
TuxSH 159c9cb475 Implement our own DCache cleaning functions 2016-06-13 21:14:53 +02:00
TuxSH 2943dcb2e9 Refactor firm.c as well as other files 2016-06-12 22:14:52 +02:00
TuxSH 984c3e549c Merge branch 'master' into developer
Conflicts:
	Makefile
2016-06-11 00:00:53 +02:00
TuxSH edfd63e1f7 We don't need to flush DCache when launching payloads.
Fixes a derp as well.
2016-06-10 23:33:03 +02:00
TuxSH e593584a47 Move screen management code to screen.c and fix cache-related issues
- Screen brightness is now updated as soon as the user selects a brightness option, on all boot environments
- Payloads can now be 1KB bigger
- Some cache-related bugs may have been fixed
2016-06-10 21:48:22 +02:00
TuxSH ef60c8ea4c Refactor the exception handling code 2016-06-08 21:44:04 +02:00
TuxSH e478908dca Make the exception handlers dump more information
You'll need to the latest version of exception_dump_parser.py
2016-06-07 19:25:45 +02:00
TuxSH ca587692eb Merge branch 'master' into developer 2016-06-05 20:56:57 +02:00
TuxSH f78dd5365c External .code section loading for titles and some refactoring 2016-06-05 20:43:49 +02:00
TuxSH f9d6cdccb0 This is what happens when I don't have a N3DS 2016-06-05 12:08:55 +02:00
TuxSH 35fdd470b3 Fix previous commit on N3DS, with dev. features enabled 2016-06-04 23:51:00 +02:00
TuxSH edff11be7b Stub svcBreak with "bkpt 65535" so we can debug it 2016-06-04 21:14:00 +02:00
TuxSH bb230de72c The ARM11 exception handlers are now working.
Refactored the exception handling code in general.
2016-06-03 21:38:35 +02:00
TuxSH 2d7dde9cf9 ARM11 exception handlers (not working yet, it fails to retrieve the data after the reboot)
Uncomment the appropriate line in firm.c to test.
2016-06-02 22:33:44 +02:00
TuxSH b77d619873 Merge branch 'master' into developer 2016-05-28 23:49:07 +02:00
TuxSH ae1033d975 Update start.s (thanks @delebile and/or @d0k3) 2016-05-28 23:47:30 +02:00
TuxSH 99d28c4f79 Move the code that sets up the exception handlers 2016-05-28 22:05:07 +02:00
TuxSH 2424865fa1 Make developer features multi-choice, since modifying UNITINFO prevents accessing eShop on retail consoles (you can now choose "ErrDisp" for a less aggressive patch) 2016-05-28 16:13:22 +02:00
TuxSH 6a280723f8 Fix developer-branch-exclusive patches 2016-05-27 22:06:11 +02:00
Aurora f85bbfff58 Merge branch 'master' into developer 2016-05-27 16:30:03 +02:00
Aurora d239d82379 Fixed release archive building 2016-05-27 16:29:39 +02:00
Aurora 9017de6082 More cleanup 2016-05-27 15:15:48 +02:00
Aurora 477414a636 Merge from master, fix derp, cleanup 2016-05-27 14:56:18 +02:00
Aurora 5fac49447c Update authors for the Cakehax loader 2016-05-27 14:08:06 +02:00
Aurora 30b3a51309 Cleanup 2016-05-27 04:16:49 +02:00
TuxSH bafba1197e Fix and refactor stuff 2016-05-25 22:56:26 +02:00
TuxSH 2fab0be5e8 Merge branch 'master' into developer
Conflicts:
	Makefile
	source/firm.c
	source/patches.c
	source/patches.h
2016-05-25 22:28:50 +02:00
TuxSH 7ea2a0a278 Remove the anti-DG check on 11.0 firmware (and future ones) 2016-05-25 20:50:45 +02:00
TuxSH a3ae38520c Fix the latest two commits 2016-05-25 20:08:37 +02:00
Aurora c36fa01651 Move patches within emunand.c 2016-05-25 15:35:50 +02:00
Aurora 9aeac7af92 Move patches to patches.c and emunand.c, section 0 copying to launchFirm for consistency 2016-05-25 14:34:43 +02:00
TuxSH 859944dc8e Update Makefile 2016-05-21 22:59:14 +02:00
TuxSH a6dc3c8fc7 Merge pull request #86 from mariogamer2/master
Print commit in settings
2016-05-21 10:50:11 +02:00
mariogamer2 61c02ed079 Print git commit in menu settings,taked from: https://github.com/roxas75/rxTools/commit/81566b7b27961fc4e9a94d6df10e23b3c75a01c5 2016-05-19 18:57:21 -04:00
TuxSH afc6f51ff2 Revised and working RO patch 2016-05-14 20:26:32 +02:00
TuxSH c32eefaa51 Patched CRO0/CRR0 hash&signature checks
This needs testing.
2016-05-14 15:35:59 +02:00
TuxSH b6969cf0d1 Make "Enable developer features" the last option for compatibility with the master branch 2016-05-13 09:15:40 +02:00
TuxSH 58a33ee6e9 Merge branch 'master' into developer
Conflicts:
	source/firm.c
2016-05-13 08:46:24 +02:00
Aurora 050f433046 Small chrono function refactoring 2016-05-13 05:01:32 +02:00
TuxSH d48f6b62ce Fixed a build issue 2016-05-12 18:12:10 +02:00
Aurora ffee64c67f Skip the svcBackdoor function on 9.0 O3DS FIRM - <= 9.5 N3DS FIRM 2016-05-12 15:28:48 +02:00
Aurora 8cbc535755 Minor pedantic changes (3) 2016-05-12 15:16:46 +02:00
TuxSH ca07af2fe9 Update fs.c 2016-05-12 15:08:12 +02:00
TuxSH 2fe5da97eb Merge branch 'master' into developer 2016-05-12 15:03:27 +02:00
Aurora 6ffaeadd1b Minor pedantic changes (3) 2016-05-12 14:48:52 +02:00
TuxSH 2c10b6bff2 Merge branch 'master' into developer
Conflicts:
	source/firm.c
	source/patches.c
	source/patches.h
2016-05-12 14:31:48 +02:00
TuxSH 76acfd9934 Minor pedantic changes (2) 2016-05-12 13:35:39 +02:00
TuxSH 06cc4f7172 Minor pedantic changes 2016-05-12 12:24:14 +02:00
Aurora 158659e5b0 More cleanup 2016-05-12 03:13:17 +02:00
Aurora 7e46046e3b Merge branch 'master' of https://github.com/AuroraWright/Luma3DS 2016-05-11 19:29:49 +02:00
Aurora 808c4b7361 Cleanup, possibly slight speedup by limiting Process9 memsearches to the P9 code 2016-05-11 19:28:45 +02:00
TuxSH 03dc4fc425 Update the FRIENDS module patch 2016-05-11 14:43:24 +02:00
TuxSH b4029dcd73 Merge branch 'master' into developer
Conflicts:
	source/firm.c
	source/patches.h
2016-05-11 01:32:06 +02:00
TuxSH 1750b256eb Do things right 2016-05-11 01:08:54 +02:00
TuxSH d00d82ac89 Update firm.c 2016-05-10 23:27:54 +02:00
TuxSH edb5a82a89 Restore svcBackdoor (on ARM11, for 11.0 and higher) 2016-05-10 23:06:32 +02:00
TuxSH f7552f7c32 Update patcher.c 2016-05-10 02:12:44 +02:00
TuxSH 4483b65b25 Update config.c 2016-05-10 01:38:08 +02:00
TuxSH d2f53626ae Add precise and reliable time measurement (with a resolution of 67MHz).
Splash screens now last 3 seconds after they have been loaded.
The delay after pressing START in the configuration menu is now 2s long.
2016-05-10 01:27:58 +02:00
TuxSH ac01fe417e Merge branch 'master' into developer
Conflicts:
	source/firm.c
	source/patches.c
	source/patches.h
	source/utils.h
2016-05-09 20:45:06 +02:00
Aurora 2fd8c7aace Moved GPU register clearing to the config only, as it causes artifacts 2016-05-09 14:38:20 +02:00
Aurora b90b138766 Cleanup, fix latest ctrulib, removed reboot after config (needs testing!), fixed L+SELECT payload 2016-05-09 03:41:29 +02:00
TuxSH c3ad7eda08 Derp 2016-05-08 17:59:15 +02:00
TuxSH 02c6a3c214 Make FCRAM (and VRAM as a side effect) globally executable from arm11 kernel (only when "developer features" are enabled) 2016-05-08 01:23:22 +02:00
TuxSH 8dd9c1a1af Merge branch 'master' into developer
Conflicts:
	source/firm.c
2016-05-08 00:07:25 +02:00
TuxSH be54052b6d Make 3ds_injector able to be bigger than the official loader module (max. 25KB on O3DS due to memory limitations). Thanks @mid-kid for the idea. 2016-05-07 23:40:02 +02:00
TuxSH 9e87679ee2 Use a much better algorithm for getLoader (Luma3DS boots around 0.25s faster now) 2016-05-07 19:16:53 +02:00
TuxSH 17964f8cd1 Exception register dumps are now displayed on screen, among other things 2016-05-06 22:50:01 +02:00
TuxSH a63fb971d4 Add support for k9/p9 exception handling on all FIRMs 2016-05-06 20:22:43 +02:00
TuxSH 4b500349e6 Update README.md 2016-05-06 18:34:35 +02:00
TuxSH 8e554e17c9 Update README.md 2016-05-06 17:18:01 +02:00
TuxSH 1d77206ae4 Refactor arm9 exception handling code (2) 2016-05-06 16:41:18 +02:00
TuxSH 4340c326dc Refactor arm9 exception handling code 2016-05-06 15:45:25 +02:00
TuxSH c6cb97ae30 Fix all supported arm9 exception vectors other than the Data Abort one 2016-05-06 12:49:03 +02:00
Aurora 9d68c980e6 Added support for 9.5 New 3DS FIRM to the arm9loader 2016-05-05 04:43:44 +02:00
Aurora e2596a0a61 Merge changes from master 2016-05-04 23:49:55 +02:00
Aurora 17d3c6491a Cleanup, removed redundant file reading code 2016-05-03 20:03:37 +02:00
Aurora f55fc421ea Moved and specialized error code for the exception vectors 2016-05-03 17:18:18 +02:00
Aurora 169b12fc20 Merge changes from master, added support for netloader companion (payload must be "nlc.bin" and will be deleted after being read, moved exception vectors 2016-05-03 16:57:00 +02:00
Aurora 905f816bbe Get rid of the double FatFs 2016-05-03 03:17:00 +02:00
Aurora fef48a449a Code refactoring, added support for SAFE_MODE FIRM on A9LH (you can update safely from it now). Thanks to delebile for the O3DS SAFE_MODE FIRM FIRM0/1 protection! 2016-05-03 01:21:43 +02:00
Aurora 95d06c115a Fixed crashes loading an emuNAND if the SD was too small to be able to hold it 2016-05-02 02:07:23 +02:00
Aurora 113059e57c Fixed L+R booting the updated NAND with the FIRM from the outdated NAND 2016-05-01 19:48:59 +02:00
Aurora 408c70b90c Merge branch 'master' into developer 2016-04-30 03:34:52 +02:00
Aurora 5b51574ebf We do not need all that space anymore 2016-04-30 03:34:28 +02:00
Aurora 1e6d7a5aee Merge changes from master 2016-04-29 18:45:30 +02:00
Aurora a28b50cee8 We do not need all that space anymore 2016-04-29 18:07:00 +02:00
Aurora df112b550b Move loadPayload to fs.c, and the path to the beginning of the chainloader 2016-04-29 17:22:13 +02:00
Aurora 85615d1916 Fix external FIRM loading 2016-04-29 15:21:49 +02:00
Aurora c6d3158b56 Remade the chainloader to only try to load the right payload for the pressed button, got rid of the default payload (start now boots "start_NAME.bin"), sel_NAME is now select_NAME as there is no more SFN limitations anymore 2016-04-29 15:08:33 +02:00
Aurora 4a4de608ec Merge branch 'master' into developer 2016-04-28 16:55:18 +02:00
Aurora e651c3d9cc Small cleanup 2016-04-28 16:27:32 +02:00
Aurora 9c12496b30 Merge branch 'master' into developer 2016-04-28 00:44:01 +02:00
Aurora bfc2448662 Simplify makefiles 2016-04-28 00:43:25 +02:00
Aurora faa04b0309 Merge branch 'master' into developer 2016-04-28 00:31:46 +02:00
Aurora ca1ea7fd6e Simplify makefiles 2016-04-28 00:31:29 +02:00
Aurora 57dc1b09ad Merge branch 'master' into developer 2016-04-27 16:18:01 +02:00
Aurora 5a9d0e2569 Fail 2016-04-27 16:16:25 +02:00
Aurora f6d3abbc11 Merge branch 'master' into developer 2016-04-27 15:47:36 +02:00
Aurora 041ca8451e Use the older cxi, should fix NANDs with incomplete background updates 2016-04-27 15:37:13 +02:00
Aurora 9ab3a7c451 Merge branch 'master' into developer 2016-04-27 04:52:36 +02:00
Aurora 2382e6d82c Fixed oversight in the injector 2016-04-27 04:52:23 +02:00
Aurora f0e1937eeb Add ARM9 exception vectors feature from @TuxSH 2016-04-26 22:23:47 +02:00
Aurora efd08ff731 Revert "Move the UNITINFO patch to the developer version"
This reverts commit f9a1f1a79b.
2016-04-26 22:00:29 +02:00
337 changed files with 52649 additions and 12886 deletions
+90
View File
@@ -0,0 +1,90 @@
<!--
-- THIS IS NOT A SUPPORT FORUM! For support go here:
-- Nintendo Homebrew: https://discord.gg/MjzatM8
--
-- Rosalina feature requests go here: https://github.com/AuroraWright/Luma3DS/issues/752
--
-- Also check the Wiki (https://github.com/AuroraWright/Luma3DS/wiki) before making an issue.
--
-- For GBA/DSiWare/DS/AGB_FIRM/TWL_FIRM problems: https://3ds.guide/troubleshooting
-- If you're using an emu/redNAND try installing anything on it to sysNAND.
-- Please make sure to read "Enable game patching" https://github.com/AuroraWright/Luma3DS/wiki/Options-and-usage before posting any issues about the "Enable game patching" option(s).
--
-- Luma updaters that don't support Boot9Strap/Sighax won't work.
-- This is due to support for non-B9S/Sighax entrypoints being dropped.
--
-- Please fill in the placeholders.-->
**System model:**
[e.g. 2DS, New 3DS, Old 3DS]
**SysNAND version (+emu/redNAND version if applicable):**
[e.g. 11.6.0-39U SysNAND, 11.6.0-39J EmuNAND]
**Entrypoint (How/what you're using to boot Luma3DS):**
[e.g. Boot9Strap/Sighax, etc.]
**Luma3DS version:**
[e.g. 8.1.1 stable or if using nightly/hourly specify the commit like this https://github.com/AuroraWright/Luma3DS/commit/9570e6cbeca53128433abbf5e3473cb8a07fe69e]
<!--You can check which version you're on in System Settings. It will be on the bottom right of the top screen.-->
**Luma3DS configuration/options:**
Default EmuNAND: ( )
Screen brightness: ( )
Splash: ( )
PIN lock: ( )
New 3DS CPU: ( )
<!--This option is only available for New 3DS/2DS.-->
--
Autoboot EmuNAND: ( )
Use EmuNAND FIRM if booting with R: ( )
Enable loading external FIRMs and modules: ( )
<!--Firmware (.bin) files are not required by Luma, or NTR CFW anymore.
-- If you're having issues with this option enabled try deleting them from the luma folder on the root of the SD card or /rw/luma on CTRNAND and disabling this option.-->
Enable game patching: ( )
Show NAND or user string in System Settings: ( )
Show GBA boot screen in patched AGB_FIRM: ( )
Patch ARM9 access: ( )
Set developer UNITINFO: ( )
Disable ARM11 exception handlers: ( )
--
**Explanation of the issue:**
**Steps to reproduce:**
1.
2.
**Dump file:**
<!--If the issue leads to a crash you must uncheck the "Disable ARM11 exception handlers" option.
-- The error message will tell you where the dump is.
-- Zip the dmp file and drag & drop it below.-->
+14 -6
View File
@@ -1,12 +1,20 @@
.vscode
out
build
loader/build
screeninit/build
injector/build
arm11/build
sysmodules/loader/build
sysmodules/rosalina/build
chainloader/build
exceptions/arm9/build
exceptions/arm11/build
*.bin
*.3dsx
*.smdh
*.firm
*.o
*.d
*.elf
*.bat
*.cxi
.DS_Store
*.dmp
.project
.cproject
.settings
-6
View File
@@ -1,6 +0,0 @@
[submodule "CakeBrah"]
path = CakeBrah
url = https://github.com/mid-kid/CakeBrah
[submodule "CakeHax"]
path = CakeHax
url = https://github.com/mid-kid/CakeHax
Submodule CakeBrah deleted from 42ebe0d0bc
Submodule CakeHax deleted from 5245c7b9dc
+127 -72
View File
@@ -4,119 +4,174 @@ ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
ifneq ($(strip $(shell firmtool -v 2>&1 | grep usage)),)
$(error "Please install firmtool v1.1 or greater")
endif
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
LD := arm-none-eabi-ld
OC := arm-none-eabi-objcopy
include $(DEVKITARM)/base_tools
name := Luma3DS
version := $(shell git describe --abbrev=0 --tags)
revision := $(shell git describe --tags --match v[0-9]* --abbrev=8 | sed 's/-[0-9]*-g/-/')
version_major := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f1 -d.)
version_minor := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f2 -d.)
version_build := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f3 -d.)
commit := $(shell git rev-parse --short=8 HEAD)
is_release := 0
ifeq ($(strip $(revision)),)
revision := v0.0.0-0
version_major := 0
version_minor := 0
version_build := 0
endif
ifeq ($(strip $(commit)),)
commit := 0
endif
ifeq ($(strip $(version_build)),)
version_build := 0
endif
ifeq ($(strip $(shell git describe --tags --match v[0-9]* | grep -)),)
is_release := 1
endif
dir_source := source
dir_patches := patches
dir_loader := loader
dir_screeninit := screeninit
dir_injector := injector
dir_mset := CakeHax
dir_ninjhax := CakeBrah
dir_arm11 := arm11
dir_chainloader := chainloader
dir_exceptions := exceptions
dir_arm9_exceptions := $(dir_exceptions)/arm9
dir_k11_extension := k11_extension
dir_sysmodules := sysmodules
dir_loader := $(dir_sysmodules)/loader
dir_rosalina := $(dir_sysmodules)/rosalina
dir_sm := $(dir_sysmodules)/sm
dir_pxi := $(dir_sysmodules)/pxi
dir_build := build
dir_out := out
ASFLAGS := -mcpu=arm946e-s
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2 -flto -ffast-math
LDFLAGS := -nostartfiles
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) APP_DESCRIPTION="Noob-friendly 3DS CFW." APP_AUTHOR="Aurora Wright" --no-print-directory
CFLAGS := -Wall -Wextra $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
LDFLAGS := -nostartfiles -Wl,--nmagic
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
bundled = $(dir_build)/patches.h $(dir_build)/loader.h $(dir_build)/screeninit.h
bundled = $(dir_build)/reboot.bin.o $(dir_build)/emunand.bin.o $(dir_build)/chainloader.bin.o $(dir_build)/arm9_exceptions.bin.o
modules = $(dir_build)/loader.cxi $(dir_build)/rosalina.cxi $(dir_build)/sm.cxi $(dir_build)/pxi.cxi
define bin2o
bin2s $< | $(AS) -o $(@)
endef
.PHONY: all
all: launcher a9lh ninjhax
.PHONY: launcher
launcher: $(dir_out)/$(name).dat
.PHONY: a9lh
a9lh: $(dir_out)/arm9loaderhax.bin
.PHONY: ninjhax
ninjhax: $(dir_out)/3ds/$(name)
all: firm
.PHONY: release
release: $(dir_out)/$(name)$(version).7z
release: $(dir_out)/$(name)$(revision).7z
.PHONY: firm
firm: $(dir_out)/boot.firm
.PHONY: clean
clean:
@$(MAKE) $(FLAGS) -C $(dir_mset) clean
@$(MAKE) $(FLAGS) -C $(dir_ninjhax) clean
@$(MAKE) -C $(dir_arm11) clean
@$(MAKE) -C $(dir_chainloader) clean
@$(MAKE) -C $(dir_arm9_exceptions) clean
@$(MAKE) -C $(dir_k11_extension) clean
@$(MAKE) -C $(dir_loader) clean
@$(MAKE) -C $(dir_screeninit) clean
@$(MAKE) -C $(dir_injector) clean
@$(MAKE) -C $(dir_rosalina) clean
@$(MAKE) -C $(dir_sm) clean
@$(MAKE) -C $(dir_pxi) clean
@rm -rf $(dir_out) $(dir_build)
$(dir_out):
@mkdir -p "$(dir_out)/luma/payloads"
.PRECIOUS: $(dir_build)/%.bin
$(dir_out)/$(name).dat: $(dir_build)/main.bin $(dir_out)
@$(MAKE) $(FLAGS) -C $(dir_mset) launcher
@dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
.PHONY: $(dir_arm11)
.PHONY: $(dir_chainloader)
.PHONY: $(dir_arm9_exceptions)
.PHONY: $(dir_k11_extension)
.PHONY: $(dir_loader)
.PHONY: $(dir_rosalina)
.PHONY: $(dir_sm)
.PHONY: $(dir_pxi)
$(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin $(dir_out)
@cp -a $(dir_build)/main.bin $@
$(dir_out)/3ds/$(name): $(dir_out)
@mkdir -p "$@"
@$(MAKE) $(FLAGS) -C $(dir_ninjhax)
@mv $(dir_out)/$(name).3dsx $(dir_out)/$(name).smdh $@
$(dir_out)/$(name)$(revision).7z: all
@mkdir -p "$(@D)"
@[ -f "$@" ] || 7z a -mx $@ ./$(@D)/* ./$(dir_exceptions)/exception_dump_parser -xr!.DS_Store
$(dir_out)/$(name)$(version).7z: launcher a9lh ninjhax
@7z a -mx $@ ./$(@D)/*
$(dir_out)/boot.firm: $(dir_build)/modules.bin $(dir_build)/arm11.elf $(dir_build)/main.elf $(dir_build)/k11_extension.bin
@mkdir -p "$(@D)"
@firmtool build $@ -D $^ -A 0x18180000 0x18000000 -C XDMA XDMA NDMA XDMA
$(dir_build)/main.bin: $(dir_build)/main.elf
$(OC) -S -O binary $< $@
$(dir_build)/modules.bin: $(modules)
@mkdir -p "$(@D)"
cat $^ > $@
$(dir_build)/main.elf: $(objects)
$(dir_build)/arm11.elf: $(dir_arm11)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/main.elf: $(bundled) $(objects)
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/patches.h: $(dir_patches)/emunand.s $(dir_patches)/reboot.s $(dir_injector)/Makefile
$(dir_build)/k11_extension.bin: $(dir_k11_extension)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/loader.cxi: $(dir_loader)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/rosalina.cxi: $(dir_rosalina)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/sm.cxi: $(dir_sm)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/pxi.cxi: $(dir_pxi)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/%.bin.o: $(dir_build)/%.bin
@$(bin2o)
$(dir_build)/chainloader.bin: $(dir_chainloader)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/arm9_exceptions.bin: $(dir_arm9_exceptions)
@mkdir -p "$(@D)"
@$(MAKE) -C $<
$(dir_build)/%.bin: $(dir_patches)/%.s
@mkdir -p "$(@D)"
@armips $<
@armips $(word 2,$^)
@$(MAKE) -C $(dir_injector)
@mv emunand.bin reboot.bin $(dir_injector)/injector.cxi $(@D)
@bin2c -o $@ -n emunand $(@D)/emunand.bin -n reboot $(@D)/reboot.bin -n injector $(@D)/injector.cxi
$(dir_build)/loader.h: $(dir_loader)/Makefile
@$(MAKE) -C $(dir_loader)
@mv $(dir_loader)/loader.bin $(@D)
@bin2c -o $@ -n loader $(@D)/loader.bin
$(dir_build)/memory.o $(dir_build)/strings.o: CFLAGS += -O3
$(dir_build)/config.o: CFLAGS += -DCONFIG_TITLE="\"$(name) $(revision) configuration\""
$(dir_build)/patches.o: CFLAGS += -DVERSION_MAJOR="$(version_major)" -DVERSION_MINOR="$(version_minor)"\
-DVERSION_BUILD="$(version_build)" -DISRELEASE="$(is_release)" -DCOMMIT_HASH="0x$(commit)"
$(dir_build)/firm.o: $(dir_build)/modules.bin
$(dir_build)/firm.o: CFLAGS += -DLUMA_SECTION0_SIZE="$(shell wc -c $(dir_build)/modules.bin | tr -d [:space:][:alpha:][:punct:])"
$(dir_build)/screeninit.h: $(dir_screeninit)/Makefile
@$(MAKE) -C $(dir_screeninit)
@mv $(dir_screeninit)/screeninit.bin $(@D)
@bin2c -o $@ -n screeninit $(@D)/screeninit.bin
$(dir_build)/bundled.h: $(bundled)
@$(foreach f, $(bundled),\
echo "extern const u8" `(echo $(basename $(notdir $(f))) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> $@;\
echo "extern const u32" `(echo $(basename $(notdir $(f)))| sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> $@;\
)
$(dir_build)/memory.o : CFLAGS += -O3
$(dir_build)/config.o : CFLAGS += -DCONFIG_TITLE="\"$(name) $(version) configuration\""
$(dir_build)/%.o: $(dir_source)/%.c $(bundled)
$(dir_build)/%.o: $(dir_source)/%.c $(dir_build)/bundled.h
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/%.o: $(dir_source)/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.c
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
include $(call rwildcard, $(dir_build), *.d)
+28 -11
View File
@@ -1,23 +1,40 @@
# Luma3DS
*Noob-proof (N)3DS "Custom Firmware"*
**Compiling:**
## What it is
First you need to clone the repository recursively with: 'git clone --recursive https://github.com/AuroraWright/Luma3DS.git'
To compile, you'll need [armips](https://github.com/Kingcom/armips), [bin2c](https://sourceforge.net/projects/bin2c/), and a recent build of [makerom](https://github.com/profi200/Project_CTR) added to your PATH.
For your convenience, here are [Windows](http://www91.zippyshare.com/v/ePGpjk9r/file.html) and [Linux](https://mega.nz/#!uQ1T1IAD!Q91O0e12LXKiaXh_YjXD3D5m8_W3FuMI-hEa6KVMRDQ) builds of armips (thanks to who compiled them!).
Finally just run 'make' and everything should work!
You can find the compiled files in the 'out' folder.
**Luma3DS** is a program to patch the system software of (New) Nintendo 3DS handheld consoles "on the fly", adding features (such as per-game language settings and debugging capabilities for developers) and removing restrictions enforced by Nintendo (such as the region lock).
It also allows you to run unauthorized ("homebrew") content by removing signature checks.
To use it, you will need a console capable of running homebrew software on the ARM9 processor. We recommend [Plailect's guide](https://3ds.guide/) for details on how to get your system ready.
**Setup / Usage / Features:**
Since Luma3DS v8.0, Luma3DS has its own in-game menu, triggerable by `L+Down+Select` (see the [release notes](https://github.com/AuroraWright/Luma3DS/releases/tag/v8.0)).
---
## Compiling
First you need to clone the repository with: `git clone https://github.com/AuroraWright/Luma3DS.git`
To compile, you'll need [armips](https://github.com/Kingcom/armips) and a build of a recent commit of [makerom](https://github.com/profi200/Project_CTR) added to your PATH. You'll also need to install [firmtool](https://github.com/TuxSH/firmtool), its README contains installation instructions.
You'll also need to update your [libctru](https://github.com/smealum/ctrulib) install, building from the latest commit.
Here are [Windows](https://buildbot.orphis.net/armips/) and [Linux](https://mega.nz/#!uQ1T1IAD!Q91O0e12LXKiaXh_YjXD3D5m8_W3FuMI-hEa6KVMRDQ) builds of armips (thanks to who compiled them!) and [makerom](https://github.com/Steveice10/buildtools/tree/master/3ds) (thanks @Steveice10!).
Run `make` and everything should work!
You can find the compiled files in the `out` folder.
---
## Setup / Usage / Features
See https://github.com/AuroraWright/Luma3DS/wiki
**Credits:**
---
## Credits
See https://github.com/AuroraWright/Luma3DS/wiki/Credits
**Licensing:**
---
## Licensing
This software is licensed under the terms of the GPLv3.
You can find a copy of the license in the LICENSE.txt file.
You can find a copy of the license in the LICENSE.txt file.
+7 -23
View File
@@ -4,37 +4,30 @@ ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
LD := arm-none-eabi-ld
OC := arm-none-eabi-objcopy
include $(DEVKITARM)/base_tools
name := $(shell basename $(CURDIR))
dir_source := source
dir_build := build
dir_out := ../$(dir_build)
ASFLAGS := -mcpu=arm946e-s
CFLAGS := -Wall -Wextra -MMD -MP -mthumb -mthumb-interwork $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
LDFLAGS := -nostartfiles
ASFLAGS := -mcpu=mpcore
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
LDFLAGS := -nostartfiles -Wl,--nmagic
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
.PHONY: all
all: $(name).bin
all: $(dir_out)/$(name).elf
.PHONY: clean
clean:
@rm -rf $(dir_build)
$(name).bin: $(dir_build)/$(name).elf
$(OC) -S -O binary $< $@
$(dir_build)/$(name).elf: $(objects)
$(dir_out)/$(name).elf: $(objects)
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/%.o: $(dir_source)/%.c
@@ -44,12 +37,3 @@ $(dir_build)/%.o: $(dir_source)/%.c
$(dir_build)/%.o: $(dir_source)/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.c
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
include $(call rwildcard, $(dir_build), *.d)
+16
View File
@@ -0,0 +1,16 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x1FF80000;
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
.data : ALIGN(4) { *(.data*); . = ALIGN(4); }
.bss : ALIGN(8) { __bss_start = .; *(.bss* COMMON); . = ALIGN(8); __bss_end = .; }
__stack_top__ = 0x1FFFE000;
. = ALIGN(4);
}
+211
View File
@@ -0,0 +1,211 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
/*
* Screen init code by dark_samus, bil1s, Normmatt, delebile and others
* LCD deinit code by tiniVi
*/
#include "types.h"
#include "memory.h"
void prepareForFirmlaunch(void);
extern u32 prepareForFirmlaunchSize;
extern volatile Arm11Operation operation;
static void initScreens(u32 brightnessLevel, struct fb *fbs)
{
*(vu32 *)0x10141200 = 0x1007F;
*(vu32 *)0x10202014 = 0x00000001;
*(vu32 *)0x1020200C &= 0xFFFEFFFE;
*(vu32 *)0x10202240 = brightnessLevel;
*(vu32 *)0x10202A40 = brightnessLevel;
*(vu32 *)0x10202244 = 0x1023E;
*(vu32 *)0x10202A44 = 0x1023E;
//Top screen
*(vu32 *)0x10400400 = 0x000001c2;
*(vu32 *)0x10400404 = 0x000000d1;
*(vu32 *)0x10400408 = 0x000001c1;
*(vu32 *)0x1040040c = 0x000001c1;
*(vu32 *)0x10400410 = 0x00000000;
*(vu32 *)0x10400414 = 0x000000cf;
*(vu32 *)0x10400418 = 0x000000d1;
*(vu32 *)0x1040041c = 0x01c501c1;
*(vu32 *)0x10400420 = 0x00010000;
*(vu32 *)0x10400424 = 0x0000019d;
*(vu32 *)0x10400428 = 0x00000002;
*(vu32 *)0x1040042c = 0x00000192;
*(vu32 *)0x10400430 = 0x00000192;
*(vu32 *)0x10400434 = 0x00000192;
*(vu32 *)0x10400438 = 0x00000001;
*(vu32 *)0x1040043c = 0x00000002;
*(vu32 *)0x10400440 = 0x01960192;
*(vu32 *)0x10400444 = 0x00000000;
*(vu32 *)0x10400448 = 0x00000000;
*(vu32 *)0x1040045C = 0x00f00190;
*(vu32 *)0x10400460 = 0x01c100d1;
*(vu32 *)0x10400464 = 0x01920002;
*(vu32 *)0x10400468 = (u32)fbs[0].top_left;
*(vu32 *)0x1040046C = (u32)fbs[1].top_left;
*(vu32 *)0x10400470 = 0x80341;
*(vu32 *)0x10400474 = 0x00010501;
*(vu32 *)0x10400478 = 0;
*(vu32 *)0x10400494 = (u32)fbs[0].top_right;
*(vu32 *)0x10400498 = (u32)fbs[1].top_right;
*(vu32 *)0x10400490 = 0x000002D0;
*(vu32 *)0x1040049C = 0x00000000;
//Disco register
for(u32 i = 0; i < 256; i++)
*(vu32 *)0x10400484 = 0x10101 * i;
//Bottom screen
*(vu32 *)0x10400500 = 0x000001c2;
*(vu32 *)0x10400504 = 0x000000d1;
*(vu32 *)0x10400508 = 0x000001c1;
*(vu32 *)0x1040050c = 0x000001c1;
*(vu32 *)0x10400510 = 0x000000cd;
*(vu32 *)0x10400514 = 0x000000cf;
*(vu32 *)0x10400518 = 0x000000d1;
*(vu32 *)0x1040051c = 0x01c501c1;
*(vu32 *)0x10400520 = 0x00010000;
*(vu32 *)0x10400524 = 0x0000019d;
*(vu32 *)0x10400528 = 0x00000052;
*(vu32 *)0x1040052c = 0x00000192;
*(vu32 *)0x10400530 = 0x00000192;
*(vu32 *)0x10400534 = 0x0000004f;
*(vu32 *)0x10400538 = 0x00000050;
*(vu32 *)0x1040053c = 0x00000052;
*(vu32 *)0x10400540 = 0x01980194;
*(vu32 *)0x10400544 = 0x00000000;
*(vu32 *)0x10400548 = 0x00000011;
*(vu32 *)0x1040055C = 0x00f00140;
*(vu32 *)0x10400560 = 0x01c100d1;
*(vu32 *)0x10400564 = 0x01920052;
*(vu32 *)0x10400568 = (u32)fbs[0].bottom;
*(vu32 *)0x1040056C = (u32)fbs[1].bottom;
*(vu32 *)0x10400570 = 0x80301;
*(vu32 *)0x10400574 = 0x00010501;
*(vu32 *)0x10400578 = 0;
*(vu32 *)0x10400590 = 0x000002D0;
*(vu32 *)0x1040059C = 0x00000000;
//Disco register
for(u32 i = 0; i < 256; i++)
*(vu32 *)0x10400584 = 0x10101 * i;
}
static void setupFramebuffers(struct fb *fbs)
{
*(vu32 *)0x10400468 = (u32)fbs[0].top_left;
*(vu32 *)0x1040046c = (u32)fbs[1].top_left;
*(vu32 *)0x10400494 = (u32)fbs[0].top_right;
*(vu32 *)0x10400498 = (u32)fbs[1].top_right;
*(vu32 *)0x10400568 = (u32)fbs[0].bottom;
*(vu32 *)0x1040056c = (u32)fbs[1].bottom;
}
static void clearScreens(struct fb *fb)
{
//Setting up two simultaneous memory fills using the GPU
vu32 *REGs_PSC0 = (vu32 *)0x10400010,
*REGs_PSC1 = (vu32 *)0x10400020;
REGs_PSC0[0] = (u32)fb->top_left >> 3; //Start address
REGs_PSC0[1] = (u32)(fb->top_left + SCREEN_TOP_FBSIZE) >> 3; //End address
REGs_PSC0[2] = 0; //Fill value
REGs_PSC0[3] = (2 << 8) | 1; //32-bit pattern; start
REGs_PSC1[0] = (u32)fb->bottom >> 3; //Start address
REGs_PSC1[1] = (u32)(fb->bottom + SCREEN_BOTTOM_FBSIZE) >> 3; //End address
REGs_PSC1[2] = 0; //Fill value
REGs_PSC1[3] = (2 << 8) | 1; //32-bit pattern; start
while(!((REGs_PSC0[3] & 2) && (REGs_PSC1[3] & 2)));
}
static void swapFramebuffers(bool isAlternate)
{
u32 isAlternateTmp = isAlternate ? 1 : 0;
*(vu32 *)0x10400478 = (*(vu32 *)0x10400478 & 0xFFFFFFFE) | isAlternateTmp;
*(vu32 *)0x10400578 = (*(vu32 *)0x10400478 & 0xFFFFFFFE) | isAlternateTmp;
}
static void updateBrightness(u32 brightnessLevel)
{
//Change brightness
*(vu32 *)0x10202240 = brightnessLevel;
*(vu32 *)0x10202A40 = brightnessLevel;
}
static void deinitScreens(void)
{
//Shutdown LCDs
*(vu32 *)0x10202A44 = 0;
*(vu32 *)0x10202244 = 0;
*(vu32 *)0x10202014 = 0;
}
void main(void)
{
operation = ARM11_READY;
while(true)
{
switch(operation)
{
case ARM11_READY:
continue;
case INIT_SCREENS:
initScreens(*(vu32 *)ARM11_PARAMETERS_ADDRESS, (struct fb *)(ARM11_PARAMETERS_ADDRESS + 4));
break;
case SETUP_FRAMEBUFFERS:
setupFramebuffers((struct fb *)ARM11_PARAMETERS_ADDRESS);
break;
case CLEAR_SCREENS:
clearScreens((struct fb *)ARM11_PARAMETERS_ADDRESS);
break;
case SWAP_FRAMEBUFFERS:
swapFramebuffers(*(volatile bool *)ARM11_PARAMETERS_ADDRESS);
break;
case UPDATE_BRIGHTNESS:
updateBrightness(*(vu32 *)ARM11_PARAMETERS_ADDRESS);
break;
case DEINIT_SCREENS:
deinitScreens();
break;
case PREPARE_ARM11_FOR_FIRMLAUNCH:
memcpy((void *)0x1FFFFC00, (void *)prepareForFirmlaunch, prepareForFirmlaunchSize);
*(vu32 *)0x1FFFFFFC = 0;
((void (*)(u32, volatile Arm11Operation *))0x1FFFFC00)(ARM11_READY, &operation);
}
operation = ARM11_READY;
}
}
+56
View File
@@ -0,0 +1,56 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
/*
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
*/
#include "memory.h"
void memcpy(void *dest, const void *src, u32 size)
{
u8 *destc = (u8 *)dest;
const u8 *srcc = (const u8 *)src;
for(u32 i = 0; i < size; i++)
destc[i] = srcc[i];
}
void memset(void *dest, u32 filler, u32 size)
{
u8 *destc = (u8 *)dest;
for(u32 i = 0; i < size; i++)
destc[i] = (u8)filler;
}
void memset32(void *dest, u32 filler, u32 size)
{
u32 *dest32 = (u32 *)dest;
for(u32 i = 0; i < size / 4; i++)
dest32[i] = filler;
}
+37
View File
@@ -0,0 +1,37 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
/*
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
*/
#pragma once
#include "types.h"
void memcpy(void *dest, const void *src, u32 size);
void memset(void *dest, u32 value, u32 size) __attribute__((used));
void memset32(void *dest, u32 filler, u32 size);
+81
View File
@@ -0,0 +1,81 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.section .text.start
.align 4
.global _start
.type _start, %function
_start:
b start
.global operation
operation:
.word 0
start:
@ Disable interrupts and switch to supervisor mode
cpsid aif, #0x13
@ Set the control register to reset default: everything disabled
ldr r0, =0x54078
mcr p15, 0, r0, c1, c0, 0
@ Set the auxiliary control register to reset default.
@ Enables instruction folding, static branch prediction,
@ dynamic branch prediction, and return stack.
mov r0, #0xF
mcr p15, 0, r0, c1, c0, 1
@ Invalidate both caches, flush the prefetch buffer then DSB
mov r0, #0
mcr p15, 0, r0, c7, c5, 4
mcr p15, 0, r0, c7, c7, 0
mcr p15, 0, r0, c7, c10, 4
@ Clear BSS
ldr r0, =__bss_start
mov r1, #0
ldr r2, =__bss_end
sub r2, r0
bl memset32
ldr sp, =__stack_top__
b main
.global prepareForFirmlaunch
.type prepareForFirmlaunch, %function
prepareForFirmlaunch:
str r0, [r1] @ tell ARM9 we're done
mov r0, #0x20000000
_wait_for_core0_entrypoint_loop:
ldr r1, [r0, #-4] @ check if core0's entrypoint is 0
cmp r1, #0
beq _wait_for_core0_entrypoint_loop
bx r1 @ jump to core0's entrypoint
prepareForFirmlaunchEnd:
.global prepareForFirmlaunchSize
prepareForFirmlaunchSize: .word prepareForFirmlaunchEnd - prepareForFirmlaunch
+65
View File
@@ -0,0 +1,65 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
//Common data types
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
#define SCREEN_TOP_WIDTH 400
#define SCREEN_BOTTOM_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_TOP_FBSIZE (3 * SCREEN_TOP_WIDTH * SCREEN_HEIGHT)
#define SCREEN_BOTTOM_FBSIZE (3 * SCREEN_BOTTOM_WIDTH * SCREEN_HEIGHT)
#define ARM11_PARAMETERS_ADDRESS 0x1FFFF000
struct fb {
u8 *top_left;
u8 *top_right;
u8 *bottom;
};
typedef enum
{
INIT_SCREENS = 0,
SETUP_FRAMEBUFFERS,
CLEAR_SCREENS,
SWAP_FRAMEBUFFERS,
UPDATE_BRIGHTNESS,
DEINIT_SCREENS,
PREPARE_ARM11_FOR_FIRMLAUNCH,
ARM11_READY,
} Arm11Operation;
+10 -13
View File
@@ -4,39 +4,37 @@ ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
CC := arm-none-eabi-gcc
AS := arm-none-eabi-as
LD := arm-none-eabi-ld
OC := arm-none-eabi-objcopy
include $(DEVKITARM)/base_tools
name := $(shell basename $(CURDIR))
dir_source := source
dir_build := build
dir_out := ../$(dir_build)
ASFLAGS := -mcpu=mpcore -mfloat-abi=hard
CFLAGS := -Wall -Wextra -MMD -MP -mthumb -mthumb-interwork $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
LDFLAGS := -nostdlib
ASFLAGS := -mcpu=arm946e-s
CFLAGS := -Wall -Wextra -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
LDFLAGS := -nostartfiles -Wl,--nmagic
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
.PHONY: all
all: $(name).bin
all: $(dir_out)/$(name).bin
.PHONY: clean
clean:
@rm -rf $(dir_build)
$(name).bin: $(dir_build)/$(name).elf
$(OC) -S -O binary $< $@
$(dir_out)/$(name).bin: $(dir_build)/$(name).elf
$(OBJCOPY) -S -O binary $< $@
$(dir_build)/$(name).elf: $(objects)
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/memory.o: CFLAGS += -O3
$(dir_build)/%.o: $(dir_source)/%.c
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
@@ -44,4 +42,3 @@ $(dir_build)/%.o: $(dir_source)/%.c
$(dir_build)/%.o: $(dir_source)/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
include $(call rwildcard, $(dir_build), *.d)
+21
View File
@@ -0,0 +1,21 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x01FF9000;
__start__ = ABSOLUTE(.);
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
.data : ALIGN(4) { *(.data*); . = ALIGN(8); *(.bss* COMMON); . = ALIGN(8); }
. = ALIGN(4);
__end__ = ABSOLUTE(.);
__stack_top__ = 0x01FFB800;
__stack_bottom__ = 0x01FFA800;
}
+31
View File
@@ -0,0 +1,31 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
void flushCaches(void);
+60
View File
@@ -0,0 +1,60 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.text
.arm
.align 4
.global flushCaches
.type flushCaches, %function
flushCaches:
@ Clean and flush both the data cache and instruction caches
@ Adpated from http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0155a/ch03s03s05.html ,
@ and https://github.com/gemarcano/libctr9_io/blob/master/src/ctr_system_ARM.c#L39 as well
@ Note: ARM's example is actually for a 8KB DCache (which is what the 3DS has)
@ Implemented in bootROM at addresses 0xffff0830 (DCache) and 0xffff0ab4 (ICache)
mov r1, #0 @ segment counter
outer_loop:
mov r0, #0 @ line counter
inner_loop:
orr r2, r1, r0 @ generate segment and line address
mcr p15, 0, r2, c7, c14, 2 @ clean and flush the line
add r0, #0x20 @ increment to next line
cmp r0, #0x400
bne inner_loop
add r1, #0x40000000
cmp r1, #0
bne outer_loop
mcr p15, 0, r1, c7, c10, 4 @ drain write buffer
@ Flush instruction cache
mcr p15, 0, r1, c7, c5, 0
bx lr
+42
View File
@@ -0,0 +1,42 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "firm.h"
#include "memory.h"
#include "cache.h"
void disableMpuAndJumpToEntrypoints(int argc, char **argv, void *arm11Entry, void *arm9Entry);
void launchFirm(Firm *firm, int argc, char **argv)
{
//Copy FIRM sections to respective memory locations
for(u32 sectionNum = 0; sectionNum < 4; sectionNum++)
memcpy(firm->section[sectionNum].address, (u8 *)firm + firm->section[sectionNum].offset, firm->section[sectionNum].size);
disableMpuAndJumpToEntrypoints(argc, argv, firm->arm9Entry, firm->arm11Entry);
__builtin_unreachable();
}
+50
View File
@@ -0,0 +1,50 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
typedef struct __attribute__((packed))
{
u32 offset;
u8 *address;
u32 size;
u32 procType;
u8 hash[0x20];
} FirmSection;
typedef struct __attribute__((packed))
{
char magic[4];
u32 reserved1;
u8 *arm11Entry;
u8 *arm9Entry;
u8 reserved2[0x30];
FirmSection section[4];
} Firm;
void launchFirm(Firm *firm, int argc, char **argv);
+58
View File
@@ -0,0 +1,58 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "memory.h"
#include "cache.h"
#include "firm.h"
void main(int argc, char **argv, Firm *firm)
{
char *argvPassed[2],
absPath[24 + 255];
struct fb fbs[2];
if(argc > 0)
{
u32 i;
for(i = 0; i < sizeof(absPath) - 1 && argv[0][i] != 0; i++)
absPath[i] = argv[0][i];
absPath[i] = 0;
argvPassed[0] = (char *)absPath;
}
if(argc == 2)
{
struct fb *fbsrc = (struct fb *)argv[1];
fbs[0] = fbsrc[0];
fbs[1] = fbsrc[1];
argvPassed[1] = (char *)&fbs;
}
launchFirm(firm, argc, argvPassed);
}
+40
View File
@@ -0,0 +1,40 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
/*
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
*/
#include "memory.h"
void memcpy(void *dest, const void *src, u32 size)
{
u8 *destc = (u8 *)dest;
const u8 *srcc = (const u8 *)src;
for(u32 i = 0; i < size; i++)
destc[i] = srcc[i];
}
+35
View File
@@ -0,0 +1,35 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
/*
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
*/
#pragma once
#include "types.h"
void memcpy(void *dest, const void *src, u32 size);
+60
View File
@@ -0,0 +1,60 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.arm
.section .text.start
.align 4
.global _start
_start:
ldr sp, =__stack_top__
b main
.text
.balign 4
.global disableMpuAndJumpToEntrypoints
.type disableMpuAndJumpToEntrypoints, %function
disableMpuAndJumpToEntrypoints:
mov r4, r0
mov r5, r1
mov r6, r2
mov r7, r3
bl flushCaches
@ Disable caches / MPU
mrc p15, 0, r0, c1, c0, 0 @ read control register
bic r0, #(1<<12) @ - instruction cache disable
bic r0, #(1<<2) @ - data cache disable
bic r0, #(1<<0) @ - MPU disable
mcr p15, 0, r0, c1, c0, 0 @ write control register
@ Set the ARM11 entrypoint
mov r0, #0x20000000
str r7, [r0, #-4]
@ Jump to the ARM9 entrypoint
mov r0, r4
mov r1, r5
ldr r2, =0x3BEEF
bx r6
+45
View File
@@ -0,0 +1,45 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include <stdint.h>
//Common data types
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
struct fb {
u8 *top_left;
u8 *top_right;
u8 *bottom;
};
+42
View File
@@ -0,0 +1,42 @@
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/base_tools
name := arm9_exceptions
dir_source := source
dir_build := build
dir_out := ../../$(dir_build)
ASFLAGS := -mcpu=arm946e-s
CFLAGS := -Wall -Wextra -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -Os -ffast-math
LDFLAGS := -nostartfiles -Wl,--nmagic
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
.PHONY: all
all: $(dir_out)/$(name).bin
.PHONY: clean
clean:
@rm -rf $(dir_build)
$(dir_out)/$(name).bin: $(dir_build)/$(name).elf
$(OBJCOPY) -S -O binary $< $@
$(dir_build)/$(name).elf: $(objects)
$(CC) $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/%.o: $(dir_source)/%.c
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/%.o: $(dir_source)/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
+14
View File
@@ -0,0 +1,14 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x01FF8000;
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
.data : ALIGN(4) { *(.data*); . = ALIGN(8); *(.bss* COMMON); . = ALIGN(8); }
. = ALIGN(4);
}
+51
View File
@@ -0,0 +1,51 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
typedef struct __attribute__((packed))
{
u32 magic[2];
u16 versionMinor, versionMajor;
u16 processor, core;
u32 type;
u32 totalSize;
u32 registerDumpSize;
u32 codeDumpSize;
u32 stackDumpSize;
u32 additionalDataSize;
} ExceptionDumpHeader;
void FIQHandler(void);
void undefinedInstructionHandler(void);
void dataAbortHandler(void);
void prefetchAbortHandler(void);
u32 safecpy(void *dst, const void *src, u32 len);
+152
View File
@@ -0,0 +1,152 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.macro GEN_USUAL_HANDLER name, index
\name\()Handler:
ldr sp, =_regs
stmia sp, {r0-r7}
mov r0, #\index
b _commonHandler
.endm
.text
.arm
.balign 4
.global _commonHandler
.type _commonHandler, %function
_commonHandler:
mov r1, r0
mov r0, sp
mrs r2, spsr
mrs r3, cpsr
add r6, r0, #(8 * 4)
orr r3, #0xc0 @ mask interrupts
msr cpsr_cx, r3
ands r4, r2, #0xf @ get the mode that triggered the exception
moveq r4, #0xf @ usr => sys
bic r5, r3, #0xf
orr r5, r4
msr cpsr_c, r5 @ change processor mode
stmia r6!, {r8-lr}
msr cpsr_c, r3 @ restore processor mode
str lr, [r6], #4
str r2, [r6]
msr cpsr_cxsf, #0xdf @ finally, switch to system mode, mask interrupts and clear flags (in case of double faults)
ldr sp, =0x02000000
b mainHandler
.global FIQHandler
.type FIQHandler, %function
GEN_USUAL_HANDLER FIQ, 0
.global undefinedInstructionHandler
.type undefinedInstructionHandler, %function
GEN_USUAL_HANDLER undefinedInstruction, 1
.global prefetchAbortHandler
.type prefetchAbortHandler, %function
prefetchAbortHandler:
msr cpsr_cx, #0xd7 @ mask interrupts (abort mode)
mrs sp, spsr
and sp, #0x3f
cmp sp, #0x13
bne _prefetchAbortNormalHandler
ldr sp, =BreakPtr
ldr sp, [sp]
cmp sp, #0
beq _prefetchAbortNormalHandler
add sp, #(1*4 + 4)
cmp lr, sp
bne _prefetchAbortNormalHandler
mov sp, r8
pop {r8-r11}
ldr lr, [sp, #8]!
ldr sp, [sp, #4]
msr spsr_cxsf, sp
tst sp, #0x20
addne lr, #2 @ adjust address for later
GEN_USUAL_HANDLER _prefetchAbortNormal, 2
.global dataAbortHandler
.type dataAbortHandler, %function
dataAbortHandler:
msr cpsr_cx, #0xd7 @ mask interrupts (abort mode)
mrs sp, spsr
and sp, #0x3f
cmp sp, #0x1f
bne _dataAbortNormalHandler
sub lr, #8
adr sp, safecpy
cmp lr, sp
blo _j_dataAbortNormalHandler
adr sp, _safecpy_end
cmp lr, sp
bhs _j_dataAbortNormalHandler
msr spsr_f, #(1 << 30)
mov r12, #0
adds pc, lr, #4
_j_dataAbortNormalHandler:
add lr, #8
GEN_USUAL_HANDLER _dataAbortNormal, 3
.global safecpy
.type safecpy, %function
safecpy:
push {r4, lr}
mov r3, #0
movs r12, #1
_safecpy_loop:
ldrb r4, [r1, r3]
cmp r12, #0
beq _safecpy_loop_end
strb r4, [r0, r3]
add r3, #1
cmp r3, r2
blo _safecpy_loop
_safecpy_loop_end:
mov r0, r3
pop {r4, pc}
_safecpy_end:
.bss
.balign 4
_regs: .skip (4 * 17)
+143
View File
@@ -0,0 +1,143 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
/*
* Thanks to whoever contributed in the development of this file
*/
#include "i2c.h"
//-----------------------------------------------------------------------------
static const struct { u8 bus_id, reg_addr; } dev_data[] = {
{0, 0x4A}, {0, 0x7A}, {0, 0x78},
{1, 0x4A}, {1, 0x78}, {1, 0x2C},
{1, 0x2E}, {1, 0x40}, {1, 0x44},
{2, 0xD6}, {2, 0xD0}, {2, 0xD2},
{2, 0xA4}, {2, 0x9A}, {2, 0xA0},
};
static inline u8 i2cGetDeviceBusId(u8 device_id)
{
return dev_data[device_id].bus_id;
}
static inline u8 i2cGetDeviceRegAddr(u8 device_id)
{
return dev_data[device_id].reg_addr;
}
//-----------------------------------------------------------------------------
static vu8 *reg_data_addrs[] = {
(vu8 *)(I2C1_REG_OFF + I2C_REG_DATA),
(vu8 *)(I2C2_REG_OFF + I2C_REG_DATA),
(vu8 *)(I2C3_REG_OFF + I2C_REG_DATA),
};
static inline vu8 *i2cGetDataReg(u8 bus_id)
{
return reg_data_addrs[bus_id];
}
//-----------------------------------------------------------------------------
static vu8 *reg_cnt_addrs[] = {
(vu8 *)(I2C1_REG_OFF + I2C_REG_CNT),
(vu8 *)(I2C2_REG_OFF + I2C_REG_CNT),
(vu8 *)(I2C3_REG_OFF + I2C_REG_CNT),
};
static inline vu8 *i2cGetCntReg(u8 bus_id)
{
return reg_cnt_addrs[bus_id];
}
//-----------------------------------------------------------------------------
static inline void i2cWaitBusy(u8 bus_id)
{
while (*i2cGetCntReg(bus_id) & 0x80);
}
static inline bool i2cGetResult(u8 bus_id)
{
i2cWaitBusy(bus_id);
return (*i2cGetCntReg(bus_id) >> 4) & 1;
}
static void i2cStop(u8 bus_id, u8 arg0)
{
*i2cGetCntReg(bus_id) = (arg0 << 5) | 0xC0;
i2cWaitBusy(bus_id);
*i2cGetCntReg(bus_id) = 0xC5;
}
//-----------------------------------------------------------------------------
static bool i2cSelectDevice(u8 bus_id, u8 dev_reg)
{
i2cWaitBusy(bus_id);
*i2cGetDataReg(bus_id) = dev_reg;
*i2cGetCntReg(bus_id) = 0xC2;
return i2cGetResult(bus_id);
}
static bool i2cSelectRegister(u8 bus_id, u8 reg)
{
i2cWaitBusy(bus_id);
*i2cGetDataReg(bus_id) = reg;
*i2cGetCntReg(bus_id) = 0xC0;
return i2cGetResult(bus_id);
}
//-----------------------------------------------------------------------------
bool i2cWriteRegister(u8 dev_id, u8 reg, u8 data)
{
u8 bus_id = i2cGetDeviceBusId(dev_id);
u8 dev_addr = i2cGetDeviceRegAddr(dev_id);
for(u32 i = 0; i < 8; i++)
{
if(i2cSelectDevice(bus_id, dev_addr) && i2cSelectRegister(bus_id, reg))
{
i2cWaitBusy(bus_id);
*i2cGetDataReg(bus_id) = data;
*i2cGetCntReg(bus_id) = 0xC1;
i2cStop(bus_id, 0);
if(i2cGetResult(bus_id)) return true;
}
*i2cGetCntReg(bus_id) = 0xC5;
i2cWaitBusy(bus_id);
}
return false;
}
+48
View File
@@ -0,0 +1,48 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
/*
* Thanks to whoever contributed in the development of this file
*/
#pragma once
#include "types.h"
#define I2C1_REG_OFF 0x10161000
#define I2C2_REG_OFF 0x10144000
#define I2C3_REG_OFF 0x10148000
#define I2C_REG_DATA 0
#define I2C_REG_CNT 1
#define I2C_REG_CNTEX 2
#define I2C_REG_SCL 4
#define I2C_DEV_MCU 3
#define I2C_DEV_GYRO 10
#define I2C_DEV_IR 13
bool i2cWriteRegister(u8 dev_id, u8 reg, u8 data);
+82
View File
@@ -0,0 +1,82 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "i2c.h"
#include "handlers.h"
#define FINAL_BUFFER 0x25000000
#define REG_DUMP_SIZE 4 * 17
#define CODE_DUMP_SIZE 48
void __attribute__((noreturn)) mainHandler(u32 *registerDump, u32 type)
{
ExceptionDumpHeader dumpHeader;
u8 codeDump[CODE_DUMP_SIZE];
dumpHeader.magic[0] = 0xDEADC0DE;
dumpHeader.magic[1] = 0xDEADCAFE;
dumpHeader.versionMajor = 1;
dumpHeader.versionMinor = 2;
dumpHeader.processor = 9;
dumpHeader.core = 0;
dumpHeader.type = type;
dumpHeader.registerDumpSize = REG_DUMP_SIZE;
dumpHeader.codeDumpSize = CODE_DUMP_SIZE;
dumpHeader.additionalDataSize = 0;
u32 cpsr = registerDump[16];
u32 pc = registerDump[15] - (type < 3 ? (((cpsr & 0x20) != 0 && type == 1) ? 2 : 4) : 8);
registerDump[15] = pc;
//Dump code
u8 *instr = (u8 *)pc + ((cpsr & 0x20) ? 2 : 4) - dumpHeader.codeDumpSize; //wouldn't work well on 32-bit Thumb instructions, but it isn't much of a problem
dumpHeader.codeDumpSize = ((u32)instr & (((cpsr & 0x20) != 0) ? 1 : 3)) != 0 ? 0 : safecpy(codeDump, instr, dumpHeader.codeDumpSize);
//Copy register dump and code dump
u8 *final = (u8 *)(FINAL_BUFFER + sizeof(ExceptionDumpHeader));
final += safecpy(final, registerDump, dumpHeader.registerDumpSize);
final += safecpy(final, codeDump, dumpHeader.codeDumpSize);
//Dump stack in place
dumpHeader.stackDumpSize = safecpy(final, (const void *)registerDump[13], 0x1000 - (registerDump[13] & 0xFFF));
dumpHeader.totalSize = sizeof(ExceptionDumpHeader) + dumpHeader.registerDumpSize + dumpHeader.codeDumpSize + dumpHeader.stackDumpSize + dumpHeader.additionalDataSize;
//Copy header (actually optimized by the compiler)
*(ExceptionDumpHeader *)FINAL_BUFFER = dumpHeader;
if(ARESCREENSINITIALIZED) i2cWriteRegister(I2C_DEV_MCU, 0x22, 1 << 0); //Shutdown LCD
((void (*)())0xFFFF0830)(); //Ensure that all memory transfers have completed and that the data cache has been flushed
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); //Reboot
while(true);
}
+39
View File
@@ -0,0 +1,39 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.section .text.start
.align 4
.global _start
_start:
add pc, r0, #(handlers - .) @ Dummy instruction
.global BreakPtr
BreakPtr: .word 0
.global handlers
handlers:
.word FIQHandler
.word undefinedInstructionHandler
.word prefetchAbortHandler
.word dataAbortHandler
+45
View File
@@ -0,0 +1,45 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
//Common data types
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
#define PDN_GPU_CNT (*(vu8 *)0x10141200)
#define ARESCREENSINITIALIZED (PDN_GPU_CNT != 1)
@@ -0,0 +1,188 @@
#!/usr/bin/env python
# Requires Python >= 3.2 or >= 2.7
# This file is part of Luma3DS
# Copyright (C) 2016 Aurora Wright, TuxSH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Additional Terms 7.b of GPLv3 applies to this file: Requiring preservation of specified
# reasonable legal notices or author attributions in that material or in the Appropriate Legal
# Notices displayed by works containing it.
__author__ = "TuxSH"
__copyright__ = "Copyright (c) 2016 TuxSH"
__license__ = "GPLv3"
__version__ = "v1.2"
"""
Parses Luma3DS exception dumps
"""
import argparse
from struct import unpack_from
import os
import subprocess
# Source of hexdump: https://gist.github.com/ImmortalPC/c340564823f283fe530b
# Credits for hexdump go to the original authors
# Slightly edited by TuxSH
def hexdump(addr, src, length=16, sep='.' ):
'''
@brief Return {src} in hex dump.
@param[in] length {Int} Nb Bytes by row.
@param[in] sep {Char} For the text part, {sep} will be used for non ASCII char.
@return {Str} The hexdump
@note Full support for python2 and python3 !
'''
result = []
# Python3 support
try:
xrange(0,1)
except NameError:
xrange = range
for i in xrange(0, len(src), length):
subSrc = src[i:i+length]
hexa = ''
isMiddle = False
for h in xrange(0,len(subSrc)):
if h == length/2:
hexa += ' '
h = subSrc[h]
if not isinstance(h, int):
h = ord(h)
h = hex(h).replace('0x','')
if len(h) == 1:
h = '0'+h
hexa += h+' '
hexa = hexa.strip(' ')
text = ''
for c in subSrc:
if not isinstance(c, int):
c = ord(c)
if 0x20 <= c < 0x7F:
text += chr(c)
else:
text += sep
result.append(('%08x: %-'+str(length*(2+1)+1)+'s |%s|') % (addr + i, hexa, text))
return '\n'.join(result)
def makeRegisterLine(A, rA, B, rB):
return "{0:<15}{1:<20}{2:<15}{3:<20}".format(A, "{0:08x}".format(rA), B, "{0:08x}".format(rB))
handledExceptionNames = ("FIQ", "undefined instruction", "prefetch abort", "data abort")
registerNames = tuple("r{0}".format(i) for i in range(13)) + ("sp", "lr", "pc", "cpsr") + ("dfsr", "ifsr", "far") + ("fpexc", "fpinst", "fpinst2")
svcBreakReasons = ("(svcBreak: panic)", "(svcBreak: assertion failed)", "(svcBreak: user-related)")
faultStatusSources = {
0b1:'Alignment', 0b100:'Instruction cache maintenance operation fault',
0b1100:'External Abort on translation - First-level', 0b1110:'External Abort on translation - Second-level',
0b101:'Translation - Section', 0b111:'Translation - Page', 0b11:'Access bit - Section', 0b110:'Access bit - Page',
0b1001:'Domain - Section', 0b1011:'Domain - Page', 0b1101:'Permission - Section', 0b1111:'Permission - Page',
0b1000:'Precise External Abort', 0b10110:'Imprecise External Abort', 0b10:'Debug event'
}
def main(args=None):
parser = argparse.ArgumentParser(description="Parse Luma3DS exception dumps")
parser.add_argument("filename")
args = parser.parse_args()
data = b""
with open(args.filename, "rb") as f: data = f.read()
if unpack_from("<2I", data) != (0xdeadc0de, 0xdeadcafe):
raise SystemExit("Invalid file format")
version, processor, exceptionType, _, nbRegisters, codeDumpSize, stackDumpSize, additionalDataSize = unpack_from("<8I", data, 8)
nbRegisters //= 4
if version < (1 << 16) | 2:
raise SystemExit("Incompatible format version, please use the appropriate parser.")
registers = unpack_from("<{0}I".format(nbRegisters), data, 40)
codeOffset = 40 + 4 * nbRegisters
codeDump = data[codeOffset : codeOffset + codeDumpSize]
stackOffset = codeOffset + codeDumpSize
stackDump = data[stackOffset : stackOffset + stackDumpSize]
addtionalDataOffset = stackOffset + stackDumpSize
additionalData = data[addtionalDataOffset : addtionalDataOffset + additionalDataSize]
if processor == 9: print("Processor: ARM9")
else: print("Processor: ARM11 (core {0})".format(processor >> 16))
typeDetailsStr = ""
if exceptionType == 2:
if (registers[16] & 0x20) == 0 and codeDumpSize >= 4:
instr = unpack_from("<I", codeDump[-4:])[0]
if instr == 0xe12fff7e:
typeDetailsStr = " (kernel panic)"
elif instr == 0xef00003c:
typeDetailsStr = " " + (svcBreakReasons[registers[0]] if registers[0] < 3 else "(svcBreak)")
elif (registers[16] & 0x20) == 1 and codeDumpSize >= 2:
instr = unpack_from("<I", codeDump[-4:])[0]
if instr == 0xdf3c:
typeDetailsStr = " " + (svcBreakReasons[registers[0]] if registers[0] < 3 else "(svcBreak)")
elif processor != 9 and (registers[20] & 0x80000000) != 0:
typeDetailsStr = " (VFP exception)"
print("Exception type: {0}{1}".format("unknown" if exceptionType >= len(handledExceptionNames) else handledExceptionNames[exceptionType], typeDetailsStr))
if processor == 11 and exceptionType >= 2:
xfsr = registers[18] if exceptionType == 2 else registers[17]
print("Fault status: " + faultStatusSources[xfsr & 0xf])
if additionalDataSize != 0:
print("Current process: {0} ({1:016x})".format(additionalData[:8].decode("ascii"), unpack_from("<Q", additionalData, 8)[0]))
print("\nRegister dump:\n")
for i in range(0, nbRegisters - (nbRegisters % 2), 2):
if i == 16: print("")
print(makeRegisterLine(registerNames[i], registers[i], registerNames[i+1], registers[i+1]))
if nbRegisters % 2 == 1: print("{0:<15}{1:<20}".format(registerNames[nbRegisters - 1], "{0:08x}".format(registers[nbRegisters - 1])))
if processor == 11 and exceptionType == 3:
print("{0:<15}{1:<20}Access type: {2}".format("FAR", "{0:08x}".format(registers[19]), "Write" if registers[17] & (1 << 11) != 0 else "Read"))
thumb = registers[16] & 0x20 != 0
addr = registers[15] - codeDumpSize + (2 if thumb else 4)
print("\nCode dump:\n")
objdump_res = ""
try:
path = os.path.join(os.environ["DEVKITARM"], "bin", "arm-none-eabi-objdump")
if os.name == "nt" and path[0] == '/':
path = ''.join((path[1], ':', path[2:]))
objdump_res = subprocess.check_output((
path, "-marm", "-b", "binary",
"--adjust-vma="+hex(addr - codeOffset), "--start-address="+hex(addr),
"--stop-address="+hex(addr + codeDumpSize), "-D", "-z", "-M",
"reg-names-std" + (",force-thumb" if thumb else ""), args.filename
)).decode("utf-8")
objdump_res = '\n'.join(objdump_res[objdump_res.find('<.data+'):].split('\n')[1:])
except: objdump_res = ""
print(objdump_res if objdump_res != "" else hexdump(addr, codeDump))
print("\nStack dump:\n")
print(hexdump(registers[13], stackDump))
if __name__ == "__main__":
main()
+13
View File
@@ -0,0 +1,13 @@
from setuptools import setup, find_packages
setup(
name='luma3ds_exception_dump_parser',
version='1.2',
url='https://github.com/AuroraWright/Luma3DS',
author='TuxSH',
license='GPLv3',
description='Parses Luma3DS exception dumps',
install_requires=[''],
packages=find_packages(),
entry_points={'console_scripts': ['luma3ds_exception_dump_parser=luma3ds_exception_dump_parser.__main__:main']},
)
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

-97
View File
@@ -1,97 +0,0 @@
#pragma once
#include <3ds/types.h>
typedef struct
{
u8 reserved[5];
u8 flag;
u8 remasterversion[2];
} PACKED exheader_systeminfoflags;
typedef struct
{
u32 address;
u32 nummaxpages;
u32 codesize;
} PACKED exheader_codesegmentinfo;
typedef struct
{
u8 name[8];
exheader_systeminfoflags flags;
exheader_codesegmentinfo text;
u8 stacksize[4];
exheader_codesegmentinfo ro;
u8 reserved[4];
exheader_codesegmentinfo data;
u32 bsssize;
} PACKED exheader_codesetinfo;
typedef struct
{
u64 programid[0x30];
} PACKED exheader_dependencylist;
typedef struct
{
u8 savedatasize[4];
u8 reserved[4];
u8 jumpid[8];
u8 reserved2[0x30];
} PACKED exheader_systeminfo;
typedef struct
{
u8 extsavedataid[8];
u8 systemsavedataid[8];
u8 reserved[8];
u8 accessinfo[7];
u8 otherattributes;
} PACKED exheader_storageinfo;
typedef struct
{
u64 programid;
u8 flags[8];
u16 resourcelimitdescriptor[0x10];
exheader_storageinfo storageinfo;
u64 serviceaccesscontrol[0x20];
u8 reserved[0x1f];
u8 resourcelimitcategory;
} PACKED exheader_arm11systemlocalcaps;
typedef struct
{
u32 descriptors[28];
u8 reserved[0x10];
} PACKED exheader_arm11kernelcapabilities;
typedef struct
{
u8 descriptors[15];
u8 descversion;
} PACKED exheader_arm9accesscontrol;
typedef struct
{
// systemcontrol info {
// coreinfo {
exheader_codesetinfo codesetinfo;
exheader_dependencylist deplist;
// }
exheader_systeminfo systeminfo;
// }
// accesscontrolinfo {
exheader_arm11systemlocalcaps arm11systemlocalcaps;
exheader_arm11kernelcapabilities arm11kernelcaps;
exheader_arm9accesscontrol arm9accesscontrol;
// }
struct {
u8 signature[0x100];
u8 ncchpubkeymodulus[0x100];
exheader_arm11systemlocalcaps arm11systemlocalcaps;
exheader_arm11kernelcapabilities arm11kernelcaps;
exheader_arm9accesscontrol arm9accesscontrol;
} PACKED accessdesc;
} PACKED exheader_header;
-9
View File
@@ -1,9 +0,0 @@
#pragma once
#include <3ds/types.h>
Result fsldrInit(void);
void fsldrExit(void);
Result FSLDR_InitializeWithSdkVersion(Handle session, u32 version);
Result FSLDR_SetPriority(u32 priority);
Result FSLDR_OpenFileDirectly(Handle* out, FS_Archive archive, FS_Path path, u32 openFlags, u32 attributes);
-5
View File
@@ -1,5 +0,0 @@
#pragma once
#include <3ds/types.h>
void memcpy(void *dest, const void *src, u32 size);
-516
View File
@@ -1,516 +0,0 @@
#include <3ds.h>
#include "memory.h"
#include "patcher.h"
#include "ifile.h"
#ifndef PATH_MAX
#define PATH_MAX 255
#define CONFIG(a) ((loadConfig() >> (a + 16)) & 1)
#define MULTICONFIG(a) ((loadConfig() >> (a * 2 + 6)) & 3)
#define BOOTCONFIG(a, b) ((loadConfig() >> a) & b)
#endif
static int memcmp(const void *buf1, const void *buf2, u32 size)
{
const u8 *buf1c = (const u8 *)buf1;
const u8 *buf2c = (const u8 *)buf2;
for(u32 i = 0; i < size; i++)
{
int cmp = buf1c[i] - buf2c[i];
if(cmp) return cmp;
}
return 0;
}
//Quick Search algorithm, adapted from http://igm.univ-mlv.fr/~lecroq/string/node19.html#SECTION00190
static u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize)
{
const u8 *patternc = (const u8 *)pattern;
//Preprocessing
u32 table[256];
for(u32 i = 0; i < 256; ++i)
table[i] = patternSize + 1;
for(u32 i = 0; i < patternSize; ++i)
table[patternc[i]] = patternSize - i;
//Searching
u32 j = 0;
while(j <= size - patternSize)
{
if(memcmp(patternc, startPos + j, patternSize) == 0)
return startPos + j;
j += table[startPos[j + patternSize]];
}
return NULL;
}
static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, int offset, const void *replace, u32 repSize, u32 count)
{
u32 i;
for(i = 0; i < count; i++)
{
u8 *found = memsearch(start, pattern, size, patSize);
if(found == NULL) break;
memcpy(found + offset, replace, repSize);
u32 at = (u32)(found - start);
if(at + patSize > size) break;
size -= at + patSize;
start = found + patSize;
}
return i;
}
static inline size_t strnlen(const char *string, size_t maxlen)
{
size_t size;
for(size = 0; *string && size < maxlen; string++, size++);
return size;
}
static int fileOpen(IFile *file, FS_ArchiveID id, const char *path, int flags)
{
FS_Archive archive;
FS_Path ppath;
size_t len = strnlen(path, PATH_MAX);
archive.id = id;
archive.lowPath.type = PATH_EMPTY;
archive.lowPath.size = 1;
archive.lowPath.data = (u8 *)"";
ppath.type = PATH_ASCII;
ppath.data = path;
ppath.size = len + 1;
return IFile_Open(file, archive, ppath, flags);
}
static u32 secureInfoExists(void)
{
static u32 secureInfoExists = 0;
if(!secureInfoExists)
{
IFile file;
if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_NAND_RW, "/sys/SecureInfo_C", FS_OPEN_READ)))
{
secureInfoExists = 1;
IFile_Close(&file);
}
}
return secureInfoExists;
}
static u32 loadConfig(void)
{
static u32 config = 0;
if(!config)
{
IFile file;
if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, "/luma/config.bin", FS_OPEN_READ)))
{
u64 total;
if(R_SUCCEEDED(IFile_Read(&file, &total, &config, 4))) config |= 1 << 4;
IFile_Close(&file);
}
}
return config;
}
static int loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
{
/* Here we look for "/luma/locales/[u64 titleID in hex, uppercase].txt"
If it exists it should contain, for example, "EUR IT" */
char path[] = "/luma/locales/0000000000000000.txt";
u32 i = 29;
while(progId)
{
static const char hexDigits[] = "0123456789ABCDEF";
path[i--] = hexDigits[(u32)(progId & 0xF)];
progId >>= 4;
}
IFile file;
Result ret = fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ);
if(R_SUCCEEDED(ret))
{
char buf[6];
u64 total;
ret = IFile_Read(&file, &total, buf, 6);
IFile_Close(&file);
if(!R_SUCCEEDED(ret) || total < 6) return -1;
for(u32 i = 0; i < 7; ++i)
{
static const char *regions[] = {"JPN", "USA", "EUR", "AUS", "CHN", "KOR", "TWN"};
if(memcmp(buf, regions[i], 3) == 0)
{
*regionId = (u8)i;
break;
}
}
for(u32 i = 0; i < 12; ++i)
{
static const char *languages[] = {"JP", "EN", "FR", "DE", "IT", "ES", "ZH", "KO", "NL", "PT", "RU", "TW"};
if(memcmp(buf + 4, languages[i], 2) == 0)
{
*languageId = (u8)i;
break;
}
}
}
return ret;
}
static u8 *getCfgOffsets(u8 *code, u32 size, u32 *CFGUHandleOffset)
{
/* HANS:
Look for error code which is known to be stored near cfg:u handle
this way we can find the right candidate
(handle should also be stored right after end of candidate function) */
u32 n = 0,
possible[24];
for(u8 *pos = code + 4; n < 24 && pos < code + size - 4; pos += 4)
{
if(*(u32 *)pos == 0xD8A103F9)
{
for(u32 *l = (u32 *)pos - 4; n < 24 && l < (u32 *)pos + 4; l++)
if(*l <= 0x10000000) possible[n++] = *l;
}
}
for(u8 *CFGU_GetConfigInfoBlk2_endPos = code; CFGU_GetConfigInfoBlk2_endPos < code + size - 8; CFGU_GetConfigInfoBlk2_endPos += 4)
{
static const u32 CFGU_GetConfigInfoBlk2_endPattern[] = {0xE8BD8010, 0x00010082};
//There might be multiple implementations of GetConfigInfoBlk2 but let's search for the one we want
u32 *cmp = (u32 *)CFGU_GetConfigInfoBlk2_endPos;
if(cmp[0] == CFGU_GetConfigInfoBlk2_endPattern[0] && cmp[1] == CFGU_GetConfigInfoBlk2_endPattern[1])
{
*CFGUHandleOffset = *((u32 *)CFGU_GetConfigInfoBlk2_endPos + 2);
for(u32 i = 0; i < n; i++)
if(possible[i] == *CFGUHandleOffset) return CFGU_GetConfigInfoBlk2_endPos;
CFGU_GetConfigInfoBlk2_endPos += 4;
}
}
return NULL;
}
static void patchCfgGetLanguage(u8 *code, u32 size, u8 languageId, u8 *CFGU_GetConfigInfoBlk2_endPos)
{
u8 *CFGU_GetConfigInfoBlk2_startPos; //Let's find STMFD SP (there might be a NOP before, but nevermind)
for(CFGU_GetConfigInfoBlk2_startPos = CFGU_GetConfigInfoBlk2_endPos - 4;
CFGU_GetConfigInfoBlk2_startPos >= code && *((u16 *)CFGU_GetConfigInfoBlk2_startPos + 1) != 0xE92D;
CFGU_GetConfigInfoBlk2_startPos -= 2);
for(u8 *languageBlkIdPos = code; languageBlkIdPos < code + size; languageBlkIdPos += 4)
{
if(*(u32 *)languageBlkIdPos == 0xA0002)
{
for(u8 *instr = languageBlkIdPos - 8; instr >= languageBlkIdPos - 0x1008 && instr >= code + 4; instr -= 4) //Should be enough
{
if(instr[3] == 0xEB) //We're looking for BL
{
u8 *calledFunction = instr;
u32 i = 0,
found;
do
{
u32 low24 = (*(u32 *)calledFunction & 0x00FFFFFF) << 2;
u32 signMask = (u32)(-(low24 >> 25)) & 0xFC000000; //Sign extension
s32 offset = (s32)(low24 | signMask) + 8; //Branch offset + 8 for prefetch
calledFunction += offset;
found = calledFunction >= CFGU_GetConfigInfoBlk2_startPos - 4 && calledFunction <= CFGU_GetConfigInfoBlk2_endPos;
i++;
}
while(i < 2 && !found && calledFunction[3] == 0xEA);
if(found)
{
*((u32 *)instr - 1) = 0xE3A00000 | languageId; // mov r0, sp => mov r0, =languageId
*(u32 *)instr = 0xE5CD0000; // bl CFGU_GetConfigInfoBlk2 => strb r0, [sp]
*((u32 *)instr + 1) = 0xE3B00000; // (1 or 2 instructions) => movs r0, 0 (result code)
//We're done
return;
}
}
}
}
}
}
static void patchCfgGetRegion(u8 *code, u32 size, u8 regionId, u32 CFGUHandleOffset)
{
for(u8 *cmdPos = code; cmdPos < code + size - 28; cmdPos += 4)
{
static const u32 cfgSecureInfoGetRegionCmdPattern[] = {0xEE1D4F70, 0xE3A00802, 0xE5A40080};
u32 *cmp = (u32 *)cmdPos;
if(cmp[0] == cfgSecureInfoGetRegionCmdPattern[0] && cmp[1] == cfgSecureInfoGetRegionCmdPattern[1] &&
cmp[2] == cfgSecureInfoGetRegionCmdPattern[2] && *((u16 *)cmdPos + 7) == 0xE59F &&
*(u32 *)(cmdPos + 20 + *((u16 *)cmdPos + 6)) == CFGUHandleOffset)
{
*((u32 *)cmdPos + 4) = 0xE3A00000 | regionId; // mov r0, =regionId
*((u32 *)cmdPos + 5) = 0xE5C40008; // strb r0, [r4, 8]
*((u32 *)cmdPos + 6) = 0xE3B00000; // movs r0, 0 (result code) ('s' not needed but nvm)
*((u32 *)cmdPos + 7) = 0xE5840004; // str r0, [r4, 4]
//The remaining, not patched, function code will do the rest for us
break;
}
}
}
void patchCode(u64 progId, u8 *code, u32 size)
{
switch(progId)
{
case 0x0004003000008F02LL: // USA Menu
case 0x0004003000008202LL: // EUR Menu
case 0x0004003000009802LL: // JPN Menu
case 0x000400300000A102LL: // CHN Menu
case 0x000400300000A902LL: // KOR Menu
case 0x000400300000B102LL: // TWN Menu
{
static const u8 regionFreePattern[] = {
0x00, 0x00, 0x55, 0xE3, 0x01, 0x10, 0xA0, 0xE3
};
static const u8 regionFreePatch[] = {
0x01, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1
};
//Patch SMDH region checks
patchMemory(code, size,
regionFreePattern,
sizeof(regionFreePattern), -16,
regionFreePatch,
sizeof(regionFreePatch), 1
);
break;
}
case 0x0004013000002C02LL: // NIM
{
static const u8 blockAutoUpdatesPattern[] = {
0x25, 0x79, 0x0B, 0x99
};
static const u8 blockAutoUpdatesPatch[] = {
0xE3, 0xA0
};
//Block silent auto-updates
patchMemory(code, size,
blockAutoUpdatesPattern,
sizeof(blockAutoUpdatesPattern), 0,
blockAutoUpdatesPatch,
sizeof(blockAutoUpdatesPatch), 1
);
//Apply only if the updated NAND hasn't been booted
if((BOOTCONFIG(0, 3) != 0) == (BOOTCONFIG(3, 1) && CONFIG(1)))
{
static const u8 skipEshopUpdateCheckPattern[] = {
0x30, 0xB5, 0xF1, 0xB0
};
static const u8 skipEshopUpdateCheckPatch[] = {
0x00, 0x20, 0x08, 0x60, 0x70, 0x47
};
//Skip update checks to access the EShop
patchMemory(code, size,
skipEshopUpdateCheckPattern,
sizeof(skipEshopUpdateCheckPattern), 0,
skipEshopUpdateCheckPatch,
sizeof(skipEshopUpdateCheckPatch), 1
);
}
break;
}
case 0x0004013000003202LL: // FRIENDS
{
static const u8 fpdVerPattern[] = {
0xE0, 0x1E, 0xFF, 0x2F, 0xE1, 0x01, 0x01, 0x01
};
static const u8 fpdVerPatch = 0x05;
//Allow online access to work with old friends modules
patchMemory(code, size,
fpdVerPattern,
sizeof(fpdVerPattern), 9,
&fpdVerPatch,
sizeof(fpdVerPatch), 1
);
break;
}
case 0x0004001000021000LL: // USA MSET
case 0x0004001000020000LL: // JPN MSET
case 0x0004001000022000LL: // EUR MSET
case 0x0004001000026000LL: // CHN MSET
case 0x0004001000027000LL: // KOR MSET
case 0x0004001000028000LL: // TWN MSET
{
if(CONFIG(5))
{
static const u16 verPattern[] = u"Ver.";
const u32 currentNand = BOOTCONFIG(0, 3);
const u32 matchingFirm = BOOTCONFIG(2, 1) == (currentNand != 0);
//Patch Ver. string
patchMemory(code, size,
verPattern,
sizeof(verPattern) - sizeof(u16), 0,
!currentNand ? ((matchingFirm) ? u" Sys" : u"SysE") :
((currentNand == 1) ? (matchingFirm ? u" Emu" : u"EmuS") : ((matchingFirm) ? u"Emu2" : u"Em2S")),
sizeof(verPattern) - sizeof(u16), 1
);
}
break;
}
case 0x0004013000008002LL: // NS
{
static const u8 stopCartUpdatesPattern[] = {
0x0C, 0x18, 0xE1, 0xD8
};
static const u8 stopCartUpdatesPatch[] = {
0x0B, 0x18, 0x21, 0xC8
};
//Disable updates from foreign carts (makes carts region-free)
patchMemory(code, size,
stopCartUpdatesPattern,
sizeof(stopCartUpdatesPattern), 0,
stopCartUpdatesPatch,
sizeof(stopCartUpdatesPatch), 2
);
u32 cpuSetting = MULTICONFIG(1);
if(cpuSetting)
{
static const u8 cfgN3dsCpuPattern[] = {
0x00, 0x40, 0xA0, 0xE1, 0x07, 0x00
};
u32 *cfgN3dsCpuLoc = (u32 *)memsearch(code, cfgN3dsCpuPattern, size, sizeof(cfgN3dsCpuPattern));
//Patch N3DS CPU Clock and L2 cache setting
if(cfgN3dsCpuLoc != NULL)
{
*(cfgN3dsCpuLoc + 1) = 0xE1A00000;
*(cfgN3dsCpuLoc + 8) = 0xE3A00000 | cpuSetting;
}
}
break;
}
case 0x0004013000001702LL: // CFG
{
static const u8 secureinfoSigCheckPattern[] = {
0x06, 0x46, 0x10, 0x48, 0xFC
};
static const u8 secureinfoSigCheckPatch[] = {
0x00, 0x26
};
//Disable SecureInfo signature check
patchMemory(code, size,
secureinfoSigCheckPattern,
sizeof(secureinfoSigCheckPattern), 0,
secureinfoSigCheckPatch,
sizeof(secureinfoSigCheckPatch), 1
);
if(secureInfoExists())
{
static const u16 secureinfoFilenamePattern[] = u"SecureInfo_";
static const u16 secureinfoFilenamePatch[] = u"C";
//Use SecureInfo_C
patchMemory(code, size,
secureinfoFilenamePattern,
sizeof(secureinfoFilenamePattern) - sizeof(u16),
sizeof(secureinfoFilenamePattern) - sizeof(u16),
secureinfoFilenamePatch,
sizeof(secureinfoFilenamePatch) - sizeof(u16), 2
);
}
break;
}
default:
if(CONFIG(4))
{
u32 tidHigh = (progId & 0xFFFFFFF000000000LL) >> 0x24;
if(tidHigh == 0x0004000)
{
//Language emulation
u8 regionId = 0xFF,
languageId = 0xFF;
if(R_SUCCEEDED(loadTitleLocaleConfig(progId, &regionId, &languageId)))
{
u32 CFGUHandleOffset;
u8 *CFGU_GetConfigInfoBlk2_endPos = getCfgOffsets(code, size, &CFGUHandleOffset);
if(CFGU_GetConfigInfoBlk2_endPos != NULL)
{
if(languageId != 0xFF) patchCfgGetLanguage(code, size, languageId, CFGU_GetConfigInfoBlk2_endPos);
if(regionId != 0xFF) patchCfgGetRegion(code, size, regionId, CFGUHandleOffset);
}
}
}
break;
}
}
}
-5
View File
@@ -1,5 +0,0 @@
#pragma once
#include <3ds/types.h>
void patchCode(u64 progId, u8 *code, u32 size);
+47
View File
@@ -0,0 +1,47 @@
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/base_tools
name := k11_extension
dir_source := source
dir_include := include
dir_build := build
ARCH := -mcpu=mpcore -mfpu=vfp
ASFLAGS := $(ARCH)
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -I$(dir_include) -fno-builtin -std=c11 -Wno-main -g -flto -O2 -ffast-math \
-mword-relocations -ffunction-sections -fdata-sections
LDFLAGS := -nostdlib -Wl,--gc-sections,--nmagic $(ARCH)
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
$(call rwildcard, $(dir_source), *.s *.c)))
.PHONY: all
all: ../$(dir_build)/$(name).bin
.PHONY: clean
clean:
@rm -rf $(dir_build)
../$(dir_build)/$(name).bin: $(dir_build)/$(name).elf
$(OBJCOPY) -S -O binary $< $@
$(dir_build)/$(name).elf: $(objects)
$(CC) $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
$(dir_build)/memory.o : CFLAGS += -O3 -marm
$(dir_build)/%.o: $(dir_source)/%.c
@mkdir -p "$(@D)"
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(dir_build)/%.o: $(dir_source)/%.s
@mkdir -p "$(@D)"
$(COMPILE.s) $(OUTPUT_OPTION) $<
include $(call rwildcard, $(dir_build), *.d)
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include "types.h"
#define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
#define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
#define CONFIG(a) (((cfwInfo.config >> (a)) & 1) != 0)
#define MULTICONFIG(a) ((cfwInfo.multiConfig >> (2 * (a))) & 3)
#define BOOTCONFIG(a, b) ((cfwInfo.bootConfig >> (a)) & (b))
#define BOOTCFG_NAND BOOTCONFIG(0, 7)
#define BOOTCFG_FIRM BOOTCONFIG(3, 7)
#define BOOTCFG_NOFORCEFLAG BOOTCONFIG(6, 1)
#define BOOTCFG_NTRCARDBOOT BOOTCONFIG(7, 1)
enum multiOptions
{
DEFAULTEMU = 0,
BRIGHTNESS,
SPLASH,
SPLASH_DURATION,
PIN,
NEWCPU
};
enum singleOptions
{
AUTOBOOTEMU = 0,
USEEMUFIRM,
LOADEXTFIRMSANDMODULES,
PATCHGAMES,
PATCHVERSTRING,
SHOWGBABOOT,
PATCHUNITINFO,
DISABLEARM11EXCHANDLERS
};
+39
View File
@@ -0,0 +1,39 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
#include "globals.h"
#include "kernel.h"
#include "utils.h"
extern KRecursiveLock dbgParamsLock;
extern u32 dbgParamWatchpointId, dbgParamDVA, dbgParamWCR, dbgParamContextId;
KSchedulableInterruptEvent *enableMonitorModeDebugging(KBaseInterruptEvent *this, u32 interruptID);
KSchedulableInterruptEvent *disableWatchpoint(KBaseInterruptEvent *this, u32 interruptID);
KSchedulableInterruptEvent *setWatchpointWithContextId(KBaseInterruptEvent *this, u32 interruptID);
@@ -0,0 +1,52 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
bool isExceptionFatal(u32 spsr, u32 *regs, u32 index);
bool isDataAbortExceptionRangeControlled(u32 spsr, u32 addr);
void FIQHandler(void);
void undefinedInstructionHandler(void);
void prefetchAbortHandler(void);
void dataAbortHandler(void);
typedef struct __attribute__((packed))
{
u32 magic[2];
u16 versionMinor, versionMajor;
u16 processor, core;
u32 type;
u32 totalSize;
u32 registerDumpSize;
u32 codeDumpSize;
u32 stackDumpSize;
u32 additionalDataSize;
} ExceptionDumpHeader;
+137
View File
@@ -0,0 +1,137 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "config.h"
#include "kernel.h"
extern KRecursiveLock *criticalSectionLock;
extern KObjectList *threadList;
extern KObjectMutex *synchronizationMutex;
extern void (*KRecursiveLock__Lock)(KRecursiveLock *this);
extern void (*KRecursiveLock__Unlock)(KRecursiveLock *this);
extern void (*KAutoObject__AddReference)(KAutoObject *this);
extern KProcess * (*KProcessHandleTable__ToKProcess)(KProcessHandleTable *this, Handle processHandle);
extern KThread * (*KProcessHandleTable__ToKThread)(KProcessHandleTable *this, Handle threadHandle);
extern KAutoObject * (*KProcessHandleTable__ToKAutoObject)(KProcessHandleTable *this, Handle handle);
extern void (*KSynchronizationObject__Signal)(KSynchronizationObject *this, bool isPulse);
extern Result (*WaitSynchronization1)(void *this_unused, KThread *thread, KSynchronizationObject *syncObject, s64 timeout);
extern Result (*KProcessHandleTable__CreateHandle)(KProcessHandleTable *this, Handle *out, KAutoObject *obj, u8 token);
extern Result (*KProcessHwInfo__MapProcessMemory)(KProcessHwInfo *this, KProcessHwInfo *other, void *dst, void *src, u32 nbPages);
extern Result (*KProcessHwInfo__UnmapProcessMemory)(KProcessHwInfo *this, void *addr, u32 nbPages);
extern Result (*KEvent__Clear)(KEvent *this);
extern void (*KObjectMutex__WaitAndAcquire)(KObjectMutex *this);
extern void (*KObjectMutex__ErrorOccured)(void);
extern void (*KScheduler__AdjustThread)(KScheduler *this, KThread *thread, u32 oldSchedulingMask);
extern void (*KScheduler__AttemptSwitchingThreadContext)(KScheduler *this);
extern Result (*ControlMemory)(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader);
extern void (*SleepThread)(s64 ns);
extern Result (*CloseHandle)(Handle handle);
extern Result (*GetHandleInfo)(s64 *out, Handle handle, u32 type);
extern Result (*GetSystemInfo)(s64 *out, s32 type, s32 param);
extern Result (*GetProcessInfo)(s64 *out, Handle processHandle, u32 type);
extern Result (*GetThreadInfo)(s64 *out, Handle threadHandle, u32 type);
extern Result (*ConnectToPort)(Handle *out, const char *name);
extern Result (*SendSyncRequest)(Handle handle);
extern Result (*OpenProcess)(Handle *out, u32 processId);
extern Result (*GetProcessId)(u32 *out, Handle process);
extern Result (*DebugActiveProcess)(Handle *out, u32 processId);
extern Result (*UnmapProcessMemory)(Handle processHandle, void *dst, u32 size);
extern Result (*KernelSetState)(u32 type, u32 varg1, u32 varg2, u32 varg3);
extern void (*flushDataCacheRange)(void *addr, u32 len);
extern void (*invalidateInstructionCacheRange)(void *addr, u32 len);
extern bool (*usrToKernelMemcpy8)(void *dst, const void *src, u32 len);
extern bool (*usrToKernelMemcpy32)(u32 *dst, const u32 *src, u32 len);
extern s32 (*usrToKernelStrncpy)(char *dst, const char *src, u32 len);
extern bool (*kernelToUsrMemcpy8)(void *dst, const void *src, u32 len);
extern bool (*kernelToUsrMemcpy32)(u32 *dst, const u32 *src, u32 len);
extern s32 (*kernelToUsrStrncpy)(char *dst, const char *src, u32 len);
extern void (*svcFallbackHandler)(u8 svcId);
extern void (*kernelpanic)(void);
extern void (*officialPostProcessSvc)(void);
extern Result (*SignalDebugEvent)(DebugEventType type, u32 info, ...);
extern bool isN3DS;
extern u32 *exceptionStackTop;
extern u32 TTBCR;
extern u32 L1MMUTableAddrs[4];
extern void *kernelUsrCopyFuncsStart, *kernelUsrCopyFuncsEnd;
extern bool *isDevUnit;
extern vu8 *configPage;
extern u32 kernelVersion;
extern FcramLayout fcramLayout;
extern KCoreContext *coreCtxs;
extern void *originalHandlers[8];
extern u32 nbSection0Modules;
extern u8 __start__[], __end__[], __bss_start__[], __bss_end__[];
extern Result (*InterruptManager__MapInterrupt)(InterruptManager *manager, KBaseInterruptEvent *iEvent, u32 interruptID,
u32 coreID, u32 priority, bool disableUponReceipt, bool levelHighActive);
extern InterruptManager *interruptManager;
extern KBaseInterruptEvent *customInterruptEvent;
extern void (*initFPU)(void);
extern void (*mcuReboot)(void);
extern void (*coreBarrier)(void);
typedef struct CfwInfo
{
char magic[4];
u8 versionMajor;
u8 versionMinor;
u8 versionBuild;
u8 flags;
u32 commitHash;
u16 configFormatVersionMajor, configFormatVersionMinor;
u32 config, multiConfig, bootConfig;
u64 hbldr3dsxTitleId;
u32 rosalinaMenuCombo;
} CfwInfo;
extern CfwInfo cfwInfo;
extern vu32 rosalinaState;
extern bool hasStartedRosalinaNetworkFuncsOnce;
+61
View File
@@ -0,0 +1,61 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
#include "globals.h"
#include "kernel.h"
#include "utils.h"
#define MAX_SESSION 345
// the structure of sessions is apparently not the same on older versions...
typedef struct SessionInfo
{
KSession *session;
char name[12];
} SessionInfo;
typedef struct LangemuAttributes
{
u64 titleId;
u8 mask, region, language, country, state;
} LangemuAttributes;
extern KRecursiveLock processLangemuLock;
extern LangemuAttributes processLangemuAttributes[0x40];
SessionInfo *SessionInfo_Lookup(KSession *session);
SessionInfo *SessionInfo_FindFirst(const char *name);
void SessionInfo_ChangeVtable(KSession *session);
void SessionInfo_Add(KSession *session, const char *name);
void SessionInfo_Remove(KSession *session);
bool doLangEmu(Result *res, u32 *cmdbuf);
Result doPublishToProcessHook(Handle handle, u32 *cmdbuf);
bool doErrfThrowHook(u32 *cmdbuf);
File diff suppressed because it is too large Load Diff
+42
View File
@@ -0,0 +1,42 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
void *memcpy(void *dest, const void *src, u32 size) USED;
int memcmp(const void *buf1, const void *buf2, u32 size) USED;
void *memset(void *dest, u32 value, u32 size) USED; // thanks binutils for the nice bug involving memset.
void *memset32(void *dest, u32 value, u32 size);
u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, u32 size);
s32 strnlen(const char *string, s32 maxlen);
s32 strlen(const char *string);
s32 strcmp(const char *str1, const char *str2);
s32 strncmp(const char *str1, const char *str2, u32 size);
void hexItoa(u64 number, char *out, u32 digits, bool uppercase);
+38
View File
@@ -0,0 +1,38 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
#include "globals.h"
#include "kernel.h"
#include "utils.h"
extern void *officialSVCs[0x7E];
void postprocessSvc(void);
void svcDefaultHandler(u8 svcId);
void *svcHook(u8 *pageEnd);
+33
View File
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
void Backdoor(void *function);
+32
View File
@@ -0,0 +1,32 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
void __attribute__((noreturn)) Break(UserBreakType type, ...);
+34
View File
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result ConnectToPortHookWrapper(u32 dummy, const char *name);
Result ConnectToPortHook(Handle *out, const char *name);
+35
View File
@@ -0,0 +1,35 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result ControlMemoryHookWrapper(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm);
Result ControlMemoryHook(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm);
Result ControlMemoryEx(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader);
@@ -0,0 +1,40 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
/// Operations for svcControlService
typedef enum ServiceOp
{
SERVICEOP_STEAL_CLIENT_SESSION = 0, ///< Steal a client session given a service or global port name
SERVICEOP_GET_NAME, ///< Get the name of a service or global port given a client or session handle
} ServiceOp;
Result ControlService(ServiceOp op, u32 varg1, u32 varg2);
+34
View File
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result CopyHandleWrapper(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle);
Result CopyHandle(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle);
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
void CustomBackdoor(void *function, ...);
+35
View File
@@ -0,0 +1,35 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
#include "globals.h"
// DEPRECATED
Result GetCFWInfo(CfwInfo *out);
+34
View File
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result GetHandleInfoHookWrapper(u32 dummy, Handle handle, u32 type);
Result GetHandleInfoHook(s64 *out, Handle handle, u32 type);
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result GetProcessInfoHookWrapper(u32 dummy, Handle processHandle, u32 type);
Result GetProcessInfoHook(s64 *out, Handle processHandle, u32 type);
+34
View File
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result GetSystemInfoHookWrapper(u32 dummy, s32 type, s32 param);
Result GetSystemInfoHook(s64 *out, s32 type, s32 param);
+34
View File
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result GetThreadInfoHookWrapper(u32 dummy, Handle threadHandle, u32 type);
Result GetThreadInfoHook(s64 *out, Handle threadHandle, u32 type);
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
bool shouldSignalSyscallDebugEvent(KProcess *process, u8 svcId);
Result KernelSetStateHook(u32 type, u32 varg1, u32 varg2, u32 varg3);
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result MapProcessMemoryEx(Handle processHandle, void *dst, void *src, u32 size);
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result SendSyncRequestHook(Handle handle);
+33
View File
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result SetGpuProt(bool prot);
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result SetWifiEnabled(bool enable);
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result TranslateHandleWrapper(u32 *outKAddr, char *outClassName, Handle handle);
Result TranslateHandle(u32 *outKAddr, char *outClassName, Handle handle);
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "utils.h"
#include "kernel.h"
#include "svc.h"
Result UnmapProcessMemoryEx(Handle processHandle, void *dst, u32 size);
+29
View File
@@ -0,0 +1,29 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
void svcHandler(void);
+119
View File
@@ -0,0 +1,119 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
#include "kernel.h"
typedef KSchedulableInterruptEvent* (*SGI0Handler_t)(KBaseInterruptEvent *this, u32 interruptID);
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360f/CCHDIFIJ.html
void executeFunctionOnCores(SGI0Handler_t func, u8 targetList, u8 targetListFilter);
void KScheduler__TriggerCrossCoreInterrupt(KScheduler *this);
void KThread__DebugReschedule(KThread *this, bool lock);
bool rosalinaThreadLockPredicate(KThread *thread);
void rosalinaRescheduleThread(KThread *thread, bool lock);
void rosalinaLockThread(KThread *thread);
void rosalinaLockAllThreads(void);
void rosalinaUnlockAllThreads(void);
// Taken from ctrulib:
static inline void __dsb(void)
{
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 4" :: [val] "r" (0) : "memory");
}
static inline void __clrex(void)
{
__asm__ __volatile__("clrex" ::: "memory");
}
static inline s32 __ldrex(s32* addr)
{
s32 val;
__asm__ __volatile__("ldrex %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
return val;
}
static inline bool __strex(s32* addr, s32 val)
{
bool res;
__asm__ __volatile__("strex %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
return res;
}
static inline s8 __ldrex8(s8* addr)
{
s8 val;
__asm__ __volatile__("ldrexb %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
return val;
}
static inline bool __strex8(s8* addr, s8 val)
{
bool res;
__asm__ __volatile__("strexb %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
return res;
}
static inline s16 __ldrex16(s16* addr)
{
s16 val;
__asm__ __volatile__("ldrexh %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
return val;
}
static inline bool __strex16(s16* addr, s16 val)
{
bool res;
__asm__ __volatile__("strexh %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
return res;
}
static inline u32 __get_cpsr(void)
{
u32 cpsr;
__asm__ __volatile__("mrs %0, cpsr" : "=r"(cpsr));
return cpsr;
}
static inline void __set_cpsr_cx(u32 cpsr)
{
__asm__ __volatile__("msr cpsr_cx, %0" :: "r"(cpsr));
}
static inline void __enable_irq(void)
{
__asm__ __volatile__("cpsie i");
}
static inline void __disable_irq(void)
{
__asm__ __volatile__("cpsid i");
}
+97
View File
@@ -0,0 +1,97 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
// Taken from ctrulib
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
/// The maximum value of a u64.
#define U64_MAX UINT64_MAX
/// would be nice if newlib had this already
#ifndef SSIZE_MAX
#ifdef SIZE_MAX
#define SSIZE_MAX ((SIZE_MAX) >> 1)
#endif
#endif
typedef uint8_t u8; ///< 8-bit unsigned integer
typedef uint16_t u16; ///< 16-bit unsigned integer
typedef uint32_t u32; ///< 32-bit unsigned integer
typedef uint64_t u64; ///< 64-bit unsigned integer
typedef int8_t s8; ///< 8-bit signed integer
typedef int16_t s16; ///< 16-bit signed integer
typedef int32_t s32; ///< 32-bit signed integer
typedef int64_t s64; ///< 64-bit signed integer
typedef volatile u8 vu8; ///< 8-bit volatile unsigned integer.
typedef volatile u16 vu16; ///< 16-bit volatile unsigned integer.
typedef volatile u32 vu32; ///< 32-bit volatile unsigned integer.
typedef volatile u64 vu64; ///< 64-bit volatile unsigned integer.
typedef volatile s8 vs8; ///< 8-bit volatile signed integer.
typedef volatile s16 vs16; ///< 16-bit volatile signed integer.
typedef volatile s32 vs32; ///< 32-bit volatile signed integer.
typedef volatile s64 vs64; ///< 64-bit volatile signed integer.
typedef u32 Handle; ///< Resource handle.
typedef s32 Result; ///< Function result.
/// Creates a bitmask from a bit number.
#define BIT(n) (1U<<(n))
/// Aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m.
#define ALIGN(m) __attribute__((aligned(m)))
/// Packs a struct (and other types?) so it won't include padding bytes.
#define PACKED __attribute__((packed))
#define USED __attribute__((used))
#define UNUSED __attribute__((unused))
/// Packs a system version from its components.
#define SYSTEM_VERSION(major, minor, revision) \
(((major)<<24)|((minor)<<16)|((revision)<<8))
#define CUR_THREAD_HANDLE 0xFFFF8000
#define CUR_PROCESS_HANDLE 0xFFFF8001
#define MPCORE_REGS_BASE (0x17E00000 | (1u << 31))
#define MPCORE_SCU_CFG (*(vu32 *)(MPCORE_REGS_BASE + 4))
#define MPCORE_INT_ACK (*(vu32 *)(MPCORE_REGS_BASE + 0x10C))
#define MPCORE_GID_REGS_BASE (MPCORE_REGS_BASE + 0x1000)
#define MPCORE_GID_SGI (*(vu32 *)(MPCORE_GID_REGS_BASE + 0xF00))
#define CFG11_REGS_BASE (0x10140000 | (1u << 31))
#define CFG11_WIFICNT (*(vu8 *)(CFG11_REGS_BASE + 0x180))
#define CFG11_MPCORE_CFG (*(vu16 *)(CFG11_REGS_BASE + 0xFFC))
#define CFG11_MPCORE_CLKCNT (*(vu16 *)(CFG11_REGS_BASE + 0x1300))
#define L2C_REGS_BASE (0x17E10000 | (1u << 31))
#define L2C_CTRL (*(vu32 *)(L2C_REGS_BASE + 0x100))
+87
View File
@@ -0,0 +1,87 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#pragma once
#include "types.h"
#include "kernel.h"
// For accessing physmem uncached (and directly)
#define PA_PTR(addr) (void *)((u32)(addr) | 1u << 31)
#define PA_FROM_VA_PTR(addr) PA_PTR(convertVAToPA(addr, false))
static inline u32 makeARMBranch(const void *src, const void *dst, bool link) // the macros for those are ugly and buggy
{
u32 instrBase = link ? 0xEB000000 : 0xEA000000;
u32 off = (u32)((const u8 *)dst - ((const u8 *)src + 8)); // the PC is always two instructions ahead of the one being executed
return instrBase | ((off >> 2) & 0xFFFFFF);
}
static inline void *decodeARMBranch(const void *src)
{
u32 instr = *(const u32 *)src;
s32 off = (instr & 0xFFFFFF) << 2;
off = (off << 6) >> 6; // sign extend
return (void *)((const u8 *)src + 8 + off);
}
// For ARM prologs in the form of: push {regs} ... sub sp, #off (this obviously doesn't intend to cover all cases)
static inline u32 computeARMFrameSize(const u32 *prolog)
{
const u32 *off;
for(off = prolog; (*off >> 16) != 0xE92D; off++); // look for stmfd sp! = push
u32 nbPushedRegs = 0;
for(u32 val = *off & 0xFFFF; val != 0; val >>= 1) // 1 bit = 1 pushed register
nbPushedRegs += val & 1;
for(; (*off >> 8) != 0xE24DD0; off++); // look for sub sp, #offset
u32 localVariablesSpaceSize = *off & 0xFF;
return 4 * nbPushedRegs + localVariablesSpaceSize;
}
static inline u32 getNumberOfCores(void)
{
return (MPCORE_SCU_CFG & 3) + 1;
}
static inline u32 getCurrentCoreID(void)
{
u32 coreId;
__asm__ volatile("mrc p15, 0, %0, c0, c0, 5" : "=r"(coreId));
return coreId & 3;
}
u32 convertVAToPA(const void *addr, bool writeCheck);
u32 safecpy(void *dst, const void *src, u32 len);
void KObjectMutex__Acquire(KObjectMutex *this);
void KObjectMutex__Release(KObjectMutex *this);
void flushEntireDataCache(void);
void invalidateEntireInstructionCache(void);
+19
View File
@@ -0,0 +1,19 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x40000000;
__start__ = .;
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
.data : ALIGN(4) { *(.data*); . = ALIGN(4); }
.bss : ALIGN(8) { __bss_start__ = .; *(.bss* COMMON); . = ALIGN(8); __bss_end__ = .; }
. = ALIGN(0x1000);
__end__ = .;
}
+147
View File
@@ -0,0 +1,147 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "debug.h"
#include "memory.h"
#include "synchronization.h"
KRecursiveLock dbgParamsLock = { NULL };
u32 dbgParamWatchpointId, dbgParamDVA, dbgParamWCR, dbgParamContextId;
KSchedulableInterruptEvent *enableMonitorModeDebugging(KBaseInterruptEvent *this UNUSED, u32 interruptID UNUSED)
{
coreBarrier();
u32 DSCR;
__asm__ __volatile__("mrc p14, 0, %[val], c0, c1, 0" : [val] "=r" (DSCR));
DSCR |= 0x8000;
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 0" :: [val] "r" (DSCR));
__dsb();
coreBarrier();
return NULL;
}
static void disableWatchpoint0(void)
{
u32 control;
// WCR0
__asm__ __volatile__("mrc p14, 0, %[val], c0, c0, 7" : [val] "=r" (control));
control &= ~1;
__asm__ __volatile__("mcr p14, 0, %[val], c0, c0, 7" :: [val] "r" (control));
// BCR4
__asm__ __volatile__("mrc p14, 0, %[val], c0, c4, 5" : [val] "=r" (control));
control &= ~1;
__asm__ __volatile__("mcr p14, 0, %[val], c0, c4, 5" :: [val] "r" (control));
}
static void disableWatchpoint1(void)
{
u32 control;
// WCR1
__asm__ __volatile__("mrc p14, 0, %[val], c0, c1, 7" : [val] "=r" (control));
control &= ~1;
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 7" :: [val] "r" (control));
// BCR5
__asm__ __volatile__("mrc p14, 0, %[val], c0, c5, 5" : [val] "=r" (control));
control &= ~1;
__asm__ __volatile__("mcr p14, 0, %[val], c0, c5, 5" :: [val] "r" (control));
}
KSchedulableInterruptEvent *disableWatchpoint(KBaseInterruptEvent *this UNUSED, u32 interruptID UNUSED)
{
coreBarrier();
if(dbgParamWatchpointId == 0)
disableWatchpoint0();
else
disableWatchpoint1();
__dsb();
coreBarrier();
return NULL;
}
static void setWatchpoint0WithContextId(u32 DVA, u32 WCR, u32 contextId)
{
// http://infocenter.arm.com/help/topic/com.arm.doc.ddi0360f/CEGCFFDF.html
u32 BCR =
(1 << 21) | /* compare with context ID */
(1 << 20) | /* linked (with a WRP in our case) */
(0xf << 5) | /* byte address select, +0 to +3 as mandated when linking with a WRP */
(3 << 1) | /* either privileged modes or user mode, as mandated when linking with a WRP */
(1 << 0) ; /* enabled */
disableWatchpoint0();
__asm__ __volatile__("mcr p14, 0, %[val], c0, c0, 6" :: [val] "r" (DVA));
__asm__ __volatile__("mcr p14, 0, %[val], c0, c4, 4" :: [val] "r" (contextId));
__asm__ __volatile__("mcr p14, 0, %[val], c0, c0, 7" :: [val] "r" (WCR));
__asm__ __volatile__("mcr p14, 0, %[val], c0, c4, 5" :: [val] "r" (BCR));
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 5" :: [val] "r" (0) : "memory"); // DMB
}
static void setWatchpoint1WithContextId(u32 DVA, u32 WCR, u32 contextId)
{
// http://infocenter.arm.com/help/topic/com.arm.doc.ddi0360f/CEGCFFDF.html
u32 BCR =
(1 << 21) | /* compare with context ID */
(1 << 20) | /* linked (with a WRP in our case) */
(0xf << 5) | /* byte address select, +0 to +3 as mandated when linking with a WRP */
(3 << 1) | /* either privileged modes or user mode, as mandated when linking with a WRP */
(1 << 0) ; /* enabled */
disableWatchpoint1();
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 6" :: [val] "r" (DVA));
__asm__ __volatile__("mcr p14, 0, %[val], c0, c5, 4" :: [val] "r" (contextId));
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 7" :: [val] "r" (WCR));
__asm__ __volatile__("mcr p14, 0, %[val], c0, c5, 5" :: [val] "r" (BCR));
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 5" :: [val] "r" (0) : "memory"); // DMB
}
KSchedulableInterruptEvent *setWatchpointWithContextId(KBaseInterruptEvent *this UNUSED, u32 interruptID UNUSED)
{
coreBarrier();
if(dbgParamWatchpointId == 0)
setWatchpoint0WithContextId(dbgParamDVA, dbgParamWCR, dbgParamContextId);
else
setWatchpoint1WithContextId(dbgParamDVA, dbgParamWCR, dbgParamContextId);
__dsb();
coreBarrier();
return NULL;
}
@@ -0,0 +1,252 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.macro TEST_IF_MODE_AND_ARM_INST_OR_JUMP lbl, mode
cpsid aif
mrs sp, spsr
tst sp, #0x20
bne \lbl
and sp, #0x1f @ get previous processor mode
cmp sp, #\mode
bne \lbl
sub sp, lr, #4
mcr p15, 0, sp, c7, c8, 0 @ VA to PA translation with privileged read permission check
mrc p15, 0, sp, c7, c4, 0 @ read PA register
tst sp, #1 @ failure bit
bne \lbl
.endm
.macro GEN_USUAL_HANDLER name, index, pos
\name\()Handler:
ldr sp, =exceptionStackTop
ldr sp, [sp]
sub sp, #0x100
push {r0-r12, lr}
mrs r0, spsr
mov r1, sp
mov r2, #\index
bl isExceptionFatal
cmp r0, #0
pop {r0-r12, lr}
bne _exc_is_fatal_\name
ldr sp, =originalHandlers
ldr sp, [sp, #\pos]
bx sp
_exc_is_fatal_\name:
push {r8, r9}
mov r8, #\index
b _commonHandler
.endm
.text
.arm
.balign 4
_die:
cpsid aif
_die_loop:
wfi
b _die_loop
_commonHandler:
cpsid aif
push {r0}
ldr r0, =_fatalExceptionOccured
ldr r0, [r0]
cmp r0, #0
bne _die_loop
pop {r0}
ldr r9, =_regs
stmia r9, {r0-r7}
mov r1, r8
pop {r8,r9}
ldr r0, =_fatalExceptionOccured
mov r4, #1
_try_lock:
ldrex r2, [r0]
strex r3, r4, [r0]
cmp r3, #0
bne _try_lock
push {r1, r12, lr} @ attempt to hang the other cores
adr r0, _die
mov r1, #0xf
mov r2, #1
mov r3, #0
bl executeFunctionOnCores
pop {r1, r12, lr}
mrs r2, spsr
mrs r3, cpsr
ldr r6, =_regs
add r6, #0x20
ands r4, r2, #0xf @ get the mode that triggered the exception
moveq r4, #0xf @ usr => sys
bic r5, r3, #0xf
orr r5, r4
msr cpsr_c, r5 @ change processor mode
stmia r6!, {r8-lr}
msr cpsr_c, r3 @ restore processor mode
str lr, [r6], #4
str r2, [r6], #4
mov r0, r6
mrc p15, 0, r4, c5, c0, 0 @ dfsr
mrc p15, 0, r5, c5, c0, 1 @ ifsr
mrc p15, 0, r6, c6, c0, 0 @ far
fmrx r7, fpexc
fmrx r8, fpinst
fmrx r9, fpinst2
bic r3, #(1<<31)
fmxr fpexc, r3 @ clear the VFP11 exception flag (if it's set)
stmia r0!, {r4-r9}
mov r0, #0
mcr p15, 0, r0, c7, c14, 0 @ Clean and Invalidate Entire Data Cache
mcr p15, 0, r0, c7, c10, 4 @ Drain Synchronization Barrier
ldr r0, =isN3DS
ldrb r0, [r0]
cmp r0, #0
beq _no_L2C
ldr r0, =(0x17e10100 | 1 << 31)
ldr r0, [r0]
tst r0, #1 @ is the L2C enabled?
beq _no_L2C
ldr r0, =0xffff
ldr r2, =(0x17e10730 | 1 << 31)
str r0, [r2, #0x4c] @ invalidate by way
_L2C_sync:
ldr r0, [r2] @ L2C cache sync register
tst r0, #1
bne _L2C_sync
_no_L2C:
msr cpsr_cxsf, #0xdf @ finally, switch to system mode, mask interrupts and clear flags (in case of double faults)
ldr sp, =exceptionStackTop
ldr sp, [sp]
sub sp, #0x100
mov r0, #0
mcr p15, 0, r0, c7, c10, 5 @ Drain Memory Barrier
ldr r0, =_regs
mrc p15, 0, r2, c0, c0, 5 @ CPU ID register
bl fatalExceptionHandlersMain
ldr r12, =mcuReboot
ldr r12, [r12]
bx r12
.global FIQHandler
.type FIQHandler, %function
GEN_USUAL_HANDLER FIQ, 0, 28
.global undefinedInstructionHandler
.type undefinedInstructionHandler, %function
undefinedInstructionHandler:
TEST_IF_MODE_AND_ARM_INST_OR_JUMP _undefinedInstructionNormalHandler, 0x10
ldr sp, [lr, #-4] @ test if it's an VFP instruction that was aborted
lsl sp, #4
sub sp, #0xc0000000
cmp sp, #0x30000000
bcs _undefinedInstructionNormalHandler
fmrx sp, fpexc
tst sp, #0x40000000
bne _undefinedInstructionNormalHandler
@ FPU init
sub lr, #4
srsfd sp!, #0x13
cps #0x13
stmfd sp, {r0-r3, r11-lr}^
sub sp, #0x20
ldr r12, =initFPU
ldr r12, [r12]
blx r12
ldmfd sp, {r0-r3, r11-lr}^
add sp, #0x20
rfefd sp! @ retry aborted instruction
GEN_USUAL_HANDLER _undefinedInstructionNormal, 1, 4
.global prefetchAbortHandler
.type prefetchAbortHandler, %function
prefetchAbortHandler:
TEST_IF_MODE_AND_ARM_INST_OR_JUMP _prefetchAbortNormalHandler, 0x13
ldr sp, =(Break + 3*4 + 4)
cmp lr, sp
bne _prefetchAbortNormalHandler
sub sp, r0, #0x110
pop {r0-r7, r12, lr}
pop {r8-r11}
ldr lr, [sp, #8]!
ldr sp, [sp, #4]
msr spsr_cxsf, sp
tst sp, #0x20
addne lr, #2 @ adjust address for later
GEN_USUAL_HANDLER _prefetchAbortNormal, 2, 12
.global dataAbortHandler
.type dataAbortHandler, %function
dataAbortHandler:
ldr sp, =exceptionStackTop
ldr sp, [sp]
push {r0-r12, lr}
mrs r0, spsr
sub r1, lr, #8
bl isDataAbortExceptionRangeControlled
cmp r0, #0
pop {r0-r12, lr}
beq _dataAbortNormalHandler
msr spsr_f, #(1 << 30)
mov r12, #0
subs pc, lr, #4
GEN_USUAL_HANDLER _dataAbortNormal, 3, 16
.bss
.balign 4
_regs: .skip (4 * 23)
_fatalExceptionOccured: .word 0
@@ -0,0 +1,131 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "fatalExceptionHandlers.h"
#include "utils.h"
#include "kernel.h"
#include "memory.h"
#include "globals.h"
#define REG_DUMP_SIZE 4 * 23
#define CODE_DUMP_SIZE 48
bool isExceptionFatal(u32 spsr, u32 *regs, u32 index)
{
if(CONFIG(DISABLEARM11EXCHANDLERS)) return false;
if((spsr & 0x1F) != 0x10) return true;
KThread *thread = currentCoreContext->objectContext.currentThread;
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
if(thread != NULL && thread->threadLocalStorage != NULL && *((vu32 *)thread->threadLocalStorage + 0x10) != 0)
return false;
if(currentProcess != NULL)
{
if(debugOfProcess(currentProcess) != NULL)
return false;
thread = KPROCESS_GET_RVALUE(currentProcess, mainThread);
if(thread != NULL && thread->threadLocalStorage != NULL && *((vu32 *)thread->threadLocalStorage + 0x10) != 0)
return false;
if(index == 3 && strcmp(codeSetOfProcess(currentProcess)->processName, "menu") == 0 && // workaround a Home Menu bug leading to a dabort
regs[0] == 0x3FFF && regs[2] == 0 && regs[5] == 2 && regs[7] == 1)
return false;
}
return true;
}
extern u32 safecpy_sz;
bool isDataAbortExceptionRangeControlled(u32 spsr, u32 addr)
{
return (!(spsr & 0x20) && (spsr & 0x1F) != 0x10) && (
((u32)kernelUsrCopyFuncsStart <= addr && addr < (u32)kernelUsrCopyFuncsEnd) ||
((u32)safecpy <= addr && addr < (u32)safecpy + safecpy_sz)
);
}
void fatalExceptionHandlersMain(u32 *registerDump, u32 type, u32 cpuId)
{
ExceptionDumpHeader dumpHeader;
u8 codeDump[CODE_DUMP_SIZE];
u8 *finalBuffer = (u8 *)PA_PTR(0x25000000);
u8 *final = finalBuffer;
dumpHeader.magic[0] = 0xDEADC0DE;
dumpHeader.magic[1] = 0xDEADCAFE;
dumpHeader.versionMajor = 1;
dumpHeader.versionMinor = 2;
dumpHeader.processor = 11;
dumpHeader.core = cpuId & 0xF;
dumpHeader.type = type;
dumpHeader.registerDumpSize = REG_DUMP_SIZE;
dumpHeader.codeDumpSize = CODE_DUMP_SIZE;
u32 cpsr = registerDump[16];
u32 pc = registerDump[15] - (type < 3 ? (((cpsr & 0x20) != 0 && type == 1) ? 2 : 4) : 8);
registerDump[15] = pc;
//Dump code
u8 *instr = (u8 *)pc + ((cpsr & 0x20) ? 2 : 4) - dumpHeader.codeDumpSize; //wouldn't work well on 32-bit Thumb instructions, but it isn't much of a problem
dumpHeader.codeDumpSize = ((u32)instr & (((cpsr & 0x20) != 0) ? 1 : 3)) != 0 ? 0 : safecpy(codeDump, instr, dumpHeader.codeDumpSize);
//Copy register dump and code dump
final = (u8 *)(finalBuffer + sizeof(ExceptionDumpHeader));
memcpy(final, registerDump, dumpHeader.registerDumpSize);
final += dumpHeader.registerDumpSize;
memcpy(final, codeDump, dumpHeader.codeDumpSize);
final += dumpHeader.codeDumpSize;
//Dump stack in place
dumpHeader.stackDumpSize = safecpy(final, (const void *)registerDump[13], 0x1000 - (registerDump[13] & 0xFFF));
final += dumpHeader.stackDumpSize;
if(currentCoreContext->objectContext.currentProcess)
{
vu64 *additionalData = (vu64 *)final;
KCodeSet *currentCodeSet = codeSetOfProcess(currentCoreContext->objectContext.currentProcess);
if(currentCodeSet != NULL)
{
dumpHeader.additionalDataSize = 16;
memcpy((void *)additionalData, currentCodeSet->processName, 8);
additionalData[1] = currentCodeSet->titleId;
}
else dumpHeader.additionalDataSize = 0;
}
else dumpHeader.additionalDataSize = 0;
dumpHeader.totalSize = sizeof(ExceptionDumpHeader) + dumpHeader.registerDumpSize + dumpHeader.codeDumpSize + dumpHeader.stackDumpSize + dumpHeader.additionalDataSize;
//Copy header (actually optimized by the compiler)
*(ExceptionDumpHeader *)finalBuffer = dumpHeader;
}
+114
View File
@@ -0,0 +1,114 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "globals.h"
KRecursiveLock *criticalSectionLock;
KObjectList *threadList;
KObjectMutex *synchronizationMutex;
void (*KRecursiveLock__Lock)(KRecursiveLock *this);
void (*KRecursiveLock__Unlock)(KRecursiveLock *this);
void (*KAutoObject__AddReference)(KAutoObject *this);
KProcess * (*KProcessHandleTable__ToKProcess)(KProcessHandleTable *this, Handle processHandle);
KThread * (*KProcessHandleTable__ToKThread)(KProcessHandleTable *this, Handle threadHandle);
KAutoObject * (*KProcessHandleTable__ToKAutoObject)(KProcessHandleTable *this, Handle handle);
void (*KSynchronizationObject__Signal)(KSynchronizationObject *this, bool isPulse);
Result (*WaitSynchronization1)(void *this_unused, KThread *thread, KSynchronizationObject *syncObject, s64 timeout);
Result (*KProcessHandleTable__CreateHandle)(KProcessHandleTable *this, Handle *out, KAutoObject *obj, u8 token);
Result (*KProcessHwInfo__MapProcessMemory)(KProcessHwInfo *this, KProcessHwInfo *other, void *dst, void *src, u32 nbPages);
Result (*KProcessHwInfo__UnmapProcessMemory)(KProcessHwInfo *this, void *addr, u32 nbPages);
Result (*KEvent__Clear)(KEvent *this);
void (*KObjectMutex__WaitAndAcquire)(KObjectMutex *this);
void (*KObjectMutex__ErrorOccured)(void);
void (*KScheduler__AdjustThread)(KScheduler *this, KThread *thread, u32 oldSchedulingMask);
void (*KScheduler__AttemptSwitchingThreadContext)(KScheduler *this);
Result (*ControlMemory)(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader);
void (*SleepThread)(s64 ns);
Result (*CloseHandle)(Handle handle);
Result (*GetHandleInfo)(s64 *out, Handle handle, u32 type);
Result (*GetSystemInfo)(s64 *out, s32 type, s32 param);
Result (*GetProcessInfo)(s64 *out, Handle processHandle, u32 type);
Result (*GetThreadInfo)(s64 *out, Handle threadHandle, u32 type);
Result (*ConnectToPort)(Handle *out, const char *name);
Result (*SendSyncRequest)(Handle handle);
Result (*OpenProcess)(Handle *out, u32 processId);
Result (*GetProcessId)(u32 *out, Handle process);
Result (*DebugActiveProcess)(Handle *out, u32 processId);
Result (*UnmapProcessMemory)(Handle processHandle, void *dst, u32 size);
Result (*KernelSetState)(u32 type, u32 varg1, u32 varg2, u32 varg3);
void (*flushDataCacheRange)(void *addr, u32 len);
void (*invalidateInstructionCacheRange)(void *addr, u32 len);
bool (*usrToKernelMemcpy8)(void *dst, const void *src, u32 len);
bool (*usrToKernelMemcpy32)(u32 *dst, const u32 *src, u32 len);
s32 (*usrToKernelStrncpy)(char *dst, const char *src, u32 len);
bool (*kernelToUsrMemcpy8)(void *dst, const void *src, u32 len);
bool (*kernelToUsrMemcpy32)(u32 *dst, const u32 *src, u32 len);
s32 (*kernelToUsrStrncpy)(char *dst, const char *src, u32 len);
void (*svcFallbackHandler)(u8 svcId);
void (*kernelpanic)(void);
void (*officialPostProcessSvc)(void);
Result (*SignalDebugEvent)(DebugEventType type, u32 info, ...);
bool isN3DS;
u32 *exceptionStackTop;
u32 TTBCR;
u32 L1MMUTableAddrs[4];
void *kernelUsrCopyFuncsStart, *kernelUsrCopyFuncsEnd;
bool *isDevUnit;
vu8 *configPage;
u32 kernelVersion;
FcramLayout fcramLayout;
KCoreContext *coreCtxs;
void *originalHandlers[8] = {NULL};
u32 nbSection0Modules;
Result (*InterruptManager__MapInterrupt)(InterruptManager *manager, KBaseInterruptEvent *iEvent, u32 interruptID,
u32 coreID, u32 priority, bool disableUponReceipt, bool levelHighActive);
InterruptManager *interruptManager;
KBaseInterruptEvent *customInterruptEvent;
void (*initFPU)(void);
void (*mcuReboot)(void);
void (*coreBarrier)(void);
CfwInfo cfwInfo;
vu32 rosalinaState;
bool hasStartedRosalinaNetworkFuncsOnce;
+318
View File
@@ -0,0 +1,318 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "ipc.h"
#include "memory.h"
static SessionInfo sessionInfos[MAX_SESSION] = { {NULL} };
static u32 nbActiveSessions = 0;
static KRecursiveLock sessionInfosLock = { NULL };
KRecursiveLock processLangemuLock;
LangemuAttributes processLangemuAttributes[0x40];
static void *customSessionVtable[0x10] = { NULL }; // should be enough
static u32 SessionInfo_FindClosestSlot(KSession *session)
{
if(nbActiveSessions == 0 || session <= sessionInfos[0].session)
return 0;
else if(session > sessionInfos[nbActiveSessions - 1].session)
return nbActiveSessions;
u32 a = 0, b = nbActiveSessions - 1, m;
do
{
m = (a + b) / 2;
if(sessionInfos[m].session < session)
a = m;
else if(sessionInfos[m].session > session)
b = m;
else
return m;
}
while(b - a > 1);
return b;
}
SessionInfo *SessionInfo_Lookup(KSession *session)
{
KRecursiveLock__Lock(criticalSectionLock);
KRecursiveLock__Lock(&sessionInfosLock);
SessionInfo *ret;
u32 id = SessionInfo_FindClosestSlot(session);
if(id == nbActiveSessions)
ret = NULL;
else
ret = (void **)(sessionInfos[id].session->autoObject.vtable) == customSessionVtable ? &sessionInfos[id] : NULL;
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
return ret;
}
SessionInfo *SessionInfo_FindFirst(const char *name)
{
KRecursiveLock__Lock(criticalSectionLock);
KRecursiveLock__Lock(&sessionInfosLock);
SessionInfo *ret;
u32 id;
for(id = 0; id < nbActiveSessions && strncmp(sessionInfos[id].name, name, 12) != 0; id++);
if(id == nbActiveSessions)
ret = NULL;
else
ret = (void **)(sessionInfos[id].session->autoObject.vtable) == customSessionVtable ? &sessionInfos[id] : NULL;
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
return ret;
}
void SessionInfo_Add(KSession *session, const char *name)
{
KAutoObject__AddReference(&session->autoObject);
SessionInfo_ChangeVtable(session);
session->autoObject.vtable->DecrementReferenceCount(&session->autoObject);
KRecursiveLock__Lock(criticalSectionLock);
KRecursiveLock__Lock(&sessionInfosLock);
if(nbActiveSessions == MAX_SESSION)
{
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
return;
}
u32 id = SessionInfo_FindClosestSlot(session);
if(id != nbActiveSessions && sessionInfos[id].session == session)
{
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
return;
}
for(u32 i = nbActiveSessions; i > id && i != 0; i--)
sessionInfos[i] = sessionInfos[i - 1];
nbActiveSessions++;
sessionInfos[id].session = session;
strncpy(sessionInfos[id].name, name, 12);
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
}
void SessionInfo_Remove(KSession *session)
{
KRecursiveLock__Lock(criticalSectionLock);
KRecursiveLock__Lock(&sessionInfosLock);
if(nbActiveSessions == MAX_SESSION)
{
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
return;
}
u32 id = SessionInfo_FindClosestSlot(session);
if(id == nbActiveSessions)
{
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
return;
}
for(u32 i = id; i < nbActiveSessions - 1; i++)
sessionInfos[i] = sessionInfos[i + 1];
memset(&sessionInfos[--nbActiveSessions], 0, sizeof(SessionInfo));
KRecursiveLock__Unlock(&sessionInfosLock);
KRecursiveLock__Unlock(criticalSectionLock);
}
static void (*KSession__dtor_orig)(KAutoObject *this);
static void KSession__dtor_hook(KAutoObject *this)
{
KSession__dtor_orig(this);
SessionInfo_Remove((KSession *)this);
}
void SessionInfo_ChangeVtable(KSession *session)
{
if(customSessionVtable[2] == NULL)
{
memcpy(customSessionVtable, session->autoObject.vtable, 0x40);
KSession__dtor_orig = session->autoObject.vtable->dtor;
customSessionVtable[2] = (void *)KSession__dtor_hook;
}
session->autoObject.vtable = (Vtable__KAutoObject *)customSessionVtable;
}
bool doLangEmu(Result *res, u32 *cmdbuf)
{
KRecursiveLock__Lock(criticalSectionLock);
KRecursiveLock__Lock(&processLangemuLock);
u64 titleId = codeSetOfProcess(currentCoreContext->objectContext.currentProcess)->titleId;
LangemuAttributes *attribs = NULL;
bool skip = true;
*res = 0;
for(u32 i = 0; i < 0x40; i++)
{
if(processLangemuAttributes[i].titleId == titleId)
attribs = &processLangemuAttributes[i];
}
if(attribs == NULL)
{
KRecursiveLock__Unlock(&processLangemuLock);
KRecursiveLock__Unlock(criticalSectionLock);
return false;
}
if((cmdbuf[0] == 0x20000 || cmdbuf[0] == 0x4060000 || cmdbuf[0] == 0x8160000) && (attribs->mask & 1)) // SecureInfoGetRegion
{
cmdbuf[0] = (cmdbuf[0] & 0xFFFF0000) | 0x80;
cmdbuf[1] = 0;
cmdbuf[2] = attribs->region;
}
else if(cmdbuf[1] == 1 && cmdbuf[2] == 0xA0002 && cmdbuf[3] == 0x1C && (attribs->mask & 2))
{
cmdbuf[0] = (cmdbuf[0] & 0xFFFF0000) | 0x40;
cmdbuf[1] = 0;
*(u8 *)cmdbuf[4] = attribs->language;
}
else if(cmdbuf[1] == 4 && cmdbuf[2] == 0xB0000 && cmdbuf[3] == 0x4C && (attribs->mask & 0xC))
{
u8 *ptr = (u8 *)cmdbuf[4];
if(attribs->mask & 4)
ptr[3] = attribs->country;
if(attribs->mask & 8)
ptr[2] = attribs->state;
ptr[0] = ptr[1] = 0;
}
else
skip = false;
KRecursiveLock__Unlock(&processLangemuLock);
KRecursiveLock__Unlock(criticalSectionLock);
return skip;
}
Result doPublishToProcessHook(Handle handle, u32 *cmdbuf)
{
Result res = 0;
u32 pid;
bool terminateRosalina = cmdbuf[1] == 0x100 && cmdbuf[2] == 0; // cmdbuf[2] to check for well-formed requests
u32 savedCmdbuf[4];
memcpy(savedCmdbuf, cmdbuf, 16);
if(!terminateRosalina || GetProcessId(&pid, cmdbuf[3]) != 0)
terminateRosalina = false;
else
{
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KProcess *process = KProcessHandleTable__ToKProcess(handleTable, cmdbuf[3]);
if((strcmp(codeSetOfProcess(process)->processName, "socket") == 0 && (rosalinaState & 2)) ||
strcmp(codeSetOfProcess(process)->processName, "pxi") == 0)
terminateRosalina = true;
else
terminateRosalina = false;
((KAutoObject *)process)->vtable->DecrementReferenceCount((KAutoObject *)process);
}
if(terminateRosalina && nbSection0Modules == 6)
{
Handle rosalinaProcessHandle;
res = OpenProcess(&rosalinaProcessHandle, 5);
if(res == 0)
{
cmdbuf[0] = cmdbuf[0];
cmdbuf[1] = 0x100;
cmdbuf[2] = 0;
cmdbuf[3] = rosalinaProcessHandle;
res = SendSyncRequest(handle);
CloseHandle(rosalinaProcessHandle);
memcpy(cmdbuf, savedCmdbuf, 16);
}
}
return SendSyncRequest(handle);
}
bool doErrfThrowHook(u32 *cmdbuf)
{
// If fatalErrorInfo->type is "card removed" or "logged", returning from ERRF:Throw is a no-op
// for the SDK function
// r6 (arm) or r4 (thumb) is copied into cmdbuf[1..31]
u32 *r0_to_r7_r12_usr = (u32 *)((u8 *)currentCoreContext->objectContext.currentThread->endOfThreadContext - 0x110);
u32 spsr = *(u32 *)((u8 *)currentCoreContext->objectContext.currentThread->endOfThreadContext - 0xCC);
u8 *srcerrbuf = (u8 *)r0_to_r7_r12_usr[(spsr & 0x20) ? 4 : 6];
const char *pname = codeSetOfProcess(currentCoreContext->objectContext.currentProcess)->processName;
static const struct
{
const char *name;
Result errCode;
} errorCodesToIgnore[] =
{
/*
If you're getting this error, you have broken your head-tracking hardware,
and should uncomment the following line:
*/
//{ "qtm", (Result)0xF96183FE },
{ "", 0 }, // impossible case to ensure the array has at least 1 element
};
for(u32 i = 0; i < sizeof(errorCodesToIgnore) / sizeof(errorCodesToIgnore[0]); i++)
{
if(strcmp(pname, errorCodesToIgnore[i].name) == 0 && (Result)cmdbuf[2] == errorCodesToIgnore[i].errCode)
{
srcerrbuf[0] = 5;
cmdbuf[0] = 0x10040;
cmdbuf[1] = 0;
return true;
}
}
return false;
}
+282
View File
@@ -0,0 +1,282 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "utils.h"
#include "globals.h"
#include "synchronization.h"
#include "fatalExceptionHandlers.h"
#include "svc.h"
#include "svc/ConnectToPort.h"
#include "svcHandler.h"
#include "memory.h"
struct KExtParameters
{
u32 ALIGN(0x400) L2MMUTableFor0x40000000[256];
u32 basePA;
void *originalHandlers[4];
u32 L1MMUTableAddrs[4];
CfwInfo cfwInfo;
} kExtParameters = { .basePA = 0x12345678 }; // place this in .data
void relocateAndSetupMMU(u32 coreId, u32 *L1Table)
{
struct KExtParameters *p0 = (struct KExtParameters *)((u32)&kExtParameters - 0x40000000 + 0x18000000);
struct KExtParameters *p = (struct KExtParameters *)((u32)&kExtParameters - 0x40000000 + p0->basePA);
if(coreId == 0)
{
// Relocate ourselves, and clear BSS
memcpy((void *)p0->basePA, (const void *)0x18000000, __bss_start__ - __start__);
memset32((u32 *)(p0->basePA + (__bss_start__ - __start__)), 0, __bss_end__ - __bss_start__);
// Map the kernel ext to 0x40000000
// 4KB extended small pages: [SYS:RW USR:-- X TYP:NORMAL SHARED OUTER NOCACHE, INNER CACHED WB WA]
for(u32 offset = 0; offset < (u32)(__end__ - __start__); offset += 0x1000)
p->L2MMUTableFor0x40000000[offset >> 12] = (p0->basePA + offset) | 0x516;
__asm__ __volatile__ ("sev");
}
else
__asm__ __volatile__ ("wfe");
// bit31 idea thanks to SALT
// Maps physmem so that, if addr is in physmem(0, 0x30000000), it can be accessed uncached&rwx as addr|(1<<31)
u32 attribs = 0x40C02; // supersection (rwx for all) of strongly ordered memory, shared
for(u32 PA = 0; PA < 0x30000000; PA += 0x01000000)
{
u32 VA = (1 << 31) | PA;
for(u32 i = 0; i < 16; i++)
L1Table[i + (VA >> 20)] = PA | attribs;
}
L1Table[0x40000000 >> 20] = (u32)p->L2MMUTableFor0x40000000 | 1;
p->L1MMUTableAddrs[coreId] = (u32)L1Table;
}
void bindSGI0Hook(void)
{
if(InterruptManager__MapInterrupt(interruptManager, customInterruptEvent, 0, getCurrentCoreID(), 0, false, false) != 0)
__asm__ __volatile__ ("bkpt 0xdead");
}
void configHook(vu8 *cfgPage)
{
configPage = cfgPage;
kernelVersion = *(vu32 *)configPage;
*(vu32 *)(configPage + 0x40) = fcramLayout.applicationSize;
*(vu32 *)(configPage + 0x44) = fcramLayout.systemSize;
*(vu32 *)(configPage + 0x48) = fcramLayout.baseSize;
*isDevUnit = true; // enable debug features
}
static void findUsefulSymbols(void)
{
u32 *off;
for(off = (u32 *)0xFFFF0000; *off != 0xE1A0D002; off++);
off += 3;
initFPU = (void (*) (void))off;
for(; *off != 0xE3A0A0C2; off++);
mcuReboot = (void (*) (void))--off;
coreBarrier = (void (*) (void))decodeARMBranch(off - 4);
for(off = (u32 *)originalHandlers[2]; *off != 0xE1A00009; off++);
svcFallbackHandler = (void (*)(u8))decodeARMBranch(off + 1);
for(; *off != 0xE92D000F; off++);
officialPostProcessSvc = (void (*)(void))decodeARMBranch(off + 1);
KProcessHandleTable__ToKProcess = (KProcess * (*)(KProcessHandleTable *, Handle))decodeARMBranch(5 + (u32 *)officialSVCs[0x76]);
for(off = (u32 *)KProcessHandleTable__ToKProcess; *off != 0xE1A00004; off++);
KAutoObject__AddReference = (void (*)(KAutoObject *))decodeARMBranch(off + 1);
for(; *off != 0xE320F000; off++);
KProcessHandleTable__ToKAutoObject = (KAutoObject * (*)(KProcessHandleTable *, Handle))decodeARMBranch(off + 1);
for(off = (u32 *)decodeARMBranch(3 + (u32 *)officialSVCs[9]); /* KThread::Terminate */ *off != 0xE5D42034; off++);
off -= 2;
criticalSectionLock = (KRecursiveLock *)off[2 + (off[0] & 0xFF) / 4];
KRecursiveLock__Lock = (void (*)(KRecursiveLock *))decodeARMBranch(off + 1);
off += 4;
for(; (*off >> 16) != 0xE59F; off++);
KRecursiveLock__Unlock = (void (*)(KRecursiveLock *))decodeARMBranch(off + 1);
for(; *off != 0xE5C4007D; off++);
KSynchronizationObject__Signal = (void (*)(KSynchronizationObject *, bool))decodeARMBranch(off + 3);
for(off = (u32 *)officialSVCs[0x19]; *off != 0xE1A04005; off++);
KEvent__Clear = (Result (*)(KEvent *))decodeARMBranch(off + 1);
for(off = (u32 *)KEvent__Clear; *off != 0xE8BD8070; off++);
synchronizationMutex = *(KObjectMutex **)(off + 1);
for(off = (u32 *)officialSVCs[0x24]; *off != 0xE59F004C; off++);
WaitSynchronization1 = (Result (*)(void *, KThread *, KSynchronizationObject *, s64))decodeARMBranch(off + 6);
for(off = (u32 *)decodeARMBranch(3 + (u32 *)officialSVCs[0x33]) /* OpenProcess */ ; *off != 0xE1A05000; off++);
KProcessHandleTable__CreateHandle = (Result (*)(KProcessHandleTable *, Handle *, KAutoObject *, u8))decodeARMBranch(off - 1);
for(off = (u32 *)decodeARMBranch(3 + (u32 *)officialSVCs[0x34]) /* OpenThread */; *off != 0xD9001BF7; off++);
threadList = *(KObjectList **)(off + 1);
KProcessHandleTable__ToKThread = (KThread * (*)(KProcessHandleTable *, Handle))decodeARMBranch((u32 *)decodeARMBranch((u32 *)officialSVCs[0x37] + 3) /* GetThreadId */ + 5);
for(off = (u32 *)officialSVCs[0x50]; off[0] != 0xE1A05000 || off[1] != 0xE2100102 || off[2] != 0x5A00000B; off++);
InterruptManager__MapInterrupt = (Result (*)(InterruptManager *, KBaseInterruptEvent *, u32, u32, u32, bool, bool))decodeARMBranch(--off);
interruptManager = *(InterruptManager **)(off - 4 + (off[-6] & 0xFFF) / 4);
for(off = (u32 *)officialSVCs[0x54]; *off != 0xE8BD8008; off++);
flushDataCacheRange = (void (*)(void *, u32))(*(u32 **)(off[1]) + 3);
for(off = (u32 *)officialSVCs[0x71]; *off != 0xE2101102; off++);
KProcessHwInfo__MapProcessMemory = (Result (*)(KProcessHwInfo *, KProcessHwInfo *, void *, void *, u32))decodeARMBranch(off - 1);
// From 4.x to 6.x the pattern will match but the result will be wrong
for(off = (u32 *)officialSVCs[0x72]; *off != 0xE2041102; off++);
KProcessHwInfo__UnmapProcessMemory = (Result (*)(KProcessHwInfo *, void *, u32))decodeARMBranch(off - 1);
for(off = (u32 *)officialSVCs[0x7C]; *off != 0x03530000; off++);
KObjectMutex__WaitAndAcquire = (void (*)(KObjectMutex *))decodeARMBranch(++off);
for(; *off != 0xE320F000; off++);
KObjectMutex__ErrorOccured = (void (*)(void))decodeARMBranch(off + 1);
for(off = (u32 *)originalHandlers[4]; *off != (u32)exceptionStackTop; off++);
kernelUsrCopyFuncsStart = (void *)off[1];
kernelUsrCopyFuncsEnd = (void *)off[2];
u32 n_cmp_0;
for(off = (u32 *)kernelUsrCopyFuncsStart, n_cmp_0 = 1; n_cmp_0 <= 6; off++)
{
if(*off == 0xE3520000)
{
// We're missing some funcs
switch(n_cmp_0)
{
case 1:
usrToKernelMemcpy8 = (bool (*)(void *, const void *, u32))off;
break;
case 2:
usrToKernelMemcpy32 = (bool (*)(u32 *, const u32 *, u32))off;
break;
case 3:
usrToKernelStrncpy = (s32 (*)(char *, const char *, u32))off;
break;
case 4:
kernelToUsrMemcpy8 = (bool (*)(void *, const void *, u32))off;
break;
case 5:
kernelToUsrMemcpy32 = (bool (*)(u32 *, const u32 *, u32))off;
break;
case 6:
kernelToUsrStrncpy = (s32 (*)(char *, const char *, u32))off;
break;
default: break;
}
n_cmp_0++;
}
}
// The official prototype of ControlMemory doesn't have that extra param'
ControlMemory = (Result (*)(u32 *, u32, u32, u32, MemOp, MemPerm, bool))
decodeARMBranch((u32 *)officialSVCs[0x01] + 5);
SleepThread = (void (*)(s64))officialSVCs[0x0A];
CloseHandle = (Result (*)(Handle))officialSVCs[0x23];
GetHandleInfo = (Result (*)(s64 *, Handle, u32))decodeARMBranch((u32 *)officialSVCs[0x29] + 3);
GetSystemInfo = (Result (*)(s64 *, s32, s32))decodeARMBranch((u32 *)officialSVCs[0x2A] + 3);
GetProcessInfo = (Result (*)(s64 *, Handle, u32))decodeARMBranch((u32 *)officialSVCs[0x2B] + 3);
GetThreadInfo = (Result (*)(s64 *, Handle, u32))decodeARMBranch((u32 *)officialSVCs[0x2C] + 3);
ConnectToPort = (Result (*)(Handle *, const char*))decodeARMBranch((u32 *)officialSVCs[0x2D] + 3);
SendSyncRequest = (Result (*)(Handle))officialSVCs[0x32];
OpenProcess = (Result (*)(Handle *, u32))decodeARMBranch((u32 *)officialSVCs[0x33] + 3);
GetProcessId = (Result (*)(u32 *, Handle))decodeARMBranch((u32 *)officialSVCs[0x35] + 3);
DebugActiveProcess = (Result (*)(Handle *, u32))decodeARMBranch((u32 *)officialSVCs[0x60] + 3);
UnmapProcessMemory = (Result (*)(Handle, void *, u32))officialSVCs[0x72];
KernelSetState = (Result (*)(u32, u32, u32, u32))((u32 *)officialSVCs[0x7C] + 1);
for(off = (u32 *)svcFallbackHandler; *off != 0xE8BD4010; off++);
kernelpanic = (void (*)(void))decodeARMBranch(off + 1);
for(off = (u32 *)0xFFFF0000; off[0] != 0xE3A01002 || off[1] != 0xE3A00004; off++);
SignalDebugEvent = (Result (*)(DebugEventType type, u32 info, ...))decodeARMBranch(off + 2);
for(; *off != 0x96007F9; off++);
isDevUnit = *(bool **)(off - 1);
///////////////////////////////////////////
// Shitty/lazy heuristic but it works on even 4.5, so...
u32 textStart = ((u32)originalHandlers[2]) & ~0xFFFF;
u32 rodataStart = (u32)(interruptManager->N3DS.privateInterrupts[1][0x1D].interruptEvent->vtable) & ~0xFFF;
u32 textSize = rodataStart - textStart;
for(off = (u32 *)textStart; off < (u32 *)(textStart + textSize - 12); off++)
{
if(off[0] == 0xE5D13034 && off[1] == 0xE1530002)
KScheduler__AdjustThread = (void (*)(KScheduler *, KThread *, u32))off;
else if(off[0] == (u32)interruptManager && off[1] == (u32)&currentCoreContext->objectContext)
KScheduler__AttemptSwitchingThreadContext = (void (*)(KScheduler *))(off - 2);
else if(off[0] == 0xE3510B1A && off[1] == 0xE3A06000)
{
u32 *off2;
for(off2 = off; *off2 != 0xE92D40F8; off2--);
invalidateInstructionCacheRange = (void (*)(void *, u32))off2;
}
}
}
void main(FcramLayout *layout, KCoreContext *ctxs)
{
struct KExtParameters *p = &kExtParameters;
u32 TTBCR_;
s64 nb;
layout->systemSize -= __end__ - __start__;
fcramLayout = *layout;
coreCtxs = ctxs;
__asm__ __volatile__("mrc p15, 0, %0, c2, c0, 2" : "=r"(TTBCR_));
TTBCR = TTBCR_;
isN3DS = getNumberOfCores() == 4;
memcpy(L1MMUTableAddrs, (const void *)p->L1MMUTableAddrs, 16);
exceptionStackTop = (u32 *)0xFFFF2000 + (1 << (32 - TTBCR - 20));
cfwInfo = p->cfwInfo;
memcpy(originalHandlers + 1, p->originalHandlers, 16);
void **arm11SvcTable = (void**)originalHandlers[2];
while(*arm11SvcTable != NULL) arm11SvcTable++; //Look for SVC0 (NULL)
memcpy(officialSVCs, arm11SvcTable, 4 * 0x7E);
findUsefulSymbols();
GetSystemInfo(&nb, 26, 0);
nbSection0Modules = (u32)nb;
rosalinaState = 0;
hasStartedRosalinaNetworkFuncsOnce = false;
}
+176
View File
@@ -0,0 +1,176 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "memory.h"
#include "utils.h"
void *memcpy(void *dest, const void *src, u32 size)
{
u8 *destc = (u8 *)dest;
const u8 *srcc = (const u8 *)src;
for(u32 i = 0; i < size; i++)
destc[i] = srcc[i];
return dest;
}
int memcmp(const void *buf1, const void *buf2, u32 size)
{
const u8 *buf1c = (const u8 *)buf1;
const u8 *buf2c = (const u8 *)buf2;
for(u32 i = 0; i < size; i++)
{
int cmp = buf1c[i] - buf2c[i];
if(cmp)
return cmp;
}
return 0;
}
void *memset(void *dest, u32 value, u32 size)
{
u8 *destc = (u8 *)dest;
for(u32 i = 0; i < size; i++) destc[i] = (u8)value;
return dest;
}
void *memset32(void *dest, u32 value, u32 size)
{
u32 *dest32 = (u32 *)dest;
for(u32 i = 0; i < size/4; i++) dest32[i] = value;
return dest;
}
//Boyer-Moore Horspool algorithm, adapted from http://www-igm.univ-mlv.fr/~lecroq/string/node18.html#SECTION00180
u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize)
{
const u8 *patternc = (const u8 *)pattern;
u32 table[256];
//Preprocessing
for(u32 i = 0; i < 256; i++)
table[i] = patternSize;
for(u32 i = 0; i < patternSize - 1; i++)
table[patternc[i]] = patternSize - i - 1;
//Searching
u32 j = 0;
while(j <= size - patternSize)
{
u8 c = startPos[j + patternSize - 1];
if(patternc[patternSize - 1] == c && memcmp(pattern, startPos + j, patternSize - 1) == 0)
return startPos + j;
j += table[c];
}
return NULL;
}
char *strcpy(char *dest, const char *src)
{
u32 i;
for(i = 0; src[i] != 0; i++)
dest[i] = src[i];
dest[i] = 0;
return dest;
}
char *strncpy(char *dest, const char *src, u32 size)
{
u32 i;
for(i = 0; i < size && src[i] != 0; i++)
dest[i] = src[i];
for(; i < size; i++)
dest[i] = 0;
return dest;
}
s32 strnlen(const char *string, s32 maxlen)
{
s32 size;
for(size = 0; *string && size < maxlen; string++, size++);
return size;
}
s32 strlen(const char *string)
{
char *stringEnd = (char *)string;
while(*stringEnd) stringEnd++;
return stringEnd - string;
}
s32 strcmp(const char *str1, const char *str2)
{
while(*str1 && (*str1 == *str2))
{
str1++;
str2++;
}
return *str1 - *str2;
}
s32 strncmp(const char *str1, const char *str2, u32 size)
{
while(size && *str1 && (*str1 == *str2))
{
str1++;
str2++;
size--;
}
if (!size)
return 0;
else
return *str1 - *str2;
}
void hexItoa(u64 number, char *out, u32 digits, bool uppercase)
{
const char hexDigits[] = "0123456789ABCDEF";
const char hexDigitsLowercase[] = "0123456789abcdef";
u32 i = 0;
while(number > 0)
{
out[digits - 1 - i++] = uppercase ? hexDigits[number & 0xF] : hexDigitsLowercase[number & 0xF];
number >>= 4;
}
while(i < digits) out[digits - 1 - i++] = '0';
}
+72
View File
@@ -0,0 +1,72 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.section .text.start
.balign 4
.global _start
_start:
b start
b startPhys
b _bindSGI0Hook
b configHook
b undefinedInstructionHandler
b svcHandler
b prefetchAbortHandler
b dataAbortHandler
.word __end__
.word kExtParameters
.word 1 @ enableUserExceptionHandlersForCPUExc
b KThread__DebugReschedule
start:
@ Only core0 executes this, the other cores are running coreBarrier
@ Skipped instruction:
str r1, [r4, #0x8]
push {r0-r12, lr}
sub r0, r4, #8
sub r1, r8, #0x8000
bl main
pop {r0-r12, pc}
startPhys:
push {r0-r12, lr}
mrc p15, 0, r0, c0, c0, 5 @ CPUID register
and r0, #3
mov r1, r2
bl relocateAndSetupMMU
pop {r0-r12, lr}
mov r12, #0x20000000 @ instruction that has been patched
bx lr
_bindSGI0Hook:
push {r0-r12, lr}
bl bindSGI0Hook
pop {r0-r12, pc}
+171
View File
@@ -0,0 +1,171 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "memory.h"
#include "synchronization.h"
#include "svc.h"
#include "svc/ControlMemory.h"
#include "svc/GetHandleInfo.h"
#include "svc/GetSystemInfo.h"
#include "svc/GetProcessInfo.h"
#include "svc/GetThreadInfo.h"
#include "svc/GetCFWInfo.h"
#include "svc/ConnectToPort.h"
#include "svc/SendSyncRequest.h"
#include "svc/Break.h"
#include "svc/SetGpuProt.h"
#include "svc/SetWifiEnabled.h"
#include "svc/Backdoor.h"
#include "svc/KernelSetState.h"
#include "svc/CustomBackdoor.h"
#include "svc/MapProcessMemoryEx.h"
#include "svc/UnmapProcessMemoryEx.h"
#include "svc/ControlService.h"
#include "svc/CopyHandle.h"
#include "svc/TranslateHandle.h"
void *officialSVCs[0x7E] = {NULL};
void signalSvcEntry(u8 *pageEnd)
{
u32 svcId = (u32) *(u8 *)(pageEnd - 0xB5);
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
if(svcId == 0xFE)
svcId = *(u32 *)(pageEnd - 0x110 + 8 * 4); // r12 ; note: max theortical SVC atm: 0x3FFFFFFF. We don't support catching svcIds >= 0x100 atm either
// Since DBGEVENT_SYSCALL_ENTRY is non blocking, we'll cheat using EXCEVENT_UNDEFINED_SYSCALL (debug->svcId is fortunately an u16!)
if(debugOfProcess(currentProcess) != NULL && shouldSignalSyscallDebugEvent(currentProcess, svcId))
SignalDebugEvent(DBGEVENT_OUTPUT_STRING, 0xFFFFFFFE, svcId);
}
void signalSvcReturn(u8 *pageEnd)
{
u32 svcId = (u32) *(u8 *)(pageEnd - 0xB5);
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
if(svcId == 0xFE)
svcId = *(u32 *)(pageEnd - 0x110 + 8 * 4); // r12 ; note: max theortical SVC atm: 0x1FFFFFFF. We don't support catching svcIds >= 0x100 atm either
// Since DBGEVENT_SYSCALL_RETURN is non blocking, we'll cheat using EXCEVENT_UNDEFINED_SYSCALL (debug->svcId is fortunately an u16!)
if(debugOfProcess(currentProcess) != NULL && shouldSignalSyscallDebugEvent(currentProcess, svcId))
SignalDebugEvent(DBGEVENT_OUTPUT_STRING, 0xFFFFFFFF, svcId);
}
void postprocessSvc(void)
{
KThread *currentThread = currentCoreContext->objectContext.currentThread;
if(!currentThread->shallTerminate && rosalinaThreadLockPredicate(currentThread))
rosalinaRescheduleThread(currentThread, true);
officialPostProcessSvc();
}
static bool doingVeryShittyPmResLimitWorkaround = false; // I feel dirty
void *svcHook(u8 *pageEnd)
{
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
u32 svcId = *(u8 *)(pageEnd - 0xB5);
if(svcId == 0xFE)
svcId = *(u32 *)(pageEnd - 0x110 + 8 * 4); // r12 ; note: max theortical SVC atm: 0x3FFFFFFF. We don't support catching svcIds >= 0x100 atm either
switch(svcId)
{
case 0x01:
return ControlMemoryHookWrapper;
case 0x17:
if(strcmp(codeSetOfProcess(currentProcess)->processName, "pm") == 0) // only called twice in pm, by the same function
{
*(vu32 *)(configPage + 0x44) += __end__ - __start__;
doingVeryShittyPmResLimitWorkaround = true;
}
return officialSVCs[0x17];
case 0x29:
return GetHandleInfoHookWrapper;
case 0x2A:
return GetSystemInfoHookWrapper;
case 0x2B:
return GetProcessInfoHookWrapper;
case 0x2C:
return GetThreadInfoHookWrapper;
case 0x2D:
return ConnectToPortHookWrapper;
case 0x2E:
return GetCFWInfo; // DEPRECATED
case 0x32:
return SendSyncRequestHook;
case 0x3C:
return (debugOfProcess(currentProcess) != NULL) ? officialSVCs[0x3C] : (void *)Break;
case 0x59:
return SetGpuProt;
case 0x5A:
return SetWifiEnabled;
case 0x79:
if(doingVeryShittyPmResLimitWorkaround)
{
*(vu32 *)(configPage + 0x44) -= __end__ - __start__;
doingVeryShittyPmResLimitWorkaround = false;
}
return officialSVCs[0x79];
case 0x7B:
return Backdoor;
case 0x7C:
return KernelSetStateHook;
case 0x80:
return CustomBackdoor;
case 0x90:
return convertVAToPA;
case 0x91:
return flushDataCacheRange;
case 0x92:
return flushEntireDataCache;
case 0x93:
return invalidateInstructionCacheRange;
case 0x94:
return invalidateEntireInstructionCache;
case 0xA0:
return MapProcessMemoryEx;
case 0xA1:
return UnmapProcessMemoryEx;
case 0xA2:
return ControlMemoryEx;
case 0xB0:
return ControlService;
case 0xB1:
return CopyHandleWrapper;
case 0xB2:
return TranslateHandleWrapper;
default:
return (svcId <= 0x7D) ? officialSVCs[svcId] : NULL;
}
}
+43
View File
@@ -0,0 +1,43 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.text
.arm
.balign 4
.global Backdoor
.type Backdoor, %function
Backdoor:
@ Nintendo's code
bic r1, sp, #0xff
orr r1, r1, #0xf00
add r1, r1, #0x28 @ get user stack.
ldr r2, [r1]
stmdb r2!, {sp, lr}
mov sp, r2 @ sp_svc = sp_usr. You'll get nice crashes if an interrupt or context switch occurs during svcBackdoor
blx r0
pop {r0, r1}
mov sp, r0
bx r1
+35
View File
@@ -0,0 +1,35 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.text
.arm
.balign 4
.global Break
.type Break, %function
Break:
bic r0, sp, #0xf00
bic r0, #0xff
add r0, #0x1000 @ get page context top
bkpt 0xffff
+56
View File
@@ -0,0 +1,56 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/ConnectToPort.h"
#include "memory.h"
#include "ipc.h"
Result ConnectToPortHook(Handle *out, const char *name)
{
char portName[12] = {0};
Result res = 0;
if(name != NULL)
{
s32 nb = usrToKernelStrncpy(portName, name, 12);
if(nb < 0)
return 0xD9001814;
else if(nb == 12 && portName[11] != 0)
return 0xE0E0181E;
}
res = ConnectToPort(out, name);
if(res != 0)
return res;
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KClientSession *clientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, *out);
if(clientSession != NULL)
{
SessionInfo_Add(clientSession->parentSession, portName);
clientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&clientSession->syncObject.autoObject);
}
return res;
}
+34
View File
@@ -0,0 +1,34 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/ControlMemory.h"
Result ControlMemoryHook(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm)
{
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
return ControlMemory(addrOut, addr0, addr1, size, op, perm, idOfProcess(currentProcess) == 1);
}
+100
View File
@@ -0,0 +1,100 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/ControlService.h"
#include "memory.h"
#include "ipc.h"
Result ControlService(ServiceOp op, u32 varg1, u32 varg2)
{
Result res = 0;
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
switch(op)
{
case SERVICEOP_GET_NAME:
{
KSession *session = NULL;
SessionInfo *info = NULL;
KAutoObject *obj = KProcessHandleTable__ToKAutoObject(handleTable, (Handle)varg2);
if(obj == NULL)
return 0xD8E007F7; // invalid handle
else
{
// not the exact same tests but it should work
if(strcmp(classNameOfAutoObject(obj), "KServerSession") == 0)
session = ((KServerSession *)obj)->parentSession;
else if(strcmp(classNameOfAutoObject(obj), "KClientSession") == 0)
session = ((KClientSession *)obj)->parentSession;
}
if(session != NULL)
info = SessionInfo_Lookup(session);
if(info == NULL)
res = 0xD8E007F7;
else
{
// names are limited to 11 characters (for ports)
// kernelToUsrStrncpy doesn't clear trailing bytes
char name[12] = { 0 };
strncpy(name, info->name, 12);
res = kernelToUsrMemcpy8((void *)varg1, name, strlen(name) + 1) ? 0 : 0xE0E01BF5;
}
obj->vtable->DecrementReferenceCount(obj);
return res;
}
case SERVICEOP_STEAL_CLIENT_SESSION:
{
char name[12] = { 0 };
SessionInfo *info = NULL;
if(name != NULL)
{
s32 nb = usrToKernelStrncpy(name, (const char *)varg2, 12);
if(nb < 0)
return 0xD9001814;
else if(nb == 12 && name[11] != 0)
return 0xE0E0181E;
}
info = SessionInfo_FindFirst(name);
if(info == NULL)
return 0x9401BFE; // timeout (the wanted service is likely not initalized)
else
{
Handle out;
res = createHandleForThisProcess(&out, &info->session->clientSession.syncObject.autoObject);
return (res != 0) ? res : (kernelToUsrMemcpy32((u32 *)varg1, (u32 *)&out, 4) ? 0 : (Result)0xE0E01BF5);
}
}
default:
return 0xF8C007F4;
}
}
+76
View File
@@ -0,0 +1,76 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/CopyHandle.h"
#include "memory.h"
Result CopyHandle(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle)
{
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KProcess *inProcess, *outProcess;
Result res;
if(inProcessHandle == CUR_PROCESS_HANDLE)
{
inProcess = currentCoreContext->objectContext.currentProcess;
KAutoObject__AddReference((KAutoObject *)inProcess);
}
else
inProcess = KProcessHandleTable__ToKProcess(handleTable, inProcessHandle);
if(inProcess == NULL)
return 0xD8E007F7; // invalid handle
if(outProcessHandle == CUR_PROCESS_HANDLE)
{
outProcess = currentCoreContext->objectContext.currentProcess;
KAutoObject__AddReference((KAutoObject *)outProcess);
}
else
outProcess = KProcessHandleTable__ToKProcess(handleTable, outProcessHandle);
if(outProcess == NULL)
{
((KAutoObject *)inProcess)->vtable->DecrementReferenceCount((KAutoObject *)inProcess);
return 0xD8E007F7; // invalid handle
}
KAutoObject *obj = KProcessHandleTable__ToKAutoObject(handleTableOfProcess(inProcess), inHandle);
if(obj == NULL)
{
((KAutoObject *)inProcess)->vtable->DecrementReferenceCount((KAutoObject *)inProcess);
((KAutoObject *)outProcess)->vtable->DecrementReferenceCount((KAutoObject *)outProcess);
return 0xD8E007F7; // invalid handle
}
res = createHandleForProcess(outHandle, outProcess, obj);
obj->vtable->DecrementReferenceCount(obj);
((KAutoObject *)inProcess)->vtable->DecrementReferenceCount((KAutoObject *)inProcess);
((KAutoObject *)outProcess)->vtable->DecrementReferenceCount((KAutoObject *)outProcess);
return res;
}
+38
View File
@@ -0,0 +1,38 @@
@ This file is part of Luma3DS
@ Copyright (C) 2016-2017 Aurora Wright, TuxSH
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
@ * Requiring preservation of specified reasonable legal notices or
@ author attributions in that material or in the Appropriate Legal
@ Notices displayed by works containing it.
@ * Prohibiting misrepresentation of the origin of that material,
@ or requiring that modified versions of such material be marked in
@ reasonable ways as different from the original version.
.text
.arm
.balign 4
.global CustomBackdoor
.type CustomBackdoor, %function
CustomBackdoor:
push {r4, lr}
mov r4, r0
mov r0, r1
mov r1, r2
mov r2, r3
blx r4
pop {r4, pc}
+33
View File
@@ -0,0 +1,33 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/GetCFWInfo.h"
// DEPRECATED
Result GetCFWInfo(CfwInfo *out)
{
return kernelToUsrMemcpy8(out, &cfwInfo, 16) ? 0 : 0xE0E01BF5;
}
+62
View File
@@ -0,0 +1,62 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/GetThreadInfo.h"
#include "memory.h"
Result GetHandleInfoHook(s64 *out, Handle handle, u32 type)
{
if(type == 0x10000) // KDebug and KProcess: get context ID
{
KProcessHwInfo *hwInfo;
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KAutoObject *obj;
if(handle == CUR_PROCESS_HANDLE)
{
obj = (KAutoObject *)(currentCoreContext->objectContext.currentProcess);
KAutoObject__AddReference(obj);
}
else
obj = KProcessHandleTable__ToKAutoObject(handleTable, handle);
if(obj == NULL)
return 0xD8E007F7;
if(strcmp(classNameOfAutoObject(obj), "KDebug") == 0)
hwInfo = hwInfoOfProcess(((KDebug *)obj)->owner);
else if(strcmp(classNameOfAutoObject(obj), "KProcess") == 0)
hwInfo = hwInfoOfProcess((KProcess *)obj);
else
hwInfo = NULL;
*out = hwInfo != NULL ? KPROCESSHWINFO_GET_RVALUE(hwInfo, contextId) : -1;
obj->vtable->DecrementReferenceCount(obj);
return 0;
}
else
return GetHandleInfo(out, handle, type);
}
+94
View File
@@ -0,0 +1,94 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/GetProcessInfo.h"
#include "memory.h"
Result GetProcessInfoHook(s64 *out, Handle processHandle, u32 type)
{
Result res = 0;
if(type >= 0x10000)
{
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KProcess *process;
if(processHandle == CUR_PROCESS_HANDLE)
{
process = currentCoreContext->objectContext.currentProcess;
KAutoObject__AddReference((KAutoObject *)process);
}
else
process = KProcessHandleTable__ToKProcess(handleTable, processHandle);
if(process == NULL)
return 0xD8E007F7; // invalid handle
switch(type)
{
case 0x10000:
memcpy(out, codeSetOfProcess(process)->processName, 8);
break;
case 0x10001:
*(u64 *)out = codeSetOfProcess(process)->titleId;
break;
case 0x10002:
*out = codeSetOfProcess(process)->nbTextPages << 12;
break;
case 0x10003:
*out = codeSetOfProcess(process)->nbRodataPages << 12;
break;
case 0x10004:
*out = codeSetOfProcess(process)->nbRwPages << 12;
break;
case 0x10005:
*out = (s64)(u64)(u32)codeSetOfProcess(process)->textSection.section.loadAddress;
break;
case 0x10006:
*out = (s64)(u64)(u32)codeSetOfProcess(process)->rodataSection.section.loadAddress;
break;
case 0x10007:
*out = (s64)(u64)(u32)codeSetOfProcess(process)->dataSection.section.loadAddress;
break;
case 0x10008:
{
KProcessHwInfo *hwInfo = hwInfoOfProcess(process);
u32 ttb = KPROCESSHWINFO_GET_RVALUE(hwInfo, translationTableBase);
*out = ttb & ~((1 << (14 - TTBCR)) - 1);
break;
}
default:
res = 0xD8E007ED; // invalid enum value
break;
}
((KAutoObject *)process)->vtable->DecrementReferenceCount((KAutoObject *)process);
}
else
res = GetProcessInfo(out, processHandle, type);
return res;
}
+140
View File
@@ -0,0 +1,140 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/GetSystemInfo.h"
#include "utils.h"
#include "ipc.h"
#include "synchronization.h"
Result GetSystemInfoHook(s64 *out, s32 type, s32 param)
{
Result res = 0;
switch(type)
{
case 0x10000:
{
switch(param)
{
case 0:
*out = SYSTEM_VERSION(cfwInfo.versionMajor, cfwInfo.versionMinor, cfwInfo.versionBuild);
break;
case 1:
*out = cfwInfo.commitHash;
break;
case 2:
*out = (cfwInfo.configFormatVersionMajor << 16) | cfwInfo.configFormatVersionMinor;
break;
case 3:
*out = cfwInfo.config;
break;
case 4:
*out = cfwInfo.multiConfig;
break;
case 5:
*out = cfwInfo.bootConfig;
break;
case 0x100:
*out = (s64)cfwInfo.hbldr3dsxTitleId;
break;
case 0x101:
*out = cfwInfo.rosalinaMenuCombo;
break;
case 0x200: // isRelease
*out = cfwInfo.flags & 1;
break;
case 0x201: // isN3DS
*out = (cfwInfo.flags >> 4) & 1;
break;
case 0x202: // isSafeMode
*out = (cfwInfo.flags >> 5) & 1;
break;
case 0x203: // isSdMode
*out = (cfwInfo.flags >> 6) & 1;
break;
default:
res = 0xF8C007F4; // not implemented
break;
}
break;
}
case 0x10001: // N3DS-related info
{
if(isN3DS)
{
switch(param)
{
case 0: // current clock rate
*out = (((CFG11_MPCORE_CLKCNT >> 1) & 3) + 1) * 268;
break;
case 1: // higher clock rate
*out = (((CFG11_MPCORE_CFG >> 2) & 1) + 2) * 268;
break;
case 2: // L2C enabled status
*out = L2C_CTRL & 1;
break;
default:
res = 0xF8C007F4;
break;
}
}
else
res = 0xF8C007F4;
break;
}
case 0x10002: // MMU config (cached values from booting)
{
switch(param)
{
case 0:
*out = TTBCR;
break;
default:
{
if((u32)param <= getNumberOfCores())
*out = L1MMUTableAddrs[param - 1];
else
res = 0xF8C007F4;
break;
}
}
break;
}
default:
GetSystemInfo(out, type, param);
break;
}
return res;
}
+60
View File
@@ -0,0 +1,60 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/GetThreadInfo.h"
#include "memory.h"
Result GetThreadInfoHook(s64 *out, Handle threadHandle, u32 type)
{
Result res = 0;
if(type == 0x10000) // Get TLS
{
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KThread *thread;
if(threadHandle == CUR_THREAD_HANDLE)
{
thread = currentCoreContext->objectContext.currentThread;
KAutoObject__AddReference(&thread->syncObject.autoObject);
}
else
thread = KProcessHandleTable__ToKThread(handleTable, threadHandle);
if(thread == NULL)
return 0xD8E007F7; // invalid handle
*out = (s64)(u64)(u32)thread->threadLocalStorage;
KAutoObject *obj = (KAutoObject *)thread;
obj->vtable->DecrementReferenceCount(obj);
}
else
res = GetThreadInfo(out, threadHandle, type);
return res;
}
+189
View File
@@ -0,0 +1,189 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/KernelSetState.h"
#include "synchronization.h"
#include "ipc.h"
#include "debug.h"
#include "memory.h"
#define MAX_DEBUG 3
static u32 nbEnabled = 0;
static u32 maskedPids[MAX_DEBUG];
static u32 masks[MAX_DEBUG][8] = {0};
bool shouldSignalSyscallDebugEvent(KProcess *process, u8 svcId)
{
u32 pid = idOfProcess(process);
u32 id;
for(id = 0; id < nbEnabled && maskedPids[id] != pid; id++);
if(id == MAX_DEBUG)
return false;
else
return ((masks[id][svcId / 32] >> (31 - (svcId % 32))) & 1) != 0;
}
Result SetSyscallDebugEventMask(u32 pid, bool enable, const u32 *mask)
{
static KRecursiveLock syscallDebugEventMaskLock = { NULL };
u32 tmpMask[8];
if(enable && nbEnabled == MAX_DEBUG)
return 0xC86018FF; // Out of resource (255)
if(enable && !usrToKernelMemcpy8(&tmpMask, mask, 32))
return 0xE0E01BF5;
KRecursiveLock__Lock(criticalSectionLock);
KRecursiveLock__Lock(&syscallDebugEventMaskLock);
if(enable)
{
maskedPids[nbEnabled] = pid;
memcpy(&masks[nbEnabled++], tmpMask, 32);
}
else
{
u32 id;
for(id = 0; id < nbEnabled && maskedPids[id] != pid; id++);
if(id == nbEnabled)
{
KRecursiveLock__Unlock(&syscallDebugEventMaskLock);
KRecursiveLock__Unlock(criticalSectionLock);
return 0xE0E01BFD; // out of range (it's not fully technically correct but meh)
}
for(u32 i = id; i < nbEnabled - 1; i++)
{
maskedPids[i] = maskedPids[i + 1];
memcpy(&masks[i], &masks[i + 1], 32);
}
maskedPids[--nbEnabled] = 0;
memset(&masks[nbEnabled], 0, 32);
}
KRecursiveLock__Unlock(&syscallDebugEventMaskLock);
KRecursiveLock__Unlock(criticalSectionLock);
return 0;
}
Result KernelSetStateHook(u32 type, u32 varg1, u32 varg2, u32 varg3)
{
Result res = 0;
switch(type)
{
case 0x10000:
{
do
{
__ldrex((s32 *)&rosalinaState);
}
while(__strex((s32 *)&rosalinaState, (s32)(rosalinaState ^ varg1)));
if(rosalinaState & 2)
hasStartedRosalinaNetworkFuncsOnce = true;
if(rosalinaState & 1)
rosalinaLockAllThreads();
else if(varg1 & 1)
rosalinaUnlockAllThreads();
break;
}
case 0x10001:
{
KRecursiveLock__Lock(criticalSectionLock);
KRecursiveLock__Lock(&processLangemuLock);
u32 i;
for(i = 0; i < 0x40 && processLangemuAttributes[i].titleId != 0ULL; i++);
if(i < 0x40)
{
processLangemuAttributes[i].titleId = ((u64)varg3 << 32) | (u32)varg2;
processLangemuAttributes[i].state = (u8)(varg1 >> 24);
processLangemuAttributes[i].country = (u8)(varg1 >> 16);
processLangemuAttributes[i].language = (u8)(varg1 >> 8);
processLangemuAttributes[i].region = (u8)((varg1 >> 4) & 0xf);
processLangemuAttributes[i].mask = (u8)(varg1 & 0xf);
}
else
res = 0xD8609013;
KRecursiveLock__Unlock(&processLangemuLock);
KRecursiveLock__Unlock(criticalSectionLock);
break;
}
case 0x10002:
{
res = SetSyscallDebugEventMask(varg1, (bool)varg2, (const u32 *)varg3);
break;
}
case 0x10003:
{
executeFunctionOnCores(enableMonitorModeDebugging, 0xF, 0);
break;
}
case 0x10004:
{
KRecursiveLock__Lock(&dbgParamsLock);
dbgParamWatchpointId = varg1;
executeFunctionOnCores(disableWatchpoint, 0xF, 0);
KRecursiveLock__Unlock(&dbgParamsLock);
break;
}
case 0x10005:
{
KRecursiveLock__Lock(&dbgParamsLock);
dbgParamWatchpointId = 0;
dbgParamDVA = varg1;
dbgParamWCR = varg2;
dbgParamContextId = varg3;
executeFunctionOnCores(setWatchpointWithContextId, 0xF, 0);
KRecursiveLock__Unlock(&dbgParamsLock);
break;
}
case 0x10006:
{
KRecursiveLock__Lock(&dbgParamsLock);
dbgParamWatchpointId = 1;
dbgParamDVA = varg1;
dbgParamWCR = varg2;
dbgParamContextId = varg3;
executeFunctionOnCores(setWatchpointWithContextId, 0xF, 0);
KRecursiveLock__Unlock(&dbgParamsLock);
break;
}
default:
{
res = KernelSetState(type, varg1, varg2, varg3);
break;
}
}
return res;
}
@@ -0,0 +1,44 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/MapProcessMemoryEx.h"
Result MapProcessMemoryEx(Handle processHandle, void *dst, void *src, u32 size)
{
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KProcessHwInfo *currentHwInfo = hwInfoOfProcess(currentCoreContext->objectContext.currentProcess);
KProcess *process = KProcessHandleTable__ToKProcess(handleTable, processHandle);
if(process == NULL)
return 0xD8E007F7;
Result res = KProcessHwInfo__MapProcessMemory(currentHwInfo, hwInfoOfProcess(process), dst, src, size >> 12);
KAutoObject *obj = (KAutoObject *)process;
obj->vtable->DecrementReferenceCount(obj);
return res;
}
+231
View File
@@ -0,0 +1,231 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "svc/SendSyncRequest.h"
#include "memory.h"
#include "ipc.h"
Result SendSyncRequestHook(Handle handle)
{
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
KClientSession *clientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, handle);
u32 *cmdbuf = (u32 *)((u8 *)currentCoreContext->objectContext.currentThread->threadLocalStorage + 0x80);
bool skip = false;
Result res = 0;
// not the exact same test but it should work
bool isValidClientSession = clientSession != NULL && strcmp(classNameOfAutoObject(&clientSession->syncObject.autoObject), "KClientSession") == 0;
if(isValidClientSession)
{
switch (cmdbuf[0])
{
case 0x10042:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && kernelVersion >= SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0)
{
res = doPublishToProcessHook(handle, cmdbuf);
skip = true;
}
else if(info != NULL && strcmp(info->name, "ndm:u") == 0 && hasStartedRosalinaNetworkFuncsOnce)
{
cmdbuf[0] = 0x10040;
cmdbuf[1] = 0;
skip = true;
}
break;
}
case 0x10082:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && (strcmp(info->name, "cfg:u") == 0 || strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk2
skip = doLangEmu(&res, cmdbuf);
break;
}
case 0x10800:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && strcmp(info->name, "err:f") == 0) // Throw
skip = doErrfThrowHook(cmdbuf);
break;
}
case 0x20000:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && (strcmp(info->name, "cfg:u") == 0 || strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // SecureInfoGetRegion
skip = doLangEmu(&res, cmdbuf);
break;
}
case 0x20002:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && strcmp(info->name, "ndm:u") == 0 && hasStartedRosalinaNetworkFuncsOnce)
{
cmdbuf[0] = 0x20040;
cmdbuf[1] = 0;
skip = true;
}
break;
}
case 0x50100:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && (strcmp(info->name, "srv:") == 0 || (kernelVersion < SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0)))
{
char name[9] = { 0 };
memcpy(name, cmdbuf + 1, 8);
skip = true;
res = SendSyncRequest(handle);
if(res == 0)
{
KClientSession *outClientSession;
outClientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, (Handle)cmdbuf[3]);
if(outClientSession != NULL)
{
if(strcmp(classNameOfAutoObject(&outClientSession->syncObject.autoObject), "KClientSession") == 0)
SessionInfo_Add(outClientSession->parentSession, name);
outClientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&outClientSession->syncObject.autoObject);
}
}
}
break;
}
case 0x80040:
{
if(!hasStartedRosalinaNetworkFuncsOnce)
break;
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
skip = info != NULL && strcmp(info->name, "ndm:u") == 0; // SuspendScheduler
if(skip)
cmdbuf[1] = 0;
break;
}
case 0x90000:
{
if(!hasStartedRosalinaNetworkFuncsOnce)
break;
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && strcmp(info->name, "ndm:u") == 0) // ResumeScheduler
{
cmdbuf[0] = 0x90040;
cmdbuf[1] = 0;
skip = true;
}
break;
}
case 0x4010042:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && kernelVersion < SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0)
{
res = doPublishToProcessHook(handle, cmdbuf);
skip = true;
}
break;
}
case 0x4010082:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk4
skip = doLangEmu(&res, cmdbuf);
break;
}
case 0x4020082:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk8
skip = doLangEmu(&res, cmdbuf);
break;
}
case 0x8010082:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk4
skip = doLangEmu(&res, cmdbuf);
break;
}
case 0x8020082:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
if(info != NULL && strcmp(info->name, "cfg:i") == 0) // GetConfigInfoBlk8
skip = doLangEmu(&res, cmdbuf);
break;
}
case 0x4060000:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession); // SecureInfoGetRegion
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0))
skip = doLangEmu(&res, cmdbuf);
break;
}
case 0x8160000:
{
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession); // SecureInfoGetRegion
if(info != NULL && strcmp(info->name, "cfg:i") == 0)
skip = doLangEmu(&res, cmdbuf);
break;
}
}
}
if(clientSession != NULL)
clientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&clientSession->syncObject.autoObject);
res = skip ? res : SendSyncRequest(handle);
return res;
}

Some files were not shown because too many files have changed in this diff Show More