Compare commits

...

242 Commits
0.9.0 ... lmeme

Author SHA1 Message Date
Michael Scire
c7fb3f7203 lmem: Implement Slab^H^H^H^HUnitHeap 2019-12-11 04:04:27 -08:00
Michael Scire
04beea44b0 lmem: implement ExpHeap 2019-12-11 01:24:45 -08:00
Michael Scire
d3bafc5b3b git subrepo push libraries
subrepo:
  subdir:   "libraries"
  merged:   "4d5a09e5"
upstream:
  origin:   "https://github.com/Atmosphere-NX/Atmosphere-libs"
  branch:   "master"
  commit:   "4d5a09e5"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-12-10 19:18:08 -08:00
Michael Scire
2c9e1a814c Bump version to 0.10.1 2019-12-10 18:33:01 -08:00
Michael Scire
df012e6e21 boot: do not use secure memory 2019-12-10 18:16:51 -08:00
Michael Scire
2420b26981 sf: Allow for more than one process id holder (ugly) 2019-12-10 18:10:47 -08:00
Michael Scire
c1d68d7f0d util: add fourcc, intrusive list fixes 2019-12-10 12:27:19 -08:00
Michael Scire
7cead4b620 Fix another off-by-one in TinyMT init calcs 2019-12-10 01:14:36 -08:00
Michael Scire
27202b2fab tinymt: correct init iter count 2019-12-09 23:53:09 -08:00
Michael Scire
1556a92a38 random: use TinyMT instead of XorShift 2019-12-09 23:50:47 -08:00
Michael Scire
206b1a1b57 kvdb: correct condition inversion in kvdb::Archive 2019-12-09 22:44:10 -08:00
Michael Scire
a26e157579 make dist: ensure libraries are built 2019-12-09 19:13:13 -08:00
Michael Scire
9578622abf sf: Improve class member function detection 2019-12-09 19:02:58 -08:00
Michael Scire
d4f99ddb4d libstratosphere: use from /atmosphere/libraries 2019-12-09 18:54:29 -08:00
Michael Scire
0105455086 git subrepo clone https://github.com/Atmosphere-NX/Atmosphere-libs libraries
subrepo:
  subdir:   "libraries"
  merged:   "07af583b"
upstream:
  origin:   "https://github.com/Atmosphere-NX/Atmosphere-libs"
  branch:   "master"
  commit:   "07af583b"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-12-09 18:54:29 -08:00
Michael Scire
28717bfd27 fusee/pm: on 5.0.0+, fix system memory pool increase.
Previously, we were only setting resource limit,
which didn't modify actual reserved pool size for
the system pool. This adds kernel patches which reduce
the applet pool size, granting the extra memory to
the system partition. The given value has been chosen
specifically to allow normal applet usages. Further
reduction may result in crashes during normal applet usage.
2019-12-09 17:56:38 -08:00
Michael Scire
71fd69eb5a git subrepo push stratosphere/libstratosphere
subrepo:
  subdir:   "stratosphere/libstratosphere"
  merged:   "303fc400"
upstream:
  origin:   "https://github.com/Atmosphere-NX/libstratosphere"
  branch:   "master"
  commit:   "303fc400"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-12-08 16:30:41 -08:00
Michael Scire
9d7b52e2d4 Remove boost submodule 2019-12-08 16:27:45 -08:00
Michael Scire
255e46e6d2 sf: correct size calculation for In/OutArray 2019-12-08 12:35:07 -08:00
Michael Scire
7472bc1c7f Improve exception wrapping 2019-12-08 03:29:47 -08:00
Michael Scire
3c7ece2f8b fs.mitm: fix infinite loop due to off-by-one in romfs read comparison 2019-12-07 21:27:12 -08:00
Michael Scire
a7e89c6dbb git subrepo push stratosphere/libstratosphere
subrepo:
  subdir:   "stratosphere/libstratosphere"
  merged:   "93d4f691"
upstream:
  origin:   "https://github.com/Atmosphere-NX/libstratosphere"
  branch:   "master"
  commit:   "93d4f691"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-12-07 18:45:59 -08:00
Michael Scire
b0cae74bb9 ro: bss size is allowed to be zero 2019-12-07 18:13:16 -08:00
Michael Scire
889ea5e5aa Fix memory corruption in romfs build (closes #708) 2019-12-07 17:43:11 -08:00
Michael Scire
7e6ff1f327 exosphere: support enabling usermode pmu regs (closes #703) 2019-12-07 15:35:34 -08:00
Michael Scire
ea49c2ccd1 Update changelog for 0.10.0 2019-12-07 15:23:25 -08:00
Michael Scire
d484872a73 git subrepo clone --force https://github.com/m4xw/emummc
subrepo:
  subdir:   "emummc"
  merged:   "bd81a674"
upstream:
  origin:   "https://github.com/m4xw/emummc"
  branch:   "develop"
  commit:   "bd81a674"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-12-07 14:54:15 -08:00
Michael Scire
6ee525201c Update emummc README 2019-12-07 14:39:01 -08:00
Michael Scire
5ac7ae7edb Update emummc for 9.1.0 2019-12-07 14:36:31 -08:00
Michael Scire
0c590eb768 Fix double semi-colon 2019-12-07 14:03:47 -08:00
Michael Scire
bd40d4f237 Turn on fs.mitm multithreading 2019-12-07 14:02:07 -08:00
Michael Scire
788436b4a3 Bump version to 0.10.0 2019-12-07 13:47:52 -08:00
Michael Scire
2bb77237bc Increase default applet reservation size to make psel work 2019-12-07 13:45:14 -08:00
Michael Scire
33827fe3a3 Implement support for 9.1.0 2019-12-07 13:44:08 -08:00
Lioncash
48b0b2fc46 dmnt_cheat_vm: Correct register Restore and ClearRegs behavior
Previously they were performing the same behavior as the Save and
ClearSave opcode types.
2019-12-07 12:41:56 -08:00
Michael Scire
4f29eedfe9 ams_mitm: implement hbl_html redirection 2019-12-07 12:41:28 -08:00
Michael Scire
66372e2b2e ams_mitm: implement ns.mitm 2019-12-07 12:41:28 -08:00
Michael Scire
2bae1ad116 Delete pre-rewrite ams_mitm code 2019-12-07 12:41:28 -08:00
Michael Scire
bbdc643b6d ams_mitm: fix directory save bugs 2019-12-07 12:41:28 -08:00
Michael Scire
a66fcde0ee fix uninitialized data access 2019-12-07 12:41:28 -08:00
Michael Scire
7835486a4d ams_mitm: Implement savedata redirection 2019-12-07 12:41:28 -08:00
Michael Scire
90367aea0d ams_mitm: add titles dir compat shim (to remove in 0.10.1) 2019-12-07 12:41:28 -08:00
Michael Scire
16c638756c ams_mitm: implement automatic backups of biskeys/cal0 2019-12-07 12:41:28 -08:00
Michael Scire
b08a97d883 shared_from_this requires public inheritance 2019-12-07 12:41:28 -08:00
Michael Scire
746dbfe018 ams_mitm: Implement emummc Nintendo folder redirection 2019-12-07 12:41:28 -08:00
Michael Scire
733f2b3cdd ams_mitm: implement layeredfs 2019-12-07 12:41:28 -08:00
Michael Scire
ad64cb5212 os/dd: primitive fixes 2019-12-07 12:41:28 -08:00
Michael Scire
b1a9e8d0df compat fixes for libnx master 2019-12-07 12:41:28 -08:00
Michael Scire
4f9838df3c avoid lambda use in shared_ptr deleters 2019-12-07 12:41:28 -08:00
Michael Scire
f4ca2c02a7 fs.mitm: Implement bis protection 2019-12-07 12:41:28 -08:00
Michael Scire
e1391d4162 stop overriding user config on update 2019-12-07 12:41:28 -08:00
Michael Scire
8d9c51f204 set_mitm: embed defaults in code, allow for missing ini 2019-12-07 12:41:28 -08:00
Michael Scire
c10ba67973 ams_mitm: Implement system settings mitm 2019-12-07 12:41:28 -08:00
Michael Scire
55610694c8 ams_mitm: Implement set:sys firmwareversion mitm 2019-12-07 12:41:28 -08:00
Michael Scire
8764d94fd9 Implement set_mitm 2019-12-07 12:41:28 -08:00
Michael Scire
5228768841 ams_mitm: implement hid mitm 2019-12-07 12:41:28 -08:00
Michael Scire
9c68bea16c Add icon for reboot to payload (closes #644) 2019-12-07 12:41:28 -08:00
Michael Scire
5484740cab hbl: support different keys for any-app vs specific
This also makes the default configuration:

To override a generic app, hold R.
To override album, do not hold R.
2019-12-07 12:41:28 -08:00
Michael Scire
421324b498 mitm/cfg: pass around override status for decision-making 2019-12-07 12:41:28 -08:00
Michael Scire
37e065fa2d ams_mitm: implement bpc:mitm 2019-12-07 12:41:28 -08:00
Michael Scire
b758e3fc55 strat: update for latest libnx. 2019-12-07 12:41:28 -08:00
Michael Scire
393596ef9a ams_mitm: begin skeleton refactor 2019-12-07 12:41:28 -08:00
Michael Scire
02d4c97c6d sf: explicitly namespace in DEFINE_SERVICE_DISPATCH_TABLE 2019-12-07 12:41:28 -08:00
Michael Scire
2c5ef434f0 sf: fixes (basic mitm service functionality now confirmed working) 2019-12-07 12:41:28 -08:00
Michael Scire
122f3e4403 libstrat: implement mitm server registration 2019-12-07 12:41:28 -08:00
Michael Scire
ea3ebbaa7d strat: TitleId -> ProgramId, titles->contents 2019-12-07 12:41:28 -08:00
Michael Scire
1636668762 strat: fixes for compat with latest libnx 2019-12-07 12:41:28 -08:00
Michael Scire
c6b9a0c4bf sf: PrepareForErrorReply is common to all objects 2019-12-07 12:41:28 -08:00
Michael Scire
93a218abeb libstrat: enable lto 2019-12-07 12:41:28 -08:00
Michael Scire
d7a06057eb strat: split out common functionality for future meso use 2019-12-07 12:41:28 -08:00
Michael Scire
8cb77ac136 namespace sts -> namespace ams
namespace sts::ams -> ams::exosphere, ams::.

This is to facilitate future use of ams:: namespace code in
mesosphere, as we'll want to include ams::util, ams::result, ams::svc...
2019-12-07 12:41:28 -08:00
Michael Scire
4059dc6187 Results: Implement namespaced, type-safe results.
Because I was working on multiple things at once, this commit also:
- Adds wrappers for/linker flags to wrap CXX exceptions to make them
  abort. This saves ~0x8000 of memory in every system module.
- Broadly replaces lines of the pattern if (cond) { return ResultX; }
  with R_UNLESS(!cond, ResultX());.
- Reworks the R_TRY_CATCH macros (and the result macros in general).
2019-12-07 12:41:28 -08:00
Michael Scire
15773e4755 libstrat: fix domain issues. in/out objects now work. 2019-12-07 12:41:28 -08:00
Michael Scire
4f455dacf4 sf: implement mitm forwarding + domains. 2019-12-07 12:41:28 -08:00
Michael Scire
0b22af1206 libstrat: namespace remaining non-namespaced code. more new-ipc updates 2019-12-07 12:41:28 -08:00
Michael Scire
ae2fa2fa60 boot: reduce memory footprint 2019-12-07 12:41:28 -08:00
Michael Scire
6abd756e0c boot2: move to separate process 2019-12-07 12:41:28 -08:00
Michael Scire
535e49a38d strat: statically allocate additional threads 2019-12-07 12:41:28 -08:00
Michael Scire
fbb5730369 strat: update for latest libnx commit 2019-12-07 12:41:28 -08:00
Michael Scire
e5d62025d3 dmnt: update for new-ipc 2019-12-07 12:41:28 -08:00
Michael Scire
89c6fc6437 creport: update for new-ipc 2019-12-07 12:41:28 -08:00
Michael Scire
799c158b86 fatal: update for new-ipc 2019-12-07 12:41:28 -08:00
Michael Scire
8d16d2152b boot: update for api changes 2019-12-07 12:41:28 -08:00
Michael Scire
635ae4e3da spl: update for new-ipc (fixes two bugs in sf) 2019-12-07 12:41:28 -08:00
Michael Scire
59140d8dfa sf-impl: remove debug condition 2019-12-07 12:41:28 -08:00
Michael Scire
2cb8aadafc pm: statically allocate more resources to save memory 2019-12-07 12:41:28 -08:00
Michael Scire
aa0826bb70 pm: update for new-ipc 2019-12-07 12:41:28 -08:00
Michael Scire
8bd2a9a23b ldr: fix copy/paste, only 1 ldr:pm session needed 2019-12-07 12:41:28 -08:00
Michael Scire
2f959785e1 loader: update for new-ipc 2019-12-07 12:41:28 -08:00
Michael Scire
88a86a3363 sf: implement CopyFromCurrentDomain 2019-12-07 12:41:28 -08:00
Michael Scire
0c7827104f hipc: begin implementing domains. fixes ro + sm together 2019-12-07 12:41:28 -08:00
Michael Scire
c8ed190e5c new-ipc: implement deferral. sm now works. 2019-12-07 12:41:28 -08:00
Michael Scire
f4dcd1db9b sf: implement service framework enough for ro to work.
This completely re-does the whole interface for ipc servers.
2019-12-07 12:41:28 -08:00
Michael Scire
bd341d5c00 libstrat: update for latest libnx, delete ipc in prep for rewrite 2019-12-07 12:41:28 -08:00
Michael Scire
add18d868f sts: add STS_UNREACHABLE_DEFAULT_CASE() 2019-12-07 12:41:28 -08:00
Michael Scire
609a302e16 os: implement waitable management.
This implements waitable management for Events (and
implements Events). It also refactors PM to use new
Event/Waitable semantics, and also adds STS_ASSERT
as a macro for asserting a boolean expression. The
rest of stratosphere has been refactored to use
STS_ASSERT whenever possible.
2019-12-07 12:41:28 -08:00
Michael Scire
e07011be32 mitm: fix long-standing C descriptor issue. 2019-12-07 12:41:28 -08:00
Michael Scire
bb223eb5ae libstrat: namespace hossynch.hpp 2019-12-07 12:41:28 -08:00
hexkyz
73d904036d fusee: relax emummc multipart check for FAT32 2019-09-27 19:35:00 +01:00
Michael Scire
542833866e git subrepo push stratosphere/libstratosphere
subrepo:
  subdir:   "stratosphere/libstratosphere"
  merged:   "8bae7b4a"
upstream:
  origin:   "https://github.com/Atmosphere-NX/libstratosphere"
  branch:   "master"
  commit:   "8bae7b4a"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-09-18 12:43:47 -07:00
Michael Scire
89c484414b dmnt: Truncate cheat names after maxlen instead of failing 2019-09-18 11:54:30 -07:00
Michael Scire
fe2dd671fb dmnt: fix edge case in debug events thread 2019-09-18 11:54:30 -07:00
Michael Scire
8abee1bdaa dmnt: fix some bugs in init 2019-09-18 11:54:30 -07:00
Michael Scire
78a730ddf6 dmnt: refactor to use sts:: namespace. 2019-09-18 11:54:30 -07:00
Michael Scire
a750e55f75 tmp-hid-mitm: less aggressively enable controllers
This fixes a crash in SSBU and possibly other games.
2019-09-14 13:37:31 -07:00
Michael Scire
c62c4846fc Bump version to 0.9.4. 2019-09-14 10:43:39 -07:00
Michael Scire
8db5b01507 hbl_html: enforce line ending = lf (fixes broken whitelist) 2019-09-14 10:43:39 -07:00
Michael Scire
a6e405c988 ldr: fix hbl_html redirection invocation 2019-09-14 10:43:39 -07:00
Michael Scire
6613fda4b1 ams_mitm: add temporary hid mitm on 9.x for compat 2019-09-14 10:43:39 -07:00
Michael Scire
a18a6e87df git subrepo pull emummc
subrepo:
  subdir:   "emummc"
  merged:   "5f5817e6"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "5f5817e6"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-09-14 10:43:39 -07:00
Michael Scire
93d83c5bb9 ams: initial support for 9.0.0 2019-09-14 10:43:39 -07:00
Michael Scire
6ee8720028 boot: fix pinmux init off-by-one 2019-08-29 00:18:40 -07:00
Michael Scire
600d68bd1a ams_mitm: fix bis key generation for newer hardware 2019-08-29 00:14:23 -07:00
hexkyz
0c3a294cbe Minor information update regarding previously unknown mysteries 2019-08-22 20:52:40 +01:00
Michael Scire
25218795b4 Bump version to 0.9.3 2019-08-08 18:06:21 -07:00
Michael Scire
a65ec67128 git subrepo push stratosphere/libstratosphere
subrepo:
  subdir:   "stratosphere/libstratosphere"
  merged:   "2d081135"
upstream:
  origin:   "https://github.com/Atmosphere-NX/libstratosphere"
  branch:   "master"
  commit:   "2d081135"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-08-08 17:50:09 -07:00
Michael Scire
5d753f2384 Add default system settings for hbl applet support 2019-08-08 17:45:31 -07:00
Michael Scire
1f2de35f94 fatal: use new vi enum value 2019-08-07 13:02:02 -07:00
Michael Scire
5c140b4f35 dist: include fusee-mtc in release zips. 2019-08-05 19:37:02 -07:00
Michael Scire
362ee3cdb0 autobackup: dump bis keys (closes #583). 2019-08-05 19:35:04 -07:00
Michael Scire
215f1bc8ee fatal: fix abort in viSetDisplayPowerState on < 3.0.0 2019-08-05 18:55:04 -07:00
hexkyz
4d72c2b37a fusee-primary: force displaying of fatal errors 2019-07-31 20:01:01 +01:00
hexkyz
dc4dbe29ae Move memory training code into it's own stage (fusee-mtc) 2019-07-26 20:38:15 +01:00
TuxSH
72dd25a99e Fix uart init 2019-07-24 00:52:02 +02:00
Michael Scire
39d041466d fatal: refactor into sts namespace 2019-07-23 14:01:16 -07:00
Michael Scire
442ebff829 util: fix copy/paste error in intrusive lists 2019-07-23 14:01:16 -07:00
hexkyz
7e169bc7df pm: work around HOS bug 2019-07-23 19:38:14 +01:00
hexkyz
00f4e5158f Add missing dummy reads in gpio code 2019-07-23 18:33:34 +01:00
hexkyz
0c688189f6 Fix uart pinmux configuration 2019-07-21 21:21:13 +01:00
hexkyz
7cee36544c Cleanup and re-write uart code 2019-07-21 19:18:15 +01:00
hexkyz
f9c1d5fc1b Fix GPIO/SFIO defines: cosmetic change, gpio code was working properly despite the mistake 2019-07-21 15:55:40 +01:00
Michael Scire
d95e20952c kvdb: fix iterator access issue 2019-07-18 20:34:15 -07:00
Michael Scire
32a90334bb spl: rsa service does not need a dispatch table 2019-07-17 20:58:46 -07:00
Michael Scire
f534d3498e git subrepo clone https://github.com/Atmosphere-NX/libstratosphere stratosphere/libstratosphere
subrepo:
  subdir:   "stratosphere/libstratosphere"
  merged:   "0c5dab80"
upstream:
  origin:   "https://github.com/Atmosphere-NX/libstratosphere"
  branch:   "master"
  commit:   "0c5dab80"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-07-17 20:04:00 -07:00
Michael Scire
3ea9f444db Remove libstratosphere submodule 2019-07-17 20:03:48 -07:00
TuxSH
5672c935ed Update libstratosphere submodule 2019-07-16 01:26:07 +02:00
Michael Scire
4cc2b5c38a creport: address review commentary 2019-07-15 14:35:48 -07:00
Michael Scire
00e3d874e3 creport: fix dangling reference to user_result 2019-07-15 14:35:48 -07:00
Michael Scire
803e91a8c4 creport: pass user break result directly 2019-07-15 14:35:48 -07:00
Michael Scire
227a1d938d creport: refactor to use sts:: namespace. 2019-07-15 14:35:48 -07:00
Michael Scire
fc7f06dc78 pm/sm: add ability to forward declare mitm'd services (closes #557) 2019-07-11 22:24:59 -07:00
Michael Scire
6777dd9b38 pm: inform sm of title ids. remove inconsistent mitm association. 2019-07-11 22:24:59 -07:00
Michael Scire
4db212ea7b pm: actually use the flag detection code in libstratosphere 2019-07-11 22:24:59 -07:00
Michael Scire
8177a27db9 pm: fix boot2 launch logic error 2019-07-11 22:24:59 -07:00
Michael Scire
27ff119ba6 pm: fix minor resource manager bugs 2019-07-11 22:24:59 -07:00
Michael Scire
c20774ff5d pm: fix missing flag clears 2019-07-11 22:24:59 -07:00
Michael Scire
a9f5b7728b pm: address review comments. 2019-07-11 22:24:59 -07:00
Michael Scire
08ad48fbf3 pm: implement correct application thread boosting mechanism 2019-07-11 22:24:59 -07:00
Michael Scire
2d0c881ffe strat: go all in on ncm::TitleId 2019-07-11 22:24:59 -07:00
Michael Scire
c916a7db88 strat: remove sizeof() / sizeof([0]) 2019-07-11 22:24:59 -07:00
Michael Scire
a5da286351 fix dumb mistake 2019-07-11 22:24:59 -07:00
Michael Scire
20a48c3a26 pm: complete rewrite 2019-07-11 22:24:59 -07:00
hexkyz
5bba0f47ff Merge pull request #625 from suppai/master
Fix compilation with latest libnx master
2019-07-08 16:56:54 +01:00
suppai
bfc987abcd Fix for libnx commit 4f441a4/latest master at time of writing 2019-07-07 23:56:21 -04:00
hexkyz
85bf7c86e0 fusee: cleanup and optimize boot sequence 2019-07-06 20:58:01 +01:00
Michael Scire
2225b86eea Adjust version string based on ReSwitched vote. 2019-07-02 11:49:24 -07:00
hexkyz
d09be18359 Fix argument type for isalnum and toupper 2019-07-02 17:22:28 +01:00
hexkyz
09ab3efddd Fix argument type for isspace 2019-07-01 20:29:43 +01:00
hexkyz
382a0192f9 Fix spacing in diskio 2019-07-01 20:20:34 +01:00
hexkyz
e3b968fa80 Update FatFs to R0.13c 2019-07-01 20:12:30 +01:00
Connor
6f85b11fcc Fix for 4.X units (new strato rework broke a method in spl) (#616)
* Fix for 4.X units (new strato rework broke a method in spl)

* Fixed formatting in spl
2019-07-01 03:53:46 -07:00
hexkyz
e561919a52 Fix logic in ldr_ro_manager
Fix argument type for isdigit/isxdigit
2019-06-30 18:48:16 +01:00
Michael Scire
b0a66a63ba Fix sept-secondary headers in fusee-secondary 2019-06-29 20:13:24 -07:00
Michael Scire
0d840e199d Bump version to 0.9.2. 2019-06-29 20:05:21 -07:00
Michael Scire
3a2bceef8d git subrepo pull emummc
subrepo:
  subdir:   "emummc"
  merged:   "5f51fa3b"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "5f51fa3b"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-06-28 11:36:07 -07:00
hexkyz
e871a754a8 fusee: remove unnecessary prefix from emummc config keys 2019-06-28 16:35:18 +01:00
hexkyz
6333327b81 fusee: update partition based emummc sector detection 2019-06-28 16:34:04 +01:00
Michael Scire
18ca8aaf5b stratosphere: all in on enum class CommandId 2019-06-27 23:34:53 -07:00
SciresM
67c0f4527e Merge pull request #603 from Atmosphere-NX/ldr_rewrite
loader: completely rewrite.
2019-06-27 23:28:00 -07:00
Michael Scire
e5c5101e8a Add missing extension cleanup. 2019-06-27 20:51:57 -07:00
Michael Scire
934ff7bbde <int> -> <s32> 2019-06-27 20:16:56 -07:00
Michael Scire
014f08f6b4 ldr: fix mount check mistake 2019-06-27 18:01:44 -07:00
Michael Scire
6ba2090c01 ldr: address review commentary. 2019-06-27 17:37:33 -07:00
Michael Scire
61fcf5e0f4 loader: completely rewrite. 2019-06-26 15:46:19 -07:00
Michael Scire
9217e4c5f9 sm: add HasService/HasMitm, refactor into sts:: 2019-06-24 17:57:49 -07:00
SciresM
3ccbb34c62 Merge pull request #598 from Atmosphere-NX/ro_refactor
ro: refactor/rewrite into sts:: namespace
2019-06-24 15:40:45 -07:00
Michael Scire
9baa4a17ed ro: refactor/rewrite into sts:: namespace 2019-06-24 02:05:51 -07:00
SciresM
6bbece39bc Merge pull request #592 from Atmosphere-NX/boot_refactor
Refactor boot sysmodule to use sts::boot namespace.
2019-06-23 20:39:39 -07:00
hexkyz
729447eab0 fusee: cleanup and simplify emummc logic 2019-06-23 18:50:20 +01:00
Michael Scire
1e7f41ea9f boot: move updater into libstrat 2019-06-22 12:30:36 -07:00
Michael Scire
d0d4888184 boot/spl: update for spl-in-libstrat 2019-06-22 12:23:46 -07:00
Michael Scire
804e5d49bb boot: split out gpio, pinmux. 2019-06-22 11:34:18 -07:00
Michael Scire
6d1d226842 remove unnecessary sts:: prefixing 2019-06-22 00:14:24 -07:00
Michael Scire
06416aeded boot: refactor to use sts::boot namespace 2019-06-22 00:10:21 -07:00
Michael Scire
4fbae9e5a4 boot: move updater to sts::updater namespace 2019-06-21 21:06:04 -07:00
Michael Scire
c87be7cd69 boot: refactor i2c driver into namespace 2019-06-21 20:25:27 -07:00
SciresM
e62754ed56 Merge pull request #585 from Atmosphere-NX/sm_rewrite
Completely re-write sm.
2019-06-21 17:37:06 -07:00
Michael Scire
53d7281e66 sm: use enums for GetInfo 2019-06-21 17:37:01 -07:00
SciresM
731a2c11a4 Merge pull request #587 from Atmosphere-NX/spl_refactor
spl: refactor into sts namespace
2019-06-21 17:33:34 -07:00
hexkyz
ec4d078d6d fusee: fix emummc multipart device 2019-06-21 22:14:14 +01:00
Michael Scire
f9b48f06a3 spl: refactor into sts namespace 2019-06-21 01:36:00 -07:00
Michael Scire
d986ffa153 sm: use AutoHandles 2019-06-20 23:51:15 -07:00
Michael Scire
2357bc70a7 Implementation cleanup 2019-06-20 23:34:59 -07:00
Michael Scire
e86e1588e3 Simplify namespacing 2019-06-20 18:32:00 -07:00
Michael Scire
4be88c7180 sm: adjust Makefile 2019-06-20 18:24:35 -07:00
Michael Scire
8e8daa64ba sm: completely rewrite module 2019-06-20 18:23:40 -07:00
Michael Scire
1671c04e24 stratosphere: prefer static waitable managers 2019-06-20 13:15:39 -07:00
Michael Scire
d3d6c552b7 stratosphere: remove trailing whitespace 2019-06-20 13:00:32 -07:00
Michael Scire
8d9336f561 git subrepo clone --branch=develop --force https://github.com/m4xw/emuMMC emummc
subrepo:
  subdir:   "emummc"
  merged:   "e935968d"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "e935968d"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-06-20 12:41:50 -07:00
Michael Scire
169ec9c12e Update libstrat 2019-06-20 05:01:42 -07:00
Michael Scire
60b831f369 ams_mitm: refactor for R_TRY 2019-06-20 04:04:33 -07:00
Michael Scire
4191dcee75 dmnt: fix missing init 2019-06-20 04:04:11 -07:00
Michael Scire
44725c8910 sm: refactor mitm service handle acquisition 2019-06-20 02:21:01 -07:00
Michael Scire
cead8a36ea stratosphere: more result cleanup 2019-06-20 02:00:59 -07:00
Michael Scire
7b6050a0cb boot: refactor for R_TRY 2019-06-20 00:57:17 -07:00
Michael Scire
491383c637 dmnt: trailing whitespace 2019-06-19 22:20:44 -07:00
Michael Scire
d7a3645f7f dmnt: update for R_TRY 2019-06-19 22:19:53 -07:00
Michael Scire
241b8f4627 fusee: fix config init/ini read order 2019-06-19 20:28:06 -07:00
Michael Scire
3f7238cb10 0.9.1 Changelog. 2019-06-19 13:02:23 -07:00
Michael Scire
1e8a6358ad Bump version to 0.9.1. 2019-06-19 13:00:46 -07:00
Michael Scire
c412d996fd git subrepo push emummc
subrepo:
  subdir:   "emummc"
  merged:   "e7799388"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "e7799388"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-06-19 13:00:30 -07:00
SciresM
f2086fe054 Merge pull request #577 from Atmosphere-NX/810_support
Implement support for 8.1.0
2019-06-19 12:59:30 -07:00
Michael Scire
3f9d6574fb emummc: support for 8.1.0 2019-06-19 12:53:24 -07:00
Michael Scire
e996acff66 Latest supported version is 8.1.0 2019-06-19 12:41:51 -07:00
Michael Scire
e274d3ef37 sept: tweak cluster verif 2019-06-19 12:40:39 -07:00
Michael Scire
8663eb1a6e sept: tweak vector check 2019-06-19 12:26:37 -07:00
Michael Scire
938da08e14 sept: add vector check to key derivation 2019-06-19 12:22:37 -07:00
Michael Scire
0468bd9483 git subrepo pull emummc
subrepo:
  subdir:   "emummc"
  merged:   "817020a9"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "817020a9"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-06-19 12:05:51 -07:00
Michael Scire
c077c75b8d sept: update makefile vars to allow for presigned bin 2019-06-19 12:04:43 -07:00
Michael Scire
24f7977fa6 SEPT_ENC_PATH -> SEPT_00_ENC_PATH + SEPT_01_ENC_PATH 2019-06-19 11:57:40 -07:00
Michael Scire
6699fda8c9 loader: implement 8.1.0 changes 2019-06-19 11:51:30 -07:00
Michael Scire
06e4158b93 sept: indulge paranoia, some. 2019-06-19 00:42:30 -07:00
Michael Scire
b82d8aaba9 sept: validate ccplex reset vector 2019-06-19 00:32:04 -07:00
Michael Scire
6829572556 sept: elide context save for safety. 2019-06-19 00:20:42 -07:00
Michael Scire
11d8021435 sept: minor fix 2019-06-18 23:58:59 -07:00
Michael Scire
493b074a9e exo: support for 8.1.0 2019-06-18 23:54:53 -07:00
Michael Scire
befd912a88 sept: update to support 8.1.0 2019-06-18 23:23:31 -07:00
Michael Scire
c96ae0148e Revise sept key generation methodology. 2019-06-18 22:22:40 -07:00
Michael Scire
63a9c856fc git subrepo pull emummc
subrepo:
  subdir:   "emummc"
  merged:   "44ecdb45"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "44ecdb45"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-06-18 11:32:03 -07:00
Michael Scire
31fde233e1 fatal: refactor for R_TRY 2019-06-17 16:41:03 -07:00
Michael Scire
f9bf8923b1 loader: refactor for R_TRY 2019-06-17 16:29:09 -07:00
Michael Scire
ee40dcd76f PM: Refactor for R_TRY, remove gotos 2019-06-17 15:27:29 -07:00
Michael Scire
c60ee15449 Merge branch 'master' of https://github.com/Atmosphere-NX/Atmosphere 2019-06-17 14:47:45 -07:00
Michael Scire
876d94c338 ro: update for R_TRY usage 2019-06-17 14:46:18 -07:00
hexkyz
7c37b7497b emummc: sanitize raw image file find loop (thanks @AnalogMan) 2019-06-17 19:47:47 +01:00
Michael Scire
dfcba5e6d4 sm: refactor to use R_TRY 2019-06-17 09:17:53 -07:00
Michael Scire
a0cf3bbed8 spl: refactor to use R_TRY 2019-06-17 09:00:15 -07:00
Michael Scire
1c503d59b5 git subrepo push emummc
subrepo:
  subdir:   "emummc"
  merged:   "b9ac428b"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "b9ac428b"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-06-16 15:01:52 -07:00
Michael Scire
0bf7df0426 emummc: fix nintendo path redir on 4.1.0 2019-06-16 15:01:10 -07:00
hexkyz
2c46ec9638 emummc: fix file based mode 2019-06-16 20:51:25 +01:00
Michael Scire
ef0c8e0aac git subrepo push emummc
subrepo:
  subdir:   "emummc"
  merged:   "417e3d36"
upstream:
  origin:   "https://github.com/m4xw/emuMMC"
  branch:   "develop"
  commit:   "417e3d36"
git-subrepo:
  version:  "0.4.0"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "5d6aba9"
2019-06-16 11:09:33 -07:00
Michael Scire
1a5801ee0f emummc: improve linkscript/building 2019-06-16 11:09:02 -07:00
1021 changed files with 148701 additions and 109918 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
config_templates/hbl_html/accessible-urls/accessible-urls.txt text eol=lf

6
.gitmodules vendored
View File

@@ -1,6 +0,0 @@
[submodule "common/include/boost"]
path = common/include/boost
url = https://github.com/Atmosphere-NX/ext-boost.git
[submodule "stratosphere/libstratosphere"]
path = stratosphere/libstratosphere
url = https://github.com/Atmosphere-NX/libstratosphere.git

View File

@@ -7,7 +7,7 @@ ifneq (, $(strip $(shell git status --porcelain 2>/dev/null)))
AMSREV := $(AMSREV)-dirty AMSREV := $(AMSREV)-dirty
endif endif
COMPONENTS := fusee stratosphere exosphere thermosphere troposphere COMPONENTS := fusee stratosphere exosphere thermosphere troposphere libraries
all: $(COMPONENTS) all: $(COMPONENTS)
@@ -17,7 +17,7 @@ thermosphere:
exosphere: thermosphere exosphere: thermosphere
$(MAKE) -C exosphere all $(MAKE) -C exosphere all
stratosphere: exosphere stratosphere: exosphere libraries
$(MAKE) -C stratosphere all $(MAKE) -C stratosphere all
troposphere: stratosphere troposphere: stratosphere
@@ -29,18 +29,21 @@ sept: exosphere
fusee: exosphere stratosphere sept fusee: exosphere stratosphere sept
$(MAKE) -C $@ all $(MAKE) -C $@ all
libraries:
$(MAKE) -C libraries all
clean: clean:
$(MAKE) -C fusee clean $(MAKE) -C fusee clean
rm -rf out rm -rf out
dist: all dist: all
$(eval MAJORVER = $(shell grep '\ATMOSPHERE_RELEASE_VERSION_MAJOR\b' common/include/atmosphere/version.h \ $(eval MAJORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MAJOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \ | tr -s [:blank:] \
| cut -d' ' -f3)) | cut -d' ' -f3))
$(eval MINORVER = $(shell grep '\ATMOSPHERE_RELEASE_VERSION_MINOR\b' common/include/atmosphere/version.h \ $(eval MINORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MINOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \ | tr -s [:blank:] \
| cut -d' ' -f3)) | cut -d' ' -f3))
$(eval MICROVER = $(shell grep '\ATMOSPHERE_RELEASE_VERSION_MICRO\b' common/include/atmosphere/version.h \ $(eval MICROVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MICRO\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \
| tr -s [:blank:] \ | tr -s [:blank:] \
| cut -d' ' -f3)) | cut -d' ' -f3))
$(eval AMSVER = $(MAJORVER).$(MINORVER).$(MICROVER)-$(AMSREV)) $(eval AMSVER = $(MAJORVER).$(MINORVER).$(MICROVER)-$(AMSREV))
@@ -50,32 +53,38 @@ dist: all
mkdir atmosphere-$(AMSVER)/atmosphere mkdir atmosphere-$(AMSVER)/atmosphere
mkdir atmosphere-$(AMSVER)/sept mkdir atmosphere-$(AMSVER)/sept
mkdir atmosphere-$(AMSVER)/switch mkdir atmosphere-$(AMSVER)/switch
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/010000000000000D mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000008
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032 mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/010000000000000D
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000034 mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000036 mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000034
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000037 mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000036
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037
mkdir -p atmosphere-$(AMSVER)/atmosphere/fatal_errors mkdir -p atmosphere-$(AMSVER)/atmosphere/fatal_errors
mkdir -p atmosphere-$(AMSVER)/atmosphere/config_templates
mkdir -p atmosphere-$(AMSVER)/atmosphere/config
cp fusee/fusee-primary/fusee-primary.bin atmosphere-$(AMSVER)/atmosphere/reboot_payload.bin cp fusee/fusee-primary/fusee-primary.bin atmosphere-$(AMSVER)/atmosphere/reboot_payload.bin
cp fusee/fusee-mtc/fusee-mtc.bin atmosphere-$(AMSVER)/atmosphere/fusee-mtc.bin
cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/sept/payload.bin cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/sept/payload.bin
cp sept/sept-primary/sept-primary.bin atmosphere-$(AMSVER)/sept/sept-primary.bin cp sept/sept-primary/sept-primary.bin atmosphere-$(AMSVER)/sept/sept-primary.bin
cp sept/sept-secondary/sept-secondary.bin atmosphere-$(AMSVER)/sept/sept-secondary.bin cp sept/sept-secondary/sept-secondary.bin atmosphere-$(AMSVER)/sept/sept-secondary.bin
cp sept/sept-secondary/sept-secondary.enc atmosphere-$(AMSVER)/sept/sept-secondary.enc cp sept/sept-secondary/sept-secondary_00.enc atmosphere-$(AMSVER)/sept/sept-secondary_00.enc
cp common/defaults/BCT.ini atmosphere-$(AMSVER)/atmosphere/BCT.ini cp sept/sept-secondary/sept-secondary_01.enc atmosphere-$(AMSVER)/sept/sept-secondary_01.enc
cp common/defaults/loader.ini atmosphere-$(AMSVER)/atmosphere/loader.ini cp config_templates/BCT.ini atmosphere-$(AMSVER)/atmosphere/config/BCT.ini
cp common/defaults/system_settings.ini atmosphere-$(AMSVER)/atmosphere/system_settings.ini cp config_templates/override_config.ini atmosphere-$(AMSVER)/atmosphere/config_templates/override_config.ini
cp -r common/defaults/kip_patches atmosphere-$(AMSVER)/atmosphere/kip_patches cp config_templates/system_settings.ini atmosphere-$(AMSVER)/atmosphere/config_templates/system_settings.ini
cp -r common/defaults/hbl_html atmosphere-$(AMSVER)/atmosphere/hbl_html cp -r config_templates/kip_patches atmosphere-$(AMSVER)/atmosphere/kip_patches
cp stratosphere/dmnt/dmnt.nsp atmosphere-$(AMSVER)/atmosphere/titles/010000000000000D/exefs.nsp cp -r config_templates/hbl_html atmosphere-$(AMSVER)/atmosphere/hbl_html
cp stratosphere/eclct.stub/eclct.stub.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/exefs.nsp cp stratosphere/boot2/boot2.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000008/exefs.nsp
cp stratosphere/fatal/fatal.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000034/exefs.nsp cp stratosphere/dmnt/dmnt.nsp atmosphere-$(AMSVER)/atmosphere/contents/010000000000000D/exefs.nsp
cp stratosphere/creport/creport.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000036/exefs.nsp cp stratosphere/eclct.stub/eclct.stub.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/exefs.nsp
cp stratosphere/ro/ro.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000037/exefs.nsp cp stratosphere/fatal/fatal.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000034/exefs.nsp
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/flags cp stratosphere/creport/creport.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000036/exefs.nsp
touch atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/flags/boot2.flag cp stratosphere/ro/ro.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/exefs.nsp
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000037/flags mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags
touch atmosphere-$(AMSVER)/atmosphere/titles/0100000000000037/flags/boot2.flag touch atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/flags/boot2.flag
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/flags
touch atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037/flags/boot2.flag
cp troposphere/reboot_to_payload/reboot_to_payload.nro atmosphere-$(AMSVER)/switch/reboot_to_payload.nro cp troposphere/reboot_to_payload/reboot_to_payload.nro atmosphere-$(AMSVER)/switch/reboot_to_payload.nro
cd atmosphere-$(AMSVER); zip -r ../atmosphere-$(AMSVER).zip ./*; cd ../; cd atmosphere-$(AMSVER); zip -r ../atmosphere-$(AMSVER).zip ./*; cd ../;
rm -r atmosphere-$(AMSVER) rm -r atmosphere-$(AMSVER)

View File

@@ -1,9 +0,0 @@
[hbl_config]
title_id=010000000000100D
override_any_app=true
path=atmosphere/hbl.nsp
override_key=R
[default_config]
override_key=!L
cheat_enable_key=!L

View File

@@ -1,31 +0,0 @@
; Disable uploading error reports to Nintendo
[eupld]
upload_enabled = u8!0x0
; Enable USB 3.0 superspeed for homebrew
[usb]
usb30_force_enabled = u8!0x0
; Control whether RO should ease its validation of NROs.
; (note: this is normally not necessary, and ips patches can be used.)
[ro]
ease_nro_restriction = u8!0x0
; Atmosphere custom settings
[atmosphere]
; Reboot from fatal automatically after some number of milliseconds.
; If field is not present or 0, fatal will wait indefinitely for user input.
fatal_auto_reboot_interval = u64!0x0
; Make the power menu's "reboot" button reboot to payload.
; Set to "normal" for normal reboot, "rcm" for rcm reboot.
power_menu_reboot_function = str!payload
; Controls whether dmnt cheats should be toggled on or off by
; default. 1 = toggled on by default, 0 = toggled off by default.
dmnt_cheats_enabled_by_default = u8!0x1
; Controls whether dmnt should always save cheat toggle state
; for restoration on new game launch. 1 = always save toggles,
; 0 = only save toggles if toggle file exists.
dmnt_always_save_cheat_toggles = u8!0x0
; Controls whether fs.mitm should redirect save files
; to directories on the sd card.
; 0 = Do not redirect, 1 = Redirect.
; NOTE: EXPERIMENTAL
; If you do not know what you are doing, do not touch this yet.
fsmitm_redirect_saves_to_sd = u8!0x0

View File

@@ -1,6 +1,7 @@
BCT0 BCT0
[stage1] [stage1]
stage2_path = atmosphere/fusee-secondary.bin stage2_path = atmosphere/fusee-secondary.bin
stage2_mtc_path = atmosphere/fusee-mtc.bin
stage2_addr = 0xF0000000 stage2_addr = 0xF0000000
stage2_entrypoint = 0xF0000000 stage2_entrypoint = 0xF0000000
@@ -11,6 +12,8 @@ debugmode_user = 0
; Note: Disabling usermode exception handlers will cause atmosphere to not fail gracefully under error conditions. ; Note: Disabling usermode exception handlers will cause atmosphere to not fail gracefully under error conditions.
; Support will not be provided to users who disable these. If you do not know what you are doing, leave them on. ; Support will not be provided to users who disable these. If you do not know what you are doing, leave them on.
disable_user_exception_handlers = 0 disable_user_exception_handlers = 0
; Note: It's currently unknown what effects enabling the usermode PMU register access may have on official code.
enable_user_pmu_access = 0
[stratosphere] [stratosphere]
; To force-enable nogc, add nogc = 1 ; To force-enable nogc, add nogc = 1

View File

@@ -0,0 +1,10 @@
[hbl_config]
; program_id=010000000000100D
; override_any_app=true
; path=atmosphere/hbl.nsp
; override_key=!R
; override_any_app_key=R
[default_config]
; override_key=!L
; cheat_enable_key=!L

View File

@@ -0,0 +1,43 @@
; Disable uploading error reports to Nintendo
[eupld]
; upload_enabled = u8!0x0
; Control whether RO should ease its validation of NROs.
; (note: this is normally not necessary, and ips patches can be used.)
[ro]
; ease_nro_restriction = u8!0x0
; Atmosphere custom settings
[atmosphere]
; Reboot from fatal automatically after some number of milliseconds.
; If field is not present or 0, fatal will wait indefinitely for user input.
; fatal_auto_reboot_interval = u64!0x0
; Make the power menu's "reboot" button reboot to payload.
; Set to "normal" for normal reboot, "rcm" for rcm reboot.
; power_menu_reboot_function = str!payload
; Controls whether dmnt cheats should be toggled on or off by
; default. 1 = toggled on by default, 0 = toggled off by default.
; dmnt_cheats_enabled_by_default = u8!0x1
; Controls whether dmnt should always save cheat toggle state
; for restoration on new game launch. 1 = always save toggles,
; 0 = only save toggles if toggle file exists.
; dmnt_always_save_cheat_toggles = u8!0x0
; Enable writing to BIS partitions for HBL.
; This is probably undesirable for normal usage.
; enable_hbl_bis_write = u8!0x0
; Enable reading the CAL0 partition for HBL.
; This is probably undesirable for normal usage.
; enable_hbl_cal_read = u8!0x0
; Controls whether fs.mitm should redirect save files
; to directories on the sd card.
; 0 = Do not redirect, 1 = Redirect.
; NOTE: EXPERIMENTAL
; If you do not know what you are doing, do not touch this yet.
; fsmitm_redirect_saves_to_sd = u8!0x0
[hbloader]
; Controls the size of the homebrew heap when running as applet.
; If set to zero, all available applet memory is used as heap.
; The default is zero.
; applet_heap_size = u64!0x0
; Controls the amount of memory to reserve when running as applet
; for usage by other applets. This setting has no effect if
; applet_heap_size is non-zero. The default is 0x8600000.
; applet_heap_reservation_size = u64!0x8600000

View File

@@ -1,4 +1,165 @@
# Changelog # Changelog
## 0.10.1
+ A bug was fixed that caused memory reallocation to the system pool to work improperly on firmware 5.0.0 and above.
+ Atmosphere was always trying to deallocate memory away from the applet pool and towards the system pool.
+ The intent of this is to facilitate running more custom sysmodules/atmosphere binaries.
+ However, while memory was always successfully taken away from the applet pool, on 5.0.0+ granting it to the system pool did not work for technical reasons.
+ If you are interested in the technical details, talk to SciresM.
+ This has now been fixed by adding new kernel patches, and memory is correctly granted to the system pool as intended.
+ Atmosphere's library system has been overhauled:
+ libstratosphere's repository has been rebranded, more generally, to "Atmosphere-libs".
+ In addition to libstratosphere, a new general library for not-stratosphere-specific code has been added.
+ This is currently named `libvapours`.
+ In the future, kernel functionality will be available as `libmesosphere`.
+ The build system for stratosphere system modules has been similarly overhauled.
+ A number of other bugs were fixed, including:
+ A bug was fixed that could cause memory corruption when redirecting certain Romfs content.
+ A bug was fixed that could cause an infinite loop when redirecting certain Romfs content.
+ A bug was fixed that could cause certain NROs to fail to load.
+ This caused the latest version of Super Smash Bros to display "An error has occurred" on launch.
+ A bug was fixed that caused input/output array sizes for certain circumstances to be calculated incorrectly.
+ This caused cheats to fail to function properly.
+ C++ exception code is now more thoroughly removed from stratosphere executables.
+ This saves a minor amount of memory.
+ A number of minor logic inversions were fixed in libstratosphere.
+ These did not affect any code currently used by released Atmosphere binaries.
+ *Please note**: Because this update is releasing so soon after 0.10.0, the removal of the temporary hid-mitm has been postponed to 0.10.2.
+ Please ensure your homebrew is updated.
+ Random number generation now uses TinyMT instead of XorShift.
+ General system stability improvements to enhance the user's experience.
## 0.10.0
+ Support was added for 9.1.0
+ **Please note**: The temporary hid-mitm added in Atmosphere 0.9.0 will be removed in Atmosphere 0.10.1.
+ Please ensure your homebrew is updated.
+ The Stratosphere rewrite was completed.
+ libstratosphere was rewritten as part of Stratosphere's refactor.
+ Code responsible for providing and managing IPC services was greatly improved.
+ The new code is significantly more accurate (it is bug-for-bug compatible with Nintendo's code), and significantly faster.
+ ams.mitm was rewritten as part of Stratosphere's refactor.
+ Saves redirected to the SD card are now separated for sysmmc vs emummc.
+ **Please note**: If you find any bugs, please report them so they can be fixed.
+ Thanks to the rewrite, Atmosphere now uses significantly less memory.
+ Roughly 10 additional megabytes are now available for custom system modules to use.
+ This means you can potentially run more custom system modules simultaneously.
+ If system modules are incompatible, please ask their authors to reduce their memory footprints.
+ Atmosphere's configuration layout has had major changes.
+ Configuration now lives inside /atmosphere/config/.
+ Atmosphere code now knows what default values should be, and includes them in code.
+ It is no longer an error if configuration inis are not present.
+ Correspondingly, Atmosphere no longer distributes default configuration inis.
+ Templates are provided in /atmosphere/config_templates.
+ loader.ini was renamed to override_config.ini.
+ This fixes the longstanding problem that atmosphere updates overwrote user configuration when extracted.
+ Atmosphere's process override layout was changed.
+ Atmosphere now uses the /atmosphere/contents directory, instead of /atmosphere/titles.
+ This goes along with a refactoring to remove all reference to "title id" from code, as Nintendo does not use the term.
+ To make this transition easier, a temporary functionality has been added that migrates folders to the new directory.
+ When booting into 0.10.0, Atmosphere will rename /atmosphere/titles/`<program id>` to /atmosphere/contents/`<program id>`.
+ This functionality may or may not be removed in some future update.
+ This should solve any transition difficulties for the typical user.
+ Please make sure that any future mods you install extract to the correct directory.
+ Support for configuring override keys for hbl was improved.
+ The key used to override applications versus a specific program can now be different.
+ The key to override a specific program can be managed via override_key.
+ The key to override any app can be managed via override_any_app_key.
+ Default override behavior was changed.
+ By default, atmosphere will now override the album applet with hbl unless R is held.
+ By default, atmosphere will now override any application with hbl only if R is held.
+ The default amount of applet memory reserved has been slightly increased.
+ This allows the profile selector applet to work by default in applet mode.
+ The way process override status is captured was changed.
+ Process override keys are now captured exactly once, when the process is created.
+ This fixes the longstanding issue where letting go of the override button partway into the process launch could cause problems.
+ The Mitm API was changed to pass around override status.
+ Mitm services now know what keys were held when the client was created, as well as whether the client is HBL/should override contents.
+ An extension was added to pm:info to allow querying a process's override status.
+ Thanks to process override capture improvements, hbl html behavior has been greatly improved.
+ Web applets launched by hbl will now always see the /atmosphere/hbl_html filesystem
+ Support was added to exosphere for enabling usermode access to the PMU registers.
+ This can be controlled via exosphere!enable_user_pmu_access in BCT.ini.
+ An enormous number of minor bugs were fixed.
+ dmnt's cheat VM had a fix for an inversion in opcode behavior.
+ An issue was fixed in fs.mitm's management of domain object IDs that could lead to system corruption in rare cases.
+ The Mitm API no longer silently fails when attempting to handle commands passing C descriptors.
+ On previous atmosphere versions, certain commands to FS would silently fail due to this...
+ No users reported any visible errors, but it was definitely a problem behind the scenes.
+ These commands are now handled correctly.
+ Atmosphere can now display a fatal error screen significantly earlier in the boot process, if things go wrong early on.
+ The temporary hid mitm will no longer sometimes cause games to fail to detect input.
+ Mitm Domain object ID management no longer desynchronizes from the host process.
+ An issue was fixed that could cause service acquisition to hang forever if certain sm commands were called in a precise order.
+ An off-by-one was fixed that could cause memory corruption in server memory management.
+ ... and too many more bugs fixed to reasonably list them all :)
+ General system stability improvements to enhance the user's experience.
## 0.9.4
+ Support was added for 9.0.0.
+ **Please note**: 9.0.0 made a number of changes that may cause some issues with homebrew. Details:
+ 9.0.0 changed HID in a way that causes libnx to be unable to detect button input.
+ Homebrew should be recompiled with newest libnx to fix this.
+ Atmosphere now provides a temporary hid-mitm that will cause homebrew to continue to work as expected.
+ This mitm will be removed in a future Atmosphere revision once homebrew has been updated, to allow users to use a custom hid mitm again if they desire.
+ 9.0.0 introduced an dependency in FS on the USB system module in order to launch the SD card.
+ This means the USB system module must now be launched before the SD card is initialized.
+ Correspondingly, the USB system module can no longer be IPS patched, and its settings cannot be reliably mitm'd.
+ We know this is frustrating, so we'll be looking into whether there is some way of addressing this in the future.
+ An off-by-one error was fixed in `boot` system module's pinmux initialization.
+ This could theoretically have caused issues with HdmiCec communication.
+ No users reported issues, so it's unclear if this was a problem in practice.
+ A bug was fixed that could cause webapplet launching homebrew to improperly set the accessible url whitelist.
+ BIS key generation has been fixed for newer hardware.
+ Newer hardware uses new, per-firmware device key to generate BIS keys instead of the first device key, so previously the wrong keys were generated as backup.
+ This only affects units manufactured after ~5.0.0.
+ General system stability improvements to enhance the user's experience.
## 0.9.3
+ Thanks to hexkyz, fusee's boot sequence has been greatly optimized.
+ Memory training is now managed by a separate binary (`fusee-mtc`, loaded by fusee-primary before fusee-secondary).
+ Unnecessarily long splash screen display times were reduced.
+ The end result is that Atmosphere now boots *significantly* faster. :)
+ **Note:** This means fusee-primary must be updated for Atmosphere to boot successfully.
+ The version string was adjusted, and now informs users whether or not they are using emummc.
+ Atmosphere now automatically backs up the user's BIS keys on boot.
+ This should prevent a user from corrupting nand without access to a copy of the keys needed to fix it.
+ This is especially relevant on ipatched units, where the RCM vulnerability is not an option for addressing bricks.
+ The `pm` system module was rewritten as part of Stratosphere's ongoing refactor.
+ Support was added for forward-declaring a mitm'd service before a custom user sysmodule is launched.
+ This should help resolve dependency issues with service registration times.
+ SM is now informed of every process's title id, including built-in system modules.
+ The `creport` system module was rewritten as part of Stratosphere's ongoing refactor.
+ creport now dumps up to 0x100 of stack from each thread in the target process.
+ A few bugs were fixed, including one that caused creport to incorrectly dump process dying messages.
+ Defaults were added to `system_settings.ini` for controlling hbloader's memory usage in applet mode.
+ These defaults reserve enough memory so that homebrew can launch swkbd while in applet mode.
+ The `fatal` system module was rewritten as part of Stratosphere's ongoing refactor.
+ Incorrect display output ("2000-0000") has been fixed. Fatal will now correctly show 2162-0002 when this occurs.
+ A longstanding bug in how fatal manages the displays has been fixed, and official display init behavior is now matched precisely.
+ General system stability improvements to enhance the user's experience.
## 0.9.2
+ A number of emummc bugfixes were added (all thanks to @m4xw's hard work). The following is a summary of emummc changes:
+ Support for file-based emummc instances was fixed.
+ Please note: file-based emummc is still unoptimized, and so may be much slower than partition-based.
+ This speed differential should hopefully be made better in a future emummc update.
+ The way emummc handles power management was completely overhauled.
+ Emummc now properly handles init/de-init, and now supports low voltage mode.
+ Much better support for shutdown was added, which should assuage corruption/synchronization problems.
+ This should also improve support for more types of SD cards.
+ A bug was fixed that caused emummc to not work on lower system versions due to missing SVC access.
+ **Please note**: The configuration entries used for emummc have been changed.
+ `emummc_` prefixes have been removed, since they are superfluous given the `emummc` category they are under.
+ As an example, `emummc!emummc_enabled` is now `emummc!enabled`.
+ INI configurations made by @CTCaer's [tool](https://github.com/ctcaer/hekate/releases/latest) (which is the recommended way to manage emummc) should automatically work as expected/be corrected.
+ **If you do not wish to use the above, you will need to manually correct your configuration file**.
+ General system stability improvements to enhance the user's experience.
+ Stratosphere is currently in the process of being re-written/refactored.
+ Stratosphere was my (SciresM's) first C++ project, ever -- the code written for it a year ago when I was learning C++ is/was of much lower quality than code written more recently.
+ Code is thus being re-rwitten for clarity/stlye/to de-duplicate functionality, with much being moved into libstratosphere.
+ Stratosphere will, after the rewrite, globally use the `sts::` namespace -- this should greatly enhancing libstratosphere's ability to provide functionality for system modules.
+ The rewritten modules consistently have lower memory footprints, and should be easier to maintain going forwards.
+ The `sm`, `boot`, `spl`, `ro`, and `loader` modules have been tackled so far.
+ General system stability improvements to enhance the user's experience.
## 0.9.1
+ Support was added for 8.1.0.
+ Please note, emummc is still considered **beta/experimental** -- this is not the inevitable bugfix update for it, although some number of bugs have been fixed. :)
+ General system stability improvements to enhance the user's experience.
## 0.9.0 ## 0.9.0
+ Creport output was improved significantly. + Creport output was improved significantly.
+ Thread names are now dumped on crash in addition to 0x100 of TLS from each thread. + Thread names are now dumped on crash in addition to 0x100 of TLS from each thread.

View File

@@ -6,7 +6,7 @@
[subrepo] [subrepo]
remote = https://github.com/m4xw/emuMMC remote = https://github.com/m4xw/emuMMC
branch = develop branch = develop
commit = e72e8f1c8fb7ad8fe7cdedc3784729ea8e11f927 commit = bd81a674a946c30b566e1732a95c18f19b701558
parent = 87a1aa17a7693ef39ffea91ad0fa1b530f278bb0 parent = 6ee525201ccef107c61d81ba73c891e3eb5f0215
method = rebase method = rebase
cmdver = 0.4.0 cmdver = 0.4.0

View File

@@ -17,7 +17,7 @@ else
EMUMMCDIR ?= $(CURDIR)/../ EMUMMCDIR ?= $(CURDIR)/../
endif endif
include $(EMUMMCDIR)/nx/switch_rules include $(DEVKITPRO)/libnx/switch_rules
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
@@ -31,7 +31,7 @@ CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
ASFLAGS := -g $(ARCH) ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(EMUMMCDIR)/nx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
ifneq ($(BUILD),$(notdir $(CURDIR))) ifneq ($(BUILD),$(notdir $(CURDIR)))

View File

@@ -2,7 +2,7 @@
*A SDMMC driver replacement for Nintendo's Filesystem Services, by **m4xw*** *A SDMMC driver replacement for Nintendo's Filesystem Services, by **m4xw***
### Supported Horizon Versions ### Supported Horizon Versions
**1.0.0 - 8.0.1** **1.0.0 - 9.1.0**
## Features ## Features
* Arbitrary SDMMC backend selection * Arbitrary SDMMC backend selection

View File

@@ -116,6 +116,7 @@
"svcReplyAndReceive": "0x43", "svcReplyAndReceive": "0x43",
"svcReplyAndReceiveWithUserBuffer": "0x44", "svcReplyAndReceiveWithUserBuffer": "0x44",
"svcCreateEvent": "0x45", "svcCreateEvent": "0x45",
"svcReadWriteRegister": "0x4E",
"svcCreateInterruptEvent": "0x53", "svcCreateInterruptEvent": "0x53",
"svcQueryIoMapping": "0x55", "svcQueryIoMapping": "0x55",
"svcCreateDeviceAddressSpace": "0x56", "svcCreateDeviceAddressSpace": "0x56",

View File

@@ -1,229 +0,0 @@
OUTPUT_ARCH(aarch64)
ENTRY(_start)
PHDRS
{
code PT_LOAD FLAGS(5) /* Read | Execute */;
rodata PT_LOAD FLAGS(4) /* Read */;
data PT_LOAD FLAGS(6) /* Read | Write */;
dyn PT_DYNAMIC;
}
SECTIONS
{
/* =========== CODE section =========== */
PROVIDE(__start__ = 0x0);
. = __start__;
__code_start = . ;
/*.trampoline :
{
KEEP (*(.trampoline))
. = ALIGN(8);
} :code
.emuMMC_ctx :
{
KEEP (*(.emuMMC_ctx))
. = ALIGN(8);
} :code */
.crt0 :
{
KEEP (*(.crt0))
. = ALIGN(8);
} :code
.init :
{
KEEP( *(.init) )
. = ALIGN(8);
} :code
.plt :
{
*(.plt)
*(.iplt)
. = ALIGN(8);
} :code
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
. = ALIGN(8);
} :code
.fini :
{
KEEP( *(.fini) )
. = ALIGN(8);
} :code
/* =========== RODATA section =========== */
. = ALIGN(0x1000);
__rodata_start = . ;
.nx-module-name : { KEEP (*(.nx-module-name)) } :rodata
.rodata :
{
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(8);
} :rodata
.eh_frame_hdr : { __eh_frame_hdr_start = .; *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) __eh_frame_hdr_end = .; } :rodata
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } :rodata
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } :rodata
.gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } : rodata
.dynamic : { *(.dynamic) } :rodata :dyn
.dynsym : { *(.dynsym) } :rodata
.dynstr : { *(.dynstr) } :rodata
.rela.dyn : { *(.rela.*) } :rodata
.interp : { *(.interp) } :rodata
.hash : { *(.hash) } :rodata
.gnu.hash : { *(.gnu.hash) } :rodata
.gnu.version : { *(.gnu.version) } :rodata
.gnu.version_d : { *(.gnu.version_d) } :rodata
.gnu.version_r : { *(.gnu.version_r) } :rodata
.note.gnu.build-id : { *(.note.gnu.build-id) } :rodata
/* =========== DATA section =========== */
. = ALIGN(0x1000);
__data_start = . ;
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } :data
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } :data
.gnu_extab : ONLY_IF_RW { *(.gnu_extab*) } : data
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } :data
.tdata ALIGN(8) :
{
__tdata_lma = .;
*(.tdata .tdata.* .gnu.linkonce.td.*)
. = ALIGN(8);
__tdata_lma_end = .;
} :data
.tbss ALIGN(8) :
{
*(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
. = ALIGN(8);
} :data
.preinit_array ALIGN(8) :
{
PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE (__preinit_array_end = .);
} :data
.init_array ALIGN(8) :
{
PROVIDE (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE (__init_array_end = .);
} :data
.fini_array ALIGN(8) :
{
PROVIDE (__fini_array_start = .);
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE (__fini_array_end = .);
} :data
.ctors ALIGN(8) :
{
KEEP (*crtbegin.o(.ctors)) /* MUST be first -- GCC requires it */
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} :data
.dtors ALIGN(8) :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} :data
__got_start__ = .;
.got : { *(.got) *(.igot) } :data
.got.plt : { *(.got.plt) *(.igot.plt) } :data
__got_end__ = .;
.data ALIGN(8) :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
} :data
__bss_start__ = .;
.bss ALIGN(8) :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(8);
/* Reserve space for the TLS segment of the main thread */
__tls_start = .;
. += + SIZEOF(.tdata) + SIZEOF(.tbss);
__tls_end = .;
} : data
__bss_end__ = .;
. = ALIGN(0x1000);
__end__ = ABSOLUTE(.) ;
PROVIDE(__injected_size__ = (__end__ - __start__));
/* ==================
==== Metadata ====
================== */
/* Discard sections that difficult post-processing */
/DISCARD/ : { *(.group .comment .note) }
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
}

View File

@@ -1,8 +0,0 @@
%rename link old_link
*link:
%(old_link) -T %:getenv(PWD /nx/switch.ld) -pie --gc-sections -z text -z nodynamic-undefined-weak --build-id=sha1 --nx-module-name
*startfile:
crti%O%s crtbegin%O%s

View File

@@ -1,81 +0,0 @@
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITPRO)/devkitA64/base_rules
PORTLIBS := $(PORTLIBS_PATH)/switch
PATH := $(PORTLIBS)/bin:$(PATH)
LIBNX ?= $(DEVKITPRO)/libnx
ifeq ($(strip $(APP_TITLE)),)
APP_TITLE := $(notdir $(OUTPUT))
endif
ifeq ($(strip $(APP_AUTHOR)),)
APP_AUTHOR := Unspecified Author
endif
ifeq ($(strip $(APP_VERSION)),)
APP_VERSION := 1.0.0
endif
ifeq ($(strip $(APP_ICON)),)
APP_ICON := $(LIBNX)/default_icon.jpg
endif
#---------------------------------------------------------------------------------
%.nacp: $(MAKEFILE_LIST)
@nacptool --create "$(APP_TITLE)" "$(APP_AUTHOR)" "$(APP_VERSION)" $@ $(NACPFLAGS)
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.npdm: $(APP_JSON)
@npdmtool $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
define make_pfs0
@mkdir -p exefs
@[ $(BUILD_EXEFS_SRC) ] && [ -d $(BUILD_EXEFS_SRC) ] && cp -R $(BUILD_EXEFS_SRC)/* exefs || echo > /dev/null
@cp $*.nso exefs/main
@[ $(APP_JSON) ] && cp $*.npdm exefs/main.npdm || echo > /dev/null
@build_pfs0 exefs $@
@echo built ... $(notdir $@)
endef
ifeq ($(strip $(APP_JSON)),)
%.pfs0: %.nso
else
%.pfs0: %.nso %.npdm
endif
$(make_pfs0)
ifeq ($(strip $(APP_JSON)),)
%.nsp: %.nso
else
%.nsp: %.nso %.npdm
endif
$(make_pfs0)
#---------------------------------------------------------------------------------
%.nso: %.elf
@elf2nso $< $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.nro: %.elf
@elf2nro $< $@ $(NROFLAGS)
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.kip: %.elf
@elf2kip $< $(APP_JSON) $@
@echo built ... $(notdir $@)
#---------------------------------------------------------------------------------
%.elf:
@echo linking $(notdir $@)
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
@$(NM) -CSn $@ > $(notdir $*.lst)

View File

@@ -39,6 +39,12 @@
#include "offsets/700_exfat.h" #include "offsets/700_exfat.h"
#include "offsets/800.h" #include "offsets/800.h"
#include "offsets/800_exfat.h" #include "offsets/800_exfat.h"
#include "offsets/810.h"
#include "offsets/810_exfat.h"
#include "offsets/900.h"
#include "offsets/900_exfat.h"
#include "offsets/910.h"
#include "offsets/910_exfat.h"
#include "../utils/fatal.h" #include "../utils/fatal.h"
#define GET_OFFSET_STRUCT_NAME(vers) g_offsets##vers #define GET_OFFSET_STRUCT_NAME(vers) g_offsets##vers
@@ -59,7 +65,7 @@ static const fs_offsets_t GET_OFFSET_STRUCT_NAME(vers) = { \
.nand_mutex = FS_OFFSET##vers##_NAND_MUTEX, \ .nand_mutex = FS_OFFSET##vers##_NAND_MUTEX, \
.active_partition = FS_OFFSET##vers##_ACTIVE_PARTITION, \ .active_partition = FS_OFFSET##vers##_ACTIVE_PARTITION, \
.sdmmc_das_handle = FS_OFFSET##vers##_SDMMC_DAS_HANDLE, \ .sdmmc_das_handle = FS_OFFSET##vers##_SDMMC_DAS_HANDLE, \
.shutdown_sd = FS_OFFSET##vers##_SHUTDOWN_SD, \ .sdmmc_accessor_controller_close = FS_OFFSET##vers##_SDMMC_WRAPPER_CONTROLLER_CLOSE, \
.sd_das_init = FS_OFFSET##vers##_SD_DAS_INIT, \ .sd_das_init = FS_OFFSET##vers##_SD_DAS_INIT, \
.nintendo_paths = FS_OFFSET##vers##_NINTENDO_PATHS, \ .nintendo_paths = FS_OFFSET##vers##_NINTENDO_PATHS, \
} }
@@ -88,6 +94,12 @@ DEFINE_OFFSET_STRUCT(_700);
DEFINE_OFFSET_STRUCT(_700_EXFAT); DEFINE_OFFSET_STRUCT(_700_EXFAT);
DEFINE_OFFSET_STRUCT(_800); DEFINE_OFFSET_STRUCT(_800);
DEFINE_OFFSET_STRUCT(_800_EXFAT); DEFINE_OFFSET_STRUCT(_800_EXFAT);
DEFINE_OFFSET_STRUCT(_810);
DEFINE_OFFSET_STRUCT(_810_EXFAT);
DEFINE_OFFSET_STRUCT(_900);
DEFINE_OFFSET_STRUCT(_900_EXFAT);
DEFINE_OFFSET_STRUCT(_910);
DEFINE_OFFSET_STRUCT(_910_EXFAT);
const fs_offsets_t *get_fs_offsets(enum FS_VER version) { const fs_offsets_t *get_fs_offsets(enum FS_VER version) {
switch (version) { switch (version) {
@@ -137,6 +149,18 @@ const fs_offsets_t *get_fs_offsets(enum FS_VER version) {
return &(GET_OFFSET_STRUCT_NAME(_800)); return &(GET_OFFSET_STRUCT_NAME(_800));
case FS_VER_8_0_0_EXFAT: case FS_VER_8_0_0_EXFAT:
return &(GET_OFFSET_STRUCT_NAME(_800_EXFAT)); return &(GET_OFFSET_STRUCT_NAME(_800_EXFAT));
case FS_VER_8_1_0:
return &(GET_OFFSET_STRUCT_NAME(_810));
case FS_VER_8_1_0_EXFAT:
return &(GET_OFFSET_STRUCT_NAME(_810_EXFAT));
case FS_VER_9_0_0:
return &(GET_OFFSET_STRUCT_NAME(_900));
case FS_VER_9_0_0_EXFAT:
return &(GET_OFFSET_STRUCT_NAME(_900_EXFAT));
case FS_VER_9_1_0:
return &(GET_OFFSET_STRUCT_NAME(_910));
case FS_VER_9_1_0_EXFAT:
return &(GET_OFFSET_STRUCT_NAME(_910_EXFAT));
default: default:
fatal_abort(Fatal_UnknownVersion); fatal_abort(Fatal_UnknownVersion);
} }

View File

@@ -24,6 +24,7 @@
typedef struct { typedef struct {
int opcode_reg; int opcode_reg;
uint32_t adrp_offset; uint32_t adrp_offset;
uint32_t add_rel_offset;
} fs_offsets_nintendo_path_t; } fs_offsets_nintendo_path_t;
typedef struct { typedef struct {
@@ -40,13 +41,13 @@ typedef struct {
// Misc funcs // Misc funcs
uintptr_t lock_mutex; uintptr_t lock_mutex;
uintptr_t unlock_mutex; uintptr_t unlock_mutex;
uintptr_t sdmmc_accessor_controller_close;
// Misc data // Misc data
uintptr_t sd_mutex; uintptr_t sd_mutex;
uintptr_t nand_mutex; uintptr_t nand_mutex;
uintptr_t active_partition; uintptr_t active_partition;
uintptr_t sdmmc_das_handle; uintptr_t sdmmc_das_handle;
// NOPs // NOPs
uintptr_t shutdown_sd;
uintptr_t sd_das_init; uintptr_t sd_das_init;
// Nintendo Paths // Nintendo Paths
fs_offsets_nintendo_path_t nintendo_paths[]; fs_offsets_nintendo_path_t nintendo_paths[];

View File

@@ -20,7 +20,8 @@
#include "../utils/types.h" #include "../utils/types.h"
typedef struct { typedef struct
{
char *device_addr_buffer; char *device_addr_buffer;
uint64_t device_addr_buffer_size; uint64_t device_addr_buffer_size;
char *device_addr_buffer_masked; char *device_addr_buffer_masked;
@@ -28,25 +29,30 @@ typedef struct {
_Static_assert(__alignof(sdmmc_dma_buffer_t) == 8, "sdmmc_dma_buffer_t definition"); _Static_assert(__alignof(sdmmc_dma_buffer_t) == 8, "sdmmc_dma_buffer_t definition");
typedef struct sdmmc_accessor_vt { typedef struct sdmmc_accessor_vt
{
void *ctor; void *ctor;
void *dtor; void *dtor;
void *map_device_addr_space; void *map_device_addr_space;
void *unmap_device_addr_space; void *unmap_device_addr_space;
void *controller_open; void *controller_open;
void *controller_close; uint64_t (*sdmmc_accessor_controller_close)(void *);
uint64_t (*read_write)(void *, uint64_t, uint64_t, void *, uint64_t, uint64_t); uint64_t (*read_write)(void *, uint64_t, uint64_t, void *, uint64_t, uint64_t);
// More not included because we don't use it. // More not included because we don't use it.
} sdmmc_accessor_vt_t; } sdmmc_accessor_vt_t;
typedef struct { _Static_assert(__alignof(sdmmc_accessor_vt_t) == 8, "sdmmc_accessor_vt_t definition");
typedef struct
{
void *vtab; void *vtab;
t210_sdmmc_t *io_map; t210_sdmmc_t *io_map;
sdmmc_dma_buffer_t dmaBuffers[3]; sdmmc_dma_buffer_t dmaBuffers[3];
// More not included because we don't use it. // More not included because we don't use it.
} mmc_obj_t; } mmc_obj_t;
typedef struct { typedef struct
{
sdmmc_accessor_vt_t *vtab; sdmmc_accessor_vt_t *vtab;
mmc_obj_t *parent; mmc_obj_t *parent;
// More not included because we don't use it. // More not included because we don't use it.

View File

@@ -56,6 +56,15 @@ enum FS_VER
FS_VER_8_0_0, FS_VER_8_0_0,
FS_VER_8_0_0_EXFAT, FS_VER_8_0_0_EXFAT,
FS_VER_8_1_0,
FS_VER_8_1_0_EXFAT,
FS_VER_9_0_0,
FS_VER_9_0_0_EXFAT,
FS_VER_9_1_0,
FS_VER_9_1_0_EXFAT,
FS_VER_MAX, FS_VER_MAX,
}; };

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_100_LOCK_MUTEX 0x2884 #define FS_OFFSET_100_LOCK_MUTEX 0x2884
#define FS_OFFSET_100_UNLOCK_MUTEX 0x28F0 #define FS_OFFSET_100_UNLOCK_MUTEX 0x28F0
#define FS_OFFSET_100_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x6A8AC
// Misc Data // Misc Data
#define FS_OFFSET_100_SD_MUTEX 0xE36058 #define FS_OFFSET_100_SD_MUTEX 0xE36058
#define FS_OFFSET_100_NAND_MUTEX 0xE30610 #define FS_OFFSET_100_NAND_MUTEX 0xE30610
@@ -41,17 +43,16 @@
#define FS_OFFSET_100_SDMMC_DAS_HANDLE 0xE2F730 #define FS_OFFSET_100_SDMMC_DAS_HANDLE 0xE2F730
// NOPs // NOPs
#define FS_OFFSET_100_SHUTDOWN_SD 0x22548
#define FS_OFFSET_100_SD_DAS_INIT 0x0 #define FS_OFFSET_100_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_100_NINTENDO_PATHS \ #define FS_OFFSET_100_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 9, .adrp_offset = 0x00032C58}, \ {.opcode_reg = 9, .adrp_offset = 0x00032C58, .add_rel_offset = 4}, \
{.opcode_reg = 8, .adrp_offset = 0x00032C60}, \ {.opcode_reg = 8, .adrp_offset = 0x00032C60, .add_rel_offset = 4}, \
{.opcode_reg = 9, .adrp_offset = 0x00032F3C}, \ {.opcode_reg = 9, .adrp_offset = 0x00032F3C, .add_rel_offset = 4}, \
{.opcode_reg = 8, .adrp_offset = 0x00032F44}, \ {.opcode_reg = 8, .adrp_offset = 0x00032F44, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_100_H__ #endif // __FS_100_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_200_LOCK_MUTEX 0x3264 #define FS_OFFSET_200_LOCK_MUTEX 0x3264
#define FS_OFFSET_200_UNLOCK_MUTEX 0x32D0 #define FS_OFFSET_200_UNLOCK_MUTEX 0x32D0
#define FS_OFFSET_200_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x733F4
// Misc Data // Misc Data
#define FS_OFFSET_200_SD_MUTEX 0xE42268 #define FS_OFFSET_200_SD_MUTEX 0xE42268
#define FS_OFFSET_200_NAND_MUTEX 0xE3CED0 #define FS_OFFSET_200_NAND_MUTEX 0xE3CED0
@@ -41,16 +43,15 @@
#define FS_OFFSET_200_SDMMC_DAS_HANDLE 0xE3BDD0 #define FS_OFFSET_200_SDMMC_DAS_HANDLE 0xE3BDD0
// NOPs // NOPs
#define FS_OFFSET_200_SHUTDOWN_SD 0x20C48
#define FS_OFFSET_200_SD_DAS_INIT 0x0 #define FS_OFFSET_200_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_200_NINTENDO_PATHS \ #define FS_OFFSET_200_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x00033F08}, \ {.opcode_reg = 3, .adrp_offset = 0x00033F08, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00035084}, \ {.opcode_reg = 3, .adrp_offset = 0x00035084, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x0003537C}, \ {.opcode_reg = 3, .adrp_offset = 0x0003537C, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_200_H__ #endif // __FS_200_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_200_EXFAT_LOCK_MUTEX 0x3264 #define FS_OFFSET_200_EXFAT_LOCK_MUTEX 0x3264
#define FS_OFFSET_200_EXFAT_UNLOCK_MUTEX 0x32D0 #define FS_OFFSET_200_EXFAT_UNLOCK_MUTEX 0x32D0
#define FS_OFFSET_200_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x733F4
// Misc Data // Misc Data
#define FS_OFFSET_200_EXFAT_SD_MUTEX 0xF22268 #define FS_OFFSET_200_EXFAT_SD_MUTEX 0xF22268
#define FS_OFFSET_200_EXFAT_NAND_MUTEX 0xF1CED0 #define FS_OFFSET_200_EXFAT_NAND_MUTEX 0xF1CED0
@@ -41,16 +43,15 @@
#define FS_OFFSET_200_EXFAT_SDMMC_DAS_HANDLE 0xF1BDD0 #define FS_OFFSET_200_EXFAT_SDMMC_DAS_HANDLE 0xF1BDD0
// NOPs // NOPs
#define FS_OFFSET_200_EXFAT_SHUTDOWN_SD 0x20C48
#define FS_OFFSET_200_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_200_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_200_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_200_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x00033F08}, \ {.opcode_reg = 3, .adrp_offset = 0x00033F08, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00035084}, \ {.opcode_reg = 3, .adrp_offset = 0x00035084, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x0003537C}, \ {.opcode_reg = 3, .adrp_offset = 0x0003537C, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_200_EXFAT_H__ #endif // __FS_200_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_210_LOCK_MUTEX 0x3264 #define FS_OFFSET_210_LOCK_MUTEX 0x3264
#define FS_OFFSET_210_UNLOCK_MUTEX 0x32D0 #define FS_OFFSET_210_UNLOCK_MUTEX 0x32D0
#define FS_OFFSET_210_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x737D4
// Misc Data // Misc Data
#define FS_OFFSET_210_SD_MUTEX 0xE43268 #define FS_OFFSET_210_SD_MUTEX 0xE43268
#define FS_OFFSET_210_NAND_MUTEX 0xE3DED0 #define FS_OFFSET_210_NAND_MUTEX 0xE3DED0
@@ -41,16 +43,15 @@
#define FS_OFFSET_210_SDMMC_DAS_HANDLE 0xE3CDD0 #define FS_OFFSET_210_SDMMC_DAS_HANDLE 0xE3CDD0
// NOPs // NOPs
#define FS_OFFSET_210_SHUTDOWN_SD 0x20E60
#define FS_OFFSET_210_SD_DAS_INIT 0x0 #define FS_OFFSET_210_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_210_NINTENDO_PATHS \ #define FS_OFFSET_210_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000342E0}, \ {.opcode_reg = 3, .adrp_offset = 0x000342E0, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x0003545C}, \ {.opcode_reg = 3, .adrp_offset = 0x0003545C, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x00035754}, \ {.opcode_reg = 3, .adrp_offset = 0x00035754, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_210_H__ #endif // __FS_210_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_210_EXFAT_LOCK_MUTEX 0x3264 #define FS_OFFSET_210_EXFAT_LOCK_MUTEX 0x3264
#define FS_OFFSET_210_EXFAT_UNLOCK_MUTEX 0x32D0 #define FS_OFFSET_210_EXFAT_UNLOCK_MUTEX 0x32D0
#define FS_OFFSET_210_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x737D4
// Misc Data // Misc Data
#define FS_OFFSET_210_EXFAT_SD_MUTEX 0xF22268 #define FS_OFFSET_210_EXFAT_SD_MUTEX 0xF22268
#define FS_OFFSET_210_EXFAT_NAND_MUTEX 0xF1CED0 #define FS_OFFSET_210_EXFAT_NAND_MUTEX 0xF1CED0
@@ -41,16 +43,15 @@
#define FS_OFFSET_210_EXFAT_SDMMC_DAS_HANDLE 0xF1BDD0 #define FS_OFFSET_210_EXFAT_SDMMC_DAS_HANDLE 0xF1BDD0
// NOPs // NOPs
#define FS_OFFSET_210_EXFAT_SHUTDOWN_SD 0x20E60
#define FS_OFFSET_210_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_210_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_210_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_210_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000342E0}, \ {.opcode_reg = 3, .adrp_offset = 0x000342E0, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x0003545C}, \ {.opcode_reg = 3, .adrp_offset = 0x0003545C, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x00035754}, \ {.opcode_reg = 3, .adrp_offset = 0x00035754, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_210_EXFAT_H__ #endif // __FS_210_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_300_LOCK_MUTEX 0x35CC #define FS_OFFSET_300_LOCK_MUTEX 0x35CC
#define FS_OFFSET_300_UNLOCK_MUTEX 0x3638 #define FS_OFFSET_300_UNLOCK_MUTEX 0x3638
#define FS_OFFSET_300_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A270
// Misc Data // Misc Data
#define FS_OFFSET_300_SD_MUTEX 0xE69268 #define FS_OFFSET_300_SD_MUTEX 0xE69268
#define FS_OFFSET_300_NAND_MUTEX 0xE646F0 #define FS_OFFSET_300_NAND_MUTEX 0xE646F0
@@ -41,16 +43,15 @@
#define FS_OFFSET_300_SDMMC_DAS_HANDLE 0xE635A0 #define FS_OFFSET_300_SDMMC_DAS_HANDLE 0xE635A0
// NOPs // NOPs
#define FS_OFFSET_300_SHUTDOWN_SD 0x258D8
#define FS_OFFSET_300_SD_DAS_INIT 0x0 #define FS_OFFSET_300_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_300_NINTENDO_PATHS \ #define FS_OFFSET_300_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000391F4}, \ {.opcode_reg = 3, .adrp_offset = 0x000391F4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A480}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A480, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A778}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A778, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_300_H__ #endif // __FS_300_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_300_EXFAT_LOCK_MUTEX 0x35CC #define FS_OFFSET_300_EXFAT_LOCK_MUTEX 0x35CC
#define FS_OFFSET_300_EXFAT_UNLOCK_MUTEX 0x3638 #define FS_OFFSET_300_EXFAT_UNLOCK_MUTEX 0x3638
#define FS_OFFSET_300_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A270
// Misc Data // Misc Data
#define FS_OFFSET_300_EXFAT_SD_MUTEX 0xF4C268 #define FS_OFFSET_300_EXFAT_SD_MUTEX 0xF4C268
#define FS_OFFSET_300_EXFAT_NAND_MUTEX 0xF476F0 #define FS_OFFSET_300_EXFAT_NAND_MUTEX 0xF476F0
@@ -41,16 +43,15 @@
#define FS_OFFSET_300_EXFAT_SDMMC_DAS_HANDLE 0xF465A0 #define FS_OFFSET_300_EXFAT_SDMMC_DAS_HANDLE 0xF465A0
// NOPs // NOPs
#define FS_OFFSET_300_EXFAT_SHUTDOWN_SD 0x258D8
#define FS_OFFSET_300_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_300_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_300_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_300_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000391F4}, \ {.opcode_reg = 3, .adrp_offset = 0x000391F4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A480}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A480, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A778}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A778, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_300_EXFAT_H__ #endif // __FS_300_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_301_LOCK_MUTEX 0x3638 #define FS_OFFSET_301_LOCK_MUTEX 0x3638
#define FS_OFFSET_301_UNLOCK_MUTEX 0x36A4 #define FS_OFFSET_301_UNLOCK_MUTEX 0x36A4
#define FS_OFFSET_301_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A32C
// Misc Data // Misc Data
#define FS_OFFSET_301_SD_MUTEX 0xE69268 #define FS_OFFSET_301_SD_MUTEX 0xE69268
#define FS_OFFSET_301_NAND_MUTEX 0xE646F0 #define FS_OFFSET_301_NAND_MUTEX 0xE646F0
@@ -41,16 +43,15 @@
#define FS_OFFSET_301_SDMMC_DAS_HANDLE 0xE635A0 #define FS_OFFSET_301_SDMMC_DAS_HANDLE 0xE635A0
// NOPs // NOPs
#define FS_OFFSET_301_SHUTDOWN_SD 0x25944
#define FS_OFFSET_301_SD_DAS_INIT 0x0 #define FS_OFFSET_301_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_301_NINTENDO_PATHS \ #define FS_OFFSET_301_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x00039260}, \ {.opcode_reg = 3, .adrp_offset = 0x00039260, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A4EC}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A4EC, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A7E4}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A7E4, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_301_H__ #endif // __FS_301_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_301_EXFAT_LOCK_MUTEX 0x3638 #define FS_OFFSET_301_EXFAT_LOCK_MUTEX 0x3638
#define FS_OFFSET_301_EXFAT_UNLOCK_MUTEX 0x36A4 #define FS_OFFSET_301_EXFAT_UNLOCK_MUTEX 0x36A4
#define FS_OFFSET_301_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x8A32C
// Misc Data // Misc Data
#define FS_OFFSET_301_EXFAT_SD_MUTEX 0xF4C268 #define FS_OFFSET_301_EXFAT_SD_MUTEX 0xF4C268
#define FS_OFFSET_301_EXFAT_NAND_MUTEX 0xF476F0 #define FS_OFFSET_301_EXFAT_NAND_MUTEX 0xF476F0
@@ -41,16 +43,15 @@
#define FS_OFFSET_301_EXFAT_SDMMC_DAS_HANDLE 0xF465A0 #define FS_OFFSET_301_EXFAT_SDMMC_DAS_HANDLE 0xF465A0
// NOPs // NOPs
#define FS_OFFSET_301_EXFAT_SHUTDOWN_SD 0x25944
#define FS_OFFSET_301_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_301_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_301_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_301_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x00039260}, \ {.opcode_reg = 3, .adrp_offset = 0x00039260, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A4EC}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A4EC, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x0003A7E4}, \ {.opcode_reg = 3, .adrp_offset = 0x0003A7E4, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_301_EXFAT_H__ #endif // __FS_301_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_400_LOCK_MUTEX 0x39A0 #define FS_OFFSET_400_LOCK_MUTEX 0x39A0
#define FS_OFFSET_400_UNLOCK_MUTEX 0x3A0C #define FS_OFFSET_400_UNLOCK_MUTEX 0x3A0C
#define FS_OFFSET_400_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DB48
// Misc Data // Misc Data
#define FS_OFFSET_400_SD_MUTEX 0xE80268 #define FS_OFFSET_400_SD_MUTEX 0xE80268
#define FS_OFFSET_400_NAND_MUTEX 0xE7BC60 #define FS_OFFSET_400_NAND_MUTEX 0xE7BC60
@@ -41,16 +43,15 @@
#define FS_OFFSET_400_SDMMC_DAS_HANDLE 0xE7ABF0 #define FS_OFFSET_400_SDMMC_DAS_HANDLE 0xE7ABF0
// NOPs // NOPs
#define FS_OFFSET_400_SHUTDOWN_SD 0x32D70
#define FS_OFFSET_400_SD_DAS_INIT 0x0 #define FS_OFFSET_400_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_400_NINTENDO_PATHS \ #define FS_OFFSET_400_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x0002023C}, \ {.opcode_reg = 3, .adrp_offset = 0x0002023C, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00021BE8}, \ {.opcode_reg = 3, .adrp_offset = 0x00021BE8, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x00021EC4}, \ {.opcode_reg = 3, .adrp_offset = 0x00021EC4, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_400_H__ #endif // __FS_400_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_400_EXFAT_LOCK_MUTEX 0x39A0 #define FS_OFFSET_400_EXFAT_LOCK_MUTEX 0x39A0
#define FS_OFFSET_400_EXFAT_UNLOCK_MUTEX 0x3A0C #define FS_OFFSET_400_EXFAT_UNLOCK_MUTEX 0x3A0C
#define FS_OFFSET_400_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DB48
// Misc Data // Misc Data
#define FS_OFFSET_400_EXFAT_SD_MUTEX 0xF63268 #define FS_OFFSET_400_EXFAT_SD_MUTEX 0xF63268
#define FS_OFFSET_400_EXFAT_NAND_MUTEX 0xF5EC60 #define FS_OFFSET_400_EXFAT_NAND_MUTEX 0xF5EC60
@@ -41,16 +43,15 @@
#define FS_OFFSET_400_EXFAT_SDMMC_DAS_HANDLE 0xF5DBF0 #define FS_OFFSET_400_EXFAT_SDMMC_DAS_HANDLE 0xF5DBF0
// NOPs // NOPs
#define FS_OFFSET_400_EXFAT_SHUTDOWN_SD 0x32D70
#define FS_OFFSET_400_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_400_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_400_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_400_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x0002023C}, \ {.opcode_reg = 3, .adrp_offset = 0x0002023C, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00021BE8}, \ {.opcode_reg = 3, .adrp_offset = 0x00021BE8, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x00021EC4}, \ {.opcode_reg = 3, .adrp_offset = 0x00021EC4, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_400_EXFAT_H__ #endif // __FS_400_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_410_LOCK_MUTEX 0x39A0 #define FS_OFFSET_410_LOCK_MUTEX 0x39A0
#define FS_OFFSET_410_UNLOCK_MUTEX 0x3A0C #define FS_OFFSET_410_UNLOCK_MUTEX 0x3A0C
#define FS_OFFSET_410_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DBAC
// Misc Data // Misc Data
#define FS_OFFSET_410_SD_MUTEX 0xE80268 #define FS_OFFSET_410_SD_MUTEX 0xE80268
#define FS_OFFSET_410_NAND_MUTEX 0xE7BC60 #define FS_OFFSET_410_NAND_MUTEX 0xE7BC60
@@ -41,16 +43,15 @@
#define FS_OFFSET_410_SDMMC_DAS_HANDLE 0xE7ABF0 #define FS_OFFSET_410_SDMMC_DAS_HANDLE 0xE7ABF0
// NOPs // NOPs
#define FS_OFFSET_410_SHUTDOWN_SD 0x32D70
#define FS_OFFSET_410_SD_DAS_INIT 0x0 #define FS_OFFSET_410_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_410_NINTENDO_PATHS \ #define FS_OFFSET_410_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x0002023C}, \ {.opcode_reg = 3, .adrp_offset = 0x0002023C, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00021BE8}, \ {.opcode_reg = 3, .adrp_offset = 0x00021BE8, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 3, .adrp_offset = 0x00021EC4}, \ {.opcode_reg = 3, .adrp_offset = 0x00021EC4, .add_rel_offset = 0x0000000C}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_410_H__ #endif // __FS_410_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_410_EXFAT_LOCK_MUTEX 0x39A0 #define FS_OFFSET_410_EXFAT_LOCK_MUTEX 0x39A0
#define FS_OFFSET_410_EXFAT_UNLOCK_MUTEX 0x3A0C #define FS_OFFSET_410_EXFAT_UNLOCK_MUTEX 0x3A0C
#define FS_OFFSET_410_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x9DBAC
// Misc Data // Misc Data
#define FS_OFFSET_410_EXFAT_SD_MUTEX 0xF63268 #define FS_OFFSET_410_EXFAT_SD_MUTEX 0xF63268
#define FS_OFFSET_410_EXFAT_NAND_MUTEX 0xF5EC60 #define FS_OFFSET_410_EXFAT_NAND_MUTEX 0xF5EC60
@@ -41,16 +43,15 @@
#define FS_OFFSET_410_EXFAT_SDMMC_DAS_HANDLE 0xF5DBF0 #define FS_OFFSET_410_EXFAT_SDMMC_DAS_HANDLE 0xF5DBF0
// NOPs // NOPs
#define FS_OFFSET_410_EXFAT_SHUTDOWN_SD 0x32D70
#define FS_OFFSET_410_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_410_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_410_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_410_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x0002023C}, \ {.opcode_reg = 3, .adrp_offset = 0x0002023C, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00021BE8}, \ {.opcode_reg = 3, .adrp_offset = 0x00021BE8, .add_rel_offset = 12}, \
{.opcode_reg = 3, .adrp_offset = 0x00021EC4}, \ {.opcode_reg = 3, .adrp_offset = 0x00021EC4, .add_rel_offset = 12}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_410_EXFAT_H__ #endif // __FS_410_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_500_LOCK_MUTEX 0x4080 #define FS_OFFSET_500_LOCK_MUTEX 0x4080
#define FS_OFFSET_500_UNLOCK_MUTEX 0x40D0 #define FS_OFFSET_500_UNLOCK_MUTEX 0x40D0
#define FS_OFFSET_500_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9380
// Misc Data // Misc Data
#define FS_OFFSET_500_SD_MUTEX 0xEC3268 #define FS_OFFSET_500_SD_MUTEX 0xEC3268
#define FS_OFFSET_500_NAND_MUTEX 0xEBDE58 #define FS_OFFSET_500_NAND_MUTEX 0xEBDE58
@@ -41,16 +43,15 @@
#define FS_OFFSET_500_SDMMC_DAS_HANDLE 0xEBCE30 #define FS_OFFSET_500_SDMMC_DAS_HANDLE 0xEBCE30
// NOPs // NOPs
#define FS_OFFSET_500_SHUTDOWN_SD 0x443E8
#define FS_OFFSET_500_SD_DAS_INIT 0x0 #define FS_OFFSET_500_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_500_NINTENDO_PATHS \ #define FS_OFFSET_500_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x00028980}, \ {.opcode_reg = 3, .adrp_offset = 0x00028980, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002ACE4}, \ {.opcode_reg = 3, .adrp_offset = 0x0002ACE4, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002B220}, \ {.opcode_reg = 3, .adrp_offset = 0x0002B220, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_500_H__ #endif // __FS_500_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_500_EXFAT_LOCK_MUTEX 0x4080 #define FS_OFFSET_500_EXFAT_LOCK_MUTEX 0x4080
#define FS_OFFSET_500_EXFAT_UNLOCK_MUTEX 0x40D0 #define FS_OFFSET_500_EXFAT_UNLOCK_MUTEX 0x40D0
#define FS_OFFSET_500_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9380
// Misc Data // Misc Data
#define FS_OFFSET_500_EXFAT_SD_MUTEX 0xFA8268 #define FS_OFFSET_500_EXFAT_SD_MUTEX 0xFA8268
#define FS_OFFSET_500_EXFAT_NAND_MUTEX 0xFA2E58 #define FS_OFFSET_500_EXFAT_NAND_MUTEX 0xFA2E58
@@ -41,16 +43,15 @@
#define FS_OFFSET_500_EXFAT_SDMMC_DAS_HANDLE 0xFA1E30 #define FS_OFFSET_500_EXFAT_SDMMC_DAS_HANDLE 0xFA1E30
// NOPs // NOPs
#define FS_OFFSET_500_EXFAT_SHUTDOWN_SD 0x443E8
#define FS_OFFSET_500_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_500_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_500_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_500_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x00028980}, \ {.opcode_reg = 3, .adrp_offset = 0x00028980, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002ACE4}, \ {.opcode_reg = 3, .adrp_offset = 0x0002ACE4, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002B220}, \ {.opcode_reg = 3, .adrp_offset = 0x0002B220, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_500_EXFAT_H__ #endif // __FS_500_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_510_LOCK_MUTEX 0x4080 #define FS_OFFSET_510_LOCK_MUTEX 0x4080
#define FS_OFFSET_510_UNLOCK_MUTEX 0x40D0 #define FS_OFFSET_510_UNLOCK_MUTEX 0x40D0
#define FS_OFFSET_510_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9750
// Misc Data // Misc Data
#define FS_OFFSET_510_SD_MUTEX 0xEC4268 #define FS_OFFSET_510_SD_MUTEX 0xEC4268
#define FS_OFFSET_510_NAND_MUTEX 0xEBEE58 #define FS_OFFSET_510_NAND_MUTEX 0xEBEE58
@@ -41,16 +43,15 @@
#define FS_OFFSET_510_SDMMC_DAS_HANDLE 0xEBDE30 #define FS_OFFSET_510_SDMMC_DAS_HANDLE 0xEBDE30
// NOPs // NOPs
#define FS_OFFSET_510_SHUTDOWN_SD 0x44578
#define FS_OFFSET_510_SD_DAS_INIT 0x0 #define FS_OFFSET_510_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_510_NINTENDO_PATHS \ #define FS_OFFSET_510_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000289B0}, \ {.opcode_reg = 3, .adrp_offset = 0x000289B0, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002AD14}, \ {.opcode_reg = 3, .adrp_offset = 0x0002AD14, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002B250}, \ {.opcode_reg = 3, .adrp_offset = 0x0002B250, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_510_H__ #endif // __FS_510_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_510_EXFAT_LOCK_MUTEX 0x4080 #define FS_OFFSET_510_EXFAT_LOCK_MUTEX 0x4080
#define FS_OFFSET_510_EXFAT_UNLOCK_MUTEX 0x40D0 #define FS_OFFSET_510_EXFAT_UNLOCK_MUTEX 0x40D0
#define FS_OFFSET_510_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0xC9750
// Misc Data // Misc Data
#define FS_OFFSET_510_EXFAT_SD_MUTEX 0xFA9268 #define FS_OFFSET_510_EXFAT_SD_MUTEX 0xFA9268
#define FS_OFFSET_510_EXFAT_NAND_MUTEX 0xFA3E58 #define FS_OFFSET_510_EXFAT_NAND_MUTEX 0xFA3E58
@@ -41,16 +43,15 @@
#define FS_OFFSET_510_EXFAT_SDMMC_DAS_HANDLE 0xFA2E30 #define FS_OFFSET_510_EXFAT_SDMMC_DAS_HANDLE 0xFA2E30
// NOPs // NOPs
#define FS_OFFSET_510_EXFAT_SHUTDOWN_SD 0x44578
#define FS_OFFSET_510_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_510_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_510_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_510_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000289B0}, \ {.opcode_reg = 3, .adrp_offset = 0x000289B0, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002AD14}, \ {.opcode_reg = 3, .adrp_offset = 0x0002AD14, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0002B250}, \ {.opcode_reg = 3, .adrp_offset = 0x0002B250, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_510_EXFAT_H__ #endif // __FS_510_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_600_LOCK_MUTEX 0x1412C0 #define FS_OFFSET_600_LOCK_MUTEX 0x1412C0
#define FS_OFFSET_600_UNLOCK_MUTEX 0x141310 #define FS_OFFSET_600_UNLOCK_MUTEX 0x141310
#define FS_OFFSET_600_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x148500
// Misc Data // Misc Data
#define FS_OFFSET_600_SD_MUTEX 0xF06268 #define FS_OFFSET_600_SD_MUTEX 0xF06268
#define FS_OFFSET_600_NAND_MUTEX 0xF01BA0 #define FS_OFFSET_600_NAND_MUTEX 0xF01BA0
@@ -41,17 +43,16 @@
#define FS_OFFSET_600_SDMMC_DAS_HANDLE 0xE01670 #define FS_OFFSET_600_SDMMC_DAS_HANDLE 0xE01670
// NOPs // NOPs
#define FS_OFFSET_600_SHUTDOWN_SD 0xB2F28
#define FS_OFFSET_600_SD_DAS_INIT 0x0 #define FS_OFFSET_600_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_600_NINTENDO_PATHS \ #define FS_OFFSET_600_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000790DC}, \ {.opcode_reg = 3, .adrp_offset = 0x000790DC, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0007A924}, \ {.opcode_reg = 3, .adrp_offset = 0x0007A924, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0007AB18}, \ {.opcode_reg = 3, .adrp_offset = 0x0007AB18, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0007AEF4}, \ {.opcode_reg = 3, .adrp_offset = 0x0007AEF4, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0} \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0} \
} }
#endif // __FS_600_H__ #endif // __FS_600_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_600_EXFAT_LOCK_MUTEX 0x14C9C0 #define FS_OFFSET_600_EXFAT_LOCK_MUTEX 0x14C9C0
#define FS_OFFSET_600_EXFAT_UNLOCK_MUTEX 0x14CA10 #define FS_OFFSET_600_EXFAT_UNLOCK_MUTEX 0x14CA10
#define FS_OFFSET_600_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x153C00
// Misc Data // Misc Data
#define FS_OFFSET_600_EXFAT_SD_MUTEX 0xFEB268 #define FS_OFFSET_600_EXFAT_SD_MUTEX 0xFEB268
#define FS_OFFSET_600_EXFAT_NAND_MUTEX 0xFE6BA0 #define FS_OFFSET_600_EXFAT_NAND_MUTEX 0xFE6BA0
@@ -41,17 +43,16 @@
#define FS_OFFSET_600_EXFAT_SDMMC_DAS_HANDLE 0xEE6670 #define FS_OFFSET_600_EXFAT_SDMMC_DAS_HANDLE 0xEE6670
// NOPs // NOPs
#define FS_OFFSET_600_EXFAT_SHUTDOWN_SD 0xBE628
#define FS_OFFSET_600_EXFAT_SD_DAS_INIT 0x0 #define FS_OFFSET_600_EXFAT_SD_DAS_INIT 0x0
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_600_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_600_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x000847DC}, \ {.opcode_reg = 3, .adrp_offset = 0x000847DC, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00086024}, \ {.opcode_reg = 3, .adrp_offset = 0x00086024, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00086218}, \ {.opcode_reg = 3, .adrp_offset = 0x00086218, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x000865F4}, \ {.opcode_reg = 3, .adrp_offset = 0x000865F4, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0} \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0} \
} }
#endif // __FS_600_EXFAT_H__ #endif // __FS_600_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_700_LOCK_MUTEX 0x148A90 #define FS_OFFSET_700_LOCK_MUTEX 0x148A90
#define FS_OFFSET_700_UNLOCK_MUTEX 0x148AE0 #define FS_OFFSET_700_UNLOCK_MUTEX 0x148AE0
#define FS_OFFSET_700_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x14FD50
// Misc Data // Misc Data
#define FS_OFFSET_700_SD_MUTEX 0xF123E8 #define FS_OFFSET_700_SD_MUTEX 0xF123E8
#define FS_OFFSET_700_NAND_MUTEX 0xF0DBE8 #define FS_OFFSET_700_NAND_MUTEX 0xF0DBE8
@@ -41,18 +43,17 @@
#define FS_OFFSET_700_SDMMC_DAS_HANDLE 0xE0E7A0 #define FS_OFFSET_700_SDMMC_DAS_HANDLE 0xE0E7A0
// NOPs // NOPs
#define FS_OFFSET_700_SHUTDOWN_SD 0xB8FCC
#define FS_OFFSET_700_SD_DAS_INIT 0x85FE8 #define FS_OFFSET_700_SD_DAS_INIT 0x85FE8
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_700_NINTENDO_PATHS \ #define FS_OFFSET_700_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x0007DA90}, \ {.opcode_reg = 3, .adrp_offset = 0x0007DA90, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0007F344}, \ {.opcode_reg = 3, .adrp_offset = 0x0007F344, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0007F538}, \ {.opcode_reg = 3, .adrp_offset = 0x0007F538, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0007F914}, \ {.opcode_reg = 3, .adrp_offset = 0x0007F914, .add_rel_offset = 4}, \
{.opcode_reg = 4, .adrp_offset = 0x0007FAD8}, \ {.opcode_reg = 4, .adrp_offset = 0x0007FAD8, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_700_H__ #endif // __FS_700_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_700_EXFAT_LOCK_MUTEX 0x154040 #define FS_OFFSET_700_EXFAT_LOCK_MUTEX 0x154040
#define FS_OFFSET_700_EXFAT_UNLOCK_MUTEX 0x154090 #define FS_OFFSET_700_EXFAT_UNLOCK_MUTEX 0x154090
#define FS_OFFSET_700_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x15B300
// Misc Data // Misc Data
#define FS_OFFSET_700_EXFAT_SD_MUTEX 0xFF73E8 #define FS_OFFSET_700_EXFAT_SD_MUTEX 0xFF73E8
#define FS_OFFSET_700_EXFAT_NAND_MUTEX 0xFF2BE8 #define FS_OFFSET_700_EXFAT_NAND_MUTEX 0xFF2BE8
@@ -41,18 +43,17 @@
#define FS_OFFSET_700_EXFAT_SDMMC_DAS_HANDLE 0xEF3A00 #define FS_OFFSET_700_EXFAT_SDMMC_DAS_HANDLE 0xEF3A00
// NOPs // NOPs
#define FS_OFFSET_700_EXFAT_SHUTDOWN_SD 0xC457C
#define FS_OFFSET_700_EXFAT_SD_DAS_INIT 0x91598 #define FS_OFFSET_700_EXFAT_SD_DAS_INIT 0x91598
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_700_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_700_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x00089040}, \ {.opcode_reg = 3, .adrp_offset = 0x00089040, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008A8F4}, \ {.opcode_reg = 3, .adrp_offset = 0x0008A8F4, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008AAE8}, \ {.opcode_reg = 3, .adrp_offset = 0x0008AAE8, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008AEC4}, \ {.opcode_reg = 3, .adrp_offset = 0x0008AEC4, .add_rel_offset = 4}, \
{.opcode_reg = 4, .adrp_offset = 0x0008B088}, \ {.opcode_reg = 4, .adrp_offset = 0x0008B088, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0}, \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
} }
#endif // __FS_700_EXFAT_H__ #endif // __FS_700_EXFAT_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_800_LOCK_MUTEX 0x14B6D0 #define FS_OFFSET_800_LOCK_MUTEX 0x14B6D0
#define FS_OFFSET_800_UNLOCK_MUTEX 0x14B720 #define FS_OFFSET_800_UNLOCK_MUTEX 0x14B720
#define FS_OFFSET_800_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1529E0
// Misc Data // Misc Data
#define FS_OFFSET_800_SD_MUTEX 0xF1A3E8 #define FS_OFFSET_800_SD_MUTEX 0xF1A3E8
#define FS_OFFSET_800_NAND_MUTEX 0xF15BE8 #define FS_OFFSET_800_NAND_MUTEX 0xF15BE8
@@ -41,18 +43,17 @@
#define FS_OFFSET_800_SDMMC_DAS_HANDLE 0xE167C0 #define FS_OFFSET_800_SDMMC_DAS_HANDLE 0xE167C0
// NOPs // NOPs
#define FS_OFFSET_800_SHUTDOWN_SD 0xBAF6C
#define FS_OFFSET_800_SD_DAS_INIT 0x87D58 #define FS_OFFSET_800_SD_DAS_INIT 0x87D58
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_800_NINTENDO_PATHS \ #define FS_OFFSET_800_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x0007F5F0}, \ {.opcode_reg = 3, .adrp_offset = 0x0007F5F0, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00081084}, \ {.opcode_reg = 3, .adrp_offset = 0x00081084, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00081278}, \ {.opcode_reg = 3, .adrp_offset = 0x00081278, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00081654}, \ {.opcode_reg = 3, .adrp_offset = 0x00081654, .add_rel_offset = 4}, \
{.opcode_reg = 4, .adrp_offset = 0x00081818}, \ {.opcode_reg = 4, .adrp_offset = 0x00081818, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0} \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0} \
} }
#endif // __FS_800_H__ #endif // __FS_800_H__

View File

@@ -34,6 +34,8 @@
#define FS_OFFSET_800_EXFAT_LOCK_MUTEX 0x156C80 #define FS_OFFSET_800_EXFAT_LOCK_MUTEX 0x156C80
#define FS_OFFSET_800_EXFAT_UNLOCK_MUTEX 0x156CD0 #define FS_OFFSET_800_EXFAT_UNLOCK_MUTEX 0x156CD0
#define FS_OFFSET_800_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x15DF90
// Misc Data // Misc Data
#define FS_OFFSET_800_EXFAT_SD_MUTEX 0xFFE3E8 #define FS_OFFSET_800_EXFAT_SD_MUTEX 0xFFE3E8
#define FS_OFFSET_800_EXFAT_NAND_MUTEX 0xFF9BE8 #define FS_OFFSET_800_EXFAT_NAND_MUTEX 0xFF9BE8
@@ -41,18 +43,17 @@
#define FS_OFFSET_800_EXFAT_SDMMC_DAS_HANDLE 0xEFAA20 #define FS_OFFSET_800_EXFAT_SDMMC_DAS_HANDLE 0xEFAA20
// NOPs // NOPs
#define FS_OFFSET_800_EXFAT_SHUTDOWN_SD 0xC651C
#define FS_OFFSET_800_EXFAT_SD_DAS_INIT 0x93308 #define FS_OFFSET_800_EXFAT_SD_DAS_INIT 0x93308
// Nintendo Paths // Nintendo Paths
#define FS_OFFSET_800_EXFAT_NINTENDO_PATHS \ #define FS_OFFSET_800_EXFAT_NINTENDO_PATHS \
{ \ { \
{.opcode_reg = 3, .adrp_offset = 0x0008ABA0}, \ {.opcode_reg = 3, .adrp_offset = 0x0008ABA0, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008C634}, \ {.opcode_reg = 3, .adrp_offset = 0x0008C634, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008C828}, \ {.opcode_reg = 3, .adrp_offset = 0x0008C828, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008CC04}, \ {.opcode_reg = 3, .adrp_offset = 0x0008CC04, .add_rel_offset = 4}, \
{.opcode_reg = 4, .adrp_offset = 0x0008CDC8}, \ {.opcode_reg = 4, .adrp_offset = 0x0008CDC8, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0} \ {.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0} \
} }
#endif // __FS_800_EXFAT_H__ #endif // __FS_800_EXFAT_H__

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
* Copyright (c) 2019 Atmosphere-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/>.
*/
#ifndef __FS_810_H__
#define __FS_810_H__
// Accessor vtable getters
#define FS_OFFSET_810_SDMMC_ACCESSOR_GC 0x15EA20
#define FS_OFFSET_810_SDMMC_ACCESSOR_SD 0x15E790
#define FS_OFFSET_810_SDMMC_ACCESSOR_NAND 0x15AC80
// Hooks
#define FS_OFFSET_810_SDMMC_WRAPPER_READ 0x152A80
#define FS_OFFSET_810_SDMMC_WRAPPER_WRITE 0x152B60
#define FS_OFFSET_810_RTLD 0x5B4
#define FS_OFFSET_810_RTLD_DESTINATION 0x9C
#define FS_OFFSET_810_CLKRST_SET_MIN_V_CLK_RATE 0x16F370
// Misc funcs
#define FS_OFFSET_810_LOCK_MUTEX 0x14B6D0
#define FS_OFFSET_810_UNLOCK_MUTEX 0x14B720
#define FS_OFFSET_810_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1529E0
// Misc Data
#define FS_OFFSET_810_SD_MUTEX 0xF1A3E8
#define FS_OFFSET_810_NAND_MUTEX 0xF15BE8
#define FS_OFFSET_810_ACTIVE_PARTITION 0xF15C28
#define FS_OFFSET_810_SDMMC_DAS_HANDLE 0xE167C0
// NOPs
#define FS_OFFSET_810_SD_DAS_INIT 0x87D58
// Nintendo Paths
#define FS_OFFSET_810_NINTENDO_PATHS \
{ \
{.opcode_reg = 3, .adrp_offset = 0x0007F5F0, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00081084, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00081278, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x00081654, .add_rel_offset = 4}, \
{.opcode_reg = 4, .adrp_offset = 0x00081818, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0} \
}
#endif // __FS_810_H__

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
* Copyright (c) 2019 Atmosphere-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/>.
*/
#ifndef __FS_810_EXFAT_H__
#define __FS_810_EXFAT_H__
// Accessor vtable getters
#define FS_OFFSET_810_EXFAT_SDMMC_ACCESSOR_GC 0x169FD0
#define FS_OFFSET_810_EXFAT_SDMMC_ACCESSOR_SD 0x169D40
#define FS_OFFSET_810_EXFAT_SDMMC_ACCESSOR_NAND 0x166230
// Hooks
#define FS_OFFSET_810_EXFAT_SDMMC_WRAPPER_READ 0x15E030
#define FS_OFFSET_810_EXFAT_SDMMC_WRAPPER_WRITE 0x15E110
#define FS_OFFSET_810_EXFAT_RTLD 0x5B4
#define FS_OFFSET_810_EXFAT_RTLD_DESTINATION 0x9C
#define FS_OFFSET_810_EXFAT_CLKRST_SET_MIN_V_CLK_RATE 0x17A920
// Misc funcs
#define FS_OFFSET_810_EXFAT_LOCK_MUTEX 0x156C80
#define FS_OFFSET_810_EXFAT_UNLOCK_MUTEX 0x156CD0
#define FS_OFFSET_810_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x15DF90
// Misc Data
#define FS_OFFSET_810_EXFAT_SD_MUTEX 0xFFE3E8
#define FS_OFFSET_810_EXFAT_NAND_MUTEX 0xFF9BE8
#define FS_OFFSET_810_EXFAT_ACTIVE_PARTITION 0xFF9C28
#define FS_OFFSET_810_EXFAT_SDMMC_DAS_HANDLE 0xEFAA20
// NOPs
#define FS_OFFSET_810_EXFAT_SD_DAS_INIT 0x93308
// Nintendo Paths
#define FS_OFFSET_810_EXFAT_NINTENDO_PATHS \
{ \
{.opcode_reg = 3, .adrp_offset = 0x0008ABA0, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008C634, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008C828, .add_rel_offset = 4}, \
{.opcode_reg = 3, .adrp_offset = 0x0008CC04, .add_rel_offset = 4}, \
{.opcode_reg = 4, .adrp_offset = 0x0008CDC8, .add_rel_offset = 4}, \
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0} \
}
#endif // __FS_810_EXFAT_H__

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
* Copyright (c) 2019 Atmosphere-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/>.
*/
#ifndef __FS_900_H__
#define __FS_900_H__
// Accessor vtable getters
#define FS_OFFSET_900_SDMMC_ACCESSOR_GC 0x1430F0
#define FS_OFFSET_900_SDMMC_ACCESSOR_SD 0x141200
#define FS_OFFSET_900_SDMMC_ACCESSOR_NAND 0x13C080
// Hooks
#define FS_OFFSET_900_SDMMC_WRAPPER_READ 0x1377E0
#define FS_OFFSET_900_SDMMC_WRAPPER_WRITE 0x1378C0
#define FS_OFFSET_900_RTLD 0x454
#define FS_OFFSET_900_RTLD_DESTINATION 0x9C
#define FS_OFFSET_900_CLKRST_SET_MIN_V_CLK_RATE 0x136A00
// Misc funcs
#define FS_OFFSET_900_LOCK_MUTEX 0x25280
#define FS_OFFSET_900_UNLOCK_MUTEX 0x252D0
#define FS_OFFSET_900_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137740
// Misc Data
#define FS_OFFSET_900_SD_MUTEX 0xE1D3E8
#define FS_OFFSET_900_NAND_MUTEX 0xE18258
#define FS_OFFSET_900_ACTIVE_PARTITION 0xE18298
#define FS_OFFSET_900_SDMMC_DAS_HANDLE 0xDFEFA0
// NOPs
#define FS_OFFSET_900_SD_DAS_INIT 0x1472BC
// Nintendo Paths
#define FS_OFFSET_900_NINTENDO_PATHS \
{ \
{.opcode_reg = 3, .adrp_offset = 0x00068A60, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00070A40, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081CB4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081EF4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 4, .adrp_offset = 0x0008211C, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
}
#endif // __FS_900_H__

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
* Copyright (c) 2019 Atmosphere-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/>.
*/
#ifndef __FS_900_EXFAT_H__
#define __FS_900_EXFAT_H__
// Accessor vtable getters
#define FS_OFFSET_900_EXFAT_SDMMC_ACCESSOR_GC 0x1430F0
#define FS_OFFSET_900_EXFAT_SDMMC_ACCESSOR_SD 0x141200
#define FS_OFFSET_900_EXFAT_SDMMC_ACCESSOR_NAND 0x13C080
// Hooks
#define FS_OFFSET_900_EXFAT_SDMMC_WRAPPER_READ 0x1377E0
#define FS_OFFSET_900_EXFAT_SDMMC_WRAPPER_WRITE 0x1378C0
#define FS_OFFSET_900_EXFAT_RTLD 0x454
#define FS_OFFSET_900_EXFAT_RTLD_DESTINATION 0x9C
#define FS_OFFSET_900_EXFAT_CLKRST_SET_MIN_V_CLK_RATE 0x136A00
// Misc funcs
#define FS_OFFSET_900_EXFAT_LOCK_MUTEX 0x25280
#define FS_OFFSET_900_EXFAT_UNLOCK_MUTEX 0x252D0
#define FS_OFFSET_900_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137740
// Misc Data
#define FS_OFFSET_900_EXFAT_SD_MUTEX 0xE2B3E8
#define FS_OFFSET_900_EXFAT_NAND_MUTEX 0xE26258
#define FS_OFFSET_900_EXFAT_ACTIVE_PARTITION 0xE26298
#define FS_OFFSET_900_EXFAT_SDMMC_DAS_HANDLE 0xE0CFA0
// NOPs
#define FS_OFFSET_900_EXFAT_SD_DAS_INIT 0x1472BC
// Nintendo Paths
#define FS_OFFSET_900_EXFAT_NINTENDO_PATHS \
{ \
{.opcode_reg = 3, .adrp_offset = 0x00068A60, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00070A40, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081CB4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081EF4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 4, .adrp_offset = 0x0008211C, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
}
#endif // __FS_900_EXFAT_H__

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
* Copyright (c) 2019 Atmosphere-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/>.
*/
#ifndef __FS_910_H__
#define __FS_910_H__
// Accessor vtable getters
#define FS_OFFSET_910_SDMMC_ACCESSOR_GC 0x143100
#define FS_OFFSET_910_SDMMC_ACCESSOR_SD 0x141210
#define FS_OFFSET_910_SDMMC_ACCESSOR_NAND 0x13C090
// Hooks
#define FS_OFFSET_910_SDMMC_WRAPPER_READ 0x1377F0
#define FS_OFFSET_910_SDMMC_WRAPPER_WRITE 0x1378D0
#define FS_OFFSET_910_RTLD 0x454
#define FS_OFFSET_910_RTLD_DESTINATION 0x9C
#define FS_OFFSET_910_CLKRST_SET_MIN_V_CLK_RATE 0x136A10
// Misc funcs
#define FS_OFFSET_910_LOCK_MUTEX 0x25280
#define FS_OFFSET_910_UNLOCK_MUTEX 0x252D0
#define FS_OFFSET_910_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137750
// Misc Data
#define FS_OFFSET_910_SD_MUTEX 0xE1D3E8
#define FS_OFFSET_910_NAND_MUTEX 0xE18258
#define FS_OFFSET_910_ACTIVE_PARTITION 0xE18298
#define FS_OFFSET_910_SDMMC_DAS_HANDLE 0xDFEFA0
// NOPs
#define FS_OFFSET_910_SD_DAS_INIT 0x1472CC
// Nintendo Paths
#define FS_OFFSET_910_NINTENDO_PATHS \
{ \
{.opcode_reg = 3, .adrp_offset = 0x00068A70, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00070A50, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081CC4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081F04, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 4, .adrp_offset = 0x0008212C, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
}
#endif // __FS_910_H__

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
* Copyright (c) 2019 Atmosphere-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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/>.
*/
#ifndef __FS_910_EXFAT_H__
#define __FS_910_EXFAT_H__
// Accessor vtable getters
#define FS_OFFSET_910_EXFAT_SDMMC_ACCESSOR_GC 0x143100
#define FS_OFFSET_910_EXFAT_SDMMC_ACCESSOR_SD 0x141210
#define FS_OFFSET_910_EXFAT_SDMMC_ACCESSOR_NAND 0x13C090
// Hooks
#define FS_OFFSET_910_EXFAT_SDMMC_WRAPPER_READ 0x1377F0
#define FS_OFFSET_910_EXFAT_SDMMC_WRAPPER_WRITE 0x1378D0
#define FS_OFFSET_910_EXFAT_RTLD 0x454
#define FS_OFFSET_910_EXFAT_RTLD_DESTINATION 0x9C
#define FS_OFFSET_910_EXFAT_CLKRST_SET_MIN_V_CLK_RATE 0x136A10
// Misc funcs
#define FS_OFFSET_910_EXFAT_LOCK_MUTEX 0x25280
#define FS_OFFSET_910_EXFAT_UNLOCK_MUTEX 0x252D0
#define FS_OFFSET_910_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x137750
// Misc Data
#define FS_OFFSET_910_EXFAT_SD_MUTEX 0xE2B3E8
#define FS_OFFSET_910_EXFAT_NAND_MUTEX 0xE26258
#define FS_OFFSET_910_EXFAT_ACTIVE_PARTITION 0xE26298
#define FS_OFFSET_910_EXFAT_SDMMC_DAS_HANDLE 0xE0CFA0
// NOPs
#define FS_OFFSET_910_EXFAT_SD_DAS_INIT 0x1472CC
// Nintendo Paths
#define FS_OFFSET_910_EXFAT_NINTENDO_PATHS \
{ \
{.opcode_reg = 3, .adrp_offset = 0x00068A70, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00070A50, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081CC4, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 3, .adrp_offset = 0x00081F04, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 4, .adrp_offset = 0x0008212C, .add_rel_offset = 0x00000004}, \
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
}
#endif // __FS_910_EXFAT_H__

View File

@@ -23,9 +23,15 @@
#include "sd.h" #include "sd.h"
#include "../utils/types.h" #include "../utils/types.h"
#include "../utils/util.h" #include "../utils/util.h"
#include "../utils/fatal.h"
#include "../emuMMC/emummc.h"
#define DPRINTF(...) //fprintf(stdout, __VA_ARGS__) #define DPRINTF(...) //fprintf(stdout, __VA_ARGS__)
sdmmc_accessor_t *_current_accessor = NULL;
bool sdmmc_memcpy_buf = false;
extern bool custom_driver;
static inline u32 unstuff_bits(u32 *resp, u32 start, u32 size) static inline u32 unstuff_bits(u32 *resp, u32 start, u32 size)
{ {
const u32 mask = (size < 32 ? 1 << size : 0) - 1; const u32 mask = (size < 32 ? 1 << size : 0) - 1;
@@ -41,6 +47,119 @@ static inline u32 unstuff_bits(u32 *resp, u32 start, u32 size)
* Common functions for SD and MMC. * Common functions for SD and MMC.
*/ */
// FS DMA calculations.
intptr_t sdmmc_calculate_dma_addr(sdmmc_accessor_t *_this, void *buf, unsigned int num_sectors)
{
int dma_buf_idx = 0;
char *_buf = (char *)buf;
char *actual_buf_start = _buf;
char *actual_buf_end = &_buf[512 * num_sectors];
char *dma_buffer_start = _this->parent->dmaBuffers[0].device_addr_buffer;
if (dma_buffer_start <= _buf && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[0].device_addr_buffer_size])
{
dma_buf_idx = 0;
}
else
{
dma_buffer_start = _this->parent->dmaBuffers[1].device_addr_buffer;
if (dma_buffer_start <= actual_buf_start && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[1].device_addr_buffer_size])
{
dma_buf_idx = 1;
}
else
{
dma_buffer_start = _this->parent->dmaBuffers[2].device_addr_buffer;
if (dma_buffer_start <= actual_buf_start && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[2].device_addr_buffer_size])
{
dma_buf_idx = 2;
}
else
{
// If buffer is on a random heap
return 0;
}
}
}
sdmmc_memcpy_buf = false;
intptr_t admaaddr = (intptr_t)&_this->parent->dmaBuffers[dma_buf_idx].device_addr_buffer_masked[actual_buf_start - dma_buffer_start];
return admaaddr;
}
int sdmmc_calculate_dma_index(sdmmc_accessor_t *_this, void *buf, unsigned int num_sectors)
{
int dma_buf_idx = 0;
char *_buf = (char *)buf;
char *actual_buf_start = _buf;
char *actual_buf_end = &_buf[512 * num_sectors];
char *dma_buffer_start = _this->parent->dmaBuffers[0].device_addr_buffer;
if (dma_buffer_start <= _buf && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[0].device_addr_buffer_size])
{
dma_buf_idx = 0;
}
else
{
dma_buffer_start = _this->parent->dmaBuffers[1].device_addr_buffer;
if (dma_buffer_start <= actual_buf_start && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[1].device_addr_buffer_size])
{
dma_buf_idx = 1;
}
else
{
dma_buffer_start = _this->parent->dmaBuffers[2].device_addr_buffer;
if (dma_buffer_start <= actual_buf_start && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[2].device_addr_buffer_size])
{
dma_buf_idx = 2;
}
else
{
// If buffer is on a random heap
return -1;
}
}
}
sdmmc_memcpy_buf = false;
return dma_buf_idx;
}
int sdmmc_calculate_fitting_dma_index(sdmmc_accessor_t *_this, unsigned int num_sectors)
{
int dma_buf_idx = 0;
int blkSize = num_sectors * 512;
if (_this->parent->dmaBuffers[0].device_addr_buffer_size >= blkSize)
{
dma_buf_idx = 0;
}
else
{
if (_this->parent->dmaBuffers[1].device_addr_buffer_size >= blkSize)
{
dma_buf_idx = 1;
}
else
{
if (_this->parent->dmaBuffers[2].device_addr_buffer_size >= blkSize)
{
dma_buf_idx = 2;
}
else
{
// Can't find a fitting buffer
return 0;
}
}
}
sdmmc_memcpy_buf = true;
return dma_buf_idx;
}
static int _sdmmc_storage_check_result(u32 res) static int _sdmmc_storage_check_result(u32 res)
{ {
//Error mask: //Error mask:
@@ -129,9 +248,11 @@ static int _sdmmc_storage_check_status(sdmmc_storage_t *storage)
static int _sdmmc_storage_readwrite_ex(sdmmc_storage_t *storage, u32 *blkcnt_out, u32 sector, u32 num_sectors, void *buf, u32 is_write) static int _sdmmc_storage_readwrite_ex(sdmmc_storage_t *storage, u32 *blkcnt_out, u32 sector, u32 num_sectors, void *buf, u32 is_write)
{ {
sdmmc_cmd_t cmdbuf; sdmmc_cmd_t cmdbuf;
sdmmc_req_t reqbuf;
u32 tmp = 0;
sdmmc_init_cmd(&cmdbuf, is_write ? MMC_WRITE_MULTIPLE_BLOCK : MMC_READ_MULTIPLE_BLOCK, sector, SDMMC_RSP_TYPE_1, 0); sdmmc_init_cmd(&cmdbuf, is_write ? MMC_WRITE_MULTIPLE_BLOCK : MMC_READ_MULTIPLE_BLOCK, sector, SDMMC_RSP_TYPE_1, 0);
sdmmc_req_t reqbuf;
reqbuf.buf = buf; reqbuf.buf = buf;
reqbuf.num_sectors = num_sectors; reqbuf.num_sectors = num_sectors;
reqbuf.blksize = 512; reqbuf.blksize = 512;
@@ -141,11 +262,11 @@ static int _sdmmc_storage_readwrite_ex(sdmmc_storage_t *storage, u32 *blkcnt_out
if (!sdmmc_execute_cmd(storage->sdmmc, &cmdbuf, &reqbuf, blkcnt_out)) if (!sdmmc_execute_cmd(storage->sdmmc, &cmdbuf, &reqbuf, blkcnt_out))
{ {
u32 tmp = 0;
sdmmc_stop_transmission(storage->sdmmc, &tmp); sdmmc_stop_transmission(storage->sdmmc, &tmp);
_sdmmc_storage_get_status(storage, &tmp, 0); _sdmmc_storage_get_status(storage, &tmp, 0);
return 0; return 0;
} }
return 1; return 1;
} }
@@ -186,15 +307,113 @@ out:;
return 1; return 1;
} }
extern _sdmmc_accessor_sd sdmmc_accessor_sd;
extern _sdmmc_accessor_nand sdmmc_accessor_nand;
int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf) int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf)
{
if (!custom_driver)
{
sdmmc_accessor_t *accessor_sd = sdmmc_accessor_sd();
sdmmc_accessor_t *accessor_nand = sdmmc_accessor_nand();
if (sdmmc_calculate_dma_addr(accessor_sd, buf, num_sectors))
{
return !accessor_sd->vtab->read_write(accessor_sd, sector, num_sectors, buf, num_sectors * 512, 1);
}
else
{
if (sdmmc_calculate_dma_addr(accessor_nand, buf, num_sectors))
{
// buf is on the nand dma buffer
int original_dma_idx = sdmmc_calculate_dma_index(accessor_nand, buf, num_sectors);
sdmmc_dma_buffer_t *original_dma_buffer = &accessor_nand->parent->dmaBuffers[original_dma_idx];
// Next entry
int dma_idx = sdmmc_calculate_fitting_dma_index(accessor_sd, num_sectors) + 1;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer = original_dma_buffer->device_addr_buffer;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_masked = original_dma_buffer->device_addr_buffer_masked;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_size = original_dma_buffer->device_addr_buffer_size;
u64 res = accessor_sd->vtab->read_write(accessor_sd, sector, num_sectors, buf, num_sectors * 512, 1);
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer = 0;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_masked = 0;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_size = 0;
return !res;
}
else
{
// buf is on a heap
int dma_idx = sdmmc_calculate_fitting_dma_index(accessor_sd, num_sectors);
void *dma_buf = &accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer[0];
u64 res = accessor_sd->vtab->read_write(accessor_sd, sector, num_sectors, dma_buf, num_sectors * 512, 1);
memcpy(buf, dma_buf, num_sectors * 512);
return !res;
}
}
}
else
{ {
return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 0); return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 0);
} }
}
int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf) int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf)
{
if (!custom_driver)
{
sdmmc_accessor_t *accessor_sd = sdmmc_accessor_sd();
sdmmc_accessor_t *accessor_nand = sdmmc_accessor_nand();
if (sdmmc_calculate_dma_addr(accessor_sd, buf, num_sectors))
{
return !accessor_sd->vtab->read_write(accessor_sd, sector, num_sectors, buf, num_sectors * 512, 0);
}
else
{
if (sdmmc_calculate_dma_addr(accessor_nand, buf, num_sectors))
{
// buf is on the nand dma buffer
int original_dma_idx = sdmmc_calculate_dma_index(accessor_nand, buf, num_sectors);
sdmmc_dma_buffer_t *original_dma_buffer = &accessor_nand->parent->dmaBuffers[original_dma_idx];
// Next entry
int dma_idx = sdmmc_calculate_fitting_dma_index(accessor_sd, num_sectors) + 1;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer = original_dma_buffer->device_addr_buffer;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_masked = original_dma_buffer->device_addr_buffer_masked;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_size = original_dma_buffer->device_addr_buffer_size;
u64 res = accessor_sd->vtab->read_write(accessor_sd, sector, num_sectors, buf, num_sectors * 512, 0);
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer = 0;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_masked = 0;
accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer_size = 0;
return !res;
}
else
{
// buf is on a heap
int dma_idx = sdmmc_calculate_fitting_dma_index(accessor_sd, num_sectors);
void *dma_buf = &accessor_sd->parent->dmaBuffers[dma_idx].device_addr_buffer[0];
memcpy(dma_buf, buf, num_sectors * 512);
u64 res = accessor_sd->vtab->read_write(accessor_sd, sector, num_sectors, dma_buf, num_sectors * 512, 0);
return !res;
}
}
}
else
{ {
return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 1); return _sdmmc_storage_readwrite(storage, sector, num_sectors, buf, 1);
} }
}
/* /*
* MMC specific functions. * MMC specific functions.
@@ -623,7 +842,7 @@ static int _sd_storage_get_op_cond(sdmmc_storage_t *storage, int is_version_1, i
if (cond & SD_OCR_CCS) if (cond & SD_OCR_CCS)
storage->has_sector_access = 1; storage->has_sector_access = 1;
if (false && cond & SD_ROCR_S18A && supports_low_voltage) if (cond & SD_ROCR_S18A && supports_low_voltage)
{ {
//The low voltage regulator configuration is valid for SDMMC1 only. //The low voltage regulator configuration is valid for SDMMC1 only.
if (storage->sdmmc->id == SDMMC_1 && if (storage->sdmmc->id == SDMMC_1 &&

View File

@@ -19,6 +19,7 @@
#define _SDMMC_H_ #define _SDMMC_H_
#include "../utils/types.h" #include "../utils/types.h"
#include "../FS/FS.h"
#include "sdmmc_driver.h" #include "sdmmc_driver.h"
typedef struct _mmc_cid typedef struct _mmc_cid
@@ -102,6 +103,9 @@ typedef struct _sdmmc_storage_t
sd_ssr_t ssr; sd_ssr_t ssr;
} sdmmc_storage_t; } sdmmc_storage_t;
extern sdmmc_accessor_t *_current_accessor;
extern bool sdmmc_memcpy_buf;
int sdmmc_storage_end(sdmmc_storage_t *storage); int sdmmc_storage_end(sdmmc_storage_t *storage);
int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf); int sdmmc_storage_read(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf);
int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf); int sdmmc_storage_write(sdmmc_storage_t *storage, u32 sector, u32 num_sectors, void *buf);
@@ -109,5 +113,8 @@ int sdmmc_storage_init_mmc(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32
int sdmmc_storage_set_mmc_partition(sdmmc_storage_t *storage, u32 partition); int sdmmc_storage_set_mmc_partition(sdmmc_storage_t *storage, u32 partition);
int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type); int sdmmc_storage_init_sd(sdmmc_storage_t *storage, sdmmc_t *sdmmc, u32 id, u32 bus_width, u32 type);
int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc); int sdmmc_storage_init_gc(sdmmc_storage_t *storage, sdmmc_t *sdmmc);
intptr_t sdmmc_calculate_dma_addr(sdmmc_accessor_t *_this, void *buf, unsigned int num_sectors);
int sdmmc_calculate_dma_index(sdmmc_accessor_t *_this, void *buf, unsigned int num_sectors);
int sdmmc_calculate_fitting_dma_index(sdmmc_accessor_t *_this, unsigned int num_sectors);
#endif #endif

View File

@@ -27,6 +27,7 @@
#include "../soc/pmc.h" #include "../soc/pmc.h"
#include "../soc/pinmux.h" #include "../soc/pinmux.h"
#include "../soc/gpio.h" #include "../soc/gpio.h"
#include "../utils/fatal.h"
#define DPRINTF(...) #define DPRINTF(...)
@@ -788,7 +789,15 @@ static int _sdmmc_config_dma(sdmmc_t *sdmmc, u32 *blkcnt_out, sdmmc_req_t *req)
u32 blkcnt = req->num_sectors; u32 blkcnt = req->num_sectors;
if (blkcnt >= 0xFFFF) if (blkcnt >= 0xFFFF)
blkcnt = 0xFFFF; blkcnt = 0xFFFF;
u64 admaaddr = sdmmc->dma_addr_fs;
u64 admaaddr = (u64)sdmmc_calculate_dma_addr(_current_accessor, req->buf, blkcnt);
if (!admaaddr)
{
// buf is on a heap
int dma_idx = sdmmc_calculate_fitting_dma_index(_current_accessor, blkcnt);
admaaddr = (u64)&_current_accessor->parent->dmaBuffers[dma_idx].device_addr_buffer_masked[0];
sdmmc->last_dma_idx = dma_idx;
}
//Check alignment. //Check alignment.
if (admaaddr & 7) if (admaaddr & 7)
@@ -870,7 +879,22 @@ static int _sdmmc_execute_cmd_inner(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_
if (req) if (req)
{ {
_sdmmc_config_dma(sdmmc, &blkcnt, req); _sdmmc_config_dma(sdmmc, &blkcnt, req);
if(!sdmmc_memcpy_buf)
{
// Flush from/to phys
armDCacheFlush(req->buf, req->blksize * blkcnt); armDCacheFlush(req->buf, req->blksize * blkcnt);
}
else
{
if(req->is_write)
{
void* dma_addr = &_current_accessor->parent->dmaBuffers[sdmmc->last_dma_idx].device_addr_buffer[0];
memcpy(dma_addr, req->buf, req->blksize * blkcnt);
// Flush to phys
armDCacheFlush(dma_addr, req->blksize * blkcnt);
}
}
_sdmmc_enable_interrupts(sdmmc); _sdmmc_enable_interrupts(sdmmc);
is_data_present = true; is_data_present = true;
@@ -892,8 +916,15 @@ static int _sdmmc_execute_cmd_inner(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_
{ {
sdmmc->expected_rsp_type = cmd->rsp_type; sdmmc->expected_rsp_type = cmd->rsp_type;
_sdmmc_cache_rsp(sdmmc, sdmmc->rsp, 0x10, cmd->rsp_type); _sdmmc_cache_rsp(sdmmc, sdmmc->rsp, 0x10, cmd->rsp_type);
/*if(sdmmc->rsp[0] & 0xFDF9A080)
{
res = 0;
sdmmc->rsp[0] = 0; // Reset error
}*/
} }
if (req)
if (res && req)
_sdmmc_update_dma(sdmmc); _sdmmc_update_dma(sdmmc);
} }
@@ -903,7 +934,22 @@ static int _sdmmc_execute_cmd_inner(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_
{ {
if (req) if (req)
{ {
if(!req->is_write)
{
if(!sdmmc_memcpy_buf)
{
// Flush from phys
armDCacheFlush(req->buf, req->blksize * blkcnt); armDCacheFlush(req->buf, req->blksize * blkcnt);
}
else
{
void* dma_addr = &_current_accessor->parent->dmaBuffers[sdmmc->last_dma_idx].device_addr_buffer[0];
// Flush from phys
armDCacheFlush(dma_addr, req->blksize * blkcnt);
// Copy to buffer
memcpy(req->buf, dma_addr, req->blksize * blkcnt);
}
}
if (blkcnt_out) if (blkcnt_out)
*blkcnt_out = blkcnt; *blkcnt_out = blkcnt;
@@ -948,10 +994,13 @@ static int _sdmmc_config_sdmmc1()
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT1) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP; PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT1) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP;
PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT0) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP; PINMUX_AUX(PINMUX_AUX_SDMMC1_DAT0) = PINMUX_DRIVE_2X | PINMUX_INPUT_ENABLE | PINMUX_PARKED | PINMUX_PULL_UP;
//Make sure SDMMC1 controller is reset.
smcReadWriteRegister(PMC_BASE + APBDEV_PMC_NO_IOPOWER, (1 << 12), (1 << 12));
usleep(1000);
//Make sure the SDMMC1 controller is powered. //Make sure the SDMMC1 controller is powered.
//PMC(APBDEV_PMC_NO_IOPOWER) &= ~(1 << 12); smcReadWriteRegister(PMC_BASE + APBDEV_PMC_NO_IOPOWER, ~(1 << 12), (1 << 12));
//Assume 3.3V SD card voltage. smcReadWriteRegister(PMC_BASE + APBDEV_PMC_PWR_DET_VAL, (1 << 12), (1 << 12));
//PMC(APBDEV_PMC_PWR_DET_VAL) |= (1 << 12);
//Set enable SD card power. //Set enable SD card power.
PINMUX_AUX(PINMUX_AUX_DMIC3_CLK) = PINMUX_INPUT_ENABLE | PINMUX_PULL_DOWN | 1; //GPIO control, pull down. PINMUX_AUX(PINMUX_AUX_DMIC3_CLK) = PINMUX_INPUT_ENABLE | PINMUX_PULL_DOWN | 1; //GPIO control, pull down.
@@ -962,10 +1011,10 @@ static int _sdmmc_config_sdmmc1()
usleep(1000); usleep(1000);
//Enable SD card power. //Enable SD card power.
//max77620_regulator_set_voltage(REGULATOR_LDO2, 3300000); max77620_regulator_set_voltage(REGULATOR_LDO2, 3300000);
//max77620_regulator_enable(REGULATOR_LDO2, 1); max77620_regulator_enable(REGULATOR_LDO2, 1);
//usleep(1000); usleep(1000);
//For good measure. //For good measure.
APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = 0x10000000; APB_MISC(APB_MISC_GP_SDMMC1_PAD_CFGPADCTRL) = 0x10000000;
@@ -1008,7 +1057,7 @@ int sdmmc_init(sdmmc_t *sdmmc, u32 id, u32 power, u32 bus_width, u32 type, int n
sdmmc->regs->veniotrimctl &= 0xFFFFFFFB; sdmmc->regs->veniotrimctl &= 0xFFFFFFFB;
static const u32 trim_values[] = { 2, 8, 3, 8 }; static const u32 trim_values[] = { 2, 8, 3, 8 };
sdmmc->regs->venclkctl = (sdmmc->regs->venclkctl & 0xE0FFFFFF) | (trim_values[sdmmc->id] << 24); sdmmc->regs->venclkctl = (sdmmc->regs->venclkctl & 0xE0FFFFFF) | (trim_values[sdmmc->id] << 24);
sdmmc->regs->sdmemcmppadctl = (sdmmc->regs->sdmemcmppadctl & 0xF) | 7; sdmmc->regs->sdmemcmppadctl = (sdmmc->regs->sdmemcmppadctl & 0xFFFFFFF0) | 7;
if (!_sdmmc_autocal_config_offset(sdmmc, power)) if (!_sdmmc_autocal_config_offset(sdmmc, power))
return 0; return 0;
_sdmmc_autocal_execute(sdmmc, power); _sdmmc_autocal_execute(sdmmc, power);
@@ -1040,8 +1089,9 @@ void sdmmc_end(sdmmc_t *sdmmc)
if (sdmmc->id == SDMMC_1) if (sdmmc->id == SDMMC_1)
{ {
gpio_output_enable(GPIO_PORT_E, GPIO_PIN_4, GPIO_OUTPUT_DISABLE); gpio_output_enable(GPIO_PORT_E, GPIO_PIN_4, GPIO_OUTPUT_DISABLE);
//max77620_regulator_enable(REGULATOR_LDO2, 0); msleep(1); // To power cycle min 1ms without power is needed.
msleep(100); // To power cycle min 1ms without power is needed. max77620_regulator_enable(REGULATOR_LDO2, 0);
msleep(100); // Some extra.
} }
_sdmmc_get_clkcon(sdmmc); _sdmmc_get_clkcon(sdmmc);
@@ -1095,7 +1145,7 @@ int sdmmc_enable_low_voltage(sdmmc_t *sdmmc)
_sdmmc_get_clkcon(sdmmc); _sdmmc_get_clkcon(sdmmc);
max77620_regulator_set_voltage(REGULATOR_LDO2, 1800000); max77620_regulator_set_voltage(REGULATOR_LDO2, 1800000);
PMC(APBDEV_PMC_PWR_DET_VAL) &= ~(1 << 12); smcReadWriteRegister(PMC_BASE + APBDEV_PMC_PWR_DET_VAL, ~(1 << 12), (1 << 12));
_sdmmc_autocal_config_offset(sdmmc, SDMMC_POWER_1_8); _sdmmc_autocal_config_offset(sdmmc, SDMMC_POWER_1_8);
_sdmmc_autocal_execute(sdmmc, SDMMC_POWER_1_8); _sdmmc_autocal_execute(sdmmc, SDMMC_POWER_1_8);

View File

@@ -83,7 +83,7 @@ typedef struct _sdmmc_t
int venclkctl_set; int venclkctl_set;
u32 venclkctl_tap; u32 venclkctl_tap;
u32 expected_rsp_type; u32 expected_rsp_type;
u64 dma_addr_fs; u64 last_dma_idx;
u64 dma_addr_next; u64 dma_addr_next;
u32 rsp[4]; u32 rsp[4];
u32 rsp3; u32 rsp3;

View File

@@ -24,6 +24,7 @@
#include "emummc.h" #include "emummc.h"
#include "emummc_ctx.h" #include "emummc_ctx.h"
static bool sdmmc_first_init = false;
static bool storageMMCinitialized = false; static bool storageMMCinitialized = false;
static bool storageSDinitialized = false; static bool storageSDinitialized = false;
@@ -68,8 +69,17 @@ static void _sdmmc_ensure_device_attached(void)
static void _sdmmc_ensure_initialized(void) static void _sdmmc_ensure_initialized(void)
{ {
// The boot sysmodule will eventually kill power to SD. Detect this, and reinitialize when it happens.
static bool init_done = false; static bool init_done = false;
// First Initial init
if (!sdmmc_first_init)
{
sdmmc_initialize();
sdmmc_first_init = true;
}
else
{
// The boot sysmodule will eventually kill power to SD. Detect this, and reinitialize when it happens.
if (!init_done) if (!init_done)
{ {
if (gpio_read(GPIO_PORT_E, GPIO_PIN_4) == 0) if (gpio_read(GPIO_PORT_E, GPIO_PIN_4) == 0)
@@ -80,27 +90,11 @@ static void _sdmmc_ensure_initialized(void)
} }
} }
} }
void sdmmc_finalize(void)
{
if (!sdmmc_storage_end(&sd_storage))
{
fatal_abort(Fatal_InitSD);
}
storageSDinitialized = false;
} }
static void _file_based_update_filename(char *outFilename, u32 sd_path_len, u32 part_idx) static void _file_based_update_filename(char *outFilename, u32 sd_path_len, u32 part_idx)
{ {
if (part_idx < 10) snprintf(outFilename + sd_path_len, 3, "%02d", part_idx);
{
outFilename[sd_path_len] = '0';
itoa(part_idx, &outFilename[sd_path_len + 1], 10);
}
else
{
itoa(part_idx, &outFilename[sd_path_len], 10);
}
} }
static void _file_based_emmc_finalize(void) static void _file_based_emmc_finalize(void)
@@ -108,11 +102,13 @@ static void _file_based_emmc_finalize(void)
if ((emuMMC_ctx.EMMC_Type == emuMMC_SD_File) && fat_mounted) if ((emuMMC_ctx.EMMC_Type == emuMMC_SD_File) && fat_mounted)
{ {
// Close all open handles. // Close all open handles.
f_close(f_emu.fp_boot0); f_close(&f_emu.fp_boot0);
f_close(f_emu.fp_boot1); f_close(&f_emu.fp_boot1);
for (int i = 0; i < f_emu.parts; i++) for (int i = 0; i < f_emu.parts; i++)
f_close(f_emu.fp_gpp[i]); {
f_close(&f_emu.fp_gpp[i]);
}
// Force unmount FAT volume. // Force unmount FAT volume.
f_mount(NULL, "", 1); f_mount(NULL, "", 1);
@@ -121,6 +117,18 @@ static void _file_based_emmc_finalize(void)
} }
} }
void sdmmc_finalize(void)
{
_file_based_emmc_finalize();
if (!sdmmc_storage_end(&sd_storage))
{
fatal_abort(Fatal_InitSD);
}
storageSDinitialized = false;
}
static void _file_based_emmc_initialize(void) static void _file_based_emmc_initialize(void)
{ {
char path[sizeof(emuMMC_ctx.storagePath) + 0x20]; char path[sizeof(emuMMC_ctx.storagePath) + 0x20];
@@ -128,40 +136,36 @@ static void _file_based_emmc_initialize(void)
memset(&f_emu, 0, sizeof(file_based_ctxt)); memset(&f_emu, 0, sizeof(file_based_ctxt));
memcpy(path, (void *)emuMMC_ctx.storagePath, sizeof(emuMMC_ctx.storagePath)); memcpy(path, (void *)emuMMC_ctx.storagePath, sizeof(emuMMC_ctx.storagePath));
strcat(path, "/eMMC"); strcat(path, "/eMMC/");
int path_len = strlen(path); int path_len = strlen(path);
// Open BOOT0 physical partition. // Open BOOT0 physical partition.
f_emu.fp_boot0 = (FIL *)malloc(sizeof(FIL));
memcpy(path + path_len, "BOOT0", 6); memcpy(path + path_len, "BOOT0", 6);
if (f_open(f_emu.fp_boot0, path, FA_READ | FA_WRITE) != FR_OK) if (f_open(&f_emu.fp_boot0, path, FA_READ | FA_WRITE) != FR_OK)
fatal_abort(Fatal_InitSD); fatal_abort(Fatal_InitSD);
// Open BOOT1 physical partition. // Open BOOT1 physical partition.
f_emu.fp_boot1 = (FIL *)malloc(sizeof(FIL));
memcpy(path + path_len, "BOOT1", 6); memcpy(path + path_len, "BOOT1", 6);
if (f_open(f_emu.fp_boot1, path, FA_READ | FA_WRITE) != FR_OK) if (f_open(&f_emu.fp_boot1, path, FA_READ | FA_WRITE) != FR_OK)
fatal_abort(Fatal_InitSD); fatal_abort(Fatal_InitSD);
// Open handles for GPP physical partition files. // Open handles for GPP physical partition files.
_file_based_update_filename(path, path_len, 00); _file_based_update_filename(path, path_len, 00);
if (f_open(f_emu.fp_gpp[0], path, FA_READ | FA_WRITE) != FR_OK)
if (f_open(&f_emu.fp_gpp[0], path, FA_READ | FA_WRITE) != FR_OK)
fatal_abort(Fatal_InitSD); fatal_abort(Fatal_InitSD);
f_emu.part_size = f_size(f_emu.fp_gpp[0]); f_emu.part_size = f_size(&f_emu.fp_gpp[0]) >> 9;
// Iterate folder for split parts and stop if next doesn't exist. // Iterate folder for split parts and stop if next doesn't exist.
// Supports up to 32 parts of any size. // Supports up to 32 parts of any size.
// TODO: decide on max parts and define them. (hekate produces up to 30 parts on 1GB mode.) // TODO: decide on max parts and define them. (hekate produces up to 30 parts on 1GB mode.)
for (f_emu.parts = 1; f_emu.parts < 32; f_emu.parts++) for (f_emu.parts = 1; f_emu.parts < 32; f_emu.parts++)
{ {
f_emu.fp_gpp[f_emu.parts] = (FIL *)malloc(sizeof(FIL));
_file_based_update_filename(path, path_len, f_emu.parts); _file_based_update_filename(path, path_len, f_emu.parts);
if (f_open(f_emu.fp_gpp[f_emu.parts], path, FA_READ | FA_WRITE) != FR_OK) if (f_open(&f_emu.fp_gpp[f_emu.parts], path, FA_READ | FA_WRITE) != FR_OK)
{ {
free(f_emu.fp_gpp[f_emu.parts]);
// Check if single file. // Check if single file.
if (f_emu.parts == 1) if (f_emu.parts == 1)
f_emu.parts = 0; f_emu.parts = 0;
@@ -187,6 +191,9 @@ bool sdmmc_initialize(void)
} }
if (!storageSDinitialized) if (!storageSDinitialized)
{
int retries = 5;
while (retries)
{ {
if (sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11)) if (sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11))
{ {
@@ -203,8 +210,15 @@ bool sdmmc_initialize(void)
_file_based_emmc_initialize(); _file_based_emmc_initialize();
} }
break;
} }
else
retries--;
msleep(100);
}
if (!storageSDinitialized)
{ {
fatal_abort(Fatal_InitSD); fatal_abort(Fatal_InitSD);
} }
@@ -213,38 +227,6 @@ bool sdmmc_initialize(void)
return storageMMCinitialized && storageSDinitialized; return storageMMCinitialized && storageSDinitialized;
} }
// FS DMA calculations.
intptr_t sdmmc_calculate_dma_addr(sdmmc_accessor_t *_this, void *buf, unsigned int num_sectors)
{
int dma_buf_idx = 0;
char *_buf = (char *)buf;
char *actual_buf_start = _buf;
char *actual_buf_end = &_buf[512 * num_sectors];
char *dma_buffer_start = _this->parent->dmaBuffers[FS_SDMMC_EMMC].device_addr_buffer;
if (dma_buffer_start <= _buf && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[FS_SDMMC_EMMC].device_addr_buffer_size])
{
dma_buf_idx = FS_SDMMC_EMMC;
}
else
{
dma_buffer_start = _this->parent->dmaBuffers[FS_SDMMC_SD].device_addr_buffer;
if (dma_buffer_start <= actual_buf_start && actual_buf_end <= &dma_buffer_start[_this->parent->dmaBuffers[FS_SDMMC_SD].device_addr_buffer_size])
{
dma_buf_idx = FS_SDMMC_SD;
}
else
{
dma_buffer_start = _this->parent->dmaBuffers[FS_SDMMC_GC].device_addr_buffer;
dma_buf_idx = FS_SDMMC_GC;
}
}
intptr_t admaaddr = (intptr_t)&_this->parent->dmaBuffers[dma_buf_idx].device_addr_buffer_masked[actual_buf_start - dma_buffer_start];
return admaaddr;
}
sdmmc_accessor_t *sdmmc_accessor_get(int mmc_id) sdmmc_accessor_t *sdmmc_accessor_get(int mmc_id)
{ {
sdmmc_accessor_t *_this; sdmmc_accessor_t *_this;
@@ -267,16 +249,22 @@ sdmmc_accessor_t *sdmmc_accessor_get(int mmc_id)
} }
void mutex_lock_handler(int mmc_id) void mutex_lock_handler(int mmc_id)
{
if (custom_driver)
{ {
lock_mutex(sd_mutex); lock_mutex(sd_mutex);
}
lock_mutex(nand_mutex); lock_mutex(nand_mutex);
} }
void mutex_unlock_handler(int mmc_id) void mutex_unlock_handler(int mmc_id)
{ {
unlock_mutex(nand_mutex); unlock_mutex(nand_mutex);
if (custom_driver)
{
unlock_mutex(sd_mutex); unlock_mutex(sd_mutex);
} }
}
int sdmmc_nand_get_active_partition_index() int sdmmc_nand_get_active_partition_index()
{ {
@@ -314,19 +302,19 @@ static uint64_t emummc_read_write_inner(void *buf, unsigned int sector, unsigned
case FS_EMMC_PARTITION_GPP: case FS_EMMC_PARTITION_GPP:
if (f_emu.parts) if (f_emu.parts)
{ {
fp_tmp = f_emu.fp_gpp[sector / f_emu.part_size]; fp_tmp = &f_emu.fp_gpp[sector / f_emu.part_size];
sector = sector % f_emu.part_size; sector = sector % f_emu.part_size;
} }
else else
{ {
fp_tmp = f_emu.fp_gpp[0]; fp_tmp = &f_emu.fp_gpp[0];
} }
break; break;
case FS_EMMC_PARTITION_BOOT1: case FS_EMMC_PARTITION_BOOT1:
fp_tmp = f_emu.fp_boot1; fp_tmp = &f_emu.fp_boot1;
break; break;
case FS_EMMC_PARTITION_BOOT0: case FS_EMMC_PARTITION_BOOT0:
fp_tmp = f_emu.fp_boot0; fp_tmp = &f_emu.fp_boot0;
break; break;
} }
@@ -335,10 +323,44 @@ static uint64_t emummc_read_write_inner(void *buf, unsigned int sector, unsigned
; //TODO. Out of range. close stuff and fatal? ; //TODO. Out of range. close stuff and fatal?
} }
uint64_t res = 0;
if (!is_write) if (!is_write)
return !(f_read(fp_tmp, buf, num_sectors << 9, NULL)); res = !(f_read(fp_tmp, buf, num_sectors << 9, NULL));
else else
return !(f_write(fp_tmp, buf, num_sectors << 9, NULL)); res = !(f_write(fp_tmp, buf, num_sectors << 9, NULL));
return res;
}
// Controller close wrapper
uint64_t sdmmc_wrapper_controller_close(int mmc_id)
{
sdmmc_accessor_t *_this;
_this = sdmmc_accessor_get(mmc_id);
if (_this != NULL)
{
if (mmc_id == FS_SDMMC_SD)
{
return 0;
}
if (mmc_id == FS_SDMMC_EMMC)
{
// Close file handles and unmount
_file_based_emmc_finalize();
// Close SD
sdmmc_accessor_get(FS_SDMMC_SD)->vtab->sdmmc_accessor_controller_close(sdmmc_accessor_get(FS_SDMMC_SD));
// Close eMMC
return _this->vtab->sdmmc_accessor_controller_close(_this);
}
return _this->vtab->sdmmc_accessor_controller_close(_this);
}
fatal_abort(Fatal_CloseAccessor);
} }
// FS read wrapper. // FS read wrapper.
@@ -354,6 +376,8 @@ uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned in
if (mmc_id == FS_SDMMC_EMMC || mmc_id == FS_SDMMC_SD) if (mmc_id == FS_SDMMC_EMMC || mmc_id == FS_SDMMC_SD)
{ {
mutex_lock_handler(mmc_id); mutex_lock_handler(mmc_id);
// Assign FS accessor to the SDMMC driver
_current_accessor = _this;
// Make sure we're attached to the device address space. // Make sure we're attached to the device address space.
_sdmmc_ensure_device_attached(); _sdmmc_ensure_device_attached();
// Make sure we're still initialized if boot killed sd card power. // Make sure we're still initialized if boot killed sd card power.
@@ -362,8 +386,6 @@ uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned in
if (mmc_id == FS_SDMMC_EMMC) if (mmc_id == FS_SDMMC_EMMC)
{ {
sd_storage.sdmmc->dma_addr_fs = (u64)sdmmc_calculate_dma_addr(_this, buf, num_sectors);
// Call hekates driver. // Call hekates driver.
if (emummc_read_write_inner(buf, sector, num_sectors, false)) if (emummc_read_write_inner(buf, sector, num_sectors, false))
{ {
@@ -377,7 +399,17 @@ uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned in
if (mmc_id == FS_SDMMC_SD) if (mmc_id == FS_SDMMC_SD)
{ {
sd_storage.sdmmc->dma_addr_fs = (u64)sdmmc_calculate_dma_addr(_this, buf, num_sectors); static bool first_sd_read = true;
if (first_sd_read)
{
first_sd_read = false;
// Because some SD cards have issues with emuMMC's driver
// we currently swap to FS's driver after first SD read
// TODO: Fix remaining driver issues
custom_driver = false;
// FS will handle sd mutex w/o custom driver from here on
unlock_mutex(sd_mutex);
}
// Call hekates driver. // Call hekates driver.
if (sdmmc_storage_read(&sd_storage, sector, num_sectors, buf)) if (sdmmc_storage_read(&sd_storage, sector, num_sectors, buf))
@@ -410,8 +442,7 @@ uint64_t sdmmc_wrapper_write(int mmc_id, unsigned int sector, unsigned int num_s
if (mmc_id == FS_SDMMC_EMMC) if (mmc_id == FS_SDMMC_EMMC)
{ {
mutex_lock_handler(mmc_id); mutex_lock_handler(mmc_id);
_current_accessor = _this;
sd_storage.sdmmc->dma_addr_fs = (u64)sdmmc_calculate_dma_addr(_this, buf, num_sectors);
// Call hekates driver. // Call hekates driver.
if (emummc_read_write_inner(buf, sector, num_sectors, true)) if (emummc_read_write_inner(buf, sector, num_sectors, true))
@@ -427,9 +458,9 @@ uint64_t sdmmc_wrapper_write(int mmc_id, unsigned int sector, unsigned int num_s
if (mmc_id == FS_SDMMC_SD) if (mmc_id == FS_SDMMC_SD)
{ {
mutex_lock_handler(mmc_id); mutex_lock_handler(mmc_id);
_current_accessor = _this;
sector += 0; sector += 0;
sd_storage.sdmmc->dma_addr_fs = (u64)sdmmc_calculate_dma_addr(_this, buf, num_sectors);
// Call hekates driver. // Call hekates driver.
if (sdmmc_storage_write(&sd_storage, sector, num_sectors, buf)) if (sdmmc_storage_write(&sd_storage, sector, num_sectors, buf))

View File

@@ -50,8 +50,8 @@ sdmmc_accessor_t *sdmmc_accessor_get(int mmc_id);
void mutex_lock_handler(int mmc_id); void mutex_lock_handler(int mmc_id);
void mutex_unlock_handler(int mmc_id); void mutex_unlock_handler(int mmc_id);
intptr_t sdmmc_calculate_dma_addr(sdmmc_accessor_t *_this, void *buf, unsigned int num_sectors); // Hooks
uint64_t sdmmc_wrapper_controller_close(int mmc_id);
uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned int sector, unsigned int num_sectors); uint64_t sdmmc_wrapper_read(void *buf, uint64_t bufSize, int mmc_id, unsigned int sector, unsigned int num_sectors);
uint64_t sdmmc_wrapper_write(int mmc_id, unsigned int sector, unsigned int num_sectors, void *buf, uint64_t bufSize); uint64_t sdmmc_wrapper_write(int mmc_id, unsigned int sector, unsigned int num_sectors, void *buf, uint64_t bufSize);
@@ -61,9 +61,9 @@ typedef struct _file_based_ctxt
uint64_t parts; uint64_t parts;
uint64_t part_size; uint64_t part_size;
FATFS *sd_fs; FATFS *sd_fs;
FIL *fp_boot0; FIL fp_boot0;
FIL *fp_boot1; FIL fp_boot1;
FIL *fp_gpp[32]; FIL fp_gpp[32];
} file_based_ctxt; } file_based_ctxt;
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -22,6 +22,8 @@
#include <string.h> #include <string.h>
#include "nx/svc.h" #include "nx/svc.h"
#include "nx/smc.h" #include "nx/smc.h"
#include "soc/clock.h"
#include "soc/i2c.h"
#include "emuMMC/emummc.h" #include "emuMMC/emummc.h"
#include "emuMMC/emummc_ctx.h" #include "emuMMC/emummc_ctx.h"
#include "FS/FS_offsets.h" #include "FS/FS_offsets.h"
@@ -40,7 +42,7 @@ uintptr_t text_base;
char inner_heap[INNER_HEAP_SIZE]; char inner_heap[INNER_HEAP_SIZE];
size_t inner_heap_size = INNER_HEAP_SIZE; size_t inner_heap_size = INNER_HEAP_SIZE;
extern char _start; extern char _start;
extern char __injected_size__; extern char __argdata__;
// Nintendo Path // Nintendo Path
// TODO // TODO
@@ -53,7 +55,7 @@ static char nintendo_path_contents_100[0x100] = "/Nintendo/Contents";
static const fs_offsets_t *fs_offsets; static const fs_offsets_t *fs_offsets;
// Defined by linkerscript // Defined by linkerscript
#define INJECTED_SIZE ((uintptr_t)&__injected_size__ - (uintptr_t)&_start) #define INJECTED_SIZE ((uintptr_t)&__argdata__ - (uintptr_t)&_start)
#define INJECT_OFFSET(type, offset) (type)(text_base + INJECTED_SIZE + offset) #define INJECT_OFFSET(type, offset) (type)(text_base + INJECTED_SIZE + offset)
#define GENERATE_ADD(register, register_target, value) (0x91000000 | value << 10 | register << 5 | register_target) #define GENERATE_ADD(register, register_target, value) (0x91000000 | value << 10 | register << 5 | register_target)
@@ -154,15 +156,14 @@ void write_nop(uintptr_t source)
smcWriteAddress32((void *)source, GENERATE_NOP()); smcWriteAddress32((void *)source, GENERATE_NOP());
} }
void write_adrp_add(int reg, uintptr_t pc, intptr_t destination) void write_adrp_add(int reg, uintptr_t pc, uintptr_t add_rel_offset, intptr_t destination)
{ {
uintptr_t add_opcode_location = pc + sizeof(uint32_t); uintptr_t add_opcode_location = pc + add_rel_offset;
intptr_t offset = (destination & 0xFFFFF000) - (pc & 0xFFFFF000); intptr_t offset = (destination & 0xFFFFF000) - (pc & 0xFFFFF000);
uint32_t opcode_adrp = GENERATE_ADRP(reg, offset); uint32_t opcode_adrp = GENERATE_ADRP(reg, offset);
uint32_t opcode_add = GENERATE_ADD(reg, reg, (destination & 0x00000FFF)); uint32_t opcode_add = GENERATE_ADD(reg, reg, (destination & 0x00000FFF));
// TODO: use 64 write?
smcWriteAddress32((void *)pc, opcode_adrp); smcWriteAddress32((void *)pc, opcode_adrp);
smcWriteAddress32((void *)add_opcode_location, opcode_add); smcWriteAddress32((void *)add_opcode_location, opcode_add);
} }
@@ -175,6 +176,8 @@ void setup_hooks(void)
INJECT_HOOK(fs_offsets->sdmmc_wrapper_read, sdmmc_wrapper_read); INJECT_HOOK(fs_offsets->sdmmc_wrapper_read, sdmmc_wrapper_read);
// sdmmc_wrapper_write hook // sdmmc_wrapper_write hook
INJECT_HOOK(fs_offsets->sdmmc_wrapper_write, sdmmc_wrapper_write); INJECT_HOOK(fs_offsets->sdmmc_wrapper_write, sdmmc_wrapper_write);
// sdmmc_wrapper_controller_close hook
INJECT_HOOK(fs_offsets->sdmmc_accessor_controller_close, sdmmc_wrapper_controller_close);
// On 8.0.0+, we need to hook the regulator setup, because // On 8.0.0+, we need to hook the regulator setup, because
// otherwise it will abort because we have already turned it on. // otherwise it will abort because we have already turned it on.
@@ -204,10 +207,6 @@ void populate_function_pointers(void)
void write_nops(void) void write_nops(void)
{ {
// This NOPs out a call to ShutdownSdCard when preparing for shutdown/reboot.
// This prevents the PatrolReader from hanging when saving its state, which
// occurs immediately afterwards (in ShutdownMmc).
INJECT_NOP(fs_offsets->shutdown_sd);
// On 7.0.0+, we need to attach to device address space ourselves. // On 7.0.0+, we need to attach to device address space ourselves.
// This patches an abort that happens when Nintendo's code sees SD // This patches an abort that happens when Nintendo's code sees SD
// is already attached // is already attached
@@ -268,7 +267,7 @@ void setup_nintendo_paths(void)
{ {
intptr_t nintendo_path_location = (intptr_t)&nintendo_path; intptr_t nintendo_path_location = (intptr_t)&nintendo_path;
uintptr_t fs_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[i].adrp_offset); uintptr_t fs_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[i].adrp_offset);
write_adrp_add(fs_offsets->nintendo_paths[i].opcode_reg, fs_adrp_opcode_location, nintendo_path_location); write_adrp_add(fs_offsets->nintendo_paths[i].opcode_reg, fs_adrp_opcode_location, fs_offsets->nintendo_paths[i].add_rel_offset, nintendo_path_location);
} }
} }
else else
@@ -281,8 +280,8 @@ void setup_nintendo_paths(void)
intptr_t album_path_location = nintendo_album_path_location + path_len - 6; // "/Album" intptr_t album_path_location = nintendo_album_path_location + path_len - 6; // "/Album"
uintptr_t fs_n_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[0].adrp_offset); uintptr_t fs_n_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[0].adrp_offset);
uintptr_t fs_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[1].adrp_offset); uintptr_t fs_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[1].adrp_offset);
write_adrp_add(fs_offsets->nintendo_paths[0].opcode_reg, fs_n_adrp_opcode_location, nintendo_album_path_location); write_adrp_add(fs_offsets->nintendo_paths[0].opcode_reg, fs_n_adrp_opcode_location, fs_offsets->nintendo_paths[0].add_rel_offset, nintendo_album_path_location);
write_adrp_add(fs_offsets->nintendo_paths[1].opcode_reg, fs_adrp_opcode_location, album_path_location); write_adrp_add(fs_offsets->nintendo_paths[1].opcode_reg, fs_adrp_opcode_location, fs_offsets->nintendo_paths[1].add_rel_offset, album_path_location);
} }
// Do contents path // Do contents path
{ {
@@ -291,8 +290,8 @@ void setup_nintendo_paths(void)
intptr_t contents_path_location = nintendo_contents_path_location + path_len - 9; // "/Contents" intptr_t contents_path_location = nintendo_contents_path_location + path_len - 9; // "/Contents"
uintptr_t fs_n_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[2].adrp_offset); uintptr_t fs_n_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[2].adrp_offset);
uintptr_t fs_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[3].adrp_offset); uintptr_t fs_adrp_opcode_location = INJECT_OFFSET(uintptr_t, fs_offsets->nintendo_paths[3].adrp_offset);
write_adrp_add(fs_offsets->nintendo_paths[2].opcode_reg, fs_n_adrp_opcode_location, nintendo_contents_path_location); write_adrp_add(fs_offsets->nintendo_paths[2].opcode_reg, fs_n_adrp_opcode_location, fs_offsets->nintendo_paths[2].add_rel_offset, nintendo_contents_path_location);
write_adrp_add(fs_offsets->nintendo_paths[3].opcode_reg, fs_adrp_opcode_location, contents_path_location); write_adrp_add(fs_offsets->nintendo_paths[3].opcode_reg, fs_adrp_opcode_location, fs_offsets->nintendo_paths[3].add_rel_offset, contents_path_location);
} }
} }
} }
@@ -318,5 +317,6 @@ void __init()
write_nops(); write_nops();
setup_nintendo_paths(); setup_nintendo_paths();
sdmmc_initialize(); clock_enable_i2c5();
i2c_init();
} }

File diff suppressed because it is too large Load Diff

View File

@@ -78,7 +78,7 @@ startup:
MOV W0, #0xFFFF8001 MOV W0, #0xFFFF8001
ADR X1, __data_start ADR X1, __data_start
ADR X2, __end__ ADR X2, __argdata__
SUB X2, X2, X1 SUB X2, X2, X1
MOV X3, #3 MOV X3, #3
SVC 0x73 SVC 0x73
@@ -127,5 +127,5 @@ bss_loop:
MOV X30, X27 MOV X30, X27
# FS main # FS main
ADR X16, __injected_size__ ADRP X16, __argdata__
BR X16 BR X16

View File

@@ -20,7 +20,8 @@
#include "../utils/util.h" #include "../utils/util.h"
#include "t210.h" #include "t210.h"
static u32 i2c_addrs[] = { // TODO: not hardcode I2C_5
static u64 i2c_addrs[] = {
0x7000C000, 0x7000C400, 0x7000C500, 0x7000C000, 0x7000C400, 0x7000C500,
0x7000C700, 0x7000D000, 0x7000D100 0x7000C700, 0x7000D000, 0x7000D100
}; };
@@ -28,6 +29,7 @@ static u32 i2c_addrs[] = {
static void _i2c_wait(vu32 *base) static void _i2c_wait(vu32 *base)
{ {
base[I2C_CONFIG_LOAD] = 0x25; base[I2C_CONFIG_LOAD] = 0x25;
for (u32 i = 0; i < 20; i++) for (u32 i = 0; i < 20; i++)
{ {
usleep(1); usleep(1);
@@ -44,8 +46,7 @@ static int _i2c_send_pkt(u32 idx, u32 x, u8 *buf, u32 size)
u32 tmp = 0; u32 tmp = 0;
memcpy(&tmp, buf, size); memcpy(&tmp, buf, size);
vu32 *base = (vu32 *)QueryIoMapping(i2c_addrs[0], 0x2000); vu32 *base = (vu32 *)QueryIoMapping(i2c_addrs[I2C_5], 0x1000);
base = base + (i2c_addrs[idx] - i2c_addrs[0]);
base[I2C_CMD_ADDR0] = x << 1; //Set x (send mode). base[I2C_CMD_ADDR0] = x << 1; //Set x (send mode).
base[I2C_CMD_DATA1] = tmp; //Set value. base[I2C_CMD_DATA1] = tmp; //Set value.
base[I2C_CNFG] = (2 * size - 2) | 0x2800; //Set size and send mode. base[I2C_CNFG] = (2 * size - 2) | 0x2800; //Set size and send mode.
@@ -66,8 +67,7 @@ static int _i2c_recv_pkt(u32 idx, u8 *buf, u32 size, u32 x)
if (size > 8) if (size > 8)
return 0; return 0;
vu32 *base = (vu32 *)QueryIoMapping(i2c_addrs[0], 0x2000); vu32 *base = (vu32 *)QueryIoMapping(i2c_addrs[I2C_5], 0x1000);
base = base + (i2c_addrs[idx] - i2c_addrs[0]);
base[I2C_CMD_ADDR0] = (x << 1) | 1; // Set x (recv mode). base[I2C_CMD_ADDR0] = (x << 1) | 1; // Set x (recv mode).
base[I2C_CNFG] = (size - 1) << 1 | 0x2840; // Set size and recv mode. base[I2C_CNFG] = (size - 1) << 1 | 0x2840; // Set size and recv mode.
@@ -93,10 +93,9 @@ static int _i2c_recv_pkt(u32 idx, u8 *buf, u32 size, u32 x)
return 1; return 1;
} }
void i2c_init(u32 idx) void i2c_init()
{ {
vu32 *base = (vu32 *)QueryIoMapping(i2c_addrs[0], 0x2000); vu32 *base = (vu32 *)QueryIoMapping(i2c_addrs[I2C_5], 0x1000);
base = base + (i2c_addrs[idx] - i2c_addrs[0]);
base[I2C_CLK_DIVISOR_REGISTER] = 0x50001; base[I2C_CLK_DIVISOR_REGISTER] = 0x50001;
base[I2C_BUS_CLEAR_CONFIG] = 0x90003; base[I2C_BUS_CLEAR_CONFIG] = 0x90003;
@@ -104,7 +103,6 @@ void i2c_init(u32 idx)
for (u32 i = 0; i < 10; i++) for (u32 i = 0; i < 10; i++)
{ {
usleep(20000);
if (base[INTERRUPT_STATUS_REGISTER] & 0x800) if (base[INTERRUPT_STATUS_REGISTER] & 0x800)
break; break;
} }

View File

@@ -37,7 +37,7 @@
#define I2C_BUS_CLEAR_STATUS 0x22 #define I2C_BUS_CLEAR_STATUS 0x22
#define I2C_CONFIG_LOAD 0x23 #define I2C_CONFIG_LOAD 0x23
void i2c_init(u32 idx); void i2c_init();
int i2c_send_buf_small(u32 idx, u32 x, u32 y, u8 *buf, u32 size); int i2c_send_buf_small(u32 idx, u32 x, u32 y, u8 *buf, u32 size);
int i2c_recv_buf_small(u8 *buf, u32 size, u32 idx, u32 x, u32 y); int i2c_recv_buf_small(u8 *buf, u32 size, u32 idx, u32 x, u32 y);
int i2c_send_byte(u32 idx, u32 x, u32 y, u8 b); int i2c_send_byte(u32 idx, u32 x, u32 y, u8 b);

View File

@@ -15,10 +15,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <string.h>
#include "fatal.h" #include "fatal.h"
void __attribute__((noreturn)) fatal_abort(enum FatalReason abortReason) void __attribute__((noreturn)) fatal_abort(enum FatalReason abortReason)
{ {
atmosphere_fatal_error_ctx error_ctx;
memset(&error_ctx, 0, sizeof(atmosphere_fatal_error_ctx));
// Basic error storage for Atmosphere
// TODO: Maybe include a small reboot2payload stub?
error_ctx.magic = ATMOSPHERE_REBOOT_TO_FATAL_MAGIC;
error_ctx.title_id = 0x0100000000000000; // FS
error_ctx.error_desc = abortReason;
// Copy fatal context
smcCopyToIram(ATMOSPHERE_FATAL_ERROR_ADDR, &error_ctx, sizeof(atmosphere_fatal_error_ctx));
// Reboot to RCM // Reboot to RCM
smcRebootToRcm(); smcRebootToRcm();

View File

@@ -18,7 +18,8 @@
#pragma once #pragma once
#include "../nx/smc.h" #include "../nx/smc.h"
enum FatalReason { enum FatalReason
{
Fatal_InitMMC = 0, Fatal_InitMMC = 0,
Fatal_InitSD, Fatal_InitSD,
Fatal_InvalidAccessor, Fatal_InvalidAccessor,
@@ -28,7 +29,49 @@ enum FatalReason {
Fatal_UnknownVersion, Fatal_UnknownVersion,
Fatal_BadResult, Fatal_BadResult,
Fatal_GetConfig, Fatal_GetConfig,
Fatal_CloseAccessor,
Fatal_Max Fatal_Max
}; };
#define AMS_FATAL_ERROR_MAX_STACKTRACE 0x20
#define AMS_FATAL_ERROR_MAX_STACKDUMP 0x100
/* Atmosphere reboot-to-fatal-error. */
typedef struct
{
uint32_t magic;
uint32_t error_desc;
uint64_t title_id;
union {
uint64_t gprs[32];
struct
{
uint64_t _gprs[29];
uint64_t fp;
uint64_t lr;
uint64_t sp;
};
};
uint64_t pc;
uint64_t module_base;
uint32_t pstate;
uint32_t afsr0;
uint32_t afsr1;
uint32_t esr;
uint64_t far;
uint64_t report_identifier; /* Normally just system tick. */
uint64_t stack_trace_size;
uint64_t stack_dump_size;
uint64_t stack_trace[AMS_FATAL_ERROR_MAX_STACKTRACE];
uint8_t stack_dump[AMS_FATAL_ERROR_MAX_STACKDUMP];
} atmosphere_fatal_error_ctx;
/* "AFE1" */
#define ATMOSPHERE_REBOOT_TO_FATAL_MAGIC 0x31454641
/* "AFE0" */
#define ATMOSPHERE_REBOOT_TO_FATAL_MAGIC_0 0x30454641
#define ATMOSPHERE_FATAL_ERROR_ADDR 0x4003E000
#define ATMOSPHERE_FATAL_ERROR_CONTEXT ((volatile atmosphere_fatal_error_ctx *)(ATMOSPHERE_FATAL_ERROR_ADDR))
void __attribute__((noreturn)) fatal_abort(enum FatalReason abortReason); void __attribute__((noreturn)) fatal_abort(enum FatalReason abortReason);

View File

@@ -1,7 +1,8 @@
ParseClipboard() ParseClipboard()
Func FormatLineData($sLineData) Func FormatLineData($sLineData, $sLineDataAdd)
Local $lineData = StringReplace($sLineData, @TAB, " ") Local $lineData = StringReplace($sLineData, @TAB, " ")
Local $lineDataADRP, $lineDataADD
Local $isADRP = false Local $isADRP = false
$lineData = StringReplace($lineData, "Up o sub_71000" , "0x") $lineData = StringReplace($lineData, "Up o sub_71000" , "0x")
$isADRP = StringInStr($lineData, "ADRP") $isADRP = StringInStr($lineData, "ADRP")
@@ -13,24 +14,39 @@ Func FormatLineData($sLineData)
$lineDataAddr = StringReplace($lineDataAddr, "0x" , "") $lineDataAddr = StringReplace($lineDataAddr, "0x" , "")
$lineDataAddition = StringReplace($lineDataAddition, "0x" , "") $lineDataAddition = StringReplace($lineDataAddition, "0x" , "")
$addrADRP = Dec($lineDataAddr) + Dec($lineDataAddition)
If $isADRP Then $lineDataADRP = "0x" & Hex($addrADRP)
$lineData = "0x" & Hex(Dec($lineDataAddr) + Dec($lineDataAddition))
Else
Return ""
EndIf
Return "{.opcode_reg = " & $targetRegister & ", .adrp_offset = " & $lineData & "}, \" & @LF Local $lineDataADD = StringReplace($sLineDataAdd, @TAB, " ")
Local $isADD = false
$lineDataADD = StringReplace($lineDataADD, "Up o sub_71000" , "0x")
$isADD = StringInStr($lineData, "ADD")
$lineDataADD = StringSplit($lineDataADD, " ")[1]
$lineDataAddAddr = StringSplit($lineDataADD, "+")[1]
$lineDataAddAddition = StringSplit($lineDataADD, "+")[2]
$lineDataAddAddr = StringReplace($lineDataAddAddr, "0x" , "")
$lineDataAddAddition = StringReplace($lineDataAddAddition, "0x" , "")
$addrADD = Dec($lineDataAddAddr) + Dec($lineDataAddAddition)
$addrADD = $addrADD - $addrADRP
$lineDataADD = "0x" & Hex($addrADD)
Return @TAB & "{.opcode_reg = " & $targetRegister & ", .adrp_offset = " & $lineDataADRP & ", .add_rel_offset = " & $lineDataADD & "}, \" & @LF
EndFunc EndFunc
Func ParseClipboard() Func ParseClipboard()
Local $sData = ClipGet() Local $sData = ClipGet()
Local $oData = "" Local $oData = ""
Local $sLineData = StringSplit(StringReplace($sData, @CRLF, @LF), @LF) Local $sLineData = StringSplit(StringReplace($sData, @CRLF, @LF), @LF)
For $i = 2 to UBound($sLineData) - 2 For $i = 2 to UBound($sLineData) - 2 Step 2
Local $lineData = FormatLineData($sLineData[$i]) Local $lineData = FormatLineData($sLineData[$i], $sLineData[$i+1])
;ConsoleWrite($lineData) ;ConsoleWrite($lineData)
$oData = $oData & $lineData $oData = $oData & $lineData
Next Next
$oData = "{ \" & @LF & $oData & @TAB & "{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \" & @LF & "}" & @LF
;ConsoleWrite($oData)
ClipPut($oData) ClipPut($oData)
EndFunc EndFunc

View File

@@ -28,7 +28,7 @@ TARGET := $(notdir $(CURDIR))
BUILD := build BUILD := build
SOURCES := src src/dbg SOURCES := src src/dbg
DATA := data DATA := data
INCLUDES := include ../common/include INCLUDES := include ../libraries/libvapours/include
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation

View File

@@ -20,7 +20,7 @@ TARGET := $(notdir $(CURDIR))
BUILD := build BUILD := build
SOURCES := src SOURCES := src
DATA := data DATA := data
INCLUDES := include ../../common/include INCLUDES := include ../../libraries/libvapours/include
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation

View File

@@ -79,7 +79,7 @@ typedef enum {
CARDEVICE_UARTC = ((1 << 5) | 0x17), CARDEVICE_UARTC = ((1 << 5) | 0x17),
CARDEVICE_I2C1 = ((0 << 5) | 0xC), CARDEVICE_I2C1 = ((0 << 5) | 0xC),
CARDEVICE_I2C5 = ((1 << 5) | 0xF), CARDEVICE_I2C5 = ((1 << 5) | 0xF),
CARDEVICE_UNK = ((3 << 5) | 0x1E), CARDEVICE_TZRAM = ((3 << 5) | 0x1E),
CARDEVICE_SE = ((3 << 5) | 0x1F), CARDEVICE_SE = ((3 << 5) | 0x1F),
CARDEVICE_HOST1X = ((0 << 5) | 0x1C), CARDEVICE_HOST1X = ((0 << 5) | 0x1C),
CARDEVICE_TSEC = ((2 << 5) | 0x13), CARDEVICE_TSEC = ((2 << 5) | 0x13),

View File

@@ -35,6 +35,14 @@
#define MC_SMMU_PTB_DATA 0x20 #define MC_SMMU_PTB_DATA 0x20
#define MC_SMMU_TLB_FLUSH 0x30 #define MC_SMMU_TLB_FLUSH 0x30
#define MC_SMMU_PTC_FLUSH 0x34 #define MC_SMMU_PTC_FLUSH 0x34
#define MC_SMMU_ASID_SECURITY 0x38
#define MC_SMMU_ASID_SECURITY_1 0x3c
#define MC_SMMU_ASID_SECURITY_2 0x9e0
#define MC_SMMU_ASID_SECURITY_3 0x9e4
#define MC_SMMU_ASID_SECURITY_4 0x9e8
#define MC_SMMU_ASID_SECURITY_5 0x9ec
#define MC_SMMU_ASID_SECURITY_6 0x9f0
#define MC_SMMU_ASID_SECURITY_7 0x9f4
#define MC_SMMU_AFI_ASID 0x238 #define MC_SMMU_AFI_ASID 0x238
#define MC_SMMU_AVPC_ASID 0x23c #define MC_SMMU_AVPC_ASID 0x23c
#define MC_SMMU_PPCS1_ASID 0x298 #define MC_SMMU_PPCS1_ASID 0x298

View File

@@ -20,7 +20,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <atmosphere.h> #include <vapours/ams_version.h>
#define BIT(n) (1u << (n)) #define BIT(n) (1u << (n))
#define BITL(n) (1ull << (n)) #define BITL(n) (1ull << (n))

View File

@@ -85,6 +85,9 @@ void bootup_misc_mmio(void) {
setup_dram_magic_numbers(); setup_dram_magic_numbers();
} }
/* On 9.0.0+, Nintendo writes random values to context save scratch here, and locks the SRK scratch. */
/* There's no real need for us to do this, so we won't. */
/* Mark TMR5, TMR6, TMR7, TMR8, WDT0, WDT1, WDT2 and WDT3 as secure. */ /* Mark TMR5, TMR6, TMR7, TMR8, WDT0, WDT1, WDT2 and WDT3 as secure. */
SHARED_TIMER_SECURE_CFG_0 = 0xF1E0; SHARED_TIMER_SECURE_CFG_0 = 0xF1E0;
@@ -140,28 +143,26 @@ void bootup_misc_mmio(void) {
APB_MISC_SECURE_REGS_APB_SLAVE_SECURITY_ENABLE_REG2_0 = sec_disable_2; APB_MISC_SECURE_REGS_APB_SLAVE_SECURITY_ENABLE_REG2_0 = sec_disable_2;
} }
/* Reset Translation Enable Registers. */ /* Reset Translation Enable registers. */
MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_0) = 0xFFFFFFFF; MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_0) = 0xFFFFFFFF;
MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_1) = 0xFFFFFFFF; MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_1) = 0xFFFFFFFF;
MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_2) = 0xFFFFFFFF; MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_2) = 0xFFFFFFFF;
MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_3) = 0xFFFFFFFF; MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_3) = 0xFFFFFFFF;
MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_4) = 0xFFFFFFFF; MAKE_MC_REG(MC_SMMU_TRANSLATION_ENABLE_4) = 0xFFFFFFFF;
/* TODO: What are these MC reg writes? */ /* Set SMMU ASID security registers. */
if (exosphere_get_target_firmware() >= ATMOSPHERE_TARGET_FIRMWARE_400) { if (exosphere_get_target_firmware() >= ATMOSPHERE_TARGET_FIRMWARE_400) {
MAKE_MC_REG(0x038) = 0xE; MAKE_MC_REG(MC_SMMU_ASID_SECURITY) = 0xE;
} else { } else {
MAKE_MC_REG(0x038) = 0x0; MAKE_MC_REG(MC_SMMU_ASID_SECURITY) = 0x0;
} }
MAKE_MC_REG(0x03C) = 0; MAKE_MC_REG(MC_SMMU_ASID_SECURITY_1) = 0;
MAKE_MC_REG(MC_SMMU_ASID_SECURITY_2) = 0;
/* MISC registers. */ MAKE_MC_REG(MC_SMMU_ASID_SECURITY_3) = 0;
MAKE_MC_REG(0x9E0) = 0; MAKE_MC_REG(MC_SMMU_ASID_SECURITY_4) = 0;
MAKE_MC_REG(0x9E4) = 0; MAKE_MC_REG(MC_SMMU_ASID_SECURITY_5) = 0;
MAKE_MC_REG(0x9E8) = 0; MAKE_MC_REG(MC_SMMU_ASID_SECURITY_6) = 0;
MAKE_MC_REG(0x9EC) = 0; MAKE_MC_REG(MC_SMMU_ASID_SECURITY_7) = 0;
MAKE_MC_REG(0x9F0) = 0;
MAKE_MC_REG(0x9F4) = 0;
if (exosphere_get_target_firmware() >= ATMOSPHERE_TARGET_FIRMWARE_400) { if (exosphere_get_target_firmware() >= ATMOSPHERE_TARGET_FIRMWARE_400) {
MAKE_MC_REG(MC_SMMU_PTB_ASID) = 0; MAKE_MC_REG(MC_SMMU_PTB_ASID) = 0;
@@ -215,7 +216,7 @@ void bootup_misc_mmio(void) {
if (!g_has_booted_up) { if (!g_has_booted_up) {
/* N doesn't do this, but we should for compatibility. */ /* N doesn't do this, but we should for compatibility. */
uart_select(UART_A); uart_config(UART_A);
clkrst_reboot(CARDEVICE_UARTA); clkrst_reboot(CARDEVICE_UARTA);
uart_init(UART_A, 115200); uart_init(UART_A, 115200);

View File

@@ -15,7 +15,7 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <atmosphere/version.h> #include <vapours/ams_version.h>
#include "bootconfig.h" #include "bootconfig.h"
#include "configitem.h" #include "configitem.h"
@@ -38,6 +38,7 @@
static bool g_hiz_mode_enabled = false; static bool g_hiz_mode_enabled = false;
static bool g_debugmode_override_user = false, g_debugmode_override_priv = false; static bool g_debugmode_override_user = false, g_debugmode_override_priv = false;
static bool g_enable_usermode_exception_handlers = true; static bool g_enable_usermode_exception_handlers = true;
static bool g_enable_usermode_pmu_access = false;
uint32_t configitem_set(bool privileged, ConfigItem item, uint64_t value) { uint32_t configitem_set(bool privileged, ConfigItem item, uint64_t value) {
switch (item) { switch (item) {
@@ -168,6 +169,10 @@ void configitem_disable_usermode_exception_handlers(void) {
g_enable_usermode_exception_handlers = false; g_enable_usermode_exception_handlers = false;
} }
void configitem_enable_usermode_pmu_access(void) {
g_enable_usermode_pmu_access = true;
}
uint32_t configitem_get(bool privileged, ConfigItem item, uint64_t *p_outvalue) { uint32_t configitem_get(bool privileged, ConfigItem item, uint64_t *p_outvalue) {
uint32_t result = 0; uint32_t result = 0;
switch (item) { switch (item) {
@@ -222,6 +227,10 @@ uint32_t configitem_get(bool privileged, ConfigItem item, uint64_t *p_outvalue)
if (g_enable_usermode_exception_handlers) { if (g_enable_usermode_exception_handlers) {
config |= KERNELCONFIGFLAG_ENABLE_USER_EXCEPTION_HANDLERS; config |= KERNELCONFIGFLAG_ENABLE_USER_EXCEPTION_HANDLERS;
} }
/* Allow for enabling usermode pmu access. */
if (g_enable_usermode_pmu_access) {
config |= KERNELCONFIGFLAG_ENABLE_USER_PMU_ACCESS;
}
*p_outvalue = config; *p_outvalue = config;
} }
break; break;

View File

@@ -61,6 +61,7 @@ bool configitem_is_debugmode_priv(void);
void configitem_set_debugmode_override(bool user, bool priv); void configitem_set_debugmode_override(bool user, bool priv);
void configitem_disable_usermode_exception_handlers(void); void configitem_disable_usermode_exception_handlers(void);
void configitem_enable_usermode_pmu_access(void);
void configitem_set_hiz_mode_enabled(bool enabled); void configitem_set_hiz_mode_enabled(bool enabled);
uint64_t configitem_get_hardware_type(void); uint64_t configitem_get_hardware_type(void);

View File

@@ -18,7 +18,7 @@
#define EXOSPHERE_EMUMMC_CONFIG_H #define EXOSPHERE_EMUMMC_CONFIG_H
#include <stdint.h> #include <stdint.h>
#include <atmosphere.h> #include <vapours/ams_version.h>
#include "utils.h" #include "utils.h"
/* "EFS0" */ /* "EFS0" */

View File

@@ -22,7 +22,7 @@
#include "mmu.h" #include "mmu.h"
#include "memory_map.h" #include "memory_map.h"
static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_CONFIG, ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG, EXOSPHERE_FLAGS_DEFAULT}; static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_CONFIG, ATMOSPHERE_TARGET_FIRMWARE_CURRENT, EXOSPHERE_FLAGS_DEFAULT};
static bool g_has_loaded_config = false; static bool g_has_loaded_config = false;
#define EXOSPHERE_CHECK_FLAG(flag) ((g_exosphere_cfg.flags & flag) != 0) #define EXOSPHERE_CHECK_FLAG(flag) ((g_exosphere_cfg.flags & flag) != 0)
@@ -57,7 +57,7 @@ unsigned int exosphere_should_perform_620_keygen(void) {
generic_panic(); generic_panic();
} }
return g_exosphere_cfg.target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_620 && EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_PERFORM_620_KEYGEN); return false;
} }
unsigned int exosphere_should_override_debugmode_priv(void) { unsigned int exosphere_should_override_debugmode_priv(void) {
@@ -84,6 +84,14 @@ unsigned int exosphere_should_disable_usermode_exception_handlers(void) {
return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS); return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS);
} }
unsigned int exosphere_should_enable_usermode_pmu_access(void) {
if (!g_has_loaded_config) {
generic_panic();
}
return EXOSPHERE_CHECK_FLAG(EXOSPHERE_FLAG_ENABLE_USERMODE_PMU_ACCESS);
}
const exo_emummc_config_t *exosphere_get_emummc_config(void) { const exo_emummc_config_t *exosphere_get_emummc_config(void) {
if (!g_has_loaded_config) { if (!g_has_loaded_config) {
generic_panic(); generic_panic();

View File

@@ -18,7 +18,7 @@
#define EXOSPHERE_EXOSPHERE_CONFIG_H #define EXOSPHERE_EXOSPHERE_CONFIG_H
#include <stdint.h> #include <stdint.h>
#include <atmosphere.h> #include <vapours/ams_version.h>
#include "utils.h" #include "utils.h"
#include "memory_map.h" #include "memory_map.h"
@@ -36,10 +36,11 @@
/* Exosphere config in DRAM shares physical/virtual mapping. */ /* Exosphere config in DRAM shares physical/virtual mapping. */
#define MAILBOX_EXOSPHERE_CONFIG_PHYS MAILBOX_EXOSPHERE_CONFIG #define MAILBOX_EXOSPHERE_CONFIG_PHYS MAILBOX_EXOSPHERE_CONFIG
#define EXOSPHERE_FLAG_PERFORM_620_KEYGEN (1 << 0u) #define EXOSPHERE_FLAG_PERFORM_620_KEYGEN_DEPRECATED (1 << 0u)
#define EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV (1 << 1u) #define EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV (1 << 1u)
#define EXOSPHERE_FLAG_IS_DEBUGMODE_USER (1 << 2u) #define EXOSPHERE_FLAG_IS_DEBUGMODE_USER (1 << 2u)
#define EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS (1 << 3u) #define EXOSPHERE_FLAG_DISABLE_USERMODE_EXCEPTION_HANDLERS (1 << 3u)
#define EXOSPHERE_FLAG_ENABLE_USERMODE_PMU_ACCESS (1 << 4u)
#define EXOSPHERE_FLAGS_DEFAULT (EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV) #define EXOSPHERE_FLAGS_DEFAULT (EXOSPHERE_FLAG_IS_DEBUGMODE_PRIV)
typedef struct { typedef struct {
@@ -58,6 +59,7 @@ unsigned int exosphere_should_perform_620_keygen(void);
unsigned int exosphere_should_override_debugmode_priv(void); unsigned int exosphere_should_override_debugmode_priv(void);
unsigned int exosphere_should_override_debugmode_user(void); unsigned int exosphere_should_override_debugmode_user(void);
unsigned int exosphere_should_disable_usermode_exception_handlers(void); unsigned int exosphere_should_disable_usermode_exception_handlers(void);
unsigned int exosphere_should_enable_usermode_pmu_access(void);
const exo_emummc_config_t *exosphere_get_emummc_config(void); const exo_emummc_config_t *exosphere_get_emummc_config(void);
@@ -66,7 +68,7 @@ static inline unsigned int exosphere_get_target_firmware_for_init(void) {
if (magic == MAGIC_EXOSPHERE_CONFIG) { if (magic == MAGIC_EXOSPHERE_CONFIG) {
return MAILBOX_EXOSPHERE_CONFIG_PHYS.target_firmware; return MAILBOX_EXOSPHERE_CONFIG_PHYS.target_firmware;
} else { } else {
return ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG; return ATMOSPHERE_TARGET_FIRMWARE_CURRENT;
} }
} }

View File

@@ -14,25 +14,56 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <string.h>
#include "i2c.h" #include "i2c.h"
#include "utils.h" #include "utils.h"
#include "timers.h" #include "timers.h"
#include "pinmux.h"
/* Prototypes for internal commands. */ /* Prototypes for internal commands. */
volatile i2c_registers_t *i2c_get_registers_from_id(unsigned int id); volatile tegra_i2c_t *i2c_get_registers_from_id(I2CDevice id);
void i2c_load_config(volatile i2c_registers_t *regs); void i2c_load_config(volatile tegra_i2c_t *regs);
bool i2c_query(unsigned int id, uint8_t device, uint8_t r, void *dst, size_t dst_size); bool i2c_query(I2CDevice id, uint8_t device, uint8_t r, void *dst, size_t dst_size);
bool i2c_send(unsigned int id, uint8_t device, uint8_t r, void *src, size_t src_size); bool i2c_send(I2CDevice id, uint8_t device, uint8_t r, void *src, size_t src_size);
bool i2c_write(volatile i2c_registers_t *regs, uint8_t device, void *src, size_t src_size); bool i2c_write(volatile tegra_i2c_t *regs, uint8_t device, void *src, size_t src_size);
bool i2c_read(volatile i2c_registers_t *regs, uint8_t device, void *dst, size_t dst_size); bool i2c_read(volatile tegra_i2c_t *regs, uint8_t device, void *dst, size_t dst_size);
/* Configure I2C pinmux. */
void i2c_config(I2CDevice id) {
volatile tegra_pinmux_t *pinmux = pinmux_get_regs();
switch (id) {
case I2C_1:
pinmux->gen1_i2c_scl = PINMUX_INPUT;
pinmux->gen1_i2c_sda = PINMUX_INPUT;
break;
case I2C_2:
pinmux->gen2_i2c_scl = PINMUX_INPUT;
pinmux->gen2_i2c_sda = PINMUX_INPUT;
break;
case I2C_3:
pinmux->gen3_i2c_scl = PINMUX_INPUT;
pinmux->gen3_i2c_sda = PINMUX_INPUT;
break;
case I2C_4:
pinmux->cam_i2c_scl = PINMUX_INPUT;
pinmux->cam_i2c_sda = PINMUX_INPUT;
break;
case I2C_5:
pinmux->pwr_i2c_scl = PINMUX_INPUT;
pinmux->pwr_i2c_sda = PINMUX_INPUT;
break;
case I2C_6:
/* Unused. */
break;
default: break;
}
}
/* Initialize I2C based on registers. */ /* Initialize I2C based on registers. */
void i2c_init(unsigned int id) { void i2c_init(I2CDevice id) {
volatile i2c_registers_t *regs = i2c_get_registers_from_id(id); volatile tegra_i2c_t *regs = i2c_get_registers_from_id(id);
/* Setup divisor, and clear the bus. */ /* Setup divisor, and clear the bus. */
regs->I2C_I2C_CLK_DIVISOR_REGISTER_0 = 0x50001; regs->I2C_I2C_CLK_DIVISOR_REGISTER_0 = 0x50001;
@@ -43,7 +74,7 @@ void i2c_init(unsigned int id) {
/* Wait a while until BUS_CLEAR_DONE is set. */ /* Wait a while until BUS_CLEAR_DONE is set. */
for (unsigned int i = 0; i < 10; i++) { for (unsigned int i = 0; i < 10; i++) {
wait(20000); wait(25);
if (regs->I2C_INTERRUPT_STATUS_REGISTER_0 & 0x800) { if (regs->I2C_INTERRUPT_STATUS_REGISTER_0 & 0x800) {
break; break;
} }
@@ -61,16 +92,16 @@ void i2c_init(unsigned int id) {
void i2c_send_pmic_cpu_shutdown_cmd(void) { void i2c_send_pmic_cpu_shutdown_cmd(void) {
uint32_t val = 0; uint32_t val = 0;
/* PMIC == Device 4:3C. */ /* PMIC == Device 4:3C. */
i2c_query(4, 0x3C, 0x41, &val, 1); i2c_query(I2C_5, MAX77620_PWR_I2C_ADDR, 0x41, &val, 1);
val |= 4; val |= 4;
i2c_send(4, 0x3C, 0x41, &val, 1); i2c_send(I2C_5, MAX77620_PWR_I2C_ADDR, 0x41, &val, 1);
} }
/* Queries the value of TI charger bit over I2C. */ /* Queries the value of TI charger bit over I2C. */
bool i2c_query_ti_charger_bit_7(void) { bool i2c_query_ti_charger_bit_7(void) {
uint32_t val = 0; uint32_t val = 0;
/* TI Charger = Device 0:6B. */ /* TI Charger = Device 0:6B. */
i2c_query(0, 0x6B, 0, &val, 1); i2c_query(I2C_1, BQ24193_I2C_ADDR, 0, &val, 1);
return (val & 0x80) != 0; return (val & 0x80) != 0;
} }
@@ -78,34 +109,34 @@ bool i2c_query_ti_charger_bit_7(void) {
void i2c_clear_ti_charger_bit_7(void) { void i2c_clear_ti_charger_bit_7(void) {
uint32_t val = 0; uint32_t val = 0;
/* TI Charger = Device 0:6B. */ /* TI Charger = Device 0:6B. */
i2c_query(0, 0x6B, 0, &val, 1); i2c_query(I2C_1, BQ24193_I2C_ADDR, 0, &val, 1);
val &= 0x7F; val &= 0x7F;
i2c_send(0, 0x6B, 0, &val, 1); i2c_send(I2C_1, BQ24193_I2C_ADDR, 0, &val, 1);
} }
/* Sets TI charger bit over I2C. */ /* Sets TI charger bit over I2C. */
void i2c_set_ti_charger_bit_7(void) { void i2c_set_ti_charger_bit_7(void) {
uint32_t val = 0; uint32_t val = 0;
/* TI Charger = Device 0:6B. */ /* TI Charger = Device 0:6B. */
i2c_query(0, 0x6B, 0, &val, 1); i2c_query(I2C_1, BQ24193_I2C_ADDR, 0, &val, 1);
val |= 0x80; val |= 0x80;
i2c_send(0, 0x6B, 0, &val, 1); i2c_send(I2C_1, BQ24193_I2C_ADDR, 0, &val, 1);
} }
/* Get registers pointer based on I2C ID. */ /* Get registers pointer based on I2C ID. */
volatile i2c_registers_t *i2c_get_registers_from_id(unsigned int id) { volatile tegra_i2c_t *i2c_get_registers_from_id(I2CDevice id) {
switch (id) { switch (id) {
case 0: case I2C_1:
return I2C1_REGS; return I2C1_REGS;
case 1: case I2C_2:
return I2C2_REGS; return I2C2_REGS;
case 2: case I2C_3:
return I2C3_REGS; return I2C3_REGS;
case 3: case I2C_4:
return I2C4_REGS; return I2C4_REGS;
case 4: case I2C_5:
return I2C5_REGS; return I2C5_REGS;
case 5: case I2C_6:
return I2C6_REGS; return I2C6_REGS;
default: default:
generic_panic(); generic_panic();
@@ -114,7 +145,7 @@ volatile i2c_registers_t *i2c_get_registers_from_id(unsigned int id) {
} }
/* Load hardware config for I2C4. */ /* Load hardware config for I2C4. */
void i2c_load_config(volatile i2c_registers_t *regs) { void i2c_load_config(volatile tegra_i2c_t *regs) {
/* Set MSTR_CONFIG_LOAD, TIMEOUT_CONFIG_LOAD, undocumented bit. */ /* Set MSTR_CONFIG_LOAD, TIMEOUT_CONFIG_LOAD, undocumented bit. */
regs->I2C_I2C_CONFIG_LOAD_0 = 0x25; regs->I2C_I2C_CONFIG_LOAD_0 = 0x25;
@@ -128,8 +159,8 @@ void i2c_load_config(volatile i2c_registers_t *regs) {
} }
/* Reads a register from a device over I2C, writes result to output. */ /* Reads a register from a device over I2C, writes result to output. */
bool i2c_query(unsigned int id, uint8_t device, uint8_t r, void *dst, size_t dst_size) { bool i2c_query(I2CDevice id, uint8_t device, uint8_t r, void *dst, size_t dst_size) {
volatile i2c_registers_t *regs = i2c_get_registers_from_id(id); volatile tegra_i2c_t *regs = i2c_get_registers_from_id(id);
uint32_t val = r; uint32_t val = r;
/* Write single byte register ID to device. */ /* Write single byte register ID to device. */
@@ -145,7 +176,7 @@ bool i2c_query(unsigned int id, uint8_t device, uint8_t r, void *dst, size_t dst
} }
/* Writes a value to a register over I2C. */ /* Writes a value to a register over I2C. */
bool i2c_send(unsigned int id, uint8_t device, uint8_t r, void *src, size_t src_size) { bool i2c_send(I2CDevice id, uint8_t device, uint8_t r, void *src, size_t src_size) {
uint32_t val = r; uint32_t val = r;
if (src_size == 0) { if (src_size == 0) {
return true; return true;
@@ -158,7 +189,7 @@ bool i2c_send(unsigned int id, uint8_t device, uint8_t r, void *src, size_t src_
} }
/* Writes bytes to device over I2C. */ /* Writes bytes to device over I2C. */
bool i2c_write(volatile i2c_registers_t *regs, uint8_t device, void *src, size_t src_size) { bool i2c_write(volatile tegra_i2c_t *regs, uint8_t device, void *src, size_t src_size) {
if (src_size > 4) { if (src_size > 4) {
return false; return false;
} else if (src_size == 0) { } else if (src_size == 0) {
@@ -177,8 +208,7 @@ bool i2c_write(volatile i2c_registers_t *regs, uint8_t device, void *src, size_t
i2c_load_config(regs); i2c_load_config(regs);
/* Config |= SEND; */ /* Config |= SEND; */
regs->I2C_I2C_CNFG_0 |= 0x200; regs->I2C_I2C_CNFG_0 = ((regs->I2C_I2C_CNFG_0 & 0xFFFFFDFF) | 0x200);
while (regs->I2C_I2C_STATUS_0 & 0x100) { while (regs->I2C_I2C_STATUS_0 & 0x100) {
/* Wait until not busy. */ /* Wait until not busy. */
@@ -189,7 +219,7 @@ bool i2c_write(volatile i2c_registers_t *regs, uint8_t device, void *src, size_t
} }
/* Reads bytes from device over I2C. */ /* Reads bytes from device over I2C. */
bool i2c_read(volatile i2c_registers_t *regs, uint8_t device, void *dst, size_t dst_size) { bool i2c_read(volatile tegra_i2c_t *regs, uint8_t device, void *dst, size_t dst_size) {
if (dst_size > 4) { if (dst_size > 4) {
return false; return false;
} else if (dst_size == 0) { } else if (dst_size == 0) {
@@ -205,8 +235,7 @@ bool i2c_read(volatile i2c_registers_t *regs, uint8_t device, void *dst, size_t
i2c_load_config(regs); i2c_load_config(regs);
/* Config |= SEND; */ /* Config |= SEND; */
regs->I2C_I2C_CNFG_0 |= 0x200; regs->I2C_I2C_CNFG_0 = ((regs->I2C_I2C_CNFG_0 & 0xFFFFFDFF) | 0x200);
while (regs->I2C_I2C_STATUS_0 & 0x100) { while (regs->I2C_I2C_STATUS_0 & 0x100) {
/* Wait until not busy. */ /* Wait until not busy. */

View File

@@ -19,10 +19,27 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "memory_map.h" #include "memory_map.h"
/* Exosphere driver for the Tegra X1 I2C registers. */ /* Exosphere driver for the Tegra X1 I2C registers. */
#define MAX77621_CPU_I2C_ADDR 0x1B
#define MAX77621_GPU_I2C_ADDR 0x1C
#define MAX17050_I2C_ADDR 0x36
#define MAX77620_PWR_I2C_ADDR 0x3C
#define MAX77620_RTC_I2C_ADDR 0x68
#define BQ24193_I2C_ADDR 0x6B
typedef enum {
I2C_1 = 0,
I2C_2 = 1,
I2C_3 = 2,
I2C_4 = 3,
I2C_5 = 4,
I2C_6 = 5,
} I2CDevice;
typedef struct { typedef struct {
uint32_t I2C_I2C_CNFG_0; uint32_t I2C_I2C_CNFG_0;
uint32_t I2C_I2C_CMD_ADDR0_0; uint32_t I2C_I2C_CMD_ADDR0_0;
@@ -65,7 +82,7 @@ typedef struct {
uint32_t I2C_I2C_INTERFACE_TIMING_1_0; uint32_t I2C_I2C_INTERFACE_TIMING_1_0;
uint32_t I2C_I2C_HS_INTERFACE_TIMING_0_0; uint32_t I2C_I2C_HS_INTERFACE_TIMING_0_0;
uint32_t I2C_I2C_HS_INTERFACE_TIMING_1_0; uint32_t I2C_I2C_HS_INTERFACE_TIMING_1_0;
} i2c_registers_t; } tegra_i2c_t;
static inline uintptr_t get_i2c_dtv_234_base(void) { static inline uintptr_t get_i2c_dtv_234_base(void) {
return MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_DTV_I2C234); return MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_DTV_I2C234);
@@ -75,17 +92,20 @@ static inline uintptr_t get_i2c56_spi2b_base(void) {
return MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_I2C56_SPI2B); return MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_I2C56_SPI2B);
} }
#define I2C1_REGS ((volatile i2c_registers_t *)(get_i2c_dtv_234_base() + 0x000)) #define I2C1_REGS ((volatile tegra_i2c_t *)(get_i2c_dtv_234_base() + 0x000))
#define I2C2_REGS ((volatile i2c_registers_t *)(get_i2c_dtv_234_base() + 0x400)) #define I2C2_REGS ((volatile tegra_i2c_t *)(get_i2c_dtv_234_base() + 0x400))
#define I2C3_REGS ((volatile i2c_registers_t *)(get_i2c_dtv_234_base() + 0x500)) #define I2C3_REGS ((volatile tegra_i2c_t *)(get_i2c_dtv_234_base() + 0x500))
#define I2C4_REGS ((volatile i2c_registers_t *)(get_i2c_dtv_234_base() + 0x700)) #define I2C4_REGS ((volatile tegra_i2c_t *)(get_i2c_dtv_234_base() + 0x700))
#define I2C5_REGS ((volatile i2c_registers_t *)(get_i2c56_spi2b_base() + 0x000)) #define I2C5_REGS ((volatile tegra_i2c_t *)(get_i2c56_spi2b_base() + 0x000))
#define I2C6_REGS ((volatile i2c_registers_t *)(get_i2c56_spi2b_base() + 0x100)) #define I2C6_REGS ((volatile tegra_i2c_t *)(get_i2c56_spi2b_base() + 0x100))
void i2c_init(unsigned int id); void i2c_config(I2CDevice id);
void i2c_init(I2CDevice id);
bool i2c_query(I2CDevice id, uint8_t device, uint8_t r, void *dst, size_t dst_size);
bool i2c_send(I2CDevice id, uint8_t device, uint8_t r, void *src, size_t src_size);
void i2c_send_pmic_cpu_shutdown_cmd(void); void i2c_send_pmic_cpu_shutdown_cmd(void);
bool i2c_query_ti_charger_bit_7(void); bool i2c_query_ti_charger_bit_7(void);
void i2c_clear_ti_charger_bit_7(void); void i2c_clear_ti_charger_bit_7(void);
void i2c_set_ti_charger_bit_7(void); void i2c_set_ti_charger_bit_7(void);

View File

@@ -42,6 +42,9 @@ static const uint8_t mkey_vectors_dev[MASTERKEY_REVISION_MAX][0x10] =
{0x78, 0xD5, 0xF1, 0x20, 0x3D, 0x16, 0xE9, 0x30, 0x32, 0x27, 0x34, 0x6F, 0xCF, 0xE0, 0x27, 0xDC}, /* Master key 04 encrypted with Master key 05. */ {0x78, 0xD5, 0xF1, 0x20, 0x3D, 0x16, 0xE9, 0x30, 0x32, 0x27, 0x34, 0x6F, 0xCF, 0xE0, 0x27, 0xDC}, /* Master key 04 encrypted with Master key 05. */
{0x6F, 0xD2, 0x84, 0x1D, 0x05, 0xEC, 0x40, 0x94, 0x5F, 0x18, 0xB3, 0x81, 0x09, 0x98, 0x8D, 0x4E}, /* Master key 05 encrypted with Master key 06. */ {0x6F, 0xD2, 0x84, 0x1D, 0x05, 0xEC, 0x40, 0x94, 0x5F, 0x18, 0xB3, 0x81, 0x09, 0x98, 0x8D, 0x4E}, /* Master key 05 encrypted with Master key 06. */
{0x37, 0xAF, 0xAB, 0x35, 0x79, 0x09, 0xD9, 0x48, 0x29, 0xD2, 0xDB, 0xA5, 0xA5, 0xF5, 0x30, 0x19}, /* Master key 06 encrypted with Master key 07. */ {0x37, 0xAF, 0xAB, 0x35, 0x79, 0x09, 0xD9, 0x48, 0x29, 0xD2, 0xDB, 0xA5, 0xA5, 0xF5, 0x30, 0x19}, /* Master key 06 encrypted with Master key 07. */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 07 encrypted with Master key 08. */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 08 encrypted with Master key 09. */
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 09 encrypted with Master key 0A. */
}; };
/* Retail unit keys. */ /* Retail unit keys. */
@@ -55,6 +58,9 @@ static const uint8_t mkey_vectors[MASTERKEY_REVISION_MAX][0x10] =
{0xEB, 0xF5, 0x6F, 0x83, 0x61, 0x9E, 0xF8, 0xFA, 0xE0, 0x87, 0xD7, 0xA1, 0x4E, 0x25, 0x36, 0xEE}, /* Master key 04 encrypted with Master key 05. */ {0xEB, 0xF5, 0x6F, 0x83, 0x61, 0x9E, 0xF8, 0xFA, 0xE0, 0x87, 0xD7, 0xA1, 0x4E, 0x25, 0x36, 0xEE}, /* Master key 04 encrypted with Master key 05. */
{0x1E, 0x1E, 0x22, 0xC0, 0x5A, 0x33, 0x3C, 0xB9, 0x0B, 0xA9, 0x03, 0x04, 0xBA, 0xDB, 0x07, 0x57}, /* Master key 05 encrypted with Master key 06. */ {0x1E, 0x1E, 0x22, 0xC0, 0x5A, 0x33, 0x3C, 0xB9, 0x0B, 0xA9, 0x03, 0x04, 0xBA, 0xDB, 0x07, 0x57}, /* Master key 05 encrypted with Master key 06. */
{0xA4, 0xD4, 0x52, 0x6F, 0xD1, 0xE4, 0x36, 0xAA, 0x9F, 0xCB, 0x61, 0x27, 0x1C, 0x67, 0x65, 0x1F}, /* Master key 06 encrypted with Master key 07. */ {0xA4, 0xD4, 0x52, 0x6F, 0xD1, 0xE4, 0x36, 0xAA, 0x9F, 0xCB, 0x61, 0x27, 0x1C, 0x67, 0x65, 0x1F}, /* Master key 06 encrypted with Master key 07. */
{0xEA, 0x60, 0xB3, 0xEA, 0xCE, 0x8F, 0x24, 0x46, 0x7D, 0x33, 0x9C, 0xD1, 0xBC, 0x24, 0x98, 0x29}, /* Master key 07 encrypted with Master key 08. */
{0x4D, 0xD9, 0x98, 0x42, 0x45, 0x0D, 0xB1, 0x3C, 0x52, 0x0C, 0x9A, 0x44, 0xBB, 0xAD, 0xAF, 0x80}, /* Master key 08 encrypted with Master key 09. */
{0xB8, 0x96, 0x9E, 0x4A, 0x00, 0x0D, 0xD6, 0x28, 0xB3, 0xD1, 0xDB, 0x68, 0x5F, 0xFB, 0xE1, 0x2A}, /* Master key 09 encrypted with Master key 0A. */
}; };
bool check_mkey_revision(unsigned int revision, bool is_retail) { bool check_mkey_revision(unsigned int revision, bool is_retail) {
@@ -125,7 +131,6 @@ unsigned int mkey_get_keyslot(unsigned int revision) {
} }
} }
void set_old_devkey(unsigned int revision, const uint8_t *key) { void set_old_devkey(unsigned int revision, const uint8_t *key) {
if (revision < MASTERKEY_REVISION_400_410 || MASTERKEY_REVISION_MAX <= revision) { if (revision < MASTERKEY_REVISION_400_410 || MASTERKEY_REVISION_MAX <= revision) {
generic_panic(); generic_panic();
@@ -135,23 +140,17 @@ void set_old_devkey(unsigned int revision, const uint8_t *key) {
} }
unsigned int devkey_get_keyslot(unsigned int revision) { unsigned int devkey_get_keyslot(unsigned int revision) {
if (!g_determined_mkey_revision || revision >= MASTERKEY_REVISION_MAX) { if (!g_determined_mkey_revision || revision > g_mkey_revision) {
generic_panic(); generic_panic();
} }
if (revision > g_mkey_revision) { if (revision < MASTERKEY_REVISION_400_410) {
generic_panic(); return KEYSLOT_SWITCH_4XOLDDEVICEKEY;
} } else if (revision < g_mkey_revision) {
if (revision >= 1) {
if (revision == MASTERKEY_REVISION_MAX) {
return KEYSLOT_SWITCH_DEVICEKEY;
} else {
/* Load into a temp keyslot. */ /* Load into a temp keyslot. */
set_aes_keyslot(KEYSLOT_SWITCH_TEMPKEY, g_old_devicekeys[revision - MASTERKEY_REVISION_400_410], 0x10); set_aes_keyslot(KEYSLOT_SWITCH_TEMPKEY, g_old_devicekeys[revision - MASTERKEY_REVISION_400_410], 0x10);
return KEYSLOT_SWITCH_TEMPKEY; return KEYSLOT_SWITCH_TEMPKEY;
}
} else { } else {
return KEYSLOT_SWITCH_4XOLDDEVICEKEY; return KEYSLOT_SWITCH_DEVICEKEY;
} }
} }

View File

@@ -19,8 +19,8 @@
/* This is glue code to enable master key support across versions. */ /* This is glue code to enable master key support across versions. */
/* TODO: Update to 0x9 on release of new master key. */ /* TODO: Update to 0xC on release of new master key. */
#define MASTERKEY_REVISION_MAX 0x8 #define MASTERKEY_REVISION_MAX 0xB
#define MASTERKEY_REVISION_100_230 0x00 #define MASTERKEY_REVISION_100_230 0x00
#define MASTERKEY_REVISION_300 0x01 #define MASTERKEY_REVISION_300 0x01
@@ -29,7 +29,10 @@
#define MASTERKEY_REVISION_500_510 0x04 #define MASTERKEY_REVISION_500_510 0x04
#define MASTERKEY_REVISION_600_610 0x05 #define MASTERKEY_REVISION_600_610 0x05
#define MASTERKEY_REVISION_620 0x06 #define MASTERKEY_REVISION_620 0x06
#define MASTERKEY_REVISION_700_CURRENT 0x07 #define MASTERKEY_REVISION_700_800 0x07
#define MASTERKEY_REVISION_810 0x08
#define MASTERKEY_REVISION_900 0x09
#define MASTERKEY_REVISION_910_CURRENT 0x0A
#define MASTERKEY_NUM_NEW_DEVICE_KEYS (MASTERKEY_REVISION_MAX - MASTERKEY_REVISION_400_410) #define MASTERKEY_NUM_NEW_DEVICE_KEYS (MASTERKEY_REVISION_MAX - MASTERKEY_REVISION_400_410)

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