Compare commits
1052 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89cc6ede1a | ||
|
|
dd6e071dde | ||
|
|
2127271b33 | ||
|
|
1600171ffa | ||
|
|
7f7a9fab2d | ||
|
|
b15d86f31d | ||
|
|
89a3dc8643 | ||
|
|
3477beb05c | ||
|
|
8447c209a7 | ||
|
|
e78f706c1a | ||
|
|
f776c56cd4 | ||
|
|
dc195dffad | ||
|
|
a2177c0510 | ||
|
|
356a94cc2e | ||
|
|
9d507e046c | ||
|
|
47c47f967a | ||
|
|
1182d3a627 | ||
|
|
938cb6492f | ||
|
|
fed62855cb | ||
|
|
4f54596658 | ||
|
|
0b41ed04d5 | ||
|
|
9509a86998 | ||
|
|
6d4d80a798 | ||
|
|
76d274cfe2 | ||
|
|
ccf13be964 | ||
|
|
e36b27ccf0 | ||
|
|
34c80ad476 | ||
|
|
97ae106d8e | ||
|
|
7cb74b74d7 | ||
|
|
337205eb08 | ||
|
|
f36977017b | ||
|
|
e40b547bb6 | ||
|
|
1fd689f5da | ||
|
|
c5c8dca14c | ||
|
|
11f820efa7 | ||
|
|
9074688491 | ||
|
|
1de27c54f1 | ||
|
|
3e67e64faa | ||
|
|
553f8d2533 | ||
|
|
ec7ae35da1 | ||
|
|
7e8da0d236 | ||
|
|
b3e6561072 | ||
|
|
41f32ed983 | ||
|
|
bbadf840ef | ||
|
|
acc50aae46 | ||
|
|
6a68a77973 | ||
|
|
0f4d66dd61 | ||
|
|
d28642d2c3 | ||
|
|
ca4685cc42 | ||
|
|
522f10582d | ||
|
|
239d113177 | ||
|
|
fd80294bf2 | ||
|
|
b379d83469 | ||
|
|
27f352fdf1 | ||
|
|
bfec874a7c | ||
|
|
93561003e8 | ||
|
|
1572bfd989 | ||
|
|
cb945612a3 | ||
|
|
1b440f7f3b | ||
|
|
78791f7b66 | ||
|
|
5def0c18e2 | ||
|
|
0e67b0f026 | ||
|
|
8052946517 | ||
|
|
b6d6cc9750 | ||
|
|
2a840f2c79 | ||
|
|
4eaf791849 | ||
|
|
be0f50b19c | ||
|
|
f30b7b9fb3 | ||
|
|
6a0f332e3c | ||
|
|
16530d3a52 | ||
|
|
20af9c6750 | ||
|
|
fee9f6b427 | ||
|
|
57d03d6333 | ||
|
|
0075fe2aa0 | ||
|
|
d54417ac0a | ||
|
|
648801d432 | ||
|
|
2be2826b0b | ||
|
|
37a9fa1bf4 | ||
|
|
65af93c8ce | ||
|
|
8353b84944 | ||
|
|
d6a89db495 | ||
|
|
f156aa8cdb | ||
|
|
f9adbcc9d9 | ||
|
|
cf8696ac70 | ||
|
|
9c5766f649 | ||
|
|
c9701f93b9 | ||
|
|
56e54cd110 | ||
|
|
55836b48af | ||
|
|
09bfdb9ee1 | ||
|
|
1c2e8dec11 | ||
|
|
506b16db37 | ||
|
|
8f03234e58 | ||
|
|
44b5e10323 | ||
|
|
48303604b0 | ||
|
|
ab2ddbc2ee | ||
|
|
9495bf30bf | ||
|
|
a4899a1bec | ||
|
|
882c6cf0d4 | ||
|
|
a5e18c82d1 | ||
|
|
22a8661fe1 | ||
|
|
8258a98647 | ||
|
|
76dde0e6db | ||
|
|
1a39cb27e4 | ||
|
|
95d2d0a6bd | ||
|
|
98d4345858 | ||
|
|
1e4431dcc9 | ||
|
|
348b175994 | ||
|
|
76f057dafb | ||
|
|
188400c5a9 | ||
|
|
a74d9c6d3e | ||
|
|
f8bcfb2f58 | ||
|
|
d63fc2bc82 | ||
|
|
8e31784996 | ||
|
|
f27cdb4543 | ||
|
|
a39adc8ac1 | ||
|
|
97bef66018 | ||
|
|
bb5518b0f6 | ||
|
|
ac73a96ce2 | ||
|
|
7075004e58 | ||
|
|
ddf8ba5116 | ||
|
|
f46773ba64 | ||
|
|
f67d333457 | ||
|
|
4116c1e00f | ||
|
|
bc1aa15dd7 | ||
|
|
ecd27f7eaa | ||
|
|
618ce671ac | ||
|
|
2a6a655804 | ||
|
|
33436ae2a6 | ||
|
|
9f2b66ac51 | ||
|
|
df93e4797e | ||
|
|
538d1dec77 | ||
|
|
2492c8273a | ||
|
|
d358df48a6 | ||
|
|
f619dafff1 | ||
|
|
0419fc4e30 | ||
|
|
13317b9548 | ||
|
|
18db70a669 | ||
|
|
f79923814d | ||
|
|
c92de03a5f | ||
|
|
3f356da879 | ||
|
|
9efac01c86 | ||
|
|
ca2622af7c | ||
|
|
aa8e0bda8c | ||
|
|
c79f11ee99 | ||
|
|
04d0770b90 | ||
|
|
fbf8a1b6d9 | ||
|
|
a3cb6a622d | ||
|
|
0790a3ceb3 | ||
|
|
4fa12f90fc | ||
|
|
d5d56e7634 | ||
|
|
a964089df4 | ||
|
|
5fd5b4da89 | ||
|
|
322a7050aa | ||
|
|
b7f4ac02c8 | ||
|
|
009f61a8b6 | ||
|
|
26d0cafb39 | ||
|
|
bd1d4a77fe | ||
|
|
f235bc83a8 | ||
|
|
9c6b540905 | ||
|
|
d2e911a58e | ||
|
|
9344a7b434 | ||
|
|
cd194fa5b2 | ||
|
|
49c0ab65df | ||
|
|
8f9c1305e4 | ||
|
|
d4193ec11d | ||
|
|
6b9b0472bc | ||
|
|
7e74258363 | ||
|
|
f6483ec602 | ||
|
|
36c1da1d61 | ||
|
|
6bcb1f8679 | ||
|
|
62932a9639 | ||
|
|
a4629e4b65 | ||
|
|
a0c2b43b34 | ||
|
|
3907c46980 | ||
|
|
7e7ab124a3 | ||
|
|
cfc6cf24bf | ||
|
|
46e9cb6b23 | ||
|
|
ba14efe1f4 | ||
|
|
3d8f62d38f | ||
|
|
3edaf0af64 | ||
|
|
9273a88db7 | ||
|
|
37ba2c15de | ||
|
|
557f2057f7 | ||
|
|
6b5cc93780 | ||
|
|
9760191af8 | ||
|
|
8845e4dd20 | ||
|
|
8cf823f548 | ||
|
|
2538769f3a | ||
|
|
89fca38807 | ||
|
|
dcc0eed69c | ||
|
|
817475257e | ||
|
|
f2861058ba | ||
|
|
5d2a7315d5 | ||
|
|
1520ab7555 | ||
|
|
d4d0fbd73b | ||
|
|
ddb8e98e95 | ||
|
|
fd69b4169f | ||
|
|
b48e0b5c5b | ||
|
|
31e2243c5c | ||
|
|
da0ee2e442 | ||
|
|
b88dc9ac6a | ||
|
|
9f78d7f62b | ||
|
|
e67c6ed3ee | ||
|
|
2e111ca91b | ||
|
|
62d51fd99d | ||
|
|
a9289b1f21 | ||
|
|
d42e938232 | ||
|
|
3d3dcb1f28 | ||
|
|
82143212ce | ||
|
|
7246a2664e | ||
|
|
1291f2520a | ||
|
|
042ecf5343 | ||
|
|
6e54dcc24c | ||
|
|
91378ef3c1 | ||
|
|
0377cbd2b4 | ||
|
|
786ecf4fe4 | ||
|
|
0fbdee313f | ||
|
|
9b8e2b933d | ||
|
|
cc64ef9670 | ||
|
|
31ff6a1da8 | ||
|
|
94532e9cea | ||
|
|
3f93bc5988 | ||
|
|
39ca23d609 | ||
|
|
47a9c1b576 | ||
|
|
d819cfd58f | ||
|
|
17828273a5 | ||
|
|
2363817265 | ||
|
|
b31018ab17 | ||
|
|
c610ec3319 | ||
|
|
b71dedccfc | ||
|
|
9ccfacd06d | ||
|
|
12b561a27d | ||
|
|
cc41003e1c | ||
|
|
3d534c9a81 | ||
|
|
24de7c5272 | ||
|
|
a1b2ea2c5b | ||
|
|
19d68b6df4 | ||
|
|
2ab41dbd01 | ||
|
|
da30c0b0f0 | ||
|
|
005684d865 | ||
|
|
da1eff82ba | ||
|
|
a17311c955 | ||
|
|
e1d0602f25 | ||
|
|
2ff9718510 | ||
|
|
33af9cfe09 | ||
|
|
79709a7ae7 | ||
|
|
a796a70d01 | ||
|
|
53e2ef24f1 | ||
|
|
c0059c83ac | ||
|
|
37eb21d297 | ||
|
|
52a18831a7 | ||
|
|
0d7cca7b20 | ||
|
|
bea73c51ae | ||
|
|
0c68750056 | ||
|
|
ae8ea7da16 | ||
|
|
69762c5dce | ||
|
|
901d4992c0 | ||
|
|
4d47d891d1 | ||
|
|
a7046909ec | ||
|
|
4bc95979de | ||
|
|
949d219c72 | ||
|
|
9a3d9aed30 | ||
|
|
4d99143da0 | ||
|
|
461035b212 | ||
|
|
0694ea8367 | ||
|
|
427a05997d | ||
|
|
84d736c2eb | ||
|
|
a16d1ebe33 | ||
|
|
43f3c84316 | ||
|
|
44cafe3f46 | ||
|
|
76d7a035bd | ||
|
|
a5b638ae7b | ||
|
|
174089e4f3 | ||
|
|
4d219813fe | ||
|
|
a798f453d2 | ||
|
|
6ec21611c0 | ||
|
|
31f4419eec | ||
|
|
60d136f9b5 | ||
|
|
0ba7f9dba0 | ||
|
|
0ac6db006a | ||
|
|
26dd61e4e6 | ||
|
|
dda11206db | ||
|
|
e8565d30a9 | ||
|
|
2d4c103854 | ||
|
|
d0b9e36908 | ||
|
|
21db0d45bd | ||
|
|
4429cb2095 | ||
|
|
cab54d1b31 | ||
|
|
1d2909ea03 | ||
|
|
d802e5329c | ||
|
|
118f81d347 | ||
|
|
ba3740a77a | ||
|
|
47369c8f5e | ||
|
|
7a05dee453 | ||
|
|
9e47369365 | ||
|
|
5379c05001 | ||
|
|
5b34b2d114 | ||
|
|
3ea8734fdd | ||
|
|
8e22080e05 | ||
|
|
692a94fe5e | ||
|
|
01c760ab88 | ||
|
|
28e5d8107f | ||
|
|
710d8cd15c | ||
|
|
8395540288 | ||
|
|
d57d8aaae7 | ||
|
|
10f555b6fb | ||
|
|
9f30244bfb | ||
|
|
0b65fcbdd7 | ||
|
|
067e217909 | ||
|
|
d6c6c421e9 | ||
|
|
90b54581b0 | ||
|
|
68d9674ca3 | ||
|
|
a9a8edeaf4 | ||
|
|
dd21a3930d | ||
|
|
53209b9be0 | ||
|
|
8308e1a8b8 | ||
|
|
986a2fb5d8 | ||
|
|
9570e6cbec | ||
|
|
93a08c5ef9 | ||
|
|
a187c0c7ce | ||
|
|
43f4475272 | ||
|
|
a7ed32e206 | ||
|
|
6eadac23b3 | ||
|
|
1c7eb8f97a | ||
|
|
a71c5f42fc | ||
|
|
de0f1dc156 | ||
|
|
bb05961f70 | ||
|
|
57900e91ba | ||
|
|
98f650a5de | ||
|
|
55b2db4a8d | ||
|
|
fbe3088744 | ||
|
|
336ab6a64c | ||
|
|
c73fec46e6 | ||
|
|
b493e2bd5f | ||
|
|
78a7d6c5af | ||
|
|
a8b2e9a50c | ||
|
|
2d7c1e42d8 | ||
|
|
64ebec3ea4 | ||
|
|
252d32aafe | ||
|
|
2349370960 | ||
|
|
6ccc0f0538 | ||
|
|
9f12a47cfc | ||
|
|
ee880802c8 | ||
|
|
ab14e77b50 | ||
|
|
1d4245e582 | ||
|
|
8636a74ba4 | ||
|
|
3b766de306 | ||
|
|
1f300e1b75 | ||
|
|
56efe6035f | ||
|
|
73e363d159 | ||
|
|
3ac134bc16 | ||
|
|
c7bb1f9655 | ||
|
|
7847646b3e | ||
|
|
ec6e9f73bb | ||
|
|
bd62f033ab | ||
|
|
ba88ec25f6 | ||
|
|
b9bc41a772 | ||
|
|
e029458b09 | ||
|
|
b3ecf1776b | ||
|
|
5fe83588eb | ||
|
|
18b8eaabae | ||
|
|
e11695c2f0 | ||
|
|
91edbf71c8 | ||
|
|
5b9b22021b | ||
|
|
033d90b866 | ||
|
|
540c0df918 | ||
|
|
6de167467f | ||
|
|
c746326eb3 | ||
|
|
0fbd384a73 | ||
|
|
e8d4a98c7b | ||
|
|
f5aa63936c | ||
|
|
62a57d0f47 | ||
|
|
958fb4c739 | ||
|
|
e231275cbe | ||
|
|
5a404c3a35 | ||
|
|
b1c07c6204 | ||
|
|
60f158d488 | ||
|
|
1887c6fae3 | ||
|
|
725a825762 | ||
|
|
b81f59d5ae | ||
|
|
39c2b8927b | ||
|
|
89dfdac7bf | ||
|
|
c087edf2ba | ||
|
|
db33c315f2 | ||
|
|
c7e7dd8248 | ||
|
|
b10d82a883 | ||
|
|
e151b3d4ef | ||
|
|
5ccf4a45c1 | ||
|
|
c5369a5cad | ||
|
|
b5eba765a5 | ||
|
|
a5ddc38477 | ||
|
|
8d102256a2 | ||
|
|
2e561f7ea9 | ||
|
|
9656fe1b6f | ||
|
|
48c23f2a43 | ||
|
|
6d82649c3c | ||
|
|
81dea35754 | ||
|
|
fdbe43421b | ||
|
|
0d71560785 | ||
|
|
108e8a0cd4 | ||
|
|
653e81c48e | ||
|
|
0dc0783094 | ||
|
|
13ef1bf6be | ||
|
|
7ea80353f6 | ||
|
|
07bbff7d11 | ||
|
|
2ff4fc3cdd | ||
|
|
c9456055ea | ||
|
|
2900f2d67b | ||
|
|
93c8c90804 | ||
|
|
36e54642d2 | ||
|
|
e04cb28711 | ||
|
|
ad1dc51e06 | ||
|
|
5b6bab7a58 | ||
|
|
9bd2fc659d | ||
|
|
f18633f65f | ||
|
|
1026bc7b4f | ||
|
|
f1dee68142 | ||
|
|
f7cc2d295c | ||
|
|
a6f254b5cf | ||
|
|
00dbbe1b28 | ||
|
|
7f33309903 | ||
|
|
c95808fa2d | ||
|
|
5b6bd048a9 | ||
|
|
28e6ad3372 | ||
|
|
9b128ebba5 | ||
|
|
71f49180c3 | ||
|
|
4a042241a8 | ||
|
|
0eab9127e3 | ||
|
|
9f11991410 | ||
|
|
fec0b95098 | ||
|
|
5081439f53 | ||
|
|
c44aebee4d | ||
|
|
706cd50f25 | ||
|
|
b1b81c87f2 | ||
|
|
bf7e30539e | ||
|
|
5f8a61201b | ||
|
|
ed8aee8b8c | ||
|
|
92ec2af587 | ||
|
|
7960c87579 | ||
|
|
700d572732 | ||
|
|
014a0d86f1 | ||
|
|
88db59405f | ||
|
|
ef2e008700 | ||
|
|
07101c053a | ||
|
|
6c5f6ac475 | ||
|
|
61ecd9a617 | ||
|
|
6f56a9bfe9 | ||
|
|
416875ee46 | ||
|
|
c875b506ea | ||
|
|
ff4517e583 | ||
|
|
92cc989dc9 | ||
|
|
6e5987e3ca | ||
|
|
f03e232b90 | ||
|
|
1eb18c1790 | ||
|
|
3076d56973 | ||
|
|
b35707edf9 | ||
|
|
dfbd0dc9e7 | ||
|
|
620ad7ba71 | ||
|
|
5e4fd53243 | ||
|
|
0ba7630354 | ||
|
|
028d0ec0d5 | ||
|
|
751fa05fcd | ||
|
|
f89845257e | ||
|
|
2f274e2f47 | ||
|
|
38088e80e1 | ||
|
|
14162828ea | ||
|
|
ab8507e09d | ||
|
|
0d25c07333 | ||
|
|
bfc8ba8447 | ||
|
|
a45f8293d9 | ||
|
|
f29b9d14d7 | ||
|
|
9c9fd2deef | ||
|
|
3bb01ffd68 | ||
|
|
bc6d9994dc | ||
|
|
e177f9e0fe | ||
|
|
c5d75d2de9 | ||
|
|
cc0cade4d2 | ||
|
|
1e3362250f | ||
|
|
db16e8d602 | ||
|
|
2a563eddd0 | ||
|
|
6b8474b7b9 | ||
|
|
b5336c81cc | ||
|
|
1fcab825bf | ||
|
|
0306556032 | ||
|
|
b093578046 | ||
|
|
9332b9eb33 | ||
|
|
141c7817a0 | ||
|
|
f155026d8f | ||
|
|
37e467ba60 | ||
|
|
3572b835b5 | ||
|
|
da4f3a72af | ||
|
|
2938bbd11f | ||
|
|
abf3017eb2 | ||
|
|
5c855ea52f | ||
|
|
c83edea7ad | ||
|
|
6d3113c8c3 | ||
|
|
48c48c7bbc | ||
|
|
e4093ed988 | ||
|
|
c79af52720 | ||
|
|
61eeaca6d5 | ||
|
|
320a79ba72 | ||
|
|
2e1b943805 | ||
|
|
bc167dde2d | ||
|
|
7d9a8b4211 | ||
|
|
0b16d88756 | ||
|
|
796cb31ed7 | ||
|
|
d7fd2f26c1 | ||
|
|
5adb8749de | ||
|
|
3474faa4a2 | ||
|
|
acd9c04ff6 | ||
|
|
833c9406b0 | ||
|
|
2f1253e27f | ||
|
|
53b847e31c | ||
|
|
7efa33dd7f | ||
|
|
4011970a57 | ||
|
|
a2cfa2be16 | ||
|
|
c4b691d688 | ||
|
|
72a7a8eee5 | ||
|
|
52d352385f | ||
|
|
c1f85650bd | ||
|
|
b830909504 | ||
|
|
4ad6b1c220 | ||
|
|
429488a4ba | ||
|
|
40c6cc11a5 | ||
|
|
594881c6ce | ||
|
|
1cc64a0fbc | ||
|
|
f492318e3c | ||
|
|
4b06bb7795 | ||
|
|
f7e570383a | ||
|
|
896a088199 | ||
|
|
f3322bd003 | ||
|
|
cef947d67d | ||
|
|
b6640d118d | ||
|
|
273d0b2ce9 | ||
|
|
9b724d776e | ||
|
|
3eaa706ccf | ||
|
|
b4c854dfe8 | ||
|
|
9cdadbe834 | ||
|
|
b3f38a8764 | ||
|
|
5d868284c6 | ||
|
|
035751980d | ||
|
|
6b80bc08d5 | ||
|
|
2089959d1b | ||
|
|
67b00ec28d | ||
|
|
127ae6b945 | ||
|
|
4f53b3ce35 | ||
|
|
c3092b482a | ||
|
|
080219f88d | ||
|
|
3fd783cd01 | ||
|
|
211cd964d7 | ||
|
|
04f42f0be4 | ||
|
|
e00ef893d0 | ||
|
|
858efa604e | ||
|
|
b63b17c54f | ||
|
|
f0e111c20e | ||
|
|
7339f57138 | ||
|
|
1e39c999f9 | ||
|
|
62f7a06192 | ||
|
|
a0531b7930 | ||
|
|
0619d04939 | ||
|
|
cd76476d26 | ||
|
|
53b6c17e33 | ||
|
|
3b7b66b272 | ||
|
|
a795a45c34 | ||
|
|
b58cbd228c | ||
|
|
fc994285f9 | ||
|
|
d5e74b91c7 | ||
|
|
c5eb2e1070 | ||
|
|
d613cb057e | ||
|
|
121792bebe | ||
|
|
e07c230106 | ||
|
|
d5ce3044c8 | ||
|
|
98ff43b4d2 | ||
|
|
1704fbcd62 | ||
|
|
014ac1cf72 | ||
|
|
b499c7ee75 | ||
|
|
2e069e326c | ||
|
|
e47d42da22 | ||
|
|
615e5dfaa7 | ||
|
|
fde2c371ef | ||
|
|
a0b4e7fd5d | ||
|
|
45c36bbcae | ||
|
|
66c041ad93 | ||
|
|
32d5c52b5f | ||
|
|
9cf5b01633 | ||
|
|
d4cf22d370 | ||
|
|
973640f023 | ||
|
|
248ea82f76 | ||
|
|
a868079a93 | ||
|
|
d270d5b9ca | ||
|
|
e9692a438b | ||
|
|
06ea123dbd | ||
|
|
85141d5eda | ||
|
|
fa13b8fbd0 | ||
|
|
5b4712644a | ||
|
|
aa422914bd | ||
|
|
22c453e297 | ||
|
|
e5f40cec5a | ||
|
|
50b24bf6c2 | ||
|
|
b575ee9e28 | ||
|
|
37030621ac | ||
|
|
f005da4d12 | ||
|
|
6295559d9c | ||
|
|
f36ff303d9 | ||
|
|
1a62e91c01 | ||
|
|
7f314dfe11 | ||
|
|
0caf9f4214 | ||
|
|
1ad600c81a | ||
|
|
bd6c7b7fdb | ||
|
|
5f93724845 | ||
|
|
ad60eac6ef | ||
|
|
b3e3a2937a | ||
|
|
d010038228 | ||
|
|
c28eada93e | ||
|
|
9d84a92b1f | ||
|
|
7884be106d | ||
|
|
5fe7c7e7e1 | ||
|
|
f244b95aad | ||
|
|
3b5a5759b8 | ||
|
|
528e7ee33b | ||
|
|
c1f55735fc | ||
|
|
185ea86284 | ||
|
|
618262f015 | ||
|
|
c0f41ac10e | ||
|
|
3010699f20 | ||
|
|
fb274538e1 | ||
|
|
1a5d953a98 | ||
|
|
2dd1baebb3 | ||
|
|
d46beac22a | ||
|
|
6ed8741006 | ||
|
|
6845e42f2c | ||
|
|
5196869634 | ||
|
|
083806bfc9 | ||
|
|
11d29368ce | ||
|
|
100c3d9e36 | ||
|
|
01fbf8c3a5 | ||
|
|
a36556d7e4 | ||
|
|
4f11162fae | ||
|
|
2cbaf39fd5 | ||
|
|
2cc46c618b | ||
|
|
a0325e91f9 | ||
|
|
e11edd5dee | ||
|
|
5e8990f571 | ||
|
|
a3fd55036a | ||
|
|
7a3d15c48b | ||
|
|
a5b52a2470 | ||
|
|
a8cd14dafd | ||
|
|
2b249bd496 | ||
|
|
c8586cfe26 | ||
|
|
f228cb241f | ||
|
|
fd33ef8496 | ||
|
|
ba1cf6473a | ||
|
|
f418dcdb7b | ||
|
|
f91c26d752 | ||
|
|
f7156f2ff2 | ||
|
|
e444b587cf | ||
|
|
a7fcc6a5cf | ||
|
|
872b1ccbb6 | ||
|
|
b7b3400296 | ||
|
|
420ccdcb82 | ||
|
|
eaa4d6323e | ||
|
|
4e7ac41a6c | ||
|
|
92f3a736a7 | ||
|
|
5a30b2b298 | ||
|
|
85aaae67bf | ||
|
|
efe66bc72e | ||
|
|
d7bdf3fc19 | ||
|
|
c4e5f4410c | ||
|
|
f5039dca56 | ||
|
|
de6f9789cb | ||
|
|
4376a1093f | ||
|
|
a413ed01f3 | ||
|
|
05bb831321 | ||
|
|
6e0f1e5235 | ||
|
|
2f915401dd | ||
|
|
14152b3072 | ||
|
|
8f3cba37b3 | ||
|
|
0853f6f7ad | ||
|
|
ae7a7ba365 | ||
|
|
724af0fdc4 | ||
|
|
550ea2116e | ||
|
|
7952271d61 | ||
|
|
ffaa5790c2 | ||
|
|
934c4bed0b | ||
|
|
6f040caa98 | ||
|
|
50e5c29b1c | ||
|
|
e0b5539b91 | ||
|
|
050f58a3bb | ||
|
|
c739ed8e48 | ||
|
|
a09fc6ebcb | ||
|
|
4367ea6afa | ||
|
|
da0adeb39e | ||
|
|
63160a22a6 | ||
|
|
2bc1927ebd | ||
|
|
66e0cfc185 | ||
|
|
7bd0e4f5b4 | ||
|
|
7271850df2 | ||
|
|
8c79285774 | ||
|
|
56a77ceac1 | ||
|
|
3034420ac2 | ||
|
|
99a157649d | ||
|
|
e6645554f0 | ||
|
|
0f83d1ffaa | ||
|
|
2286eb21a7 | ||
|
|
64c81aa5f8 | ||
|
|
29dcfca608 | ||
|
|
f1cb9630ec | ||
|
|
ebbea57400 | ||
|
|
6016dc14f8 | ||
|
|
dc8e4e5f14 | ||
|
|
72c8212a0e | ||
|
|
2cd2a081d6 | ||
|
|
b44ec544f4 | ||
|
|
063eae7e95 | ||
|
|
2552572904 | ||
|
|
b74dda42a2 | ||
|
|
6e178e2069 | ||
|
|
277d723992 | ||
|
|
2f6afe9932 | ||
|
|
edcc617780 | ||
|
|
5d39242b83 | ||
|
|
ddbe5fd27b | ||
|
|
deb91d1d02 | ||
|
|
63073ea07f | ||
|
|
a331fcd873 | ||
|
|
99654bd5b2 | ||
|
|
f10427287f | ||
|
|
5b6318ee3a | ||
|
|
98cdbe0784 | ||
|
|
e4eb3ae38d | ||
|
|
6686e4add7 | ||
|
|
96a274bf7d | ||
|
|
add17a7994 | ||
|
|
26e404c6a2 | ||
|
|
144de8b328 | ||
|
|
c0226e6fd9 | ||
|
|
57d728a9be | ||
|
|
b2e9f5377b | ||
|
|
d3d315784c | ||
|
|
942a371b6a | ||
|
|
66ffc78f60 | ||
|
|
a9570cef14 | ||
|
|
16bc08f046 | ||
|
|
024335e5cd | ||
|
|
8f32048774 | ||
|
|
33d3dd256d | ||
|
|
fc151f7595 | ||
|
|
9152884815 | ||
|
|
2b4e97bec5 | ||
|
|
a63393504f | ||
|
|
97ae8d2d44 | ||
|
|
6c59728516 | ||
|
|
201fe05a06 | ||
|
|
a78889523f | ||
|
|
5cd1a207c9 | ||
|
|
423f0ca631 | ||
|
|
7612e38d41 | ||
|
|
bf234950cb | ||
|
|
bd992fca15 | ||
|
|
45fee57abd | ||
|
|
a2bca96d47 | ||
|
|
9862256ca7 | ||
|
|
6afc8b3b5c | ||
|
|
9b4b4ec543 | ||
|
|
d412711868 | ||
|
|
0b33551d94 | ||
|
|
9c1b585054 | ||
|
|
fc3a69d9ca | ||
|
|
cce4a6d07f | ||
|
|
b16539408b | ||
|
|
eba56d0f64 | ||
|
|
f2181b1d3e | ||
|
|
c93a97f8d7 | ||
|
|
8fd2525cd1 | ||
|
|
62a70cfdac | ||
|
|
ca0a79fc89 | ||
|
|
104b8e859f | ||
|
|
a99b26ff8c | ||
|
|
9bc62ec12d | ||
|
|
84a6bb772f | ||
|
|
263a5eda56 | ||
|
|
7fb17ce52f | ||
|
|
631fad24c0 | ||
|
|
f1d77fa62a | ||
|
|
3bc247b43b | ||
|
|
3608799dff | ||
|
|
c0f042bc2a | ||
|
|
8982ff259a | ||
|
|
726b06b748 | ||
|
|
0057ab9c5a | ||
|
|
048bf0ee4d | ||
|
|
4da0708b51 | ||
|
|
4c529e3145 | ||
|
|
8ceeca372f | ||
|
|
4326ac9be1 | ||
|
|
697c64abe4 | ||
|
|
7e8cf84c42 | ||
|
|
b6d91375a5 | ||
|
|
61305688fd | ||
|
|
492ae4139f | ||
|
|
a84f393bd5 | ||
|
|
5de54d6f9f | ||
|
|
8fc797120f | ||
|
|
5406d648bc | ||
|
|
a2003fba95 | ||
|
|
a76c15d018 | ||
|
|
ae8caf3d3a | ||
|
|
f221915a95 | ||
|
|
7f93733107 | ||
|
|
e8b9e49f57 | ||
|
|
cb9576b10e | ||
|
|
06fe06f9f1 | ||
|
|
abf7c8e565 | ||
|
|
46227e6763 | ||
|
|
2ffe4a5451 | ||
|
|
18bd4bbcf6 | ||
|
|
8209433696 | ||
|
|
ad9e00acaa | ||
|
|
c96f96258f | ||
|
|
82699f3e00 | ||
|
|
e2d828a4a2 | ||
|
|
92328c6a7e | ||
|
|
3f8ad17e86 | ||
|
|
52999db43a | ||
|
|
760aa99709 | ||
|
|
51c514de84 | ||
|
|
317899b4bf | ||
|
|
4c93d2b1f9 | ||
|
|
71c5404bfe | ||
|
|
9c5248b87a | ||
|
|
83a0293af4 | ||
|
|
84f3eddaf8 | ||
|
|
a5c6b908b6 | ||
|
|
94f0d873df | ||
|
|
d6f66d24fa | ||
|
|
31458e9938 | ||
|
|
dca612ffd7 | ||
|
|
5177308d48 | ||
|
|
59ab44a8c7 | ||
|
|
c711ed6253 | ||
|
|
58c6be17eb | ||
|
|
259bcc686c | ||
|
|
356268eae5 | ||
|
|
2dd64b8a92 | ||
|
|
b5cddedb7d | ||
|
|
7afdc2b3b5 | ||
|
|
60c4956290 | ||
|
|
4c6a2f7ab1 | ||
|
|
76cee0d95b | ||
|
|
7331a919e4 | ||
|
|
27ea6b96c4 | ||
|
|
33238cee54 | ||
|
|
384dd2ad81 | ||
|
|
4885e0b8d8 | ||
|
|
2a84911d3b | ||
|
|
7f672fb417 | ||
|
|
a13fdeecf6 | ||
|
|
74ac76ba84 | ||
|
|
253e031f83 | ||
|
|
ef1ecf859c | ||
|
|
a302ad3bea | ||
|
|
0951260df7 | ||
|
|
b87dadbb72 | ||
|
|
1dd6a9821a | ||
|
|
50a2424001 | ||
|
|
61e5a4444f | ||
|
|
de3eb6ccd7 | ||
|
|
4f8c66b2b7 | ||
|
|
4d9cbc4e19 | ||
|
|
40369d44df | ||
|
|
ee3720f0b7 | ||
|
|
e5dcca1c2b | ||
|
|
ef8438a214 | ||
|
|
dfd699c16b | ||
|
|
a381c2a811 | ||
|
|
e4c87a59d0 | ||
|
|
eef30ceb3c | ||
|
|
76411387ba | ||
|
|
8d5d8d2100 | ||
|
|
802bce12a7 | ||
|
|
a1024c288e | ||
|
|
a4531b01d5 | ||
|
|
d445b20e90 | ||
|
|
24ddf5ca3d | ||
|
|
bb117d3d74 | ||
|
|
c101653077 | ||
|
|
5248b96f8a | ||
|
|
7ab59e420a | ||
|
|
83a849126a | ||
|
|
c9c373f607 | ||
|
|
aa7c2c0009 | ||
|
|
57fc4df86f | ||
|
|
75acdc8a98 | ||
|
|
070f7fcc68 | ||
|
|
4d48238fb1 | ||
|
|
9b304404f7 | ||
|
|
8e5ced8e3c | ||
|
|
95ef379ac5 | ||
|
|
915f9ccb0d | ||
|
|
3709ac301a | ||
|
|
3bc966f84e | ||
|
|
457b4cec13 | ||
|
|
88891ef6cd | ||
|
|
25811e2b52 | ||
|
|
f81c92e35b | ||
|
|
39b2aff627 | ||
|
|
905777466d | ||
|
|
4e21cf4f1c | ||
|
|
eccf9eab93 | ||
|
|
c36ad54bcb | ||
|
|
81e2b7c11c | ||
|
|
18b5cdcddf | ||
|
|
fe31114779 | ||
|
|
df30a2a320 | ||
|
|
cf7fa8ecbd | ||
|
|
389a169443 | ||
|
|
e01802e299 | ||
|
|
709aefba5d | ||
|
|
e4ed713fce | ||
|
|
d3c507b0d4 | ||
|
|
a68e14def3 | ||
|
|
8175642a2a | ||
|
|
8d1befea9e | ||
|
|
e7b8a0ef39 | ||
|
|
be6ee894f9 | ||
|
|
e0e8ed2113 | ||
|
|
c63e46b1a9 | ||
|
|
eb9c74a1ed | ||
|
|
efd83e063e | ||
|
|
ae23a1c84d | ||
|
|
fd1253caac | ||
|
|
a0e8bc1de3 | ||
|
|
004f0652c9 | ||
|
|
d5190cd788 | ||
|
|
2412faf033 | ||
|
|
72caad86cc | ||
|
|
7df9917a00 | ||
|
|
575adcbb9d | ||
|
|
2d6debddb9 | ||
|
|
53d2aac2ae | ||
|
|
96211813e3 | ||
|
|
153bbd6242 | ||
|
|
730e716f0f | ||
|
|
2238293c0f | ||
|
|
29d8e637d8 | ||
|
|
136e0d8974 | ||
|
|
0eb87df84f | ||
|
|
a9db998d84 | ||
|
|
fcb8edffdf | ||
|
|
61684ecb68 | ||
|
|
0ced86b55f | ||
|
|
159c9cb475 | ||
|
|
2943dcb2e9 | ||
|
|
984c3e549c | ||
|
|
edfd63e1f7 | ||
|
|
e593584a47 | ||
|
|
ef60c8ea4c | ||
|
|
e478908dca | ||
|
|
ca587692eb | ||
|
|
f78dd5365c | ||
|
|
f9d6cdccb0 | ||
|
|
35fdd470b3 | ||
|
|
edff11be7b | ||
|
|
bb230de72c | ||
|
|
2d7dde9cf9 | ||
|
|
b77d619873 | ||
|
|
ae1033d975 | ||
|
|
99d28c4f79 | ||
|
|
2424865fa1 | ||
|
|
6a280723f8 | ||
|
|
f85bbfff58 | ||
|
|
d239d82379 | ||
|
|
9017de6082 | ||
|
|
477414a636 | ||
|
|
5fac49447c | ||
|
|
30b3a51309 | ||
|
|
bafba1197e | ||
|
|
2fab0be5e8 | ||
|
|
7ea2a0a278 | ||
|
|
a3ae38520c | ||
|
|
c36fa01651 | ||
|
|
9aeac7af92 | ||
|
|
859944dc8e | ||
|
|
a6dc3c8fc7 | ||
|
|
61c02ed079 | ||
|
|
afc6f51ff2 | ||
|
|
c32eefaa51 | ||
|
|
b6969cf0d1 | ||
|
|
58a33ee6e9 | ||
|
|
050f433046 | ||
|
|
d48f6b62ce | ||
|
|
ffee64c67f | ||
|
|
8cbc535755 | ||
|
|
ca07af2fe9 | ||
|
|
2fe5da97eb | ||
|
|
6ffaeadd1b | ||
|
|
2c10b6bff2 | ||
|
|
76acfd9934 | ||
|
|
06cc4f7172 | ||
|
|
158659e5b0 | ||
|
|
7e46046e3b | ||
|
|
808c4b7361 | ||
|
|
03dc4fc425 | ||
|
|
b4029dcd73 | ||
|
|
1750b256eb | ||
|
|
d00d82ac89 | ||
|
|
edb5a82a89 | ||
|
|
f7552f7c32 | ||
|
|
4483b65b25 | ||
|
|
d2f53626ae | ||
|
|
ac01fe417e | ||
|
|
2fd8c7aace | ||
|
|
b90b138766 | ||
|
|
c3ad7eda08 | ||
|
|
02c6a3c214 | ||
|
|
8dd9c1a1af | ||
|
|
be54052b6d | ||
|
|
9e87679ee2 | ||
|
|
17964f8cd1 | ||
|
|
a63fb971d4 | ||
|
|
4b500349e6 | ||
|
|
8e554e17c9 | ||
|
|
1d77206ae4 | ||
|
|
4340c326dc | ||
|
|
c6cb97ae30 | ||
|
|
9d68c980e6 | ||
|
|
e2596a0a61 | ||
|
|
17d3c6491a | ||
|
|
f55fc421ea | ||
|
|
169b12fc20 | ||
|
|
905f816bbe | ||
|
|
fef48a449a | ||
|
|
95d06c115a | ||
|
|
113059e57c | ||
|
|
408c70b90c | ||
|
|
5b51574ebf | ||
|
|
1e6d7a5aee | ||
|
|
a28b50cee8 | ||
|
|
df112b550b | ||
|
|
85615d1916 | ||
|
|
c6d3158b56 | ||
|
|
4a4de608ec | ||
|
|
e651c3d9cc | ||
|
|
9c12496b30 | ||
|
|
bfc2448662 | ||
|
|
faa04b0309 | ||
|
|
ca1ea7fd6e | ||
|
|
57dc1b09ad | ||
|
|
f6d3abbc11 | ||
|
|
9ab3a7c451 | ||
|
|
f0e1937eeb | ||
|
|
efd08ff731 |
90
.github/ISSUE_TEMPLATE.md
vendored
Normal file
90
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<!--
|
||||
-- THIS IS NOT A SUPPORT FORUM! For support go here:
|
||||
-- Nintendo Homebrew: https://discord.gg/MjzatM8
|
||||
--
|
||||
-- Rosalina feature requests go here: https://github.com/AuroraWright/Luma3DS/issues/752
|
||||
--
|
||||
-- Also check the Wiki (https://github.com/AuroraWright/Luma3DS/wiki) before making an issue.
|
||||
--
|
||||
-- For GBA/DSiWare/DS/AGB_FIRM/TWL_FIRM problems: https://3ds.hacks.guide/troubleshooting
|
||||
-- If you're using an emu/redNAND try installing anything on it to sysNAND.
|
||||
-- Please make sure to read "Enable game patching" https://github.com/AuroraWright/Luma3DS/wiki/Options-and-usage before posting any issues about the "Enable game patching" option(s).
|
||||
--
|
||||
-- Luma updaters that don't support Boot9Strap/Sighax won't work.
|
||||
-- This is due to support for non-B9S/Sighax entrypoints being dropped.
|
||||
--
|
||||
-- Please fill in the placeholders.-->
|
||||
**System model:**
|
||||
|
||||
[e.g. 2DS, New 3DS, Old 3DS]
|
||||
|
||||
**SysNAND version (+emu/redNAND version if applicable):**
|
||||
|
||||
[e.g. 11.6.0-39U SysNAND, 11.6.0-39J EmuNAND]
|
||||
|
||||
**Entrypoint (How/what you're using to boot Luma3DS):**
|
||||
|
||||
[e.g. Boot9Strap/Sighax, etc.]
|
||||
|
||||
**Luma3DS version:**
|
||||
|
||||
[e.g. 8.1.1 stable or if using nightly/hourly specify the commit like this https://github.com/AuroraWright/Luma3DS/commit/9570e6cbeca53128433abbf5e3473cb8a07fe69e]
|
||||
<!--You can check which version you're on in System Settings. It will be on the bottom right of the top screen.-->
|
||||
|
||||
|
||||
**Luma3DS configuration/options:**
|
||||
|
||||
Default EmuNAND: ( )
|
||||
|
||||
Screen brightness: ( )
|
||||
|
||||
Splash: ( )
|
||||
|
||||
PIN lock: ( )
|
||||
|
||||
New 3DS CPU: ( )
|
||||
<!--This option is only available for New 3DS/2DS.-->
|
||||
|
||||
--
|
||||
|
||||
Autoboot EmuNAND: ( )
|
||||
|
||||
Use EmuNAND FIRM if booting with R: ( )
|
||||
|
||||
Enable loading external FIRMs and modules: ( )
|
||||
<!--Firmware (.bin) files are not required by Luma, or NTR CFW anymore.
|
||||
-- If you're having issues with this option enabled try deleting them from the luma folder on the root of the SD card or /rw/luma on CTRNAND and disabling this option.-->
|
||||
|
||||
Enable game patching: ( )
|
||||
|
||||
Show NAND or user string in System Settings: ( )
|
||||
|
||||
Show GBA boot screen in patched AGB_FIRM: ( )
|
||||
|
||||
Patch ARM9 access: ( )
|
||||
|
||||
Set developer UNITINFO: ( )
|
||||
|
||||
Disable ARM11 exception handlers: ( )
|
||||
|
||||
--
|
||||
|
||||
|
||||
**Explanation of the issue:**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**Steps to reproduce:**
|
||||
|
||||
1.
|
||||
|
||||
2.
|
||||
|
||||
|
||||
**Dump file:**
|
||||
<!--If the issue leads to a crash you must uncheck the "Disable ARM11 exception handlers" option.
|
||||
-- The error message will tell you where the dump is.
|
||||
-- Zip the dmp file and drag & drop it below.-->
|
||||
20
.gitignore
vendored
20
.gitignore
vendored
@@ -1,12 +1,20 @@
|
||||
.vscode
|
||||
out
|
||||
build
|
||||
loader/build
|
||||
screeninit/build
|
||||
injector/build
|
||||
arm11/build
|
||||
sysmodules/loader/build
|
||||
sysmodules/rosalina/build
|
||||
chainloader/build
|
||||
exceptions/arm9/build
|
||||
exceptions/arm11/build
|
||||
*.bin
|
||||
*.3dsx
|
||||
*.smdh
|
||||
*.firm
|
||||
*.o
|
||||
*.d
|
||||
*.elf
|
||||
*.bat
|
||||
*.cxi
|
||||
.DS_Store
|
||||
*.dmp
|
||||
.project
|
||||
.cproject
|
||||
.settings
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +0,0 @@
|
||||
[submodule "CakeBrah"]
|
||||
path = CakeBrah
|
||||
url = https://github.com/mid-kid/CakeBrah
|
||||
[submodule "CakeHax"]
|
||||
path = CakeHax
|
||||
url = https://github.com/mid-kid/CakeHax
|
||||
1
CakeBrah
1
CakeBrah
Submodule CakeBrah deleted from 42ebe0d0bc
1
CakeHax
1
CakeHax
Submodule CakeHax deleted from 5245c7b9dc
199
Makefile
199
Makefile
@@ -4,119 +4,174 @@ ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
ifneq ($(strip $(shell firmtool -v 2>&1 | grep usage)),)
|
||||
$(error "Please install firmtool v1.1 or greater")
|
||||
endif
|
||||
|
||||
CC := arm-none-eabi-gcc
|
||||
AS := arm-none-eabi-as
|
||||
LD := arm-none-eabi-ld
|
||||
OC := arm-none-eabi-objcopy
|
||||
include $(DEVKITARM)/base_tools
|
||||
|
||||
name := Luma3DS
|
||||
version := $(shell git describe --abbrev=0 --tags)
|
||||
revision := $(shell git describe --tags --match v[0-9]* --abbrev=8 | sed 's/-[0-9]*-g/-/')
|
||||
version_major := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f1 -d.)
|
||||
version_minor := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f2 -d.)
|
||||
version_build := $(shell git describe --tags --match v[0-9]* | cut -c2- | cut -f1 -d- | cut -f3 -d.)
|
||||
commit := $(shell git rev-parse --short=8 HEAD)
|
||||
is_release := 0
|
||||
|
||||
ifeq ($(strip $(revision)),)
|
||||
revision := v0.0.0-0
|
||||
version_major := 0
|
||||
version_minor := 0
|
||||
version_build := 0
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(commit)),)
|
||||
commit := 0
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(version_build)),)
|
||||
version_build := 0
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(shell git describe --tags --match v[0-9]* | grep -)),)
|
||||
is_release := 1
|
||||
endif
|
||||
|
||||
dir_source := source
|
||||
dir_patches := patches
|
||||
dir_loader := loader
|
||||
dir_screeninit := screeninit
|
||||
dir_injector := injector
|
||||
dir_mset := CakeHax
|
||||
dir_ninjhax := CakeBrah
|
||||
dir_arm11 := arm11
|
||||
dir_chainloader := chainloader
|
||||
dir_exceptions := exceptions
|
||||
dir_arm9_exceptions := $(dir_exceptions)/arm9
|
||||
dir_k11_extension := k11_extension
|
||||
dir_sysmodules := sysmodules
|
||||
dir_loader := $(dir_sysmodules)/loader
|
||||
dir_rosalina := $(dir_sysmodules)/rosalina
|
||||
dir_sm := $(dir_sysmodules)/sm
|
||||
dir_pxi := $(dir_sysmodules)/pxi
|
||||
dir_build := build
|
||||
dir_out := out
|
||||
|
||||
ASFLAGS := -mcpu=arm946e-s
|
||||
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -fshort-wchar -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||
LDFLAGS := -nostartfiles
|
||||
FLAGS := name=$(name).dat dir_out=$(abspath $(dir_out)) ICON=$(abspath icon.png) APP_DESCRIPTION="Noob-friendly 3DS CFW." APP_AUTHOR="Aurora Wright" --no-print-directory
|
||||
CFLAGS := -Wall -Wextra $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||
LDFLAGS := -nostartfiles -Wl,--nmagic
|
||||
|
||||
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||
|
||||
bundled = $(dir_build)/patches.h $(dir_build)/loader.h $(dir_build)/screeninit.h
|
||||
bundled = $(dir_build)/reboot.bin.o $(dir_build)/emunand.bin.o $(dir_build)/chainloader.bin.o $(dir_build)/arm9_exceptions.bin.o
|
||||
|
||||
modules = $(dir_build)/loader.cxi $(dir_build)/rosalina.cxi $(dir_build)/sm.cxi $(dir_build)/pxi.cxi
|
||||
|
||||
define bin2o
|
||||
bin2s $< | $(AS) -o $(@)
|
||||
endef
|
||||
|
||||
.PHONY: all
|
||||
all: launcher a9lh ninjhax
|
||||
|
||||
.PHONY: launcher
|
||||
launcher: $(dir_out)/$(name).dat
|
||||
|
||||
.PHONY: a9lh
|
||||
a9lh: $(dir_out)/arm9loaderhax.bin
|
||||
|
||||
.PHONY: ninjhax
|
||||
ninjhax: $(dir_out)/3ds/$(name)
|
||||
all: firm
|
||||
|
||||
.PHONY: release
|
||||
release: $(dir_out)/$(name)$(version).7z
|
||||
release: $(dir_out)/$(name)$(revision).7z
|
||||
|
||||
.PHONY: firm
|
||||
firm: $(dir_out)/boot.firm
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(MAKE) $(FLAGS) -C $(dir_mset) clean
|
||||
@$(MAKE) $(FLAGS) -C $(dir_ninjhax) clean
|
||||
@$(MAKE) -C $(dir_arm11) clean
|
||||
@$(MAKE) -C $(dir_chainloader) clean
|
||||
@$(MAKE) -C $(dir_arm9_exceptions) clean
|
||||
@$(MAKE) -C $(dir_k11_extension) clean
|
||||
@$(MAKE) -C $(dir_loader) clean
|
||||
@$(MAKE) -C $(dir_screeninit) clean
|
||||
@$(MAKE) -C $(dir_injector) clean
|
||||
@$(MAKE) -C $(dir_rosalina) clean
|
||||
@$(MAKE) -C $(dir_sm) clean
|
||||
@$(MAKE) -C $(dir_pxi) clean
|
||||
@rm -rf $(dir_out) $(dir_build)
|
||||
|
||||
$(dir_out):
|
||||
@mkdir -p "$(dir_out)/luma/payloads"
|
||||
.PRECIOUS: $(dir_build)/%.bin
|
||||
|
||||
$(dir_out)/$(name).dat: $(dir_build)/main.bin $(dir_out)
|
||||
@$(MAKE) $(FLAGS) -C $(dir_mset) launcher
|
||||
@dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
|
||||
.PHONY: $(dir_arm11)
|
||||
.PHONY: $(dir_chainloader)
|
||||
.PHONY: $(dir_arm9_exceptions)
|
||||
.PHONY: $(dir_k11_extension)
|
||||
.PHONY: $(dir_loader)
|
||||
.PHONY: $(dir_rosalina)
|
||||
.PHONY: $(dir_sm)
|
||||
.PHONY: $(dir_pxi)
|
||||
|
||||
$(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin $(dir_out)
|
||||
@cp -a $(dir_build)/main.bin $@
|
||||
|
||||
$(dir_out)/3ds/$(name): $(dir_out)
|
||||
@mkdir -p "$@"
|
||||
@$(MAKE) $(FLAGS) -C $(dir_ninjhax)
|
||||
@mv $(dir_out)/$(name).3dsx $(dir_out)/$(name).smdh $@
|
||||
$(dir_out)/$(name)$(revision).7z: all
|
||||
@mkdir -p "$(@D)"
|
||||
@[ -f "$@" ] || 7z a -mx $@ ./$(@D)/* ./$(dir_exceptions)/exception_dump_parser -xr!.DS_Store
|
||||
|
||||
$(dir_out)/$(name)$(version).7z: launcher a9lh ninjhax
|
||||
@7z a -mx $@ ./$(@D)/*
|
||||
$(dir_out)/boot.firm: $(dir_build)/modules.bin $(dir_build)/arm11.elf $(dir_build)/main.elf $(dir_build)/k11_extension.bin
|
||||
@mkdir -p "$(@D)"
|
||||
@firmtool build $@ -D $^ -A 0x18180000 0x18000000 -C XDMA XDMA NDMA XDMA
|
||||
|
||||
$(dir_build)/main.bin: $(dir_build)/main.elf
|
||||
$(OC) -S -O binary $< $@
|
||||
$(dir_build)/modules.bin: $(modules)
|
||||
@mkdir -p "$(@D)"
|
||||
cat $^ > $@
|
||||
|
||||
$(dir_build)/main.elf: $(objects)
|
||||
$(dir_build)/arm11.elf: $(dir_arm11)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/main.elf: $(bundled) $(objects)
|
||||
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
||||
|
||||
$(dir_build)/patches.h: $(dir_patches)/emunand.s $(dir_patches)/reboot.s $(dir_injector)/Makefile
|
||||
$(dir_build)/k11_extension.bin: $(dir_k11_extension)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/loader.cxi: $(dir_loader)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/rosalina.cxi: $(dir_rosalina)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/sm.cxi: $(dir_sm)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/pxi.cxi: $(dir_pxi)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/%.bin.o: $(dir_build)/%.bin
|
||||
@$(bin2o)
|
||||
|
||||
$(dir_build)/chainloader.bin: $(dir_chainloader)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/arm9_exceptions.bin: $(dir_arm9_exceptions)
|
||||
@mkdir -p "$(@D)"
|
||||
@$(MAKE) -C $<
|
||||
|
||||
$(dir_build)/%.bin: $(dir_patches)/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
@armips $<
|
||||
@armips $(word 2,$^)
|
||||
@$(MAKE) -C $(dir_injector)
|
||||
@mv emunand.bin reboot.bin $(dir_injector)/injector.cxi $(@D)
|
||||
@bin2c -o $@ -n emunand $(@D)/emunand.bin -n reboot $(@D)/reboot.bin -n injector $(@D)/injector.cxi
|
||||
|
||||
$(dir_build)/loader.h: $(dir_loader)/Makefile
|
||||
@$(MAKE) -C $(dir_loader)
|
||||
@mv $(dir_loader)/loader.bin $(@D)
|
||||
@bin2c -o $@ -n loader $(@D)/loader.bin
|
||||
$(dir_build)/memory.o $(dir_build)/strings.o: CFLAGS += -O3
|
||||
$(dir_build)/config.o: CFLAGS += -DCONFIG_TITLE="\"$(name) $(revision) configuration\""
|
||||
$(dir_build)/patches.o: CFLAGS += -DVERSION_MAJOR="$(version_major)" -DVERSION_MINOR="$(version_minor)"\
|
||||
-DVERSION_BUILD="$(version_build)" -DISRELEASE="$(is_release)" -DCOMMIT_HASH="0x$(commit)"
|
||||
$(dir_build)/firm.o: $(dir_build)/modules.bin
|
||||
$(dir_build)/firm.o: CFLAGS += -DLUMA_SECTION0_SIZE="$(shell wc -c $(dir_build)/modules.bin | tr -d [:space:][:alpha:][:punct:])"
|
||||
|
||||
$(dir_build)/screeninit.h: $(dir_screeninit)/Makefile
|
||||
@$(MAKE) -C $(dir_screeninit)
|
||||
@mv $(dir_screeninit)/screeninit.bin $(@D)
|
||||
@bin2c -o $@ -n screeninit $(@D)/screeninit.bin
|
||||
$(dir_build)/bundled.h: $(bundled)
|
||||
@$(foreach f, $(bundled),\
|
||||
echo "extern const u8" `(echo $(basename $(notdir $(f))) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> $@;\
|
||||
echo "extern const u32" `(echo $(basename $(notdir $(f)))| sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> $@;\
|
||||
)
|
||||
|
||||
$(dir_build)/memory.o : CFLAGS += -O3
|
||||
$(dir_build)/config.o : CFLAGS += -DCONFIG_TITLE="\"$(name) $(version) configuration\""
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.c $(bundled)
|
||||
$(dir_build)/%.o: $(dir_source)/%.c $(dir_build)/bundled.h
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
||||
|
||||
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.c
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
|
||||
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
||||
include $(call rwildcard, $(dir_build), *.d)
|
||||
|
||||
43
README.md
43
README.md
@@ -1,23 +1,42 @@
|
||||
# Luma3DS
|
||||
*Noob-proof (N)3DS "Custom Firmware"*
|
||||
|
||||
**Compiling:**
|
||||
## What it is
|
||||
|
||||
First you need to clone the repository recursively with: 'git clone --recursive https://github.com/AuroraWright/Luma3DS.git'
|
||||
To compile, you'll need [armips](https://github.com/Kingcom/armips), [bin2c](https://sourceforge.net/projects/bin2c/), and a recent build of [makerom](https://github.com/profi200/Project_CTR) added to your PATH.
|
||||
For your convenience, here are [Windows](http://www91.zippyshare.com/v/ePGpjk9r/file.html) and [Linux](https://mega.nz/#!uQ1T1IAD!Q91O0e12LXKiaXh_YjXD3D5m8_W3FuMI-hEa6KVMRDQ) builds of armips (thanks to who compiled them!).
|
||||
Finally just run 'make' and everything should work!
|
||||
You can find the compiled files in the 'out' folder.
|
||||
**Luma3DS** is a program to patch the system software of (New) Nintendo 3DS handheld consoles "on the fly", adding features (such as per-game language settings and debugging capabilities for developers) and removing restrictions enforced by Nintendo (such as the region lock).
|
||||
It also allows you to run unauthorized ("homebrew") content by removing signature checks.
|
||||
To use it, you will need a console capable of running homebrew software on the ARM9 processor. We recommend [Plailect's guide](https://3ds.hacks.guide/) for details on how to get your system ready.
|
||||
|
||||
**Setup / Usage / Features:**
|
||||
Since Luma3DS v8.0, Luma3DS has its own in-game menu, triggerable by `L+Down+Select` (see the [release notes](https://github.com/AuroraWright/Luma3DS/releases/tag/v8.0)).
|
||||
|
||||
---
|
||||
|
||||
## Compiling
|
||||
|
||||
First you need to clone the repository with: `git clone https://github.com/AuroraWright/Luma3DS.git`
|
||||
To compile, you'll need [armips](https://github.com/Kingcom/armips) and a build of a recent commit of [makerom](https://github.com/profi200/Project_CTR) added to your PATH. You'll also need to install [firmtool](https://github.com/TuxSH/firmtool), its README contains installation instructions.
|
||||
You'll also need to update your [libctru](https://github.com/smealum/ctrulib) install, building from the latest commit.
|
||||
Here are [Windows](https://buildbot.orphis.net/armips/) and [Linux](https://ev1l0rd.s-ul.eu/mEIk4atQ) builds of armips (thanks to who compiled them!).
|
||||
Run `make` and everything should work!
|
||||
You can find the compiled files in the `out` folder.
|
||||
|
||||
---
|
||||
|
||||
## Setup / Usage / Features
|
||||
|
||||
See https://github.com/AuroraWright/Luma3DS/wiki
|
||||
|
||||
**Credits:**
|
||||
|
||||
---
|
||||
|
||||
## Credits
|
||||
|
||||
See https://github.com/AuroraWright/Luma3DS/wiki/Credits
|
||||
|
||||
**Licensing:**
|
||||
---
|
||||
|
||||
This software is licensed under the terms of the GPLv3.
|
||||
You can find a copy of the license in the LICENSE.txt file.
|
||||
## Licensing
|
||||
|
||||
This software is licensed under the terms of the GPLv3.
|
||||
You can find a copy of the license in the LICENSE.txt file.
|
||||
|
||||
You can also use all of `sysmodules/rosalina/include/gdb/`, all of `sysmodules/rosalina/source/gdb/`, `sysmodules/rosalina/include/gdb.h`, `sysmodules/rosalina/source/gdb.c`, `sysmodules/rosalina/include/sock_util.h` and `sysmodules/rosalina/source/sock_util.c` under the terms of the GPLv2, as an option. If you choose to do so, you needn't include the GPLv3 notices that are present in the beginning of each of these files.
|
||||
|
||||
@@ -4,37 +4,30 @@ ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
CC := arm-none-eabi-gcc
|
||||
AS := arm-none-eabi-as
|
||||
LD := arm-none-eabi-ld
|
||||
OC := arm-none-eabi-objcopy
|
||||
include $(DEVKITARM)/base_tools
|
||||
|
||||
name := $(shell basename $(CURDIR))
|
||||
|
||||
dir_source := source
|
||||
dir_build := build
|
||||
dir_out := ../$(dir_build)
|
||||
|
||||
ASFLAGS := -mcpu=arm946e-s
|
||||
CFLAGS := -Wall -Wextra -MMD -MP -mthumb -mthumb-interwork $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||
LDFLAGS := -nostartfiles
|
||||
ASFLAGS := -mcpu=mpcore
|
||||
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||
LDFLAGS := -nostartfiles -Wl,--nmagic
|
||||
|
||||
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||
|
||||
.PHONY: all
|
||||
all: $(name).bin
|
||||
all: $(dir_out)/$(name).elf
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(dir_build)
|
||||
|
||||
$(name).bin: $(dir_build)/$(name).elf
|
||||
$(OC) -S -O binary $< $@
|
||||
|
||||
$(dir_build)/$(name).elf: $(objects)
|
||||
$(dir_out)/$(name).elf: $(objects)
|
||||
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.c
|
||||
@@ -44,12 +37,3 @@ $(dir_build)/%.o: $(dir_source)/%.c
|
||||
$(dir_build)/%.o: $(dir_source)/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
||||
|
||||
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.c
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
|
||||
$(dir_build)/fatfs/%.o: $(dir_source)/fatfs/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
||||
include $(call rwildcard, $(dir_build), *.d)
|
||||
16
arm11/linker.ld
Normal file
16
arm11/linker.ld
Normal file
@@ -0,0 +1,16 @@
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x1FF80000;
|
||||
|
||||
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
|
||||
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
|
||||
.data : ALIGN(4) { *(.data*); . = ALIGN(4); }
|
||||
.bss : ALIGN(8) { __bss_start = .; *(.bss* COMMON); . = ALIGN(8); __bss_end = .; }
|
||||
|
||||
__stack_top__ = 0x1FFFE000;
|
||||
. = ALIGN(4);
|
||||
}
|
||||
211
arm11/source/main.c
Normal file
211
arm11/source/main.c
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Screen init code by dark_samus, bil1s, Normmatt, delebile and others
|
||||
* LCD deinit code by tiniVi
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
#include "memory.h"
|
||||
|
||||
void prepareForFirmlaunch(void);
|
||||
extern u32 prepareForFirmlaunchSize;
|
||||
|
||||
extern volatile Arm11Operation operation;
|
||||
|
||||
static void initScreens(u32 brightnessLevel, struct fb *fbs)
|
||||
{
|
||||
*(vu32 *)0x10141200 = 0x1007F;
|
||||
*(vu32 *)0x10202014 = 0x00000001;
|
||||
*(vu32 *)0x1020200C &= 0xFFFEFFFE;
|
||||
*(vu32 *)0x10202240 = brightnessLevel;
|
||||
*(vu32 *)0x10202A40 = brightnessLevel;
|
||||
*(vu32 *)0x10202244 = 0x1023E;
|
||||
*(vu32 *)0x10202A44 = 0x1023E;
|
||||
|
||||
//Top screen
|
||||
*(vu32 *)0x10400400 = 0x000001c2;
|
||||
*(vu32 *)0x10400404 = 0x000000d1;
|
||||
*(vu32 *)0x10400408 = 0x000001c1;
|
||||
*(vu32 *)0x1040040c = 0x000001c1;
|
||||
*(vu32 *)0x10400410 = 0x00000000;
|
||||
*(vu32 *)0x10400414 = 0x000000cf;
|
||||
*(vu32 *)0x10400418 = 0x000000d1;
|
||||
*(vu32 *)0x1040041c = 0x01c501c1;
|
||||
*(vu32 *)0x10400420 = 0x00010000;
|
||||
*(vu32 *)0x10400424 = 0x0000019d;
|
||||
*(vu32 *)0x10400428 = 0x00000002;
|
||||
*(vu32 *)0x1040042c = 0x00000192;
|
||||
*(vu32 *)0x10400430 = 0x00000192;
|
||||
*(vu32 *)0x10400434 = 0x00000192;
|
||||
*(vu32 *)0x10400438 = 0x00000001;
|
||||
*(vu32 *)0x1040043c = 0x00000002;
|
||||
*(vu32 *)0x10400440 = 0x01960192;
|
||||
*(vu32 *)0x10400444 = 0x00000000;
|
||||
*(vu32 *)0x10400448 = 0x00000000;
|
||||
*(vu32 *)0x1040045C = 0x00f00190;
|
||||
*(vu32 *)0x10400460 = 0x01c100d1;
|
||||
*(vu32 *)0x10400464 = 0x01920002;
|
||||
*(vu32 *)0x10400468 = (u32)fbs[0].top_left;
|
||||
*(vu32 *)0x1040046C = (u32)fbs[1].top_left;
|
||||
*(vu32 *)0x10400470 = 0x80341;
|
||||
*(vu32 *)0x10400474 = 0x00010501;
|
||||
*(vu32 *)0x10400478 = 0;
|
||||
*(vu32 *)0x10400494 = (u32)fbs[0].top_right;
|
||||
*(vu32 *)0x10400498 = (u32)fbs[1].top_right;
|
||||
*(vu32 *)0x10400490 = 0x000002D0;
|
||||
*(vu32 *)0x1040049C = 0x00000000;
|
||||
|
||||
//Disco register
|
||||
for(u32 i = 0; i < 256; i++)
|
||||
*(vu32 *)0x10400484 = 0x10101 * i;
|
||||
|
||||
//Bottom screen
|
||||
*(vu32 *)0x10400500 = 0x000001c2;
|
||||
*(vu32 *)0x10400504 = 0x000000d1;
|
||||
*(vu32 *)0x10400508 = 0x000001c1;
|
||||
*(vu32 *)0x1040050c = 0x000001c1;
|
||||
*(vu32 *)0x10400510 = 0x000000cd;
|
||||
*(vu32 *)0x10400514 = 0x000000cf;
|
||||
*(vu32 *)0x10400518 = 0x000000d1;
|
||||
*(vu32 *)0x1040051c = 0x01c501c1;
|
||||
*(vu32 *)0x10400520 = 0x00010000;
|
||||
*(vu32 *)0x10400524 = 0x0000019d;
|
||||
*(vu32 *)0x10400528 = 0x00000052;
|
||||
*(vu32 *)0x1040052c = 0x00000192;
|
||||
*(vu32 *)0x10400530 = 0x00000192;
|
||||
*(vu32 *)0x10400534 = 0x0000004f;
|
||||
*(vu32 *)0x10400538 = 0x00000050;
|
||||
*(vu32 *)0x1040053c = 0x00000052;
|
||||
*(vu32 *)0x10400540 = 0x01980194;
|
||||
*(vu32 *)0x10400544 = 0x00000000;
|
||||
*(vu32 *)0x10400548 = 0x00000011;
|
||||
*(vu32 *)0x1040055C = 0x00f00140;
|
||||
*(vu32 *)0x10400560 = 0x01c100d1;
|
||||
*(vu32 *)0x10400564 = 0x01920052;
|
||||
*(vu32 *)0x10400568 = (u32)fbs[0].bottom;
|
||||
*(vu32 *)0x1040056C = (u32)fbs[1].bottom;
|
||||
*(vu32 *)0x10400570 = 0x80301;
|
||||
*(vu32 *)0x10400574 = 0x00010501;
|
||||
*(vu32 *)0x10400578 = 0;
|
||||
*(vu32 *)0x10400590 = 0x000002D0;
|
||||
*(vu32 *)0x1040059C = 0x00000000;
|
||||
|
||||
//Disco register
|
||||
for(u32 i = 0; i < 256; i++)
|
||||
*(vu32 *)0x10400584 = 0x10101 * i;
|
||||
}
|
||||
|
||||
static void setupFramebuffers(struct fb *fbs)
|
||||
{
|
||||
*(vu32 *)0x10400468 = (u32)fbs[0].top_left;
|
||||
*(vu32 *)0x1040046c = (u32)fbs[1].top_left;
|
||||
*(vu32 *)0x10400494 = (u32)fbs[0].top_right;
|
||||
*(vu32 *)0x10400498 = (u32)fbs[1].top_right;
|
||||
*(vu32 *)0x10400568 = (u32)fbs[0].bottom;
|
||||
*(vu32 *)0x1040056c = (u32)fbs[1].bottom;
|
||||
}
|
||||
|
||||
static void clearScreens(struct fb *fb)
|
||||
{
|
||||
//Setting up two simultaneous memory fills using the GPU
|
||||
|
||||
vu32 *REGs_PSC0 = (vu32 *)0x10400010,
|
||||
*REGs_PSC1 = (vu32 *)0x10400020;
|
||||
|
||||
REGs_PSC0[0] = (u32)fb->top_left >> 3; //Start address
|
||||
REGs_PSC0[1] = (u32)(fb->top_left + SCREEN_TOP_FBSIZE) >> 3; //End address
|
||||
REGs_PSC0[2] = 0; //Fill value
|
||||
REGs_PSC0[3] = (2 << 8) | 1; //32-bit pattern; start
|
||||
|
||||
REGs_PSC1[0] = (u32)fb->bottom >> 3; //Start address
|
||||
REGs_PSC1[1] = (u32)(fb->bottom + SCREEN_BOTTOM_FBSIZE) >> 3; //End address
|
||||
REGs_PSC1[2] = 0; //Fill value
|
||||
REGs_PSC1[3] = (2 << 8) | 1; //32-bit pattern; start
|
||||
|
||||
while(!((REGs_PSC0[3] & 2) && (REGs_PSC1[3] & 2)));
|
||||
}
|
||||
|
||||
static void swapFramebuffers(bool isAlternate)
|
||||
{
|
||||
u32 isAlternateTmp = isAlternate ? 1 : 0;
|
||||
*(vu32 *)0x10400478 = (*(vu32 *)0x10400478 & 0xFFFFFFFE) | isAlternateTmp;
|
||||
*(vu32 *)0x10400578 = (*(vu32 *)0x10400478 & 0xFFFFFFFE) | isAlternateTmp;
|
||||
}
|
||||
|
||||
static void updateBrightness(u32 brightnessLevel)
|
||||
{
|
||||
//Change brightness
|
||||
*(vu32 *)0x10202240 = brightnessLevel;
|
||||
*(vu32 *)0x10202A40 = brightnessLevel;
|
||||
}
|
||||
|
||||
static void deinitScreens(void)
|
||||
{
|
||||
//Shutdown LCDs
|
||||
*(vu32 *)0x10202A44 = 0;
|
||||
*(vu32 *)0x10202244 = 0;
|
||||
*(vu32 *)0x10202014 = 0;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
operation = ARM11_READY;
|
||||
|
||||
while(true)
|
||||
{
|
||||
switch(operation)
|
||||
{
|
||||
case ARM11_READY:
|
||||
continue;
|
||||
case INIT_SCREENS:
|
||||
initScreens(*(vu32 *)ARM11_PARAMETERS_ADDRESS, (struct fb *)(ARM11_PARAMETERS_ADDRESS + 4));
|
||||
break;
|
||||
case SETUP_FRAMEBUFFERS:
|
||||
setupFramebuffers((struct fb *)ARM11_PARAMETERS_ADDRESS);
|
||||
break;
|
||||
case CLEAR_SCREENS:
|
||||
clearScreens((struct fb *)ARM11_PARAMETERS_ADDRESS);
|
||||
break;
|
||||
case SWAP_FRAMEBUFFERS:
|
||||
swapFramebuffers(*(volatile bool *)ARM11_PARAMETERS_ADDRESS);
|
||||
break;
|
||||
case UPDATE_BRIGHTNESS:
|
||||
updateBrightness(*(vu32 *)ARM11_PARAMETERS_ADDRESS);
|
||||
break;
|
||||
case DEINIT_SCREENS:
|
||||
deinitScreens();
|
||||
break;
|
||||
case PREPARE_ARM11_FOR_FIRMLAUNCH:
|
||||
memcpy((void *)0x1FFFFC00, (void *)prepareForFirmlaunch, prepareForFirmlaunchSize);
|
||||
*(vu32 *)0x1FFFFFFC = 0;
|
||||
((void (*)(u32, volatile Arm11Operation *))0x1FFFFC00)(ARM11_READY, &operation);
|
||||
}
|
||||
|
||||
operation = ARM11_READY;
|
||||
}
|
||||
}
|
||||
56
arm11/source/memory.c
Normal file
56
arm11/source/memory.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
|
||||
*/
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
void memcpy(void *dest, const void *src, u32 size)
|
||||
{
|
||||
u8 *destc = (u8 *)dest;
|
||||
const u8 *srcc = (const u8 *)src;
|
||||
|
||||
for(u32 i = 0; i < size; i++)
|
||||
destc[i] = srcc[i];
|
||||
}
|
||||
|
||||
void memset(void *dest, u32 filler, u32 size)
|
||||
{
|
||||
u8 *destc = (u8 *)dest;
|
||||
|
||||
for(u32 i = 0; i < size; i++)
|
||||
destc[i] = (u8)filler;
|
||||
}
|
||||
|
||||
void memset32(void *dest, u32 filler, u32 size)
|
||||
{
|
||||
u32 *dest32 = (u32 *)dest;
|
||||
|
||||
for(u32 i = 0; i < size / 4; i++)
|
||||
dest32[i] = filler;
|
||||
}
|
||||
37
arm11/source/memory.h
Normal file
37
arm11/source/memory.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void memcpy(void *dest, const void *src, u32 size);
|
||||
void memset(void *dest, u32 value, u32 size) __attribute__((used));
|
||||
void memset32(void *dest, u32 filler, u32 size);
|
||||
81
arm11/source/start.s
Normal file
81
arm11/source/start.s
Normal file
@@ -0,0 +1,81 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.section .text.start
|
||||
.align 4
|
||||
.global _start
|
||||
.type _start, %function
|
||||
_start:
|
||||
b start
|
||||
|
||||
.global operation
|
||||
operation:
|
||||
.word 0
|
||||
|
||||
start:
|
||||
@ Disable interrupts and switch to supervisor mode
|
||||
cpsid aif, #0x13
|
||||
|
||||
@ Set the control register to reset default: everything disabled
|
||||
ldr r0, =0x54078
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
@ Set the auxiliary control register to reset default.
|
||||
@ Enables instruction folding, static branch prediction,
|
||||
@ dynamic branch prediction, and return stack.
|
||||
mov r0, #0xF
|
||||
mcr p15, 0, r0, c1, c0, 1
|
||||
|
||||
@ Invalidate both caches, flush the prefetch buffer then DSB
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c5, 4
|
||||
mcr p15, 0, r0, c7, c7, 0
|
||||
mcr p15, 0, r0, c7, c10, 4
|
||||
|
||||
@ Clear BSS
|
||||
ldr r0, =__bss_start
|
||||
mov r1, #0
|
||||
ldr r2, =__bss_end
|
||||
sub r2, r0
|
||||
bl memset32
|
||||
|
||||
ldr sp, =__stack_top__
|
||||
b main
|
||||
|
||||
.global prepareForFirmlaunch
|
||||
.type prepareForFirmlaunch, %function
|
||||
prepareForFirmlaunch:
|
||||
str r0, [r1] @ tell ARM9 we're done
|
||||
mov r0, #0x20000000
|
||||
|
||||
_wait_for_core0_entrypoint_loop:
|
||||
ldr r1, [r0, #-4] @ check if core0's entrypoint is 0
|
||||
cmp r1, #0
|
||||
beq _wait_for_core0_entrypoint_loop
|
||||
|
||||
bx r1 @ jump to core0's entrypoint
|
||||
prepareForFirmlaunchEnd:
|
||||
|
||||
.global prepareForFirmlaunchSize
|
||||
prepareForFirmlaunchSize: .word prepareForFirmlaunchEnd - prepareForFirmlaunch
|
||||
65
arm11/source/types.h
Normal file
65
arm11/source/types.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
//Common data types
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
typedef volatile u8 vu8;
|
||||
typedef volatile u16 vu16;
|
||||
typedef volatile u32 vu32;
|
||||
typedef volatile u64 vu64;
|
||||
|
||||
#define SCREEN_TOP_WIDTH 400
|
||||
#define SCREEN_BOTTOM_WIDTH 320
|
||||
#define SCREEN_HEIGHT 240
|
||||
#define SCREEN_TOP_FBSIZE (3 * SCREEN_TOP_WIDTH * SCREEN_HEIGHT)
|
||||
#define SCREEN_BOTTOM_FBSIZE (3 * SCREEN_BOTTOM_WIDTH * SCREEN_HEIGHT)
|
||||
#define ARM11_PARAMETERS_ADDRESS 0x1FFFF000
|
||||
|
||||
struct fb {
|
||||
u8 *top_left;
|
||||
u8 *top_right;
|
||||
u8 *bottom;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
INIT_SCREENS = 0,
|
||||
SETUP_FRAMEBUFFERS,
|
||||
CLEAR_SCREENS,
|
||||
SWAP_FRAMEBUFFERS,
|
||||
UPDATE_BRIGHTNESS,
|
||||
DEINIT_SCREENS,
|
||||
PREPARE_ARM11_FOR_FIRMLAUNCH,
|
||||
ARM11_READY,
|
||||
} Arm11Operation;
|
||||
23
screeninit/Makefile → chainloader/Makefile
Executable file → Normal file
23
screeninit/Makefile → chainloader/Makefile
Executable file → Normal file
@@ -4,39 +4,37 @@ ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
CC := arm-none-eabi-gcc
|
||||
AS := arm-none-eabi-as
|
||||
LD := arm-none-eabi-ld
|
||||
OC := arm-none-eabi-objcopy
|
||||
include $(DEVKITARM)/base_tools
|
||||
|
||||
name := $(shell basename $(CURDIR))
|
||||
|
||||
dir_source := source
|
||||
dir_build := build
|
||||
dir_out := ../$(dir_build)
|
||||
|
||||
ASFLAGS := -mcpu=mpcore -mfloat-abi=hard
|
||||
CFLAGS := -Wall -Wextra -MMD -MP -mthumb -mthumb-interwork $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||
LDFLAGS := -nostdlib
|
||||
ASFLAGS := -mcpu=arm946e-s
|
||||
CFLAGS := -Wall -Wextra -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -O2 -flto -ffast-math
|
||||
LDFLAGS := -nostartfiles -Wl,--nmagic
|
||||
|
||||
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||
|
||||
.PHONY: all
|
||||
all: $(name).bin
|
||||
all: $(dir_out)/$(name).bin
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(dir_build)
|
||||
|
||||
$(name).bin: $(dir_build)/$(name).elf
|
||||
$(OC) -S -O binary $< $@
|
||||
$(dir_out)/$(name).bin: $(dir_build)/$(name).elf
|
||||
$(OBJCOPY) -S -O binary $< $@
|
||||
|
||||
$(dir_build)/$(name).elf: $(objects)
|
||||
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
||||
|
||||
$(dir_build)/memory.o: CFLAGS += -O3
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.c
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
@@ -44,4 +42,3 @@ $(dir_build)/%.o: $(dir_source)/%.c
|
||||
$(dir_build)/%.o: $(dir_source)/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
||||
include $(call rwildcard, $(dir_build), *.d)
|
||||
21
chainloader/linker.ld
Normal file
21
chainloader/linker.ld
Normal file
@@ -0,0 +1,21 @@
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x01FF9000;
|
||||
|
||||
__start__ = ABSOLUTE(.);
|
||||
|
||||
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
|
||||
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
|
||||
.data : ALIGN(4) { *(.data*); . = ALIGN(8); *(.bss* COMMON); . = ALIGN(8); }
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
__end__ = ABSOLUTE(.);
|
||||
|
||||
__stack_top__ = 0x01FFB800;
|
||||
__stack_bottom__ = 0x01FFA800;
|
||||
}
|
||||
31
chainloader/source/cache.h
Normal file
31
chainloader/source/cache.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void flushCaches(void);
|
||||
60
chainloader/source/cache.s
Normal file
60
chainloader/source/cache.s
Normal file
@@ -0,0 +1,60 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.text
|
||||
.arm
|
||||
.align 4
|
||||
|
||||
.global flushCaches
|
||||
.type flushCaches, %function
|
||||
flushCaches:
|
||||
@ Clean and flush both the data cache and instruction caches
|
||||
|
||||
@ Adpated from http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0155a/ch03s03s05.html ,
|
||||
@ and https://github.com/gemarcano/libctr9_io/blob/master/src/ctr_system_ARM.c#L39 as well
|
||||
@ Note: ARM's example is actually for a 8KB DCache (which is what the 3DS has)
|
||||
|
||||
@ Implemented in bootROM at addresses 0xffff0830 (DCache) and 0xffff0ab4 (ICache)
|
||||
|
||||
mov r1, #0 @ segment counter
|
||||
outer_loop:
|
||||
mov r0, #0 @ line counter
|
||||
|
||||
inner_loop:
|
||||
orr r2, r1, r0 @ generate segment and line address
|
||||
mcr p15, 0, r2, c7, c14, 2 @ clean and flush the line
|
||||
add r0, #0x20 @ increment to next line
|
||||
cmp r0, #0x400
|
||||
bne inner_loop
|
||||
|
||||
add r1, #0x40000000
|
||||
cmp r1, #0
|
||||
bne outer_loop
|
||||
|
||||
mcr p15, 0, r1, c7, c10, 4 @ drain write buffer
|
||||
|
||||
@ Flush instruction cache
|
||||
mcr p15, 0, r1, c7, c5, 0
|
||||
|
||||
bx lr
|
||||
42
chainloader/source/firm.c
Normal file
42
chainloader/source/firm.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "firm.h"
|
||||
#include "memory.h"
|
||||
#include "cache.h"
|
||||
|
||||
void disableMpuAndJumpToEntrypoints(int argc, char **argv, void *arm11Entry, void *arm9Entry);
|
||||
|
||||
void launchFirm(Firm *firm, int argc, char **argv)
|
||||
{
|
||||
//Copy FIRM sections to respective memory locations
|
||||
for(u32 sectionNum = 0; sectionNum < 4; sectionNum++)
|
||||
memcpy(firm->section[sectionNum].address, (u8 *)firm + firm->section[sectionNum].offset, firm->section[sectionNum].size);
|
||||
|
||||
disableMpuAndJumpToEntrypoints(argc, argv, firm->arm9Entry, firm->arm11Entry);
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
50
chainloader/source/firm.h
Normal file
50
chainloader/source/firm.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
u32 offset;
|
||||
u8 *address;
|
||||
u32 size;
|
||||
u32 procType;
|
||||
u8 hash[0x20];
|
||||
} FirmSection;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
char magic[4];
|
||||
u32 reserved1;
|
||||
u8 *arm11Entry;
|
||||
u8 *arm9Entry;
|
||||
u8 reserved2[0x30];
|
||||
FirmSection section[4];
|
||||
} Firm;
|
||||
|
||||
void launchFirm(Firm *firm, int argc, char **argv);
|
||||
58
chainloader/source/main.c
Normal file
58
chainloader/source/main.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "memory.h"
|
||||
#include "cache.h"
|
||||
#include "firm.h"
|
||||
|
||||
void main(int argc, char **argv, Firm *firm)
|
||||
{
|
||||
char *argvPassed[2],
|
||||
absPath[24 + 255];
|
||||
struct fb fbs[2];
|
||||
|
||||
if(argc > 0)
|
||||
{
|
||||
u32 i;
|
||||
for(i = 0; i < sizeof(absPath) - 1 && argv[0][i] != 0; i++)
|
||||
absPath[i] = argv[0][i];
|
||||
absPath[i] = 0;
|
||||
|
||||
argvPassed[0] = (char *)absPath;
|
||||
}
|
||||
|
||||
if(argc == 2)
|
||||
{
|
||||
struct fb *fbsrc = (struct fb *)argv[1];
|
||||
|
||||
fbs[0] = fbsrc[0];
|
||||
fbs[1] = fbsrc[1];
|
||||
|
||||
argvPassed[1] = (char *)&fbs;
|
||||
}
|
||||
|
||||
launchFirm(firm, argc, argvPassed);
|
||||
}
|
||||
40
chainloader/source/memory.c
Normal file
40
chainloader/source/memory.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
|
||||
*/
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
void memcpy(void *dest, const void *src, u32 size)
|
||||
{
|
||||
u8 *destc = (u8 *)dest;
|
||||
const u8 *srcc = (const u8 *)src;
|
||||
|
||||
for(u32 i = 0; i < size; i++)
|
||||
destc[i] = srcc[i];
|
||||
}
|
||||
35
chainloader/source/memory.h
Normal file
35
chainloader/source/memory.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* memcpy adapted from https://github.com/mid-kid/CakesForeveryWan/blob/557a8e8605ab3ee173af6497486e8f22c261d0e2/source/memfuncs.c
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void memcpy(void *dest, const void *src, u32 size);
|
||||
60
chainloader/source/start.s
Normal file
60
chainloader/source/start.s
Normal file
@@ -0,0 +1,60 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
.arm
|
||||
|
||||
.section .text.start
|
||||
.align 4
|
||||
.global _start
|
||||
_start:
|
||||
ldr sp, =__stack_top__
|
||||
b main
|
||||
|
||||
.text
|
||||
.balign 4
|
||||
.global disableMpuAndJumpToEntrypoints
|
||||
.type disableMpuAndJumpToEntrypoints, %function
|
||||
disableMpuAndJumpToEntrypoints:
|
||||
mov r4, r0
|
||||
mov r5, r1
|
||||
mov r6, r2
|
||||
mov r7, r3
|
||||
|
||||
bl flushCaches
|
||||
|
||||
@ Disable caches / MPU
|
||||
mrc p15, 0, r0, c1, c0, 0 @ read control register
|
||||
bic r0, #(1<<12) @ - instruction cache disable
|
||||
bic r0, #(1<<2) @ - data cache disable
|
||||
bic r0, #(1<<0) @ - MPU disable
|
||||
mcr p15, 0, r0, c1, c0, 0 @ write control register
|
||||
|
||||
@ Set the ARM11 entrypoint
|
||||
mov r0, #0x20000000
|
||||
str r7, [r0, #-4]
|
||||
|
||||
@ Jump to the ARM9 entrypoint
|
||||
mov r0, r4
|
||||
mov r1, r5
|
||||
ldr r2, =0x3BEEF
|
||||
bx r6
|
||||
45
chainloader/source/types.h
Normal file
45
chainloader/source/types.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//Common data types
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
typedef volatile u8 vu8;
|
||||
typedef volatile u16 vu16;
|
||||
typedef volatile u32 vu32;
|
||||
typedef volatile u64 vu64;
|
||||
|
||||
struct fb {
|
||||
u8 *top_left;
|
||||
u8 *top_right;
|
||||
u8 *bottom;
|
||||
};
|
||||
42
exceptions/arm9/Makefile
Normal file
42
exceptions/arm9/Makefile
Normal file
@@ -0,0 +1,42 @@
|
||||
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/base_tools
|
||||
|
||||
name := arm9_exceptions
|
||||
|
||||
dir_source := source
|
||||
dir_build := build
|
||||
dir_out := ../../$(dir_build)
|
||||
|
||||
ASFLAGS := -mcpu=arm946e-s
|
||||
CFLAGS := -Wall -Wextra -marm $(ASFLAGS) -fno-builtin -std=c11 -Wno-main -Os -ffast-math
|
||||
LDFLAGS := -nostartfiles -Wl,--nmagic
|
||||
|
||||
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||
|
||||
.PHONY: all
|
||||
all: $(dir_out)/$(name).bin
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(dir_build)
|
||||
|
||||
$(dir_out)/$(name).bin: $(dir_build)/$(name).elf
|
||||
$(OBJCOPY) -S -O binary $< $@
|
||||
|
||||
$(dir_build)/$(name).elf: $(objects)
|
||||
$(CC) $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.c
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
||||
14
exceptions/arm9/linker.ld
Normal file
14
exceptions/arm9/linker.ld
Normal file
@@ -0,0 +1,14 @@
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x01FF8000;
|
||||
|
||||
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
|
||||
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
|
||||
.data : ALIGN(4) { *(.data*); . = ALIGN(8); *(.bss* COMMON); . = ALIGN(8); }
|
||||
|
||||
. = ALIGN(4);
|
||||
}
|
||||
51
exceptions/arm9/source/handlers.h
Normal file
51
exceptions/arm9/source/handlers.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
u32 magic[2];
|
||||
u16 versionMinor, versionMajor;
|
||||
|
||||
u16 processor, core;
|
||||
u32 type;
|
||||
|
||||
u32 totalSize;
|
||||
u32 registerDumpSize;
|
||||
u32 codeDumpSize;
|
||||
u32 stackDumpSize;
|
||||
u32 additionalDataSize;
|
||||
} ExceptionDumpHeader;
|
||||
|
||||
void FIQHandler(void);
|
||||
void undefinedInstructionHandler(void);
|
||||
void dataAbortHandler(void);
|
||||
void prefetchAbortHandler(void);
|
||||
|
||||
u32 safecpy(void *dst, const void *src, u32 len);
|
||||
152
exceptions/arm9/source/handlers.s
Normal file
152
exceptions/arm9/source/handlers.s
Normal file
@@ -0,0 +1,152 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.macro GEN_USUAL_HANDLER name, index
|
||||
\name\()Handler:
|
||||
ldr sp, =_regs
|
||||
stmia sp, {r0-r7}
|
||||
|
||||
mov r0, #\index
|
||||
b _commonHandler
|
||||
.endm
|
||||
|
||||
.text
|
||||
.arm
|
||||
.balign 4
|
||||
|
||||
.global _commonHandler
|
||||
.type _commonHandler, %function
|
||||
_commonHandler:
|
||||
mov r1, r0
|
||||
mov r0, sp
|
||||
mrs r2, spsr
|
||||
mrs r3, cpsr
|
||||
add r6, r0, #(8 * 4)
|
||||
|
||||
orr r3, #0xc0 @ mask interrupts
|
||||
msr cpsr_cx, r3
|
||||
|
||||
ands r4, r2, #0xf @ get the mode that triggered the exception
|
||||
moveq r4, #0xf @ usr => sys
|
||||
bic r5, r3, #0xf
|
||||
orr r5, r4
|
||||
msr cpsr_c, r5 @ change processor mode
|
||||
stmia r6!, {r8-lr}
|
||||
msr cpsr_c, r3 @ restore processor mode
|
||||
|
||||
str lr, [r6], #4
|
||||
str r2, [r6]
|
||||
|
||||
msr cpsr_cxsf, #0xdf @ finally, switch to system mode, mask interrupts and clear flags (in case of double faults)
|
||||
ldr sp, =0x02000000
|
||||
b mainHandler
|
||||
|
||||
|
||||
.global FIQHandler
|
||||
.type FIQHandler, %function
|
||||
GEN_USUAL_HANDLER FIQ, 0
|
||||
|
||||
.global undefinedInstructionHandler
|
||||
.type undefinedInstructionHandler, %function
|
||||
GEN_USUAL_HANDLER undefinedInstruction, 1
|
||||
|
||||
.global prefetchAbortHandler
|
||||
.type prefetchAbortHandler, %function
|
||||
prefetchAbortHandler:
|
||||
msr cpsr_cx, #0xd7 @ mask interrupts (abort mode)
|
||||
mrs sp, spsr
|
||||
and sp, #0x3f
|
||||
cmp sp, #0x13
|
||||
bne _prefetchAbortNormalHandler
|
||||
|
||||
ldr sp, =BreakPtr
|
||||
ldr sp, [sp]
|
||||
cmp sp, #0
|
||||
beq _prefetchAbortNormalHandler
|
||||
add sp, #(1*4 + 4)
|
||||
cmp lr, sp
|
||||
bne _prefetchAbortNormalHandler
|
||||
|
||||
mov sp, r8
|
||||
pop {r8-r11}
|
||||
ldr lr, [sp, #8]!
|
||||
ldr sp, [sp, #4]
|
||||
msr spsr_cxsf, sp
|
||||
tst sp, #0x20
|
||||
addne lr, #2 @ adjust address for later
|
||||
|
||||
GEN_USUAL_HANDLER _prefetchAbortNormal, 2
|
||||
|
||||
.global dataAbortHandler
|
||||
.type dataAbortHandler, %function
|
||||
dataAbortHandler:
|
||||
msr cpsr_cx, #0xd7 @ mask interrupts (abort mode)
|
||||
mrs sp, spsr
|
||||
and sp, #0x3f
|
||||
cmp sp, #0x1f
|
||||
bne _dataAbortNormalHandler
|
||||
|
||||
sub lr, #8
|
||||
adr sp, safecpy
|
||||
cmp lr, sp
|
||||
blo _j_dataAbortNormalHandler
|
||||
adr sp, _safecpy_end
|
||||
cmp lr, sp
|
||||
bhs _j_dataAbortNormalHandler
|
||||
|
||||
msr spsr_f, #(1 << 30)
|
||||
mov r12, #0
|
||||
adds pc, lr, #4
|
||||
|
||||
_j_dataAbortNormalHandler:
|
||||
add lr, #8
|
||||
|
||||
GEN_USUAL_HANDLER _dataAbortNormal, 3
|
||||
|
||||
|
||||
.global safecpy
|
||||
.type safecpy, %function
|
||||
safecpy:
|
||||
push {r4, lr}
|
||||
mov r3, #0
|
||||
movs r12, #1
|
||||
|
||||
_safecpy_loop:
|
||||
ldrb r4, [r1, r3]
|
||||
cmp r12, #0
|
||||
beq _safecpy_loop_end
|
||||
strb r4, [r0, r3]
|
||||
add r3, #1
|
||||
cmp r3, r2
|
||||
blo _safecpy_loop
|
||||
|
||||
_safecpy_loop_end:
|
||||
mov r0, r3
|
||||
pop {r4, pc}
|
||||
|
||||
_safecpy_end:
|
||||
|
||||
.bss
|
||||
.balign 4
|
||||
_regs: .skip (4 * 17)
|
||||
143
exceptions/arm9/source/i2c.c
Normal file
143
exceptions/arm9/source/i2c.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Thanks to whoever contributed in the development of this file
|
||||
*/
|
||||
|
||||
#include "i2c.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static const struct { u8 bus_id, reg_addr; } dev_data[] = {
|
||||
{0, 0x4A}, {0, 0x7A}, {0, 0x78},
|
||||
{1, 0x4A}, {1, 0x78}, {1, 0x2C},
|
||||
{1, 0x2E}, {1, 0x40}, {1, 0x44},
|
||||
{2, 0xD6}, {2, 0xD0}, {2, 0xD2},
|
||||
{2, 0xA4}, {2, 0x9A}, {2, 0xA0},
|
||||
};
|
||||
|
||||
static inline u8 i2cGetDeviceBusId(u8 device_id)
|
||||
{
|
||||
return dev_data[device_id].bus_id;
|
||||
}
|
||||
|
||||
static inline u8 i2cGetDeviceRegAddr(u8 device_id)
|
||||
{
|
||||
return dev_data[device_id].reg_addr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static vu8 *reg_data_addrs[] = {
|
||||
(vu8 *)(I2C1_REG_OFF + I2C_REG_DATA),
|
||||
(vu8 *)(I2C2_REG_OFF + I2C_REG_DATA),
|
||||
(vu8 *)(I2C3_REG_OFF + I2C_REG_DATA),
|
||||
};
|
||||
|
||||
static inline vu8 *i2cGetDataReg(u8 bus_id)
|
||||
{
|
||||
return reg_data_addrs[bus_id];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static vu8 *reg_cnt_addrs[] = {
|
||||
(vu8 *)(I2C1_REG_OFF + I2C_REG_CNT),
|
||||
(vu8 *)(I2C2_REG_OFF + I2C_REG_CNT),
|
||||
(vu8 *)(I2C3_REG_OFF + I2C_REG_CNT),
|
||||
};
|
||||
|
||||
static inline vu8 *i2cGetCntReg(u8 bus_id)
|
||||
{
|
||||
return reg_cnt_addrs[bus_id];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static inline void i2cWaitBusy(u8 bus_id)
|
||||
{
|
||||
while (*i2cGetCntReg(bus_id) & 0x80);
|
||||
}
|
||||
|
||||
static inline bool i2cGetResult(u8 bus_id)
|
||||
{
|
||||
i2cWaitBusy(bus_id);
|
||||
|
||||
return (*i2cGetCntReg(bus_id) >> 4) & 1;
|
||||
}
|
||||
|
||||
static void i2cStop(u8 bus_id, u8 arg0)
|
||||
{
|
||||
*i2cGetCntReg(bus_id) = (arg0 << 5) | 0xC0;
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetCntReg(bus_id) = 0xC5;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static bool i2cSelectDevice(u8 bus_id, u8 dev_reg)
|
||||
{
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetDataReg(bus_id) = dev_reg;
|
||||
*i2cGetCntReg(bus_id) = 0xC2;
|
||||
|
||||
return i2cGetResult(bus_id);
|
||||
}
|
||||
|
||||
static bool i2cSelectRegister(u8 bus_id, u8 reg)
|
||||
{
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetDataReg(bus_id) = reg;
|
||||
*i2cGetCntReg(bus_id) = 0xC0;
|
||||
|
||||
return i2cGetResult(bus_id);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool i2cWriteRegister(u8 dev_id, u8 reg, u8 data)
|
||||
{
|
||||
u8 bus_id = i2cGetDeviceBusId(dev_id);
|
||||
u8 dev_addr = i2cGetDeviceRegAddr(dev_id);
|
||||
|
||||
for(u32 i = 0; i < 8; i++)
|
||||
{
|
||||
if(i2cSelectDevice(bus_id, dev_addr) && i2cSelectRegister(bus_id, reg))
|
||||
{
|
||||
i2cWaitBusy(bus_id);
|
||||
*i2cGetDataReg(bus_id) = data;
|
||||
*i2cGetCntReg(bus_id) = 0xC1;
|
||||
i2cStop(bus_id, 0);
|
||||
|
||||
if(i2cGetResult(bus_id)) return true;
|
||||
}
|
||||
*i2cGetCntReg(bus_id) = 0xC5;
|
||||
i2cWaitBusy(bus_id);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
48
exceptions/arm9/source/i2c.h
Normal file
48
exceptions/arm9/source/i2c.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Thanks to whoever contributed in the development of this file
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define I2C1_REG_OFF 0x10161000
|
||||
#define I2C2_REG_OFF 0x10144000
|
||||
#define I2C3_REG_OFF 0x10148000
|
||||
|
||||
#define I2C_REG_DATA 0
|
||||
#define I2C_REG_CNT 1
|
||||
#define I2C_REG_CNTEX 2
|
||||
#define I2C_REG_SCL 4
|
||||
|
||||
#define I2C_DEV_MCU 3
|
||||
#define I2C_DEV_GYRO 10
|
||||
#define I2C_DEV_IR 13
|
||||
|
||||
bool i2cWriteRegister(u8 dev_id, u8 reg, u8 data);
|
||||
82
exceptions/arm9/source/mainHandler.c
Normal file
82
exceptions/arm9/source/mainHandler.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "i2c.h"
|
||||
#include "handlers.h"
|
||||
|
||||
#define FINAL_BUFFER 0x25000000
|
||||
|
||||
#define REG_DUMP_SIZE 4 * 17
|
||||
#define CODE_DUMP_SIZE 48
|
||||
|
||||
void __attribute__((noreturn)) mainHandler(u32 *registerDump, u32 type)
|
||||
{
|
||||
ExceptionDumpHeader dumpHeader;
|
||||
|
||||
u8 codeDump[CODE_DUMP_SIZE];
|
||||
|
||||
dumpHeader.magic[0] = 0xDEADC0DE;
|
||||
dumpHeader.magic[1] = 0xDEADCAFE;
|
||||
dumpHeader.versionMajor = 1;
|
||||
dumpHeader.versionMinor = 2;
|
||||
|
||||
dumpHeader.processor = 9;
|
||||
dumpHeader.core = 0;
|
||||
dumpHeader.type = type;
|
||||
|
||||
dumpHeader.registerDumpSize = REG_DUMP_SIZE;
|
||||
dumpHeader.codeDumpSize = CODE_DUMP_SIZE;
|
||||
dumpHeader.additionalDataSize = 0;
|
||||
|
||||
u32 cpsr = registerDump[16];
|
||||
u32 pc = registerDump[15] - (type < 3 ? (((cpsr & 0x20) != 0 && type == 1) ? 2 : 4) : 8);
|
||||
|
||||
registerDump[15] = pc;
|
||||
|
||||
//Dump code
|
||||
u8 *instr = (u8 *)pc + ((cpsr & 0x20) ? 2 : 4) - dumpHeader.codeDumpSize; //wouldn't work well on 32-bit Thumb instructions, but it isn't much of a problem
|
||||
dumpHeader.codeDumpSize = ((u32)instr & (((cpsr & 0x20) != 0) ? 1 : 3)) != 0 ? 0 : safecpy(codeDump, instr, dumpHeader.codeDumpSize);
|
||||
|
||||
//Copy register dump and code dump
|
||||
u8 *final = (u8 *)(FINAL_BUFFER + sizeof(ExceptionDumpHeader));
|
||||
final += safecpy(final, registerDump, dumpHeader.registerDumpSize);
|
||||
final += safecpy(final, codeDump, dumpHeader.codeDumpSize);
|
||||
|
||||
//Dump stack in place
|
||||
dumpHeader.stackDumpSize = safecpy(final, (const void *)registerDump[13], 0x1000 - (registerDump[13] & 0xFFF));
|
||||
|
||||
dumpHeader.totalSize = sizeof(ExceptionDumpHeader) + dumpHeader.registerDumpSize + dumpHeader.codeDumpSize + dumpHeader.stackDumpSize + dumpHeader.additionalDataSize;
|
||||
|
||||
//Copy header (actually optimized by the compiler)
|
||||
*(ExceptionDumpHeader *)FINAL_BUFFER = dumpHeader;
|
||||
|
||||
if(ARESCREENSINITIALIZED) i2cWriteRegister(I2C_DEV_MCU, 0x22, 1 << 0); //Shutdown LCD
|
||||
|
||||
((void (*)())0xFFFF0830)(); //Ensure that all memory transfers have completed and that the data cache has been flushed
|
||||
|
||||
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); //Reboot
|
||||
while(true);
|
||||
}
|
||||
39
exceptions/arm9/source/start.s
Normal file
39
exceptions/arm9/source/start.s
Normal file
@@ -0,0 +1,39 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.section .text.start
|
||||
.align 4
|
||||
.global _start
|
||||
_start:
|
||||
add pc, r0, #(handlers - .) @ Dummy instruction
|
||||
|
||||
.global BreakPtr
|
||||
BreakPtr: .word 0
|
||||
|
||||
.global handlers
|
||||
handlers:
|
||||
.word FIQHandler
|
||||
.word undefinedInstructionHandler
|
||||
.word prefetchAbortHandler
|
||||
.word dataAbortHandler
|
||||
45
exceptions/arm9/source/types.h
Normal file
45
exceptions/arm9/source/types.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
//Common data types
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
typedef volatile u8 vu8;
|
||||
typedef volatile u16 vu16;
|
||||
typedef volatile u32 vu32;
|
||||
typedef volatile u64 vu64;
|
||||
|
||||
#define PDN_GPU_CNT (*(vu8 *)0x10141200)
|
||||
|
||||
#define ARESCREENSINITIALIZED (PDN_GPU_CNT != 1)
|
||||
188
exceptions/exception_dump_parser/luma3ds_exception_dump_parser/__main__.py
Executable file
188
exceptions/exception_dump_parser/luma3ds_exception_dump_parser/__main__.py
Executable file
@@ -0,0 +1,188 @@
|
||||
#!/usr/bin/env python
|
||||
# Requires Python >= 3.2 or >= 2.7
|
||||
|
||||
# This file is part of Luma3DS
|
||||
# Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Additional Terms 7.b of GPLv3 applies to this file: Requiring preservation of specified
|
||||
# reasonable legal notices or author attributions in that material or in the Appropriate Legal
|
||||
# Notices displayed by works containing it.
|
||||
|
||||
__author__ = "TuxSH"
|
||||
__copyright__ = "Copyright (c) 2016 TuxSH"
|
||||
__license__ = "GPLv3"
|
||||
__version__ = "v1.2"
|
||||
|
||||
"""
|
||||
Parses Luma3DS exception dumps
|
||||
"""
|
||||
|
||||
import argparse
|
||||
from struct import unpack_from
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
# Source of hexdump: https://gist.github.com/ImmortalPC/c340564823f283fe530b
|
||||
# Credits for hexdump go to the original authors
|
||||
# Slightly edited by TuxSH
|
||||
|
||||
def hexdump(addr, src, length=16, sep='.' ):
|
||||
'''
|
||||
@brief Return {src} in hex dump.
|
||||
@param[in] length {Int} Nb Bytes by row.
|
||||
@param[in] sep {Char} For the text part, {sep} will be used for non ASCII char.
|
||||
@return {Str} The hexdump
|
||||
@note Full support for python2 and python3 !
|
||||
'''
|
||||
result = []
|
||||
|
||||
# Python3 support
|
||||
try:
|
||||
xrange(0,1)
|
||||
except NameError:
|
||||
xrange = range
|
||||
|
||||
for i in xrange(0, len(src), length):
|
||||
subSrc = src[i:i+length]
|
||||
hexa = ''
|
||||
isMiddle = False
|
||||
for h in xrange(0,len(subSrc)):
|
||||
if h == length/2:
|
||||
hexa += ' '
|
||||
h = subSrc[h]
|
||||
if not isinstance(h, int):
|
||||
h = ord(h)
|
||||
h = hex(h).replace('0x','')
|
||||
if len(h) == 1:
|
||||
h = '0'+h
|
||||
hexa += h+' '
|
||||
hexa = hexa.strip(' ')
|
||||
text = ''
|
||||
for c in subSrc:
|
||||
if not isinstance(c, int):
|
||||
c = ord(c)
|
||||
if 0x20 <= c < 0x7F:
|
||||
text += chr(c)
|
||||
else:
|
||||
text += sep
|
||||
result.append(('%08x: %-'+str(length*(2+1)+1)+'s |%s|') % (addr + i, hexa, text))
|
||||
|
||||
return '\n'.join(result)
|
||||
|
||||
|
||||
def makeRegisterLine(A, rA, B, rB):
|
||||
return "{0:<15}{1:<20}{2:<15}{3:<20}".format(A, "{0:08x}".format(rA), B, "{0:08x}".format(rB))
|
||||
|
||||
handledExceptionNames = ("FIQ", "undefined instruction", "prefetch abort", "data abort")
|
||||
registerNames = tuple("r{0}".format(i) for i in range(13)) + ("sp", "lr", "pc", "cpsr") + ("dfsr", "ifsr", "far") + ("fpexc", "fpinst", "fpinst2")
|
||||
svcBreakReasons = ("(svcBreak: panic)", "(svcBreak: assertion failed)", "(svcBreak: user-related)")
|
||||
faultStatusSources = {
|
||||
0b1:'Alignment', 0b100:'Instruction cache maintenance operation fault',
|
||||
0b1100:'External Abort on translation - First-level', 0b1110:'External Abort on translation - Second-level',
|
||||
0b101:'Translation - Section', 0b111:'Translation - Page', 0b11:'Access bit - Section', 0b110:'Access bit - Page',
|
||||
0b1001:'Domain - Section', 0b1011:'Domain - Page', 0b1101:'Permission - Section', 0b1111:'Permission - Page',
|
||||
0b1000:'Precise External Abort', 0b10110:'Imprecise External Abort', 0b10:'Debug event'
|
||||
}
|
||||
|
||||
def main(args=None):
|
||||
parser = argparse.ArgumentParser(description="Parse Luma3DS exception dumps")
|
||||
parser.add_argument("filename")
|
||||
args = parser.parse_args()
|
||||
data = b""
|
||||
with open(args.filename, "rb") as f: data = f.read()
|
||||
if unpack_from("<2I", data) != (0xdeadc0de, 0xdeadcafe):
|
||||
raise SystemExit("Invalid file format")
|
||||
|
||||
version, processor, exceptionType, _, nbRegisters, codeDumpSize, stackDumpSize, additionalDataSize = unpack_from("<8I", data, 8)
|
||||
nbRegisters //= 4
|
||||
|
||||
if version < (1 << 16) | 2:
|
||||
raise SystemExit("Incompatible format version, please use the appropriate parser.")
|
||||
|
||||
registers = unpack_from("<{0}I".format(nbRegisters), data, 40)
|
||||
codeOffset = 40 + 4 * nbRegisters
|
||||
codeDump = data[codeOffset : codeOffset + codeDumpSize]
|
||||
stackOffset = codeOffset + codeDumpSize
|
||||
stackDump = data[stackOffset : stackOffset + stackDumpSize]
|
||||
addtionalDataOffset = stackOffset + stackDumpSize
|
||||
additionalData = data[addtionalDataOffset : addtionalDataOffset + additionalDataSize]
|
||||
|
||||
if processor == 9: print("Processor: ARM9")
|
||||
else: print("Processor: ARM11 (core {0})".format(processor >> 16))
|
||||
|
||||
typeDetailsStr = ""
|
||||
if exceptionType == 2:
|
||||
if (registers[16] & 0x20) == 0 and codeDumpSize >= 4:
|
||||
instr = unpack_from("<I", codeDump[-4:])[0]
|
||||
if instr == 0xe12fff7e:
|
||||
typeDetailsStr = " (kernel panic)"
|
||||
elif instr == 0xef00003c:
|
||||
typeDetailsStr = " " + (svcBreakReasons[registers[0]] if registers[0] < 3 else "(svcBreak)")
|
||||
elif (registers[16] & 0x20) == 1 and codeDumpSize >= 2:
|
||||
instr = unpack_from("<I", codeDump[-4:])[0]
|
||||
if instr == 0xdf3c:
|
||||
typeDetailsStr = " " + (svcBreakReasons[registers[0]] if registers[0] < 3 else "(svcBreak)")
|
||||
|
||||
elif processor != 9 and (registers[20] & 0x80000000) != 0:
|
||||
typeDetailsStr = " (VFP exception)"
|
||||
|
||||
print("Exception type: {0}{1}".format("unknown" if exceptionType >= len(handledExceptionNames) else handledExceptionNames[exceptionType], typeDetailsStr))
|
||||
|
||||
if processor == 11 and exceptionType >= 2:
|
||||
xfsr = registers[18] if exceptionType == 2 else registers[17]
|
||||
print("Fault status: " + faultStatusSources[xfsr & 0xf])
|
||||
|
||||
if additionalDataSize != 0:
|
||||
print("Current process: {0} ({1:016x})".format(additionalData[:8].decode("ascii"), unpack_from("<Q", additionalData, 8)[0]))
|
||||
|
||||
print("\nRegister dump:\n")
|
||||
for i in range(0, nbRegisters - (nbRegisters % 2), 2):
|
||||
if i == 16: print("")
|
||||
print(makeRegisterLine(registerNames[i], registers[i], registerNames[i+1], registers[i+1]))
|
||||
if nbRegisters % 2 == 1: print("{0:<15}{1:<20}".format(registerNames[nbRegisters - 1], "{0:08x}".format(registers[nbRegisters - 1])))
|
||||
|
||||
if processor == 11 and exceptionType == 3:
|
||||
print("{0:<15}{1:<20}Access type: {2}".format("FAR", "{0:08x}".format(registers[19]), "Write" if registers[17] & (1 << 11) != 0 else "Read"))
|
||||
|
||||
thumb = registers[16] & 0x20 != 0
|
||||
addr = registers[15] - codeDumpSize + (2 if thumb else 4)
|
||||
|
||||
print("\nCode dump:\n")
|
||||
|
||||
objdump_res = ""
|
||||
try:
|
||||
path = os.path.join(os.environ["DEVKITARM"], "bin", "arm-none-eabi-objdump")
|
||||
|
||||
if os.name == "nt" and path[0] == '/':
|
||||
path = ''.join((path[1], ':', path[2:]))
|
||||
|
||||
objdump_res = subprocess.check_output((
|
||||
path, "-marm", "-b", "binary",
|
||||
"--adjust-vma="+hex(addr - codeOffset), "--start-address="+hex(addr),
|
||||
"--stop-address="+hex(addr + codeDumpSize), "-D", "-z", "-M",
|
||||
"reg-names-std" + (",force-thumb" if thumb else ""), args.filename
|
||||
)).decode("utf-8")
|
||||
objdump_res = '\n'.join(objdump_res[objdump_res.find('<.data+'):].split('\n')[1:])
|
||||
except: objdump_res = ""
|
||||
|
||||
print(objdump_res if objdump_res != "" else hexdump(addr, codeDump))
|
||||
|
||||
print("\nStack dump:\n")
|
||||
print(hexdump(registers[13], stackDump))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
13
exceptions/exception_dump_parser/setup.py
Normal file
13
exceptions/exception_dump_parser/setup.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='luma3ds_exception_dump_parser',
|
||||
version='1.2',
|
||||
url='https://github.com/AuroraWright/Luma3DS',
|
||||
author='TuxSH',
|
||||
license='GPLv3',
|
||||
description='Parses Luma3DS exception dumps',
|
||||
install_requires=[''],
|
||||
packages=find_packages(),
|
||||
entry_points={'console_scripts': ['luma3ds_exception_dump_parser=luma3ds_exception_dump_parser.__main__:main']},
|
||||
)
|
||||
@@ -1,97 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 reserved[5];
|
||||
u8 flag;
|
||||
u8 remasterversion[2];
|
||||
} PACKED exheader_systeminfoflags;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 address;
|
||||
u32 nummaxpages;
|
||||
u32 codesize;
|
||||
} PACKED exheader_codesegmentinfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 name[8];
|
||||
exheader_systeminfoflags flags;
|
||||
exheader_codesegmentinfo text;
|
||||
u8 stacksize[4];
|
||||
exheader_codesegmentinfo ro;
|
||||
u8 reserved[4];
|
||||
exheader_codesegmentinfo data;
|
||||
u32 bsssize;
|
||||
} PACKED exheader_codesetinfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u64 programid[0x30];
|
||||
} PACKED exheader_dependencylist;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 savedatasize[4];
|
||||
u8 reserved[4];
|
||||
u8 jumpid[8];
|
||||
u8 reserved2[0x30];
|
||||
} PACKED exheader_systeminfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 extsavedataid[8];
|
||||
u8 systemsavedataid[8];
|
||||
u8 reserved[8];
|
||||
u8 accessinfo[7];
|
||||
u8 otherattributes;
|
||||
} PACKED exheader_storageinfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u64 programid;
|
||||
u8 flags[8];
|
||||
u16 resourcelimitdescriptor[0x10];
|
||||
exheader_storageinfo storageinfo;
|
||||
u64 serviceaccesscontrol[0x20];
|
||||
u8 reserved[0x1f];
|
||||
u8 resourcelimitcategory;
|
||||
} PACKED exheader_arm11systemlocalcaps;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 descriptors[28];
|
||||
u8 reserved[0x10];
|
||||
} PACKED exheader_arm11kernelcapabilities;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 descriptors[15];
|
||||
u8 descversion;
|
||||
} PACKED exheader_arm9accesscontrol;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// systemcontrol info {
|
||||
// coreinfo {
|
||||
exheader_codesetinfo codesetinfo;
|
||||
exheader_dependencylist deplist;
|
||||
// }
|
||||
exheader_systeminfo systeminfo;
|
||||
// }
|
||||
// accesscontrolinfo {
|
||||
exheader_arm11systemlocalcaps arm11systemlocalcaps;
|
||||
exheader_arm11kernelcapabilities arm11kernelcaps;
|
||||
exheader_arm9accesscontrol arm9accesscontrol;
|
||||
// }
|
||||
struct {
|
||||
u8 signature[0x100];
|
||||
u8 ncchpubkeymodulus[0x100];
|
||||
exheader_arm11systemlocalcaps arm11systemlocalcaps;
|
||||
exheader_arm11kernelcapabilities arm11kernelcaps;
|
||||
exheader_arm9accesscontrol arm9accesscontrol;
|
||||
} PACKED accessdesc;
|
||||
} PACKED exheader_header;
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
Result fsldrInit(void);
|
||||
void fsldrExit(void);
|
||||
Result FSLDR_InitializeWithSdkVersion(Handle session, u32 version);
|
||||
Result FSLDR_SetPriority(u32 priority);
|
||||
Result FSLDR_OpenFileDirectly(Handle* out, FS_Archive archive, FS_Path path, u32 openFlags, u32 attributes);
|
||||
@@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
void memcpy(void *dest, const void *src, u32 size);
|
||||
@@ -1,516 +0,0 @@
|
||||
#include <3ds.h>
|
||||
#include "memory.h"
|
||||
#include "patcher.h"
|
||||
#include "ifile.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 255
|
||||
#define CONFIG(a) ((loadConfig() >> (a + 16)) & 1)
|
||||
#define MULTICONFIG(a) ((loadConfig() >> (a * 2 + 6)) & 3)
|
||||
#define BOOTCONFIG(a, b) ((loadConfig() >> a) & b)
|
||||
#endif
|
||||
|
||||
static int memcmp(const void *buf1, const void *buf2, u32 size)
|
||||
{
|
||||
const u8 *buf1c = (const u8 *)buf1;
|
||||
const u8 *buf2c = (const u8 *)buf2;
|
||||
|
||||
for(u32 i = 0; i < size; i++)
|
||||
{
|
||||
int cmp = buf1c[i] - buf2c[i];
|
||||
if(cmp) return cmp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Quick Search algorithm, adapted from http://igm.univ-mlv.fr/~lecroq/string/node19.html#SECTION00190
|
||||
static u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize)
|
||||
{
|
||||
const u8 *patternc = (const u8 *)pattern;
|
||||
|
||||
//Preprocessing
|
||||
u32 table[256];
|
||||
|
||||
for(u32 i = 0; i < 256; ++i)
|
||||
table[i] = patternSize + 1;
|
||||
for(u32 i = 0; i < patternSize; ++i)
|
||||
table[patternc[i]] = patternSize - i;
|
||||
|
||||
//Searching
|
||||
u32 j = 0;
|
||||
|
||||
while(j <= size - patternSize)
|
||||
{
|
||||
if(memcmp(patternc, startPos + j, patternSize) == 0)
|
||||
return startPos + j;
|
||||
j += table[startPos[j + patternSize]];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, int offset, const void *replace, u32 repSize, u32 count)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for(i = 0; i < count; i++)
|
||||
{
|
||||
u8 *found = memsearch(start, pattern, size, patSize);
|
||||
|
||||
if(found == NULL) break;
|
||||
|
||||
memcpy(found + offset, replace, repSize);
|
||||
|
||||
u32 at = (u32)(found - start);
|
||||
|
||||
if(at + patSize > size) break;
|
||||
|
||||
size -= at + patSize;
|
||||
start = found + patSize;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline size_t strnlen(const char *string, size_t maxlen)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
for(size = 0; *string && size < maxlen; string++, size++);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int fileOpen(IFile *file, FS_ArchiveID id, const char *path, int flags)
|
||||
{
|
||||
FS_Archive archive;
|
||||
FS_Path ppath;
|
||||
|
||||
size_t len = strnlen(path, PATH_MAX);
|
||||
archive.id = id;
|
||||
archive.lowPath.type = PATH_EMPTY;
|
||||
archive.lowPath.size = 1;
|
||||
archive.lowPath.data = (u8 *)"";
|
||||
ppath.type = PATH_ASCII;
|
||||
ppath.data = path;
|
||||
ppath.size = len + 1;
|
||||
|
||||
return IFile_Open(file, archive, ppath, flags);
|
||||
}
|
||||
|
||||
static u32 secureInfoExists(void)
|
||||
{
|
||||
static u32 secureInfoExists = 0;
|
||||
|
||||
if(!secureInfoExists)
|
||||
{
|
||||
IFile file;
|
||||
if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_NAND_RW, "/sys/SecureInfo_C", FS_OPEN_READ)))
|
||||
{
|
||||
secureInfoExists = 1;
|
||||
IFile_Close(&file);
|
||||
}
|
||||
}
|
||||
|
||||
return secureInfoExists;
|
||||
}
|
||||
|
||||
static u32 loadConfig(void)
|
||||
{
|
||||
static u32 config = 0;
|
||||
|
||||
if(!config)
|
||||
{
|
||||
IFile file;
|
||||
if(R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, "/luma/config.bin", FS_OPEN_READ)))
|
||||
{
|
||||
u64 total;
|
||||
if(R_SUCCEEDED(IFile_Read(&file, &total, &config, 4))) config |= 1 << 4;
|
||||
IFile_Close(&file);
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
static int loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
|
||||
{
|
||||
/* Here we look for "/luma/locales/[u64 titleID in hex, uppercase].txt"
|
||||
If it exists it should contain, for example, "EUR IT" */
|
||||
|
||||
char path[] = "/luma/locales/0000000000000000.txt";
|
||||
|
||||
u32 i = 29;
|
||||
|
||||
while(progId)
|
||||
{
|
||||
static const char hexDigits[] = "0123456789ABCDEF";
|
||||
path[i--] = hexDigits[(u32)(progId & 0xF)];
|
||||
progId >>= 4;
|
||||
}
|
||||
|
||||
IFile file;
|
||||
Result ret = fileOpen(&file, ARCHIVE_SDMC, path, FS_OPEN_READ);
|
||||
if(R_SUCCEEDED(ret))
|
||||
{
|
||||
char buf[6];
|
||||
u64 total;
|
||||
|
||||
ret = IFile_Read(&file, &total, buf, 6);
|
||||
IFile_Close(&file);
|
||||
|
||||
if(!R_SUCCEEDED(ret) || total < 6) return -1;
|
||||
|
||||
for(u32 i = 0; i < 7; ++i)
|
||||
{
|
||||
static const char *regions[] = {"JPN", "USA", "EUR", "AUS", "CHN", "KOR", "TWN"};
|
||||
|
||||
if(memcmp(buf, regions[i], 3) == 0)
|
||||
{
|
||||
*regionId = (u8)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(u32 i = 0; i < 12; ++i)
|
||||
{
|
||||
static const char *languages[] = {"JP", "EN", "FR", "DE", "IT", "ES", "ZH", "KO", "NL", "PT", "RU", "TW"};
|
||||
|
||||
if(memcmp(buf + 4, languages[i], 2) == 0)
|
||||
{
|
||||
*languageId = (u8)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u8 *getCfgOffsets(u8 *code, u32 size, u32 *CFGUHandleOffset)
|
||||
{
|
||||
/* HANS:
|
||||
Look for error code which is known to be stored near cfg:u handle
|
||||
this way we can find the right candidate
|
||||
(handle should also be stored right after end of candidate function) */
|
||||
|
||||
u32 n = 0,
|
||||
possible[24];
|
||||
|
||||
for(u8 *pos = code + 4; n < 24 && pos < code + size - 4; pos += 4)
|
||||
{
|
||||
if(*(u32 *)pos == 0xD8A103F9)
|
||||
{
|
||||
for(u32 *l = (u32 *)pos - 4; n < 24 && l < (u32 *)pos + 4; l++)
|
||||
if(*l <= 0x10000000) possible[n++] = *l;
|
||||
}
|
||||
}
|
||||
|
||||
for(u8 *CFGU_GetConfigInfoBlk2_endPos = code; CFGU_GetConfigInfoBlk2_endPos < code + size - 8; CFGU_GetConfigInfoBlk2_endPos += 4)
|
||||
{
|
||||
static const u32 CFGU_GetConfigInfoBlk2_endPattern[] = {0xE8BD8010, 0x00010082};
|
||||
|
||||
//There might be multiple implementations of GetConfigInfoBlk2 but let's search for the one we want
|
||||
u32 *cmp = (u32 *)CFGU_GetConfigInfoBlk2_endPos;
|
||||
|
||||
if(cmp[0] == CFGU_GetConfigInfoBlk2_endPattern[0] && cmp[1] == CFGU_GetConfigInfoBlk2_endPattern[1])
|
||||
{
|
||||
*CFGUHandleOffset = *((u32 *)CFGU_GetConfigInfoBlk2_endPos + 2);
|
||||
|
||||
for(u32 i = 0; i < n; i++)
|
||||
if(possible[i] == *CFGUHandleOffset) return CFGU_GetConfigInfoBlk2_endPos;
|
||||
|
||||
CFGU_GetConfigInfoBlk2_endPos += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void patchCfgGetLanguage(u8 *code, u32 size, u8 languageId, u8 *CFGU_GetConfigInfoBlk2_endPos)
|
||||
{
|
||||
u8 *CFGU_GetConfigInfoBlk2_startPos; //Let's find STMFD SP (there might be a NOP before, but nevermind)
|
||||
|
||||
for(CFGU_GetConfigInfoBlk2_startPos = CFGU_GetConfigInfoBlk2_endPos - 4;
|
||||
CFGU_GetConfigInfoBlk2_startPos >= code && *((u16 *)CFGU_GetConfigInfoBlk2_startPos + 1) != 0xE92D;
|
||||
CFGU_GetConfigInfoBlk2_startPos -= 2);
|
||||
|
||||
for(u8 *languageBlkIdPos = code; languageBlkIdPos < code + size; languageBlkIdPos += 4)
|
||||
{
|
||||
if(*(u32 *)languageBlkIdPos == 0xA0002)
|
||||
{
|
||||
for(u8 *instr = languageBlkIdPos - 8; instr >= languageBlkIdPos - 0x1008 && instr >= code + 4; instr -= 4) //Should be enough
|
||||
{
|
||||
if(instr[3] == 0xEB) //We're looking for BL
|
||||
{
|
||||
u8 *calledFunction = instr;
|
||||
u32 i = 0,
|
||||
found;
|
||||
|
||||
do
|
||||
{
|
||||
u32 low24 = (*(u32 *)calledFunction & 0x00FFFFFF) << 2;
|
||||
u32 signMask = (u32)(-(low24 >> 25)) & 0xFC000000; //Sign extension
|
||||
s32 offset = (s32)(low24 | signMask) + 8; //Branch offset + 8 for prefetch
|
||||
|
||||
calledFunction += offset;
|
||||
|
||||
found = calledFunction >= CFGU_GetConfigInfoBlk2_startPos - 4 && calledFunction <= CFGU_GetConfigInfoBlk2_endPos;
|
||||
i++;
|
||||
}
|
||||
while(i < 2 && !found && calledFunction[3] == 0xEA);
|
||||
|
||||
if(found)
|
||||
{
|
||||
*((u32 *)instr - 1) = 0xE3A00000 | languageId; // mov r0, sp => mov r0, =languageId
|
||||
*(u32 *)instr = 0xE5CD0000; // bl CFGU_GetConfigInfoBlk2 => strb r0, [sp]
|
||||
*((u32 *)instr + 1) = 0xE3B00000; // (1 or 2 instructions) => movs r0, 0 (result code)
|
||||
|
||||
//We're done
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void patchCfgGetRegion(u8 *code, u32 size, u8 regionId, u32 CFGUHandleOffset)
|
||||
{
|
||||
for(u8 *cmdPos = code; cmdPos < code + size - 28; cmdPos += 4)
|
||||
{
|
||||
static const u32 cfgSecureInfoGetRegionCmdPattern[] = {0xEE1D4F70, 0xE3A00802, 0xE5A40080};
|
||||
|
||||
u32 *cmp = (u32 *)cmdPos;
|
||||
|
||||
if(cmp[0] == cfgSecureInfoGetRegionCmdPattern[0] && cmp[1] == cfgSecureInfoGetRegionCmdPattern[1] &&
|
||||
cmp[2] == cfgSecureInfoGetRegionCmdPattern[2] && *((u16 *)cmdPos + 7) == 0xE59F &&
|
||||
*(u32 *)(cmdPos + 20 + *((u16 *)cmdPos + 6)) == CFGUHandleOffset)
|
||||
{
|
||||
*((u32 *)cmdPos + 4) = 0xE3A00000 | regionId; // mov r0, =regionId
|
||||
*((u32 *)cmdPos + 5) = 0xE5C40008; // strb r0, [r4, 8]
|
||||
*((u32 *)cmdPos + 6) = 0xE3B00000; // movs r0, 0 (result code) ('s' not needed but nvm)
|
||||
*((u32 *)cmdPos + 7) = 0xE5840004; // str r0, [r4, 4]
|
||||
|
||||
//The remaining, not patched, function code will do the rest for us
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void patchCode(u64 progId, u8 *code, u32 size)
|
||||
{
|
||||
switch(progId)
|
||||
{
|
||||
case 0x0004003000008F02LL: // USA Menu
|
||||
case 0x0004003000008202LL: // EUR Menu
|
||||
case 0x0004003000009802LL: // JPN Menu
|
||||
case 0x000400300000A102LL: // CHN Menu
|
||||
case 0x000400300000A902LL: // KOR Menu
|
||||
case 0x000400300000B102LL: // TWN Menu
|
||||
{
|
||||
static const u8 regionFreePattern[] = {
|
||||
0x00, 0x00, 0x55, 0xE3, 0x01, 0x10, 0xA0, 0xE3
|
||||
};
|
||||
static const u8 regionFreePatch[] = {
|
||||
0x01, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1
|
||||
};
|
||||
|
||||
//Patch SMDH region checks
|
||||
patchMemory(code, size,
|
||||
regionFreePattern,
|
||||
sizeof(regionFreePattern), -16,
|
||||
regionFreePatch,
|
||||
sizeof(regionFreePatch), 1
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x0004013000002C02LL: // NIM
|
||||
{
|
||||
static const u8 blockAutoUpdatesPattern[] = {
|
||||
0x25, 0x79, 0x0B, 0x99
|
||||
};
|
||||
static const u8 blockAutoUpdatesPatch[] = {
|
||||
0xE3, 0xA0
|
||||
};
|
||||
|
||||
//Block silent auto-updates
|
||||
patchMemory(code, size,
|
||||
blockAutoUpdatesPattern,
|
||||
sizeof(blockAutoUpdatesPattern), 0,
|
||||
blockAutoUpdatesPatch,
|
||||
sizeof(blockAutoUpdatesPatch), 1
|
||||
);
|
||||
|
||||
//Apply only if the updated NAND hasn't been booted
|
||||
if((BOOTCONFIG(0, 3) != 0) == (BOOTCONFIG(3, 1) && CONFIG(1)))
|
||||
{
|
||||
static const u8 skipEshopUpdateCheckPattern[] = {
|
||||
0x30, 0xB5, 0xF1, 0xB0
|
||||
};
|
||||
static const u8 skipEshopUpdateCheckPatch[] = {
|
||||
0x00, 0x20, 0x08, 0x60, 0x70, 0x47
|
||||
};
|
||||
|
||||
//Skip update checks to access the EShop
|
||||
patchMemory(code, size,
|
||||
skipEshopUpdateCheckPattern,
|
||||
sizeof(skipEshopUpdateCheckPattern), 0,
|
||||
skipEshopUpdateCheckPatch,
|
||||
sizeof(skipEshopUpdateCheckPatch), 1
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x0004013000003202LL: // FRIENDS
|
||||
{
|
||||
static const u8 fpdVerPattern[] = {
|
||||
0xE0, 0x1E, 0xFF, 0x2F, 0xE1, 0x01, 0x01, 0x01
|
||||
};
|
||||
|
||||
static const u8 fpdVerPatch = 0x05;
|
||||
|
||||
//Allow online access to work with old friends modules
|
||||
patchMemory(code, size,
|
||||
fpdVerPattern,
|
||||
sizeof(fpdVerPattern), 9,
|
||||
&fpdVerPatch,
|
||||
sizeof(fpdVerPatch), 1
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x0004001000021000LL: // USA MSET
|
||||
case 0x0004001000020000LL: // JPN MSET
|
||||
case 0x0004001000022000LL: // EUR MSET
|
||||
case 0x0004001000026000LL: // CHN MSET
|
||||
case 0x0004001000027000LL: // KOR MSET
|
||||
case 0x0004001000028000LL: // TWN MSET
|
||||
{
|
||||
if(CONFIG(5))
|
||||
{
|
||||
static const u16 verPattern[] = u"Ver.";
|
||||
const u32 currentNand = BOOTCONFIG(0, 3);
|
||||
const u32 matchingFirm = BOOTCONFIG(2, 1) == (currentNand != 0);
|
||||
|
||||
//Patch Ver. string
|
||||
patchMemory(code, size,
|
||||
verPattern,
|
||||
sizeof(verPattern) - sizeof(u16), 0,
|
||||
!currentNand ? ((matchingFirm) ? u" Sys" : u"SysE") :
|
||||
((currentNand == 1) ? (matchingFirm ? u" Emu" : u"EmuS") : ((matchingFirm) ? u"Emu2" : u"Em2S")),
|
||||
sizeof(verPattern) - sizeof(u16), 1
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x0004013000008002LL: // NS
|
||||
{
|
||||
static const u8 stopCartUpdatesPattern[] = {
|
||||
0x0C, 0x18, 0xE1, 0xD8
|
||||
};
|
||||
static const u8 stopCartUpdatesPatch[] = {
|
||||
0x0B, 0x18, 0x21, 0xC8
|
||||
};
|
||||
|
||||
//Disable updates from foreign carts (makes carts region-free)
|
||||
patchMemory(code, size,
|
||||
stopCartUpdatesPattern,
|
||||
sizeof(stopCartUpdatesPattern), 0,
|
||||
stopCartUpdatesPatch,
|
||||
sizeof(stopCartUpdatesPatch), 2
|
||||
);
|
||||
|
||||
u32 cpuSetting = MULTICONFIG(1);
|
||||
|
||||
if(cpuSetting)
|
||||
{
|
||||
static const u8 cfgN3dsCpuPattern[] = {
|
||||
0x00, 0x40, 0xA0, 0xE1, 0x07, 0x00
|
||||
};
|
||||
|
||||
u32 *cfgN3dsCpuLoc = (u32 *)memsearch(code, cfgN3dsCpuPattern, size, sizeof(cfgN3dsCpuPattern));
|
||||
|
||||
//Patch N3DS CPU Clock and L2 cache setting
|
||||
if(cfgN3dsCpuLoc != NULL)
|
||||
{
|
||||
*(cfgN3dsCpuLoc + 1) = 0xE1A00000;
|
||||
*(cfgN3dsCpuLoc + 8) = 0xE3A00000 | cpuSetting;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x0004013000001702LL: // CFG
|
||||
{
|
||||
static const u8 secureinfoSigCheckPattern[] = {
|
||||
0x06, 0x46, 0x10, 0x48, 0xFC
|
||||
};
|
||||
static const u8 secureinfoSigCheckPatch[] = {
|
||||
0x00, 0x26
|
||||
};
|
||||
|
||||
//Disable SecureInfo signature check
|
||||
patchMemory(code, size,
|
||||
secureinfoSigCheckPattern,
|
||||
sizeof(secureinfoSigCheckPattern), 0,
|
||||
secureinfoSigCheckPatch,
|
||||
sizeof(secureinfoSigCheckPatch), 1
|
||||
);
|
||||
|
||||
if(secureInfoExists())
|
||||
{
|
||||
static const u16 secureinfoFilenamePattern[] = u"SecureInfo_";
|
||||
static const u16 secureinfoFilenamePatch[] = u"C";
|
||||
|
||||
//Use SecureInfo_C
|
||||
patchMemory(code, size,
|
||||
secureinfoFilenamePattern,
|
||||
sizeof(secureinfoFilenamePattern) - sizeof(u16),
|
||||
sizeof(secureinfoFilenamePattern) - sizeof(u16),
|
||||
secureinfoFilenamePatch,
|
||||
sizeof(secureinfoFilenamePatch) - sizeof(u16), 2
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if(CONFIG(4))
|
||||
{
|
||||
u32 tidHigh = (progId & 0xFFFFFFF000000000LL) >> 0x24;
|
||||
|
||||
if(tidHigh == 0x0004000)
|
||||
{
|
||||
//Language emulation
|
||||
u8 regionId = 0xFF,
|
||||
languageId = 0xFF;
|
||||
|
||||
if(R_SUCCEEDED(loadTitleLocaleConfig(progId, ®ionId, &languageId)))
|
||||
{
|
||||
u32 CFGUHandleOffset;
|
||||
|
||||
u8 *CFGU_GetConfigInfoBlk2_endPos = getCfgOffsets(code, size, &CFGUHandleOffset);
|
||||
|
||||
if(CFGU_GetConfigInfoBlk2_endPos != NULL)
|
||||
{
|
||||
if(languageId != 0xFF) patchCfgGetLanguage(code, size, languageId, CFGU_GetConfigInfoBlk2_endPos);
|
||||
if(regionId != 0xFF) patchCfgGetRegion(code, size, regionId, CFGUHandleOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
void patchCode(u64 progId, u8 *code, u32 size);
|
||||
47
k11_extension/Makefile
Normal file
47
k11_extension/Makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/base_tools
|
||||
|
||||
name := k11_extension
|
||||
|
||||
dir_source := source
|
||||
dir_include := include
|
||||
dir_build := build
|
||||
|
||||
ARCH := -mcpu=mpcore -mfpu=vfp
|
||||
ASFLAGS := $(ARCH)
|
||||
CFLAGS := -Wall -Wextra -MMD -MP -marm $(ASFLAGS) -I$(dir_include) -fno-builtin -std=c11 -Wno-main -g -flto -O2 -ffast-math \
|
||||
-mword-relocations -ffunction-sections -fdata-sections
|
||||
LDFLAGS := -nostdlib -Wl,--gc-sections,--nmagic $(ARCH)
|
||||
|
||||
objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||
|
||||
.PHONY: all
|
||||
all: ../$(dir_build)/$(name).bin
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(dir_build)
|
||||
|
||||
../$(dir_build)/$(name).bin: $(dir_build)/$(name).elf
|
||||
$(OBJCOPY) -S -O binary $< $@
|
||||
|
||||
$(dir_build)/$(name).elf: $(objects)
|
||||
$(CC) $(LDFLAGS) -T linker.ld $(OUTPUT_OPTION) $^
|
||||
|
||||
$(dir_build)/memory.o : CFLAGS += -O3 -marm
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.c
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||
|
||||
$(dir_build)/%.o: $(dir_source)/%.s
|
||||
@mkdir -p "$(@D)"
|
||||
$(COMPILE.s) $(OUTPUT_OPTION) $<
|
||||
include $(call rwildcard, $(dir_build), *.d)
|
||||
37
k11_extension/include/config.h
Normal file
37
k11_extension/include/config.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define MAKE_BRANCH(src,dst) (0xEA000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
|
||||
#define MAKE_BRANCH_LINK(src,dst) (0xEB000000 | ((u32)((((u8 *)(dst) - (u8 *)(src)) >> 2) - 2) & 0xFFFFFF))
|
||||
|
||||
#define CONFIG(a) (((cfwInfo.config >> (a)) & 1) != 0)
|
||||
#define MULTICONFIG(a) ((cfwInfo.multiConfig >> (2 * (a))) & 3)
|
||||
#define BOOTCONFIG(a, b) ((cfwInfo.bootConfig >> (a)) & (b))
|
||||
|
||||
#define BOOTCFG_NAND BOOTCONFIG(0, 7)
|
||||
#define BOOTCFG_FIRM BOOTCONFIG(3, 7)
|
||||
#define BOOTCFG_NOFORCEFLAG BOOTCONFIG(6, 1)
|
||||
#define BOOTCFG_NTRCARDBOOT BOOTCONFIG(7, 1)
|
||||
|
||||
enum multiOptions
|
||||
{
|
||||
DEFAULTEMU = 0,
|
||||
BRIGHTNESS,
|
||||
SPLASH,
|
||||
SPLASH_DURATION,
|
||||
PIN,
|
||||
NEWCPU
|
||||
};
|
||||
|
||||
enum singleOptions
|
||||
{
|
||||
AUTOBOOTEMU = 0,
|
||||
USEEMUFIRM,
|
||||
LOADEXTFIRMSANDMODULES,
|
||||
PATCHGAMES,
|
||||
PATCHVERSTRING,
|
||||
SHOWGBABOOT,
|
||||
PATCHUNITINFO,
|
||||
DISABLEARM11EXCHANDLERS
|
||||
};
|
||||
39
k11_extension/include/debug.h
Normal file
39
k11_extension/include/debug.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "globals.h"
|
||||
#include "kernel.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern KRecursiveLock dbgParamsLock;
|
||||
extern u32 dbgParamWatchpointId, dbgParamDVA, dbgParamWCR, dbgParamContextId;
|
||||
|
||||
KSchedulableInterruptEvent *enableMonitorModeDebugging(KBaseInterruptEvent *this, u32 interruptID);
|
||||
KSchedulableInterruptEvent *disableWatchpoint(KBaseInterruptEvent *this, u32 interruptID);
|
||||
KSchedulableInterruptEvent *setWatchpointWithContextId(KBaseInterruptEvent *this, u32 interruptID);
|
||||
52
k11_extension/include/fatalExceptionHandlers.h
Normal file
52
k11_extension/include/fatalExceptionHandlers.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
bool isExceptionFatal(u32 spsr, u32 *regs, u32 index);
|
||||
bool isDataAbortExceptionRangeControlled(u32 spsr, u32 addr);
|
||||
|
||||
void FIQHandler(void);
|
||||
void undefinedInstructionHandler(void);
|
||||
void prefetchAbortHandler(void);
|
||||
void dataAbortHandler(void);
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
u32 magic[2];
|
||||
u16 versionMinor, versionMajor;
|
||||
|
||||
u16 processor, core;
|
||||
u32 type;
|
||||
|
||||
u32 totalSize;
|
||||
u32 registerDumpSize;
|
||||
u32 codeDumpSize;
|
||||
u32 stackDumpSize;
|
||||
u32 additionalDataSize;
|
||||
} ExceptionDumpHeader;
|
||||
137
k11_extension/include/globals.h
Normal file
137
k11_extension/include/globals.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include "kernel.h"
|
||||
|
||||
extern KRecursiveLock *criticalSectionLock;
|
||||
extern KObjectList *threadList;
|
||||
extern KObjectMutex *synchronizationMutex;
|
||||
|
||||
extern void (*KRecursiveLock__Lock)(KRecursiveLock *this);
|
||||
extern void (*KRecursiveLock__Unlock)(KRecursiveLock *this);
|
||||
|
||||
extern void (*KAutoObject__AddReference)(KAutoObject *this);
|
||||
|
||||
extern KProcess * (*KProcessHandleTable__ToKProcess)(KProcessHandleTable *this, Handle processHandle);
|
||||
extern KThread * (*KProcessHandleTable__ToKThread)(KProcessHandleTable *this, Handle threadHandle);
|
||||
extern KAutoObject * (*KProcessHandleTable__ToKAutoObject)(KProcessHandleTable *this, Handle handle);
|
||||
extern void (*KSynchronizationObject__Signal)(KSynchronizationObject *this, bool isPulse);
|
||||
extern Result (*WaitSynchronization1)(void *this_unused, KThread *thread, KSynchronizationObject *syncObject, s64 timeout);
|
||||
extern Result (*KProcessHandleTable__CreateHandle)(KProcessHandleTable *this, Handle *out, KAutoObject *obj, u8 token);
|
||||
extern Result (*KProcessHwInfo__MapProcessMemory)(KProcessHwInfo *this, KProcessHwInfo *other, void *dst, void *src, u32 nbPages);
|
||||
extern Result (*KProcessHwInfo__UnmapProcessMemory)(KProcessHwInfo *this, void *addr, u32 nbPages);
|
||||
extern Result (*KEvent__Clear)(KEvent *this);
|
||||
extern void (*KObjectMutex__WaitAndAcquire)(KObjectMutex *this);
|
||||
extern void (*KObjectMutex__ErrorOccured)(void);
|
||||
|
||||
extern void (*KScheduler__AdjustThread)(KScheduler *this, KThread *thread, u32 oldSchedulingMask);
|
||||
extern void (*KScheduler__AttemptSwitchingThreadContext)(KScheduler *this);
|
||||
|
||||
extern Result (*ControlMemory)(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader);
|
||||
extern void (*SleepThread)(s64 ns);
|
||||
extern Result (*CloseHandle)(Handle handle);
|
||||
extern Result (*GetHandleInfo)(s64 *out, Handle handle, u32 type);
|
||||
extern Result (*GetSystemInfo)(s64 *out, s32 type, s32 param);
|
||||
extern Result (*GetProcessInfo)(s64 *out, Handle processHandle, u32 type);
|
||||
extern Result (*GetThreadInfo)(s64 *out, Handle threadHandle, u32 type);
|
||||
extern Result (*ConnectToPort)(Handle *out, const char *name);
|
||||
extern Result (*SendSyncRequest)(Handle handle);
|
||||
extern Result (*OpenProcess)(Handle *out, u32 processId);
|
||||
extern Result (*GetProcessId)(u32 *out, Handle process);
|
||||
extern Result (*DebugActiveProcess)(Handle *out, u32 processId);
|
||||
extern Result (*UnmapProcessMemory)(Handle processHandle, void *dst, u32 size);
|
||||
extern Result (*KernelSetState)(u32 type, u32 varg1, u32 varg2, u32 varg3);
|
||||
|
||||
extern void (*flushDataCacheRange)(void *addr, u32 len);
|
||||
extern void (*invalidateInstructionCacheRange)(void *addr, u32 len);
|
||||
|
||||
extern bool (*usrToKernelMemcpy8)(void *dst, const void *src, u32 len);
|
||||
extern bool (*usrToKernelMemcpy32)(u32 *dst, const u32 *src, u32 len);
|
||||
extern s32 (*usrToKernelStrncpy)(char *dst, const char *src, u32 len);
|
||||
extern bool (*kernelToUsrMemcpy8)(void *dst, const void *src, u32 len);
|
||||
extern bool (*kernelToUsrMemcpy32)(u32 *dst, const u32 *src, u32 len);
|
||||
extern s32 (*kernelToUsrStrncpy)(char *dst, const char *src, u32 len);
|
||||
|
||||
extern void (*svcFallbackHandler)(u8 svcId);
|
||||
extern void (*kernelpanic)(void);
|
||||
extern void (*officialPostProcessSvc)(void);
|
||||
|
||||
extern Result (*SignalDebugEvent)(DebugEventType type, u32 info, ...);
|
||||
|
||||
extern bool isN3DS;
|
||||
extern u32 *exceptionStackTop;
|
||||
|
||||
extern u32 TTBCR;
|
||||
extern u32 L1MMUTableAddrs[4];
|
||||
|
||||
extern void *kernelUsrCopyFuncsStart, *kernelUsrCopyFuncsEnd;
|
||||
|
||||
extern bool *isDevUnit;
|
||||
|
||||
extern vu8 *configPage;
|
||||
extern u32 kernelVersion;
|
||||
extern FcramLayout fcramLayout;
|
||||
|
||||
extern KCoreContext *coreCtxs;
|
||||
|
||||
extern void *originalHandlers[8];
|
||||
extern u32 nbSection0Modules;
|
||||
|
||||
extern u8 __start__[], __end__[], __bss_start__[], __bss_end__[];
|
||||
|
||||
extern Result (*InterruptManager__MapInterrupt)(InterruptManager *manager, KBaseInterruptEvent *iEvent, u32 interruptID,
|
||||
u32 coreID, u32 priority, bool disableUponReceipt, bool levelHighActive);
|
||||
extern InterruptManager *interruptManager;
|
||||
extern KBaseInterruptEvent *customInterruptEvent;
|
||||
|
||||
extern void (*initFPU)(void);
|
||||
extern void (*mcuReboot)(void);
|
||||
extern void (*coreBarrier)(void);
|
||||
|
||||
typedef struct CfwInfo
|
||||
{
|
||||
char magic[4];
|
||||
|
||||
u8 versionMajor;
|
||||
u8 versionMinor;
|
||||
u8 versionBuild;
|
||||
u8 flags;
|
||||
|
||||
u32 commitHash;
|
||||
|
||||
u16 configFormatVersionMajor, configFormatVersionMinor;
|
||||
u32 config, multiConfig, bootConfig;
|
||||
u64 hbldr3dsxTitleId;
|
||||
u32 rosalinaMenuCombo;
|
||||
} CfwInfo;
|
||||
|
||||
extern CfwInfo cfwInfo;
|
||||
|
||||
extern vu32 rosalinaState;
|
||||
extern bool hasStartedRosalinaNetworkFuncsOnce;
|
||||
61
k11_extension/include/ipc.h
Normal file
61
k11_extension/include/ipc.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "globals.h"
|
||||
#include "kernel.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define MAX_SESSION 345
|
||||
|
||||
// the structure of sessions is apparently not the same on older versions...
|
||||
|
||||
typedef struct SessionInfo
|
||||
{
|
||||
KSession *session;
|
||||
char name[12];
|
||||
} SessionInfo;
|
||||
|
||||
typedef struct LangemuAttributes
|
||||
{
|
||||
u64 titleId;
|
||||
u8 mask, region, language, country, state;
|
||||
} LangemuAttributes;
|
||||
|
||||
extern KRecursiveLock processLangemuLock;
|
||||
extern LangemuAttributes processLangemuAttributes[0x40];
|
||||
|
||||
SessionInfo *SessionInfo_Lookup(KSession *session);
|
||||
SessionInfo *SessionInfo_FindFirst(const char *name);
|
||||
void SessionInfo_ChangeVtable(KSession *session);
|
||||
void SessionInfo_Add(KSession *session, const char *name);
|
||||
void SessionInfo_Remove(KSession *session);
|
||||
|
||||
bool doLangEmu(Result *res, u32 *cmdbuf);
|
||||
Result doPublishToProcessHook(Handle handle, u32 *cmdbuf);
|
||||
bool doErrfThrowHook(u32 *cmdbuf);
|
||||
1224
k11_extension/include/kernel.h
Normal file
1224
k11_extension/include/kernel.h
Normal file
File diff suppressed because it is too large
Load Diff
42
k11_extension/include/memory.h
Normal file
42
k11_extension/include/memory.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void *memcpy(void *dest, const void *src, u32 size) USED;
|
||||
int memcmp(const void *buf1, const void *buf2, u32 size) USED;
|
||||
void *memset(void *dest, u32 value, u32 size) USED; // thanks binutils for the nice bug involving memset.
|
||||
void *memset32(void *dest, u32 value, u32 size);
|
||||
u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize);
|
||||
char *strcpy(char *dest, const char *src);
|
||||
char *strncpy(char *dest, const char *src, u32 size);
|
||||
s32 strnlen(const char *string, s32 maxlen);
|
||||
s32 strlen(const char *string);
|
||||
s32 strcmp(const char *str1, const char *str2);
|
||||
s32 strncmp(const char *str1, const char *str2, u32 size);
|
||||
void hexItoa(u64 number, char *out, u32 digits, bool uppercase);
|
||||
38
k11_extension/include/svc.h
Normal file
38
k11_extension/include/svc.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "globals.h"
|
||||
#include "kernel.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern void *officialSVCs[0x7E];
|
||||
|
||||
void postprocessSvc(void);
|
||||
void svcDefaultHandler(u8 svcId);
|
||||
void *svcHook(u8 *pageEnd);
|
||||
33
k11_extension/include/svc/Backdoor.h
Normal file
33
k11_extension/include/svc/Backdoor.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
void Backdoor(void *function);
|
||||
32
k11_extension/include/svc/Break.h
Normal file
32
k11_extension/include/svc/Break.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
|
||||
void __attribute__((noreturn)) Break(UserBreakType type, ...);
|
||||
34
k11_extension/include/svc/ConnectToPort.h
Normal file
34
k11_extension/include/svc/ConnectToPort.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result ConnectToPortHookWrapper(u32 dummy, const char *name);
|
||||
Result ConnectToPortHook(Handle *out, const char *name);
|
||||
35
k11_extension/include/svc/ControlMemory.h
Normal file
35
k11_extension/include/svc/ControlMemory.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result ControlMemoryHookWrapper(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm);
|
||||
Result ControlMemoryHook(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm);
|
||||
Result ControlMemoryEx(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader);
|
||||
40
k11_extension/include/svc/ControlService.h
Normal file
40
k11_extension/include/svc/ControlService.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
/// Operations for svcControlService
|
||||
typedef enum ServiceOp
|
||||
{
|
||||
SERVICEOP_STEAL_CLIENT_SESSION = 0, ///< Steal a client session given a service or global port name
|
||||
SERVICEOP_GET_NAME, ///< Get the name of a service or global port given a client or session handle
|
||||
} ServiceOp;
|
||||
|
||||
Result ControlService(ServiceOp op, u32 varg1, u32 varg2);
|
||||
34
k11_extension/include/svc/CopyHandle.h
Normal file
34
k11_extension/include/svc/CopyHandle.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result CopyHandleWrapper(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle);
|
||||
Result CopyHandle(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle);
|
||||
33
k11_extension/include/svc/CustomBackdoor.h
Normal file
33
k11_extension/include/svc/CustomBackdoor.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
void CustomBackdoor(void *function, ...);
|
||||
35
k11_extension/include/svc/GetCFWInfo.h
Normal file
35
k11_extension/include/svc/GetCFWInfo.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
#include "globals.h"
|
||||
|
||||
// DEPRECATED
|
||||
Result GetCFWInfo(CfwInfo *out);
|
||||
34
k11_extension/include/svc/GetHandleInfo.h
Normal file
34
k11_extension/include/svc/GetHandleInfo.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result GetHandleInfoHookWrapper(u32 dummy, Handle handle, u32 type);
|
||||
Result GetHandleInfoHook(s64 *out, Handle handle, u32 type);
|
||||
34
k11_extension/include/svc/GetProcessInfo.h
Normal file
34
k11_extension/include/svc/GetProcessInfo.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result GetProcessInfoHookWrapper(u32 dummy, Handle processHandle, u32 type);
|
||||
Result GetProcessInfoHook(s64 *out, Handle processHandle, u32 type);
|
||||
34
k11_extension/include/svc/GetSystemInfo.h
Normal file
34
k11_extension/include/svc/GetSystemInfo.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result GetSystemInfoHookWrapper(u32 dummy, s32 type, s32 param);
|
||||
Result GetSystemInfoHook(s64 *out, s32 type, s32 param);
|
||||
34
k11_extension/include/svc/GetThreadInfo.h
Normal file
34
k11_extension/include/svc/GetThreadInfo.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result GetThreadInfoHookWrapper(u32 dummy, Handle threadHandle, u32 type);
|
||||
Result GetThreadInfoHook(s64 *out, Handle threadHandle, u32 type);
|
||||
34
k11_extension/include/svc/KernelSetState.h
Normal file
34
k11_extension/include/svc/KernelSetState.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
bool shouldSignalSyscallDebugEvent(KProcess *process, u8 svcId);
|
||||
Result KernelSetStateHook(u32 type, u32 varg1, u32 varg2, u32 varg3);
|
||||
33
k11_extension/include/svc/MapProcessMemoryEx.h
Normal file
33
k11_extension/include/svc/MapProcessMemoryEx.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result MapProcessMemoryEx(Handle processHandle, void *dst, void *src, u32 size);
|
||||
33
k11_extension/include/svc/SendSyncRequest.h
Normal file
33
k11_extension/include/svc/SendSyncRequest.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result SendSyncRequestHook(Handle handle);
|
||||
33
k11_extension/include/svc/SetGpuProt.h
Normal file
33
k11_extension/include/svc/SetGpuProt.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result SetGpuProt(bool prot);
|
||||
33
k11_extension/include/svc/SetWifiEnabled.h
Normal file
33
k11_extension/include/svc/SetWifiEnabled.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result SetWifiEnabled(bool enable);
|
||||
34
k11_extension/include/svc/TranslateHandle.h
Normal file
34
k11_extension/include/svc/TranslateHandle.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result TranslateHandleWrapper(u32 *outKAddr, char *outClassName, Handle handle);
|
||||
Result TranslateHandle(u32 *outKAddr, char *outClassName, Handle handle);
|
||||
33
k11_extension/include/svc/UnmapProcessMemoryEx.h
Normal file
33
k11_extension/include/svc/UnmapProcessMemoryEx.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result UnmapProcessMemoryEx(Handle processHandle, void *dst, u32 size);
|
||||
29
k11_extension/include/svcHandler.h
Normal file
29
k11_extension/include/svcHandler.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
void svcHandler(void);
|
||||
119
k11_extension/include/synchronization.h
Normal file
119
k11_extension/include/synchronization.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "kernel.h"
|
||||
|
||||
typedef KSchedulableInterruptEvent* (*SGI0Handler_t)(KBaseInterruptEvent *this, u32 interruptID);
|
||||
|
||||
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0360f/CCHDIFIJ.html
|
||||
void executeFunctionOnCores(SGI0Handler_t func, u8 targetList, u8 targetListFilter);
|
||||
|
||||
void KScheduler__TriggerCrossCoreInterrupt(KScheduler *this);
|
||||
void KThread__DebugReschedule(KThread *this, bool lock);
|
||||
bool rosalinaThreadLockPredicate(KThread *thread);
|
||||
void rosalinaRescheduleThread(KThread *thread, bool lock);
|
||||
void rosalinaLockThread(KThread *thread);
|
||||
void rosalinaLockAllThreads(void);
|
||||
void rosalinaUnlockAllThreads(void);
|
||||
|
||||
// Taken from ctrulib:
|
||||
|
||||
static inline void __dsb(void)
|
||||
{
|
||||
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 4" :: [val] "r" (0) : "memory");
|
||||
}
|
||||
|
||||
static inline void __clrex(void)
|
||||
{
|
||||
__asm__ __volatile__("clrex" ::: "memory");
|
||||
}
|
||||
|
||||
static inline s32 __ldrex(s32* addr)
|
||||
{
|
||||
s32 val;
|
||||
__asm__ __volatile__("ldrex %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline bool __strex(s32* addr, s32 val)
|
||||
{
|
||||
bool res;
|
||||
__asm__ __volatile__("strex %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline s8 __ldrex8(s8* addr)
|
||||
{
|
||||
s8 val;
|
||||
__asm__ __volatile__("ldrexb %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline bool __strex8(s8* addr, s8 val)
|
||||
{
|
||||
bool res;
|
||||
__asm__ __volatile__("strexb %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline s16 __ldrex16(s16* addr)
|
||||
{
|
||||
s16 val;
|
||||
__asm__ __volatile__("ldrexh %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline bool __strex16(s16* addr, s16 val)
|
||||
{
|
||||
bool res;
|
||||
__asm__ __volatile__("strexh %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline u32 __get_cpsr(void)
|
||||
{
|
||||
u32 cpsr;
|
||||
__asm__ __volatile__("mrs %0, cpsr" : "=r"(cpsr));
|
||||
return cpsr;
|
||||
}
|
||||
|
||||
static inline void __set_cpsr_cx(u32 cpsr)
|
||||
{
|
||||
__asm__ __volatile__("msr cpsr_cx, %0" :: "r"(cpsr));
|
||||
}
|
||||
|
||||
static inline void __enable_irq(void)
|
||||
{
|
||||
__asm__ __volatile__("cpsie i");
|
||||
}
|
||||
|
||||
static inline void __disable_irq(void)
|
||||
{
|
||||
__asm__ __volatile__("cpsid i");
|
||||
}
|
||||
97
k11_extension/include/types.h
Normal file
97
k11_extension/include/types.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
// Taken from ctrulib
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/// The maximum value of a u64.
|
||||
#define U64_MAX UINT64_MAX
|
||||
|
||||
/// would be nice if newlib had this already
|
||||
#ifndef SSIZE_MAX
|
||||
#ifdef SIZE_MAX
|
||||
#define SSIZE_MAX ((SIZE_MAX) >> 1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef uint8_t u8; ///< 8-bit unsigned integer
|
||||
typedef uint16_t u16; ///< 16-bit unsigned integer
|
||||
typedef uint32_t u32; ///< 32-bit unsigned integer
|
||||
typedef uint64_t u64; ///< 64-bit unsigned integer
|
||||
|
||||
typedef int8_t s8; ///< 8-bit signed integer
|
||||
typedef int16_t s16; ///< 16-bit signed integer
|
||||
typedef int32_t s32; ///< 32-bit signed integer
|
||||
typedef int64_t s64; ///< 64-bit signed integer
|
||||
|
||||
typedef volatile u8 vu8; ///< 8-bit volatile unsigned integer.
|
||||
typedef volatile u16 vu16; ///< 16-bit volatile unsigned integer.
|
||||
typedef volatile u32 vu32; ///< 32-bit volatile unsigned integer.
|
||||
typedef volatile u64 vu64; ///< 64-bit volatile unsigned integer.
|
||||
|
||||
typedef volatile s8 vs8; ///< 8-bit volatile signed integer.
|
||||
typedef volatile s16 vs16; ///< 16-bit volatile signed integer.
|
||||
typedef volatile s32 vs32; ///< 32-bit volatile signed integer.
|
||||
typedef volatile s64 vs64; ///< 64-bit volatile signed integer.
|
||||
|
||||
typedef u32 Handle; ///< Resource handle.
|
||||
typedef s32 Result; ///< Function result.
|
||||
|
||||
/// Creates a bitmask from a bit number.
|
||||
#define BIT(n) (1U<<(n))
|
||||
|
||||
/// Aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m.
|
||||
#define ALIGN(m) __attribute__((aligned(m)))
|
||||
/// Packs a struct (and other types?) so it won't include padding bytes.
|
||||
#define PACKED __attribute__((packed))
|
||||
#define USED __attribute__((used))
|
||||
#define UNUSED __attribute__((unused))
|
||||
/// Packs a system version from its components.
|
||||
#define SYSTEM_VERSION(major, minor, revision) \
|
||||
(((major)<<24)|((minor)<<16)|((revision)<<8))
|
||||
|
||||
#define CUR_THREAD_HANDLE 0xFFFF8000
|
||||
#define CUR_PROCESS_HANDLE 0xFFFF8001
|
||||
|
||||
#define MPCORE_REGS_BASE (0x17E00000 | (1u << 31))
|
||||
#define MPCORE_SCU_CFG (*(vu32 *)(MPCORE_REGS_BASE + 4))
|
||||
#define MPCORE_INT_ACK (*(vu32 *)(MPCORE_REGS_BASE + 0x10C))
|
||||
|
||||
#define MPCORE_GID_REGS_BASE (MPCORE_REGS_BASE + 0x1000)
|
||||
#define MPCORE_GID_SGI (*(vu32 *)(MPCORE_GID_REGS_BASE + 0xF00))
|
||||
|
||||
#define CFG11_REGS_BASE (0x10140000 | (1u << 31))
|
||||
#define CFG11_WIFICNT (*(vu8 *)(CFG11_REGS_BASE + 0x180))
|
||||
#define CFG11_MPCORE_CFG (*(vu16 *)(CFG11_REGS_BASE + 0xFFC))
|
||||
#define CFG11_MPCORE_CLKCNT (*(vu16 *)(CFG11_REGS_BASE + 0x1300))
|
||||
|
||||
#define L2C_REGS_BASE (0x17E10000 | (1u << 31))
|
||||
#define L2C_CTRL (*(vu32 *)(L2C_REGS_BASE + 0x100))
|
||||
87
k11_extension/include/utils.h
Normal file
87
k11_extension/include/utils.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "kernel.h"
|
||||
|
||||
// For accessing physmem uncached (and directly)
|
||||
#define PA_PTR(addr) (void *)((u32)(addr) | 1u << 31)
|
||||
#define PA_FROM_VA_PTR(addr) PA_PTR(convertVAToPA(addr, false))
|
||||
|
||||
static inline u32 makeARMBranch(const void *src, const void *dst, bool link) // the macros for those are ugly and buggy
|
||||
{
|
||||
u32 instrBase = link ? 0xEB000000 : 0xEA000000;
|
||||
u32 off = (u32)((const u8 *)dst - ((const u8 *)src + 8)); // the PC is always two instructions ahead of the one being executed
|
||||
|
||||
return instrBase | ((off >> 2) & 0xFFFFFF);
|
||||
}
|
||||
|
||||
static inline void *decodeARMBranch(const void *src)
|
||||
{
|
||||
u32 instr = *(const u32 *)src;
|
||||
s32 off = (instr & 0xFFFFFF) << 2;
|
||||
off = (off << 6) >> 6; // sign extend
|
||||
|
||||
return (void *)((const u8 *)src + 8 + off);
|
||||
}
|
||||
|
||||
// For ARM prologs in the form of: push {regs} ... sub sp, #off (this obviously doesn't intend to cover all cases)
|
||||
static inline u32 computeARMFrameSize(const u32 *prolog)
|
||||
{
|
||||
const u32 *off;
|
||||
|
||||
for(off = prolog; (*off >> 16) != 0xE92D; off++); // look for stmfd sp! = push
|
||||
u32 nbPushedRegs = 0;
|
||||
for(u32 val = *off & 0xFFFF; val != 0; val >>= 1) // 1 bit = 1 pushed register
|
||||
nbPushedRegs += val & 1;
|
||||
for(; (*off >> 8) != 0xE24DD0; off++); // look for sub sp, #offset
|
||||
u32 localVariablesSpaceSize = *off & 0xFF;
|
||||
|
||||
return 4 * nbPushedRegs + localVariablesSpaceSize;
|
||||
}
|
||||
|
||||
static inline u32 getNumberOfCores(void)
|
||||
{
|
||||
return (MPCORE_SCU_CFG & 3) + 1;
|
||||
}
|
||||
|
||||
static inline u32 getCurrentCoreID(void)
|
||||
{
|
||||
u32 coreId;
|
||||
__asm__ volatile("mrc p15, 0, %0, c0, c0, 5" : "=r"(coreId));
|
||||
return coreId & 3;
|
||||
}
|
||||
|
||||
u32 convertVAToPA(const void *addr, bool writeCheck);
|
||||
|
||||
u32 safecpy(void *dst, const void *src, u32 len);
|
||||
void KObjectMutex__Acquire(KObjectMutex *this);
|
||||
void KObjectMutex__Release(KObjectMutex *this);
|
||||
|
||||
void flushEntireDataCache(void);
|
||||
void invalidateEntireInstructionCache(void);
|
||||
19
k11_extension/linker.ld
Normal file
19
k11_extension/linker.ld
Normal file
@@ -0,0 +1,19 @@
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x40000000;
|
||||
|
||||
__start__ = .;
|
||||
|
||||
.text : ALIGN(4) { *(.text.start) *(.text*); . = ALIGN(4); }
|
||||
.rodata : ALIGN(4) { *(.rodata*); . = ALIGN(4); }
|
||||
.data : ALIGN(4) { *(.data*); . = ALIGN(4); }
|
||||
.bss : ALIGN(8) { __bss_start__ = .; *(.bss* COMMON); . = ALIGN(8); __bss_end__ = .; }
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
|
||||
__end__ = .;
|
||||
}
|
||||
147
k11_extension/source/debug.c
Normal file
147
k11_extension/source/debug.c
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "memory.h"
|
||||
#include "synchronization.h"
|
||||
|
||||
KRecursiveLock dbgParamsLock = { NULL };
|
||||
u32 dbgParamWatchpointId, dbgParamDVA, dbgParamWCR, dbgParamContextId;
|
||||
|
||||
KSchedulableInterruptEvent *enableMonitorModeDebugging(KBaseInterruptEvent *this UNUSED, u32 interruptID UNUSED)
|
||||
{
|
||||
coreBarrier();
|
||||
|
||||
u32 DSCR;
|
||||
__asm__ __volatile__("mrc p14, 0, %[val], c0, c1, 0" : [val] "=r" (DSCR));
|
||||
DSCR |= 0x8000;
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 0" :: [val] "r" (DSCR));
|
||||
|
||||
__dsb();
|
||||
coreBarrier();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void disableWatchpoint0(void)
|
||||
{
|
||||
u32 control;
|
||||
|
||||
// WCR0
|
||||
__asm__ __volatile__("mrc p14, 0, %[val], c0, c0, 7" : [val] "=r" (control));
|
||||
control &= ~1;
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c0, 7" :: [val] "r" (control));
|
||||
|
||||
// BCR4
|
||||
__asm__ __volatile__("mrc p14, 0, %[val], c0, c4, 5" : [val] "=r" (control));
|
||||
control &= ~1;
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c4, 5" :: [val] "r" (control));
|
||||
}
|
||||
|
||||
static void disableWatchpoint1(void)
|
||||
{
|
||||
u32 control;
|
||||
|
||||
// WCR1
|
||||
__asm__ __volatile__("mrc p14, 0, %[val], c0, c1, 7" : [val] "=r" (control));
|
||||
control &= ~1;
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 7" :: [val] "r" (control));
|
||||
|
||||
// BCR5
|
||||
__asm__ __volatile__("mrc p14, 0, %[val], c0, c5, 5" : [val] "=r" (control));
|
||||
control &= ~1;
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c5, 5" :: [val] "r" (control));
|
||||
}
|
||||
|
||||
KSchedulableInterruptEvent *disableWatchpoint(KBaseInterruptEvent *this UNUSED, u32 interruptID UNUSED)
|
||||
{
|
||||
coreBarrier();
|
||||
|
||||
if(dbgParamWatchpointId == 0)
|
||||
disableWatchpoint0();
|
||||
else
|
||||
disableWatchpoint1();
|
||||
|
||||
__dsb();
|
||||
coreBarrier();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void setWatchpoint0WithContextId(u32 DVA, u32 WCR, u32 contextId)
|
||||
{
|
||||
// http://infocenter.arm.com/help/topic/com.arm.doc.ddi0360f/CEGCFFDF.html
|
||||
u32 BCR =
|
||||
(1 << 21) | /* compare with context ID */
|
||||
(1 << 20) | /* linked (with a WRP in our case) */
|
||||
(0xf << 5) | /* byte address select, +0 to +3 as mandated when linking with a WRP */
|
||||
(3 << 1) | /* either privileged modes or user mode, as mandated when linking with a WRP */
|
||||
(1 << 0) ; /* enabled */
|
||||
|
||||
disableWatchpoint0();
|
||||
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c0, 6" :: [val] "r" (DVA));
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c4, 4" :: [val] "r" (contextId));
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c0, 7" :: [val] "r" (WCR));
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c4, 5" :: [val] "r" (BCR));
|
||||
|
||||
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 5" :: [val] "r" (0) : "memory"); // DMB
|
||||
}
|
||||
|
||||
static void setWatchpoint1WithContextId(u32 DVA, u32 WCR, u32 contextId)
|
||||
{
|
||||
// http://infocenter.arm.com/help/topic/com.arm.doc.ddi0360f/CEGCFFDF.html
|
||||
u32 BCR =
|
||||
(1 << 21) | /* compare with context ID */
|
||||
(1 << 20) | /* linked (with a WRP in our case) */
|
||||
(0xf << 5) | /* byte address select, +0 to +3 as mandated when linking with a WRP */
|
||||
(3 << 1) | /* either privileged modes or user mode, as mandated when linking with a WRP */
|
||||
(1 << 0) ; /* enabled */
|
||||
|
||||
disableWatchpoint1();
|
||||
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 6" :: [val] "r" (DVA));
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c5, 4" :: [val] "r" (contextId));
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c1, 7" :: [val] "r" (WCR));
|
||||
__asm__ __volatile__("mcr p14, 0, %[val], c0, c5, 5" :: [val] "r" (BCR));
|
||||
|
||||
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 5" :: [val] "r" (0) : "memory"); // DMB
|
||||
}
|
||||
|
||||
KSchedulableInterruptEvent *setWatchpointWithContextId(KBaseInterruptEvent *this UNUSED, u32 interruptID UNUSED)
|
||||
{
|
||||
coreBarrier();
|
||||
|
||||
if(dbgParamWatchpointId == 0)
|
||||
setWatchpoint0WithContextId(dbgParamDVA, dbgParamWCR, dbgParamContextId);
|
||||
else
|
||||
setWatchpoint1WithContextId(dbgParamDVA, dbgParamWCR, dbgParamContextId);
|
||||
|
||||
__dsb();
|
||||
coreBarrier();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
252
k11_extension/source/fatalExceptionHandlers.s
Normal file
252
k11_extension/source/fatalExceptionHandlers.s
Normal file
@@ -0,0 +1,252 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.macro TEST_IF_MODE_AND_ARM_INST_OR_JUMP lbl, mode
|
||||
cpsid aif
|
||||
mrs sp, spsr
|
||||
tst sp, #0x20
|
||||
bne \lbl
|
||||
and sp, #0x1f @ get previous processor mode
|
||||
cmp sp, #\mode
|
||||
bne \lbl
|
||||
|
||||
sub sp, lr, #4
|
||||
mcr p15, 0, sp, c7, c8, 0 @ VA to PA translation with privileged read permission check
|
||||
mrc p15, 0, sp, c7, c4, 0 @ read PA register
|
||||
tst sp, #1 @ failure bit
|
||||
bne \lbl
|
||||
.endm
|
||||
|
||||
|
||||
.macro GEN_USUAL_HANDLER name, index, pos
|
||||
\name\()Handler:
|
||||
ldr sp, =exceptionStackTop
|
||||
ldr sp, [sp]
|
||||
sub sp, #0x100
|
||||
|
||||
push {r0-r12, lr}
|
||||
mrs r0, spsr
|
||||
mov r1, sp
|
||||
mov r2, #\index
|
||||
bl isExceptionFatal
|
||||
cmp r0, #0
|
||||
pop {r0-r12, lr}
|
||||
bne _exc_is_fatal_\name
|
||||
|
||||
ldr sp, =originalHandlers
|
||||
ldr sp, [sp, #\pos]
|
||||
bx sp
|
||||
|
||||
_exc_is_fatal_\name:
|
||||
push {r8, r9}
|
||||
mov r8, #\index
|
||||
b _commonHandler
|
||||
.endm
|
||||
|
||||
.text
|
||||
.arm
|
||||
.balign 4
|
||||
|
||||
_die:
|
||||
cpsid aif
|
||||
_die_loop:
|
||||
wfi
|
||||
b _die_loop
|
||||
|
||||
_commonHandler:
|
||||
cpsid aif
|
||||
|
||||
push {r0}
|
||||
ldr r0, =_fatalExceptionOccured
|
||||
ldr r0, [r0]
|
||||
cmp r0, #0
|
||||
bne _die_loop
|
||||
pop {r0}
|
||||
|
||||
ldr r9, =_regs
|
||||
stmia r9, {r0-r7}
|
||||
mov r1, r8
|
||||
pop {r8,r9}
|
||||
|
||||
ldr r0, =_fatalExceptionOccured
|
||||
mov r4, #1
|
||||
|
||||
_try_lock:
|
||||
ldrex r2, [r0]
|
||||
strex r3, r4, [r0]
|
||||
cmp r3, #0
|
||||
bne _try_lock
|
||||
|
||||
push {r1, r12, lr} @ attempt to hang the other cores
|
||||
adr r0, _die
|
||||
mov r1, #0xf
|
||||
mov r2, #1
|
||||
mov r3, #0
|
||||
bl executeFunctionOnCores
|
||||
pop {r1, r12, lr}
|
||||
|
||||
mrs r2, spsr
|
||||
mrs r3, cpsr
|
||||
ldr r6, =_regs
|
||||
add r6, #0x20
|
||||
|
||||
ands r4, r2, #0xf @ get the mode that triggered the exception
|
||||
moveq r4, #0xf @ usr => sys
|
||||
bic r5, r3, #0xf
|
||||
orr r5, r4
|
||||
msr cpsr_c, r5 @ change processor mode
|
||||
stmia r6!, {r8-lr}
|
||||
msr cpsr_c, r3 @ restore processor mode
|
||||
|
||||
str lr, [r6], #4
|
||||
str r2, [r6], #4
|
||||
|
||||
mov r0, r6
|
||||
|
||||
mrc p15, 0, r4, c5, c0, 0 @ dfsr
|
||||
mrc p15, 0, r5, c5, c0, 1 @ ifsr
|
||||
mrc p15, 0, r6, c6, c0, 0 @ far
|
||||
fmrx r7, fpexc
|
||||
fmrx r8, fpinst
|
||||
fmrx r9, fpinst2
|
||||
bic r3, #(1<<31)
|
||||
fmxr fpexc, r3 @ clear the VFP11 exception flag (if it's set)
|
||||
|
||||
stmia r0!, {r4-r9}
|
||||
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c14, 0 @ Clean and Invalidate Entire Data Cache
|
||||
mcr p15, 0, r0, c7, c10, 4 @ Drain Synchronization Barrier
|
||||
|
||||
ldr r0, =isN3DS
|
||||
ldrb r0, [r0]
|
||||
cmp r0, #0
|
||||
beq _no_L2C
|
||||
ldr r0, =(0x17e10100 | 1 << 31)
|
||||
ldr r0, [r0]
|
||||
tst r0, #1 @ is the L2C enabled?
|
||||
beq _no_L2C
|
||||
|
||||
ldr r0, =0xffff
|
||||
ldr r2, =(0x17e10730 | 1 << 31)
|
||||
str r0, [r2, #0x4c] @ invalidate by way
|
||||
|
||||
_L2C_sync:
|
||||
ldr r0, [r2] @ L2C cache sync register
|
||||
tst r0, #1
|
||||
bne _L2C_sync
|
||||
|
||||
_no_L2C:
|
||||
|
||||
msr cpsr_cxsf, #0xdf @ finally, switch to system mode, mask interrupts and clear flags (in case of double faults)
|
||||
ldr sp, =exceptionStackTop
|
||||
ldr sp, [sp]
|
||||
sub sp, #0x100
|
||||
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c10, 5 @ Drain Memory Barrier
|
||||
ldr r0, =_regs
|
||||
mrc p15, 0, r2, c0, c0, 5 @ CPU ID register
|
||||
bl fatalExceptionHandlersMain
|
||||
|
||||
ldr r12, =mcuReboot
|
||||
ldr r12, [r12]
|
||||
bx r12
|
||||
|
||||
.global FIQHandler
|
||||
.type FIQHandler, %function
|
||||
GEN_USUAL_HANDLER FIQ, 0, 28
|
||||
|
||||
.global undefinedInstructionHandler
|
||||
.type undefinedInstructionHandler, %function
|
||||
undefinedInstructionHandler:
|
||||
TEST_IF_MODE_AND_ARM_INST_OR_JUMP _undefinedInstructionNormalHandler, 0x10
|
||||
|
||||
ldr sp, [lr, #-4] @ test if it's an VFP instruction that was aborted
|
||||
lsl sp, #4
|
||||
sub sp, #0xc0000000
|
||||
cmp sp, #0x30000000
|
||||
bcs _undefinedInstructionNormalHandler
|
||||
fmrx sp, fpexc
|
||||
tst sp, #0x40000000
|
||||
bne _undefinedInstructionNormalHandler
|
||||
|
||||
@ FPU init
|
||||
sub lr, #4
|
||||
srsfd sp!, #0x13
|
||||
cps #0x13
|
||||
stmfd sp, {r0-r3, r11-lr}^
|
||||
sub sp, #0x20
|
||||
ldr r12, =initFPU
|
||||
ldr r12, [r12]
|
||||
blx r12
|
||||
ldmfd sp, {r0-r3, r11-lr}^
|
||||
add sp, #0x20
|
||||
rfefd sp! @ retry aborted instruction
|
||||
|
||||
GEN_USUAL_HANDLER _undefinedInstructionNormal, 1, 4
|
||||
|
||||
.global prefetchAbortHandler
|
||||
.type prefetchAbortHandler, %function
|
||||
prefetchAbortHandler:
|
||||
TEST_IF_MODE_AND_ARM_INST_OR_JUMP _prefetchAbortNormalHandler, 0x13
|
||||
|
||||
ldr sp, =(Break + 3*4 + 4)
|
||||
cmp lr, sp
|
||||
bne _prefetchAbortNormalHandler
|
||||
|
||||
sub sp, r0, #0x110
|
||||
pop {r0-r7, r12, lr}
|
||||
pop {r8-r11}
|
||||
ldr lr, [sp, #8]!
|
||||
ldr sp, [sp, #4]
|
||||
msr spsr_cxsf, sp
|
||||
tst sp, #0x20
|
||||
addne lr, #2 @ adjust address for later
|
||||
|
||||
GEN_USUAL_HANDLER _prefetchAbortNormal, 2, 12
|
||||
|
||||
.global dataAbortHandler
|
||||
.type dataAbortHandler, %function
|
||||
dataAbortHandler:
|
||||
ldr sp, =exceptionStackTop
|
||||
ldr sp, [sp]
|
||||
push {r0-r12, lr}
|
||||
mrs r0, spsr
|
||||
sub r1, lr, #8
|
||||
bl isDataAbortExceptionRangeControlled
|
||||
cmp r0, #0
|
||||
pop {r0-r12, lr}
|
||||
beq _dataAbortNormalHandler
|
||||
|
||||
msr spsr_f, #(1 << 30)
|
||||
mov r12, #0
|
||||
subs pc, lr, #4
|
||||
|
||||
GEN_USUAL_HANDLER _dataAbortNormal, 3, 16
|
||||
|
||||
.bss
|
||||
.balign 4
|
||||
_regs: .skip (4 * 23)
|
||||
_fatalExceptionOccured: .word 0
|
||||
131
k11_extension/source/fatalExceptionHandlersMain.c
Normal file
131
k11_extension/source/fatalExceptionHandlersMain.c
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "fatalExceptionHandlers.h"
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "memory.h"
|
||||
#include "globals.h"
|
||||
|
||||
#define REG_DUMP_SIZE 4 * 23
|
||||
#define CODE_DUMP_SIZE 48
|
||||
|
||||
bool isExceptionFatal(u32 spsr, u32 *regs, u32 index)
|
||||
{
|
||||
if(CONFIG(DISABLEARM11EXCHANDLERS)) return false;
|
||||
|
||||
if((spsr & 0x1F) != 0x10) return true;
|
||||
|
||||
KThread *thread = currentCoreContext->objectContext.currentThread;
|
||||
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
|
||||
|
||||
if(thread != NULL && thread->threadLocalStorage != NULL && *((vu32 *)thread->threadLocalStorage + 0x10) != 0)
|
||||
return false;
|
||||
|
||||
if(currentProcess != NULL)
|
||||
{
|
||||
if(debugOfProcess(currentProcess) != NULL)
|
||||
return false;
|
||||
|
||||
thread = KPROCESS_GET_RVALUE(currentProcess, mainThread);
|
||||
if(thread != NULL && thread->threadLocalStorage != NULL && *((vu32 *)thread->threadLocalStorage + 0x10) != 0)
|
||||
return false;
|
||||
|
||||
if(index == 3 && strcmp(codeSetOfProcess(currentProcess)->processName, "menu") == 0 && // workaround a Home Menu bug leading to a dabort
|
||||
regs[0] == 0x3FFF && regs[2] == 0 && regs[5] == 2 && regs[7] == 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
extern u32 safecpy_sz;
|
||||
bool isDataAbortExceptionRangeControlled(u32 spsr, u32 addr)
|
||||
{
|
||||
return (!(spsr & 0x20) && (spsr & 0x1F) != 0x10) && (
|
||||
((u32)kernelUsrCopyFuncsStart <= addr && addr < (u32)kernelUsrCopyFuncsEnd) ||
|
||||
((u32)safecpy <= addr && addr < (u32)safecpy + safecpy_sz)
|
||||
);
|
||||
}
|
||||
void fatalExceptionHandlersMain(u32 *registerDump, u32 type, u32 cpuId)
|
||||
{
|
||||
ExceptionDumpHeader dumpHeader;
|
||||
|
||||
u8 codeDump[CODE_DUMP_SIZE];
|
||||
u8 *finalBuffer = (u8 *)PA_PTR(0x25000000);
|
||||
u8 *final = finalBuffer;
|
||||
|
||||
dumpHeader.magic[0] = 0xDEADC0DE;
|
||||
dumpHeader.magic[1] = 0xDEADCAFE;
|
||||
dumpHeader.versionMajor = 1;
|
||||
dumpHeader.versionMinor = 2;
|
||||
|
||||
dumpHeader.processor = 11;
|
||||
dumpHeader.core = cpuId & 0xF;
|
||||
dumpHeader.type = type;
|
||||
|
||||
dumpHeader.registerDumpSize = REG_DUMP_SIZE;
|
||||
dumpHeader.codeDumpSize = CODE_DUMP_SIZE;
|
||||
|
||||
u32 cpsr = registerDump[16];
|
||||
u32 pc = registerDump[15] - (type < 3 ? (((cpsr & 0x20) != 0 && type == 1) ? 2 : 4) : 8);
|
||||
|
||||
registerDump[15] = pc;
|
||||
|
||||
//Dump code
|
||||
u8 *instr = (u8 *)pc + ((cpsr & 0x20) ? 2 : 4) - dumpHeader.codeDumpSize; //wouldn't work well on 32-bit Thumb instructions, but it isn't much of a problem
|
||||
dumpHeader.codeDumpSize = ((u32)instr & (((cpsr & 0x20) != 0) ? 1 : 3)) != 0 ? 0 : safecpy(codeDump, instr, dumpHeader.codeDumpSize);
|
||||
|
||||
//Copy register dump and code dump
|
||||
final = (u8 *)(finalBuffer + sizeof(ExceptionDumpHeader));
|
||||
memcpy(final, registerDump, dumpHeader.registerDumpSize);
|
||||
final += dumpHeader.registerDumpSize;
|
||||
memcpy(final, codeDump, dumpHeader.codeDumpSize);
|
||||
final += dumpHeader.codeDumpSize;
|
||||
|
||||
//Dump stack in place
|
||||
dumpHeader.stackDumpSize = safecpy(final, (const void *)registerDump[13], 0x1000 - (registerDump[13] & 0xFFF));
|
||||
final += dumpHeader.stackDumpSize;
|
||||
|
||||
if(currentCoreContext->objectContext.currentProcess)
|
||||
{
|
||||
vu64 *additionalData = (vu64 *)final;
|
||||
KCodeSet *currentCodeSet = codeSetOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
if(currentCodeSet != NULL)
|
||||
{
|
||||
dumpHeader.additionalDataSize = 16;
|
||||
memcpy((void *)additionalData, currentCodeSet->processName, 8);
|
||||
additionalData[1] = currentCodeSet->titleId;
|
||||
}
|
||||
else dumpHeader.additionalDataSize = 0;
|
||||
}
|
||||
else dumpHeader.additionalDataSize = 0;
|
||||
|
||||
dumpHeader.totalSize = sizeof(ExceptionDumpHeader) + dumpHeader.registerDumpSize + dumpHeader.codeDumpSize + dumpHeader.stackDumpSize + dumpHeader.additionalDataSize;
|
||||
|
||||
//Copy header (actually optimized by the compiler)
|
||||
*(ExceptionDumpHeader *)finalBuffer = dumpHeader;
|
||||
}
|
||||
114
k11_extension/source/globals.c
Normal file
114
k11_extension/source/globals.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
KRecursiveLock *criticalSectionLock;
|
||||
KObjectList *threadList;
|
||||
KObjectMutex *synchronizationMutex;
|
||||
|
||||
void (*KRecursiveLock__Lock)(KRecursiveLock *this);
|
||||
void (*KRecursiveLock__Unlock)(KRecursiveLock *this);
|
||||
|
||||
void (*KAutoObject__AddReference)(KAutoObject *this);
|
||||
KProcess * (*KProcessHandleTable__ToKProcess)(KProcessHandleTable *this, Handle processHandle);
|
||||
KThread * (*KProcessHandleTable__ToKThread)(KProcessHandleTable *this, Handle threadHandle);
|
||||
KAutoObject * (*KProcessHandleTable__ToKAutoObject)(KProcessHandleTable *this, Handle handle);
|
||||
void (*KSynchronizationObject__Signal)(KSynchronizationObject *this, bool isPulse);
|
||||
Result (*WaitSynchronization1)(void *this_unused, KThread *thread, KSynchronizationObject *syncObject, s64 timeout);
|
||||
Result (*KProcessHandleTable__CreateHandle)(KProcessHandleTable *this, Handle *out, KAutoObject *obj, u8 token);
|
||||
Result (*KProcessHwInfo__MapProcessMemory)(KProcessHwInfo *this, KProcessHwInfo *other, void *dst, void *src, u32 nbPages);
|
||||
Result (*KProcessHwInfo__UnmapProcessMemory)(KProcessHwInfo *this, void *addr, u32 nbPages);
|
||||
Result (*KEvent__Clear)(KEvent *this);
|
||||
void (*KObjectMutex__WaitAndAcquire)(KObjectMutex *this);
|
||||
void (*KObjectMutex__ErrorOccured)(void);
|
||||
|
||||
void (*KScheduler__AdjustThread)(KScheduler *this, KThread *thread, u32 oldSchedulingMask);
|
||||
void (*KScheduler__AttemptSwitchingThreadContext)(KScheduler *this);
|
||||
|
||||
Result (*ControlMemory)(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader);
|
||||
void (*SleepThread)(s64 ns);
|
||||
Result (*CloseHandle)(Handle handle);
|
||||
Result (*GetHandleInfo)(s64 *out, Handle handle, u32 type);
|
||||
Result (*GetSystemInfo)(s64 *out, s32 type, s32 param);
|
||||
Result (*GetProcessInfo)(s64 *out, Handle processHandle, u32 type);
|
||||
Result (*GetThreadInfo)(s64 *out, Handle threadHandle, u32 type);
|
||||
Result (*ConnectToPort)(Handle *out, const char *name);
|
||||
Result (*SendSyncRequest)(Handle handle);
|
||||
Result (*OpenProcess)(Handle *out, u32 processId);
|
||||
Result (*GetProcessId)(u32 *out, Handle process);
|
||||
Result (*DebugActiveProcess)(Handle *out, u32 processId);
|
||||
Result (*UnmapProcessMemory)(Handle processHandle, void *dst, u32 size);
|
||||
Result (*KernelSetState)(u32 type, u32 varg1, u32 varg2, u32 varg3);
|
||||
|
||||
void (*flushDataCacheRange)(void *addr, u32 len);
|
||||
void (*invalidateInstructionCacheRange)(void *addr, u32 len);
|
||||
|
||||
bool (*usrToKernelMemcpy8)(void *dst, const void *src, u32 len);
|
||||
bool (*usrToKernelMemcpy32)(u32 *dst, const u32 *src, u32 len);
|
||||
s32 (*usrToKernelStrncpy)(char *dst, const char *src, u32 len);
|
||||
bool (*kernelToUsrMemcpy8)(void *dst, const void *src, u32 len);
|
||||
bool (*kernelToUsrMemcpy32)(u32 *dst, const u32 *src, u32 len);
|
||||
s32 (*kernelToUsrStrncpy)(char *dst, const char *src, u32 len);
|
||||
|
||||
void (*svcFallbackHandler)(u8 svcId);
|
||||
void (*kernelpanic)(void);
|
||||
void (*officialPostProcessSvc)(void);
|
||||
|
||||
Result (*SignalDebugEvent)(DebugEventType type, u32 info, ...);
|
||||
|
||||
bool isN3DS;
|
||||
u32 *exceptionStackTop;
|
||||
|
||||
u32 TTBCR;
|
||||
u32 L1MMUTableAddrs[4];
|
||||
|
||||
void *kernelUsrCopyFuncsStart, *kernelUsrCopyFuncsEnd;
|
||||
|
||||
bool *isDevUnit;
|
||||
|
||||
vu8 *configPage;
|
||||
u32 kernelVersion;
|
||||
FcramLayout fcramLayout;
|
||||
KCoreContext *coreCtxs;
|
||||
|
||||
void *originalHandlers[8] = {NULL};
|
||||
|
||||
u32 nbSection0Modules;
|
||||
|
||||
Result (*InterruptManager__MapInterrupt)(InterruptManager *manager, KBaseInterruptEvent *iEvent, u32 interruptID,
|
||||
u32 coreID, u32 priority, bool disableUponReceipt, bool levelHighActive);
|
||||
InterruptManager *interruptManager;
|
||||
KBaseInterruptEvent *customInterruptEvent;
|
||||
|
||||
void (*initFPU)(void);
|
||||
void (*mcuReboot)(void);
|
||||
void (*coreBarrier)(void);
|
||||
|
||||
CfwInfo cfwInfo;
|
||||
|
||||
vu32 rosalinaState;
|
||||
bool hasStartedRosalinaNetworkFuncsOnce;
|
||||
318
k11_extension/source/ipc.c
Normal file
318
k11_extension/source/ipc.c
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "ipc.h"
|
||||
#include "memory.h"
|
||||
|
||||
static SessionInfo sessionInfos[MAX_SESSION] = { {NULL} };
|
||||
static u32 nbActiveSessions = 0;
|
||||
static KRecursiveLock sessionInfosLock = { NULL };
|
||||
|
||||
KRecursiveLock processLangemuLock;
|
||||
LangemuAttributes processLangemuAttributes[0x40];
|
||||
|
||||
static void *customSessionVtable[0x10] = { NULL }; // should be enough
|
||||
|
||||
static u32 SessionInfo_FindClosestSlot(KSession *session)
|
||||
{
|
||||
if(nbActiveSessions == 0 || session <= sessionInfos[0].session)
|
||||
return 0;
|
||||
else if(session > sessionInfos[nbActiveSessions - 1].session)
|
||||
return nbActiveSessions;
|
||||
|
||||
u32 a = 0, b = nbActiveSessions - 1, m;
|
||||
|
||||
do
|
||||
{
|
||||
m = (a + b) / 2;
|
||||
if(sessionInfos[m].session < session)
|
||||
a = m;
|
||||
else if(sessionInfos[m].session > session)
|
||||
b = m;
|
||||
else
|
||||
return m;
|
||||
}
|
||||
while(b - a > 1);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
SessionInfo *SessionInfo_Lookup(KSession *session)
|
||||
{
|
||||
KRecursiveLock__Lock(criticalSectionLock);
|
||||
KRecursiveLock__Lock(&sessionInfosLock);
|
||||
|
||||
SessionInfo *ret;
|
||||
u32 id = SessionInfo_FindClosestSlot(session);
|
||||
if(id == nbActiveSessions)
|
||||
ret = NULL;
|
||||
else
|
||||
ret = (void **)(sessionInfos[id].session->autoObject.vtable) == customSessionVtable ? &sessionInfos[id] : NULL;
|
||||
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SessionInfo *SessionInfo_FindFirst(const char *name)
|
||||
{
|
||||
KRecursiveLock__Lock(criticalSectionLock);
|
||||
KRecursiveLock__Lock(&sessionInfosLock);
|
||||
|
||||
SessionInfo *ret;
|
||||
u32 id;
|
||||
for(id = 0; id < nbActiveSessions && strncmp(sessionInfos[id].name, name, 12) != 0; id++);
|
||||
if(id == nbActiveSessions)
|
||||
ret = NULL;
|
||||
else
|
||||
ret = (void **)(sessionInfos[id].session->autoObject.vtable) == customSessionVtable ? &sessionInfos[id] : NULL;
|
||||
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SessionInfo_Add(KSession *session, const char *name)
|
||||
{
|
||||
KAutoObject__AddReference(&session->autoObject);
|
||||
SessionInfo_ChangeVtable(session);
|
||||
session->autoObject.vtable->DecrementReferenceCount(&session->autoObject);
|
||||
|
||||
KRecursiveLock__Lock(criticalSectionLock);
|
||||
KRecursiveLock__Lock(&sessionInfosLock);
|
||||
|
||||
if(nbActiveSessions == MAX_SESSION)
|
||||
{
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return;
|
||||
}
|
||||
|
||||
u32 id = SessionInfo_FindClosestSlot(session);
|
||||
|
||||
if(id != nbActiveSessions && sessionInfos[id].session == session)
|
||||
{
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return;
|
||||
}
|
||||
|
||||
for(u32 i = nbActiveSessions; i > id && i != 0; i--)
|
||||
sessionInfos[i] = sessionInfos[i - 1];
|
||||
|
||||
nbActiveSessions++;
|
||||
|
||||
sessionInfos[id].session = session;
|
||||
strncpy(sessionInfos[id].name, name, 12);
|
||||
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
}
|
||||
|
||||
void SessionInfo_Remove(KSession *session)
|
||||
{
|
||||
KRecursiveLock__Lock(criticalSectionLock);
|
||||
KRecursiveLock__Lock(&sessionInfosLock);
|
||||
|
||||
if(nbActiveSessions == MAX_SESSION)
|
||||
{
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return;
|
||||
}
|
||||
|
||||
u32 id = SessionInfo_FindClosestSlot(session);
|
||||
|
||||
if(id == nbActiveSessions)
|
||||
{
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return;
|
||||
}
|
||||
|
||||
for(u32 i = id; i < nbActiveSessions - 1; i++)
|
||||
sessionInfos[i] = sessionInfos[i + 1];
|
||||
|
||||
memset(&sessionInfos[--nbActiveSessions], 0, sizeof(SessionInfo));
|
||||
|
||||
KRecursiveLock__Unlock(&sessionInfosLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
}
|
||||
|
||||
static void (*KSession__dtor_orig)(KAutoObject *this);
|
||||
static void KSession__dtor_hook(KAutoObject *this)
|
||||
{
|
||||
KSession__dtor_orig(this);
|
||||
SessionInfo_Remove((KSession *)this);
|
||||
}
|
||||
|
||||
void SessionInfo_ChangeVtable(KSession *session)
|
||||
{
|
||||
if(customSessionVtable[2] == NULL)
|
||||
{
|
||||
memcpy(customSessionVtable, session->autoObject.vtable, 0x40);
|
||||
KSession__dtor_orig = session->autoObject.vtable->dtor;
|
||||
customSessionVtable[2] = (void *)KSession__dtor_hook;
|
||||
}
|
||||
session->autoObject.vtable = (Vtable__KAutoObject *)customSessionVtable;
|
||||
}
|
||||
|
||||
bool doLangEmu(Result *res, u32 *cmdbuf)
|
||||
{
|
||||
KRecursiveLock__Lock(criticalSectionLock);
|
||||
KRecursiveLock__Lock(&processLangemuLock);
|
||||
|
||||
u64 titleId = codeSetOfProcess(currentCoreContext->objectContext.currentProcess)->titleId;
|
||||
LangemuAttributes *attribs = NULL;
|
||||
bool skip = true;
|
||||
|
||||
*res = 0;
|
||||
for(u32 i = 0; i < 0x40; i++)
|
||||
{
|
||||
if(processLangemuAttributes[i].titleId == titleId)
|
||||
attribs = &processLangemuAttributes[i];
|
||||
}
|
||||
|
||||
if(attribs == NULL)
|
||||
{
|
||||
KRecursiveLock__Unlock(&processLangemuLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return false;
|
||||
}
|
||||
|
||||
if((cmdbuf[0] == 0x20000 || cmdbuf[0] == 0x4060000 || cmdbuf[0] == 0x8160000) && (attribs->mask & 1)) // SecureInfoGetRegion
|
||||
{
|
||||
cmdbuf[0] = (cmdbuf[0] & 0xFFFF0000) | 0x80;
|
||||
cmdbuf[1] = 0;
|
||||
cmdbuf[2] = attribs->region;
|
||||
}
|
||||
else if(cmdbuf[1] == 1 && cmdbuf[2] == 0xA0002 && cmdbuf[3] == 0x1C && (attribs->mask & 2))
|
||||
{
|
||||
cmdbuf[0] = (cmdbuf[0] & 0xFFFF0000) | 0x40;
|
||||
cmdbuf[1] = 0;
|
||||
*(u8 *)cmdbuf[4] = attribs->language;
|
||||
}
|
||||
else if(cmdbuf[1] == 4 && cmdbuf[2] == 0xB0000 && cmdbuf[3] == 0x4C && (attribs->mask & 0xC))
|
||||
{
|
||||
u8 *ptr = (u8 *)cmdbuf[4];
|
||||
if(attribs->mask & 4)
|
||||
ptr[3] = attribs->country;
|
||||
if(attribs->mask & 8)
|
||||
ptr[2] = attribs->state;
|
||||
|
||||
ptr[0] = ptr[1] = 0;
|
||||
}
|
||||
else
|
||||
skip = false;
|
||||
|
||||
KRecursiveLock__Unlock(&processLangemuLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return skip;
|
||||
}
|
||||
|
||||
Result doPublishToProcessHook(Handle handle, u32 *cmdbuf)
|
||||
{
|
||||
Result res = 0;
|
||||
u32 pid;
|
||||
bool terminateRosalina = cmdbuf[1] == 0x100 && cmdbuf[2] == 0; // cmdbuf[2] to check for well-formed requests
|
||||
u32 savedCmdbuf[4];
|
||||
memcpy(savedCmdbuf, cmdbuf, 16);
|
||||
|
||||
if(!terminateRosalina || GetProcessId(&pid, cmdbuf[3]) != 0)
|
||||
terminateRosalina = false;
|
||||
else
|
||||
{
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KProcess *process = KProcessHandleTable__ToKProcess(handleTable, cmdbuf[3]);
|
||||
if((strcmp(codeSetOfProcess(process)->processName, "socket") == 0 && (rosalinaState & 2)) ||
|
||||
strcmp(codeSetOfProcess(process)->processName, "pxi") == 0)
|
||||
terminateRosalina = true;
|
||||
else
|
||||
terminateRosalina = false;
|
||||
((KAutoObject *)process)->vtable->DecrementReferenceCount((KAutoObject *)process);
|
||||
}
|
||||
|
||||
if(terminateRosalina && nbSection0Modules == 6)
|
||||
{
|
||||
Handle rosalinaProcessHandle;
|
||||
res = OpenProcess(&rosalinaProcessHandle, 5);
|
||||
if(res == 0)
|
||||
{
|
||||
cmdbuf[0] = cmdbuf[0];
|
||||
cmdbuf[1] = 0x100;
|
||||
cmdbuf[2] = 0;
|
||||
cmdbuf[3] = rosalinaProcessHandle;
|
||||
|
||||
res = SendSyncRequest(handle);
|
||||
CloseHandle(rosalinaProcessHandle);
|
||||
memcpy(cmdbuf, savedCmdbuf, 16);
|
||||
}
|
||||
}
|
||||
|
||||
return SendSyncRequest(handle);
|
||||
}
|
||||
|
||||
bool doErrfThrowHook(u32 *cmdbuf)
|
||||
{
|
||||
// If fatalErrorInfo->type is "card removed" or "logged", returning from ERRF:Throw is a no-op
|
||||
// for the SDK function
|
||||
|
||||
// r6 (arm) or r4 (thumb) is copied into cmdbuf[1..31]
|
||||
u32 *r0_to_r7_r12_usr = (u32 *)((u8 *)currentCoreContext->objectContext.currentThread->endOfThreadContext - 0x110);
|
||||
u32 spsr = *(u32 *)((u8 *)currentCoreContext->objectContext.currentThread->endOfThreadContext - 0xCC);
|
||||
u8 *srcerrbuf = (u8 *)r0_to_r7_r12_usr[(spsr & 0x20) ? 4 : 6];
|
||||
const char *pname = codeSetOfProcess(currentCoreContext->objectContext.currentProcess)->processName;
|
||||
|
||||
static const struct
|
||||
{
|
||||
const char *name;
|
||||
Result errCode;
|
||||
} errorCodesToIgnore[] =
|
||||
{
|
||||
/*
|
||||
If you're getting this error, you have broken your head-tracking hardware,
|
||||
and should uncomment the following line:
|
||||
*/
|
||||
//{ "qtm", (Result)0xF96183FE },
|
||||
|
||||
{ "", 0 }, // impossible case to ensure the array has at least 1 element
|
||||
};
|
||||
|
||||
for(u32 i = 0; i < sizeof(errorCodesToIgnore) / sizeof(errorCodesToIgnore[0]); i++)
|
||||
{
|
||||
if(strcmp(pname, errorCodesToIgnore[i].name) == 0 && (Result)cmdbuf[2] == errorCodesToIgnore[i].errCode)
|
||||
{
|
||||
srcerrbuf[0] = 5;
|
||||
cmdbuf[0] = 0x10040;
|
||||
cmdbuf[1] = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
283
k11_extension/source/main.c
Normal file
283
k11_extension/source/main.c
Normal file
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
#include "globals.h"
|
||||
#include "synchronization.h"
|
||||
#include "fatalExceptionHandlers.h"
|
||||
#include "svc.h"
|
||||
#include "svc/ConnectToPort.h"
|
||||
#include "svcHandler.h"
|
||||
#include "memory.h"
|
||||
|
||||
struct KExtParameters
|
||||
{
|
||||
u32 ALIGN(0x400) L2MMUTableFor0x40000000[256];
|
||||
u32 basePA;
|
||||
void *originalHandlers[4];
|
||||
u32 L1MMUTableAddrs[4];
|
||||
|
||||
CfwInfo cfwInfo;
|
||||
} kExtParameters = { .basePA = 0x12345678 }; // place this in .data
|
||||
|
||||
void relocateAndSetupMMU(u32 coreId, u32 *L1Table)
|
||||
{
|
||||
struct KExtParameters *p0 = (struct KExtParameters *)((u32)&kExtParameters - 0x40000000 + 0x18000000);
|
||||
struct KExtParameters *p = (struct KExtParameters *)((u32)&kExtParameters - 0x40000000 + p0->basePA);
|
||||
|
||||
if(coreId == 0)
|
||||
{
|
||||
// Relocate ourselves, and clear BSS
|
||||
memcpy((void *)p0->basePA, (const void *)0x18000000, __bss_start__ - __start__);
|
||||
memset32((u32 *)(p0->basePA + (__bss_start__ - __start__)), 0, __bss_end__ - __bss_start__);
|
||||
|
||||
// Map the kernel ext to 0x40000000
|
||||
// 4KB extended small pages: [SYS:RW USR:-- X TYP:NORMAL SHARED OUTER NOCACHE, INNER CACHED WB WA]
|
||||
for(u32 offset = 0; offset < (u32)(__end__ - __start__); offset += 0x1000)
|
||||
p->L2MMUTableFor0x40000000[offset >> 12] = (p0->basePA + offset) | 0x516;
|
||||
|
||||
__asm__ __volatile__ ("sev");
|
||||
}
|
||||
else
|
||||
__asm__ __volatile__ ("wfe");
|
||||
|
||||
// bit31 idea thanks to SALT
|
||||
// Maps physmem so that, if addr is in physmem(0, 0x30000000), it can be accessed uncached&rwx as addr|(1<<31)
|
||||
u32 attribs = 0x40C02; // supersection (rwx for all) of strongly ordered memory, shared
|
||||
for(u32 PA = 0; PA < 0x30000000; PA += 0x01000000)
|
||||
{
|
||||
u32 VA = (1 << 31) | PA;
|
||||
for(u32 i = 0; i < 16; i++)
|
||||
L1Table[i + (VA >> 20)] = PA | attribs;
|
||||
}
|
||||
|
||||
L1Table[0x40000000 >> 20] = (u32)p->L2MMUTableFor0x40000000 | 1;
|
||||
|
||||
p->L1MMUTableAddrs[coreId] = (u32)L1Table;
|
||||
}
|
||||
|
||||
void bindSGI0Hook(void)
|
||||
{
|
||||
if(InterruptManager__MapInterrupt(interruptManager, customInterruptEvent, 0, getCurrentCoreID(), 0, false, false) != 0)
|
||||
__asm__ __volatile__ ("bkpt 0xdead");
|
||||
}
|
||||
|
||||
void configHook(vu8 *cfgPage)
|
||||
{
|
||||
configPage = cfgPage;
|
||||
|
||||
kernelVersion = *(vu32 *)configPage;
|
||||
*(vu32 *)(configPage + 0x40) = fcramLayout.applicationSize;
|
||||
*(vu32 *)(configPage + 0x44) = fcramLayout.systemSize;
|
||||
*(vu32 *)(configPage + 0x48) = fcramLayout.baseSize;
|
||||
*isDevUnit = true; // enable debug features
|
||||
}
|
||||
|
||||
static void findUsefulSymbols(void)
|
||||
{
|
||||
u32 *off;
|
||||
|
||||
for(off = (u32 *)0xFFFF0000; *off != 0xE1A0D002; off++);
|
||||
off += 3;
|
||||
initFPU = (void (*) (void))off;
|
||||
|
||||
for(; *off != 0xE3A0A0C2; off++);
|
||||
mcuReboot = (void (*) (void))--off;
|
||||
coreBarrier = (void (*) (void))decodeARMBranch(off - 4);
|
||||
|
||||
for(off = (u32 *)originalHandlers[2]; *off != 0xE1A00009; off++);
|
||||
svcFallbackHandler = (void (*)(u8))decodeARMBranch(off + 1);
|
||||
for(; *off != 0xE92D000F; off++);
|
||||
officialPostProcessSvc = (void (*)(void))decodeARMBranch(off + 1);
|
||||
|
||||
KProcessHandleTable__ToKProcess = (KProcess * (*)(KProcessHandleTable *, Handle))decodeARMBranch(5 + (u32 *)officialSVCs[0x76]);
|
||||
|
||||
for(off = (u32 *)KProcessHandleTable__ToKProcess; *off != 0xE1A00004; off++);
|
||||
KAutoObject__AddReference = (void (*)(KAutoObject *))decodeARMBranch(off + 1);
|
||||
|
||||
for(; *off != 0xE320F000; off++);
|
||||
KProcessHandleTable__ToKAutoObject = (KAutoObject * (*)(KProcessHandleTable *, Handle))decodeARMBranch(off + 1);
|
||||
|
||||
for(off = (u32 *)decodeARMBranch(3 + (u32 *)officialSVCs[9]); /* KThread::Terminate */ *off != 0xE5D42034; off++);
|
||||
off -= 2;
|
||||
criticalSectionLock = (KRecursiveLock *)off[2 + (off[0] & 0xFF) / 4];
|
||||
KRecursiveLock__Lock = (void (*)(KRecursiveLock *))decodeARMBranch(off + 1);
|
||||
off += 4;
|
||||
|
||||
for(; (*off >> 16) != 0xE59F; off++);
|
||||
KRecursiveLock__Unlock = (void (*)(KRecursiveLock *))decodeARMBranch(off + 1);
|
||||
|
||||
for(; *off != 0xE5C4007D; off++);
|
||||
KSynchronizationObject__Signal = (void (*)(KSynchronizationObject *, bool))decodeARMBranch(off + 3);
|
||||
|
||||
for(off = (u32 *)officialSVCs[0x19]; *off != 0xE1A04005; off++);
|
||||
KEvent__Clear = (Result (*)(KEvent *))decodeARMBranch(off + 1);
|
||||
for(off = (u32 *)KEvent__Clear; *off != 0xE8BD8070; off++);
|
||||
synchronizationMutex = *(KObjectMutex **)(off + 1);
|
||||
|
||||
for(off = (u32 *)officialSVCs[0x24]; *off != 0xE59F004C; off++);
|
||||
WaitSynchronization1 = (Result (*)(void *, KThread *, KSynchronizationObject *, s64))decodeARMBranch(off + 6);
|
||||
|
||||
for(off = (u32 *)decodeARMBranch(3 + (u32 *)officialSVCs[0x33]) /* OpenProcess */ ; *off != 0xE1A05000; off++);
|
||||
KProcessHandleTable__CreateHandle = (Result (*)(KProcessHandleTable *, Handle *, KAutoObject *, u8))decodeARMBranch(off - 1);
|
||||
|
||||
for(off = (u32 *)decodeARMBranch(3 + (u32 *)officialSVCs[0x34]) /* OpenThread */; *off != 0xD9001BF7; off++);
|
||||
threadList = *(KObjectList **)(off + 1);
|
||||
|
||||
off = (u32 *)decodeARMBranch((u32 *)officialSVCs[0x37] + 3) + 5; /* GetThreadId */
|
||||
KProcessHandleTable__ToKThread = (KThread * (*)(KProcessHandleTable *, Handle))decodeARMBranch((*off >> 16) == 0xEB00 ? off : off + 2);
|
||||
|
||||
for(off = (u32 *)officialSVCs[0x50]; off[0] != 0xE1A05000 || off[1] != 0xE2100102 || off[2] != 0x5A00000B; off++);
|
||||
InterruptManager__MapInterrupt = (Result (*)(InterruptManager *, KBaseInterruptEvent *, u32, u32, u32, bool, bool))decodeARMBranch(--off);
|
||||
interruptManager = *(InterruptManager **)(off - 4 + (off[-6] & 0xFFF) / 4);
|
||||
for(off = (u32 *)officialSVCs[0x54]; *off != 0xE8BD8008; off++);
|
||||
flushDataCacheRange = (void (*)(void *, u32))(*(u32 **)(off[1]) + 3);
|
||||
|
||||
for(off = (u32 *)officialSVCs[0x71]; *off != 0xE2101102; off++);
|
||||
KProcessHwInfo__MapProcessMemory = (Result (*)(KProcessHwInfo *, KProcessHwInfo *, void *, void *, u32))decodeARMBranch(off - 1);
|
||||
|
||||
// From 4.x to 6.x the pattern will match but the result will be wrong
|
||||
for(off = (u32 *)officialSVCs[0x72]; *off != 0xE2041102; off++);
|
||||
KProcessHwInfo__UnmapProcessMemory = (Result (*)(KProcessHwInfo *, void *, u32))decodeARMBranch(off - 1);
|
||||
|
||||
for(off = (u32 *)officialSVCs[0x7C]; *off != 0x03530000; off++);
|
||||
KObjectMutex__WaitAndAcquire = (void (*)(KObjectMutex *))decodeARMBranch(++off);
|
||||
for(; *off != 0xE320F000; off++);
|
||||
KObjectMutex__ErrorOccured = (void (*)(void))decodeARMBranch(off + 1);
|
||||
|
||||
for(off = (u32 *)originalHandlers[4]; *off != (u32)exceptionStackTop; off++);
|
||||
kernelUsrCopyFuncsStart = (void *)off[1];
|
||||
kernelUsrCopyFuncsEnd = (void *)off[2];
|
||||
|
||||
u32 n_cmp_0;
|
||||
for(off = (u32 *)kernelUsrCopyFuncsStart, n_cmp_0 = 1; n_cmp_0 <= 6; off++)
|
||||
{
|
||||
if(*off == 0xE3520000)
|
||||
{
|
||||
// We're missing some funcs
|
||||
switch(n_cmp_0)
|
||||
{
|
||||
case 1:
|
||||
usrToKernelMemcpy8 = (bool (*)(void *, const void *, u32))off;
|
||||
break;
|
||||
case 2:
|
||||
usrToKernelMemcpy32 = (bool (*)(u32 *, const u32 *, u32))off;
|
||||
break;
|
||||
case 3:
|
||||
usrToKernelStrncpy = (s32 (*)(char *, const char *, u32))off;
|
||||
break;
|
||||
case 4:
|
||||
kernelToUsrMemcpy8 = (bool (*)(void *, const void *, u32))off;
|
||||
break;
|
||||
case 5:
|
||||
kernelToUsrMemcpy32 = (bool (*)(u32 *, const u32 *, u32))off;
|
||||
break;
|
||||
case 6:
|
||||
kernelToUsrStrncpy = (s32 (*)(char *, const char *, u32))off;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
n_cmp_0++;
|
||||
}
|
||||
}
|
||||
|
||||
// The official prototype of ControlMemory doesn't have that extra param'
|
||||
ControlMemory = (Result (*)(u32 *, u32, u32, u32, MemOp, MemPerm, bool))
|
||||
decodeARMBranch((u32 *)officialSVCs[0x01] + 5);
|
||||
SleepThread = (void (*)(s64))officialSVCs[0x0A];
|
||||
CloseHandle = (Result (*)(Handle))officialSVCs[0x23];
|
||||
GetHandleInfo = (Result (*)(s64 *, Handle, u32))decodeARMBranch((u32 *)officialSVCs[0x29] + 3);
|
||||
GetSystemInfo = (Result (*)(s64 *, s32, s32))decodeARMBranch((u32 *)officialSVCs[0x2A] + 3);
|
||||
GetProcessInfo = (Result (*)(s64 *, Handle, u32))decodeARMBranch((u32 *)officialSVCs[0x2B] + 3);
|
||||
GetThreadInfo = (Result (*)(s64 *, Handle, u32))decodeARMBranch((u32 *)officialSVCs[0x2C] + 3);
|
||||
ConnectToPort = (Result (*)(Handle *, const char*))decodeARMBranch((u32 *)officialSVCs[0x2D] + 3);
|
||||
SendSyncRequest = (Result (*)(Handle))officialSVCs[0x32];
|
||||
OpenProcess = (Result (*)(Handle *, u32))decodeARMBranch((u32 *)officialSVCs[0x33] + 3);
|
||||
GetProcessId = (Result (*)(u32 *, Handle))decodeARMBranch((u32 *)officialSVCs[0x35] + 3);
|
||||
DebugActiveProcess = (Result (*)(Handle *, u32))decodeARMBranch((u32 *)officialSVCs[0x60] + 3);
|
||||
UnmapProcessMemory = (Result (*)(Handle, void *, u32))officialSVCs[0x72];
|
||||
KernelSetState = (Result (*)(u32, u32, u32, u32))((u32 *)officialSVCs[0x7C] + 1);
|
||||
|
||||
for(off = (u32 *)svcFallbackHandler; *off != 0xE8BD4010; off++);
|
||||
kernelpanic = (void (*)(void))decodeARMBranch(off + 1);
|
||||
|
||||
for(off = (u32 *)0xFFFF0000; off[0] != 0xE3A01002 || off[1] != 0xE3A00004; off++);
|
||||
SignalDebugEvent = (Result (*)(DebugEventType type, u32 info, ...))decodeARMBranch(off + 2);
|
||||
|
||||
for(; *off != 0x96007F9; off++);
|
||||
isDevUnit = *(bool **)(off - 1);
|
||||
|
||||
///////////////////////////////////////////
|
||||
|
||||
// Shitty/lazy heuristic but it works on even 4.5, so...
|
||||
u32 textStart = ((u32)originalHandlers[2]) & ~0xFFFF;
|
||||
u32 rodataStart = (u32)(interruptManager->N3DS.privateInterrupts[1][0x1D].interruptEvent->vtable) & ~0xFFF;
|
||||
u32 textSize = rodataStart - textStart;
|
||||
for(off = (u32 *)textStart; off < (u32 *)(textStart + textSize - 12); off++)
|
||||
{
|
||||
if(off[0] == 0xE5D13034 && off[1] == 0xE1530002)
|
||||
KScheduler__AdjustThread = (void (*)(KScheduler *, KThread *, u32))off;
|
||||
else if(off[0] == (u32)interruptManager && off[1] == (u32)¤tCoreContext->objectContext)
|
||||
KScheduler__AttemptSwitchingThreadContext = (void (*)(KScheduler *))(off - 2);
|
||||
else if(off[0] == 0xE3510B1A && off[1] == 0xE3A06000)
|
||||
{
|
||||
u32 *off2;
|
||||
for(off2 = off; *off2 != 0xE92D40F8; off2--);
|
||||
invalidateInstructionCacheRange = (void (*)(void *, u32))off2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main(FcramLayout *layout, KCoreContext *ctxs)
|
||||
{
|
||||
struct KExtParameters *p = &kExtParameters;
|
||||
u32 TTBCR_;
|
||||
s64 nb;
|
||||
|
||||
layout->systemSize -= __end__ - __start__;
|
||||
fcramLayout = *layout;
|
||||
coreCtxs = ctxs;
|
||||
|
||||
__asm__ __volatile__("mrc p15, 0, %0, c2, c0, 2" : "=r"(TTBCR_));
|
||||
TTBCR = TTBCR_;
|
||||
isN3DS = getNumberOfCores() == 4;
|
||||
memcpy(L1MMUTableAddrs, (const void *)p->L1MMUTableAddrs, 16);
|
||||
exceptionStackTop = (u32 *)0xFFFF2000 + (1 << (32 - TTBCR - 20));
|
||||
cfwInfo = p->cfwInfo;
|
||||
|
||||
memcpy(originalHandlers + 1, p->originalHandlers, 16);
|
||||
void **arm11SvcTable = (void**)originalHandlers[2];
|
||||
while(*arm11SvcTable != NULL) arm11SvcTable++; //Look for SVC0 (NULL)
|
||||
memcpy(officialSVCs, arm11SvcTable, 4 * 0x7E);
|
||||
|
||||
findUsefulSymbols();
|
||||
|
||||
GetSystemInfo(&nb, 26, 0);
|
||||
nbSection0Modules = (u32)nb;
|
||||
|
||||
rosalinaState = 0;
|
||||
hasStartedRosalinaNetworkFuncsOnce = false;
|
||||
}
|
||||
176
k11_extension/source/memory.c
Normal file
176
k11_extension/source/memory.c
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "memory.h"
|
||||
#include "utils.h"
|
||||
|
||||
void *memcpy(void *dest, const void *src, u32 size)
|
||||
{
|
||||
u8 *destc = (u8 *)dest;
|
||||
const u8 *srcc = (const u8 *)src;
|
||||
|
||||
for(u32 i = 0; i < size; i++)
|
||||
destc[i] = srcc[i];
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
int memcmp(const void *buf1, const void *buf2, u32 size)
|
||||
{
|
||||
const u8 *buf1c = (const u8 *)buf1;
|
||||
const u8 *buf2c = (const u8 *)buf2;
|
||||
|
||||
for(u32 i = 0; i < size; i++)
|
||||
{
|
||||
int cmp = buf1c[i] - buf2c[i];
|
||||
if(cmp)
|
||||
return cmp;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *memset(void *dest, u32 value, u32 size)
|
||||
{
|
||||
u8 *destc = (u8 *)dest;
|
||||
|
||||
for(u32 i = 0; i < size; i++) destc[i] = (u8)value;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *memset32(void *dest, u32 value, u32 size)
|
||||
{
|
||||
u32 *dest32 = (u32 *)dest;
|
||||
|
||||
for(u32 i = 0; i < size/4; i++) dest32[i] = value;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
//Boyer-Moore Horspool algorithm, adapted from http://www-igm.univ-mlv.fr/~lecroq/string/node18.html#SECTION00180
|
||||
u8 *memsearch(u8 *startPos, const void *pattern, u32 size, u32 patternSize)
|
||||
{
|
||||
const u8 *patternc = (const u8 *)pattern;
|
||||
u32 table[256];
|
||||
|
||||
//Preprocessing
|
||||
for(u32 i = 0; i < 256; i++)
|
||||
table[i] = patternSize;
|
||||
for(u32 i = 0; i < patternSize - 1; i++)
|
||||
table[patternc[i]] = patternSize - i - 1;
|
||||
|
||||
//Searching
|
||||
u32 j = 0;
|
||||
while(j <= size - patternSize)
|
||||
{
|
||||
u8 c = startPos[j + patternSize - 1];
|
||||
if(patternc[patternSize - 1] == c && memcmp(pattern, startPos + j, patternSize - 1) == 0)
|
||||
return startPos + j;
|
||||
j += table[c];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *strcpy(char *dest, const char *src)
|
||||
{
|
||||
u32 i;
|
||||
for(i = 0; src[i] != 0; i++)
|
||||
dest[i] = src[i];
|
||||
|
||||
dest[i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
char *strncpy(char *dest, const char *src, u32 size)
|
||||
{
|
||||
u32 i;
|
||||
for(i = 0; i < size && src[i] != 0; i++)
|
||||
dest[i] = src[i];
|
||||
|
||||
for(; i < size; i++)
|
||||
dest[i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
s32 strnlen(const char *string, s32 maxlen)
|
||||
{
|
||||
s32 size;
|
||||
for(size = 0; *string && size < maxlen; string++, size++);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
s32 strlen(const char *string)
|
||||
{
|
||||
char *stringEnd = (char *)string;
|
||||
while(*stringEnd) stringEnd++;
|
||||
|
||||
return stringEnd - string;
|
||||
}
|
||||
|
||||
s32 strcmp(const char *str1, const char *str2)
|
||||
{
|
||||
while(*str1 && (*str1 == *str2))
|
||||
{
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
s32 strncmp(const char *str1, const char *str2, u32 size)
|
||||
{
|
||||
while(size && *str1 && (*str1 == *str2))
|
||||
{
|
||||
str1++;
|
||||
str2++;
|
||||
size--;
|
||||
}
|
||||
if (!size)
|
||||
return 0;
|
||||
else
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
void hexItoa(u64 number, char *out, u32 digits, bool uppercase)
|
||||
{
|
||||
const char hexDigits[] = "0123456789ABCDEF";
|
||||
const char hexDigitsLowercase[] = "0123456789abcdef";
|
||||
u32 i = 0;
|
||||
|
||||
while(number > 0)
|
||||
{
|
||||
out[digits - 1 - i++] = uppercase ? hexDigits[number & 0xF] : hexDigitsLowercase[number & 0xF];
|
||||
number >>= 4;
|
||||
}
|
||||
|
||||
while(i < digits) out[digits - 1 - i++] = '0';
|
||||
}
|
||||
72
k11_extension/source/start.s
Normal file
72
k11_extension/source/start.s
Normal file
@@ -0,0 +1,72 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.section .text.start
|
||||
.balign 4
|
||||
.global _start
|
||||
_start:
|
||||
b start
|
||||
b startPhys
|
||||
|
||||
b _bindSGI0Hook
|
||||
b configHook
|
||||
|
||||
b undefinedInstructionHandler
|
||||
b svcHandler
|
||||
b prefetchAbortHandler
|
||||
b dataAbortHandler
|
||||
|
||||
.word __end__
|
||||
.word kExtParameters
|
||||
.word 1 @ enableUserExceptionHandlersForCPUExc
|
||||
|
||||
b KThread__DebugReschedule
|
||||
start:
|
||||
@ Only core0 executes this, the other cores are running coreBarrier
|
||||
|
||||
@ Skipped instruction:
|
||||
str r1, [r4, #0x8]
|
||||
|
||||
push {r0-r12, lr}
|
||||
|
||||
sub r0, r4, #8
|
||||
sub r1, r8, #0x8000
|
||||
bl main
|
||||
|
||||
pop {r0-r12, pc}
|
||||
|
||||
startPhys:
|
||||
push {r0-r12, lr}
|
||||
mrc p15, 0, r0, c0, c0, 5 @ CPUID register
|
||||
and r0, #3
|
||||
mov r1, r2
|
||||
bl relocateAndSetupMMU
|
||||
pop {r0-r12, lr}
|
||||
mov r12, #0x20000000 @ instruction that has been patched
|
||||
bx lr
|
||||
|
||||
_bindSGI0Hook:
|
||||
push {r0-r12, lr}
|
||||
bl bindSGI0Hook
|
||||
pop {r0-r12, pc}
|
||||
171
k11_extension/source/svc.c
Normal file
171
k11_extension/source/svc.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "memory.h"
|
||||
#include "synchronization.h"
|
||||
#include "svc.h"
|
||||
#include "svc/ControlMemory.h"
|
||||
#include "svc/GetHandleInfo.h"
|
||||
#include "svc/GetSystemInfo.h"
|
||||
#include "svc/GetProcessInfo.h"
|
||||
#include "svc/GetThreadInfo.h"
|
||||
#include "svc/GetCFWInfo.h"
|
||||
#include "svc/ConnectToPort.h"
|
||||
#include "svc/SendSyncRequest.h"
|
||||
#include "svc/Break.h"
|
||||
#include "svc/SetGpuProt.h"
|
||||
#include "svc/SetWifiEnabled.h"
|
||||
#include "svc/Backdoor.h"
|
||||
#include "svc/KernelSetState.h"
|
||||
#include "svc/CustomBackdoor.h"
|
||||
#include "svc/MapProcessMemoryEx.h"
|
||||
#include "svc/UnmapProcessMemoryEx.h"
|
||||
#include "svc/ControlService.h"
|
||||
#include "svc/CopyHandle.h"
|
||||
#include "svc/TranslateHandle.h"
|
||||
|
||||
void *officialSVCs[0x7E] = {NULL};
|
||||
|
||||
void signalSvcEntry(u8 *pageEnd)
|
||||
{
|
||||
u32 svcId = (u32) *(u8 *)(pageEnd - 0xB5);
|
||||
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
|
||||
|
||||
if(svcId == 0xFE)
|
||||
svcId = *(u32 *)(pageEnd - 0x110 + 8 * 4); // r12 ; note: max theortical SVC atm: 0x3FFFFFFF. We don't support catching svcIds >= 0x100 atm either
|
||||
|
||||
// Since DBGEVENT_SYSCALL_ENTRY is non blocking, we'll cheat using EXCEVENT_UNDEFINED_SYSCALL (debug->svcId is fortunately an u16!)
|
||||
if(debugOfProcess(currentProcess) != NULL && shouldSignalSyscallDebugEvent(currentProcess, svcId))
|
||||
SignalDebugEvent(DBGEVENT_OUTPUT_STRING, 0xFFFFFFFE, svcId);
|
||||
}
|
||||
|
||||
void signalSvcReturn(u8 *pageEnd)
|
||||
{
|
||||
u32 svcId = (u32) *(u8 *)(pageEnd - 0xB5);
|
||||
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
|
||||
|
||||
if(svcId == 0xFE)
|
||||
svcId = *(u32 *)(pageEnd - 0x110 + 8 * 4); // r12 ; note: max theortical SVC atm: 0x1FFFFFFF. We don't support catching svcIds >= 0x100 atm either
|
||||
|
||||
// Since DBGEVENT_SYSCALL_RETURN is non blocking, we'll cheat using EXCEVENT_UNDEFINED_SYSCALL (debug->svcId is fortunately an u16!)
|
||||
if(debugOfProcess(currentProcess) != NULL && shouldSignalSyscallDebugEvent(currentProcess, svcId))
|
||||
SignalDebugEvent(DBGEVENT_OUTPUT_STRING, 0xFFFFFFFF, svcId);
|
||||
}
|
||||
|
||||
void postprocessSvc(void)
|
||||
{
|
||||
KThread *currentThread = currentCoreContext->objectContext.currentThread;
|
||||
if(!currentThread->shallTerminate && rosalinaThreadLockPredicate(currentThread))
|
||||
rosalinaRescheduleThread(currentThread, true);
|
||||
|
||||
officialPostProcessSvc();
|
||||
}
|
||||
|
||||
static bool doingVeryShittyPmResLimitWorkaround = false; // I feel dirty
|
||||
|
||||
void *svcHook(u8 *pageEnd)
|
||||
{
|
||||
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
|
||||
|
||||
u32 svcId = *(u8 *)(pageEnd - 0xB5);
|
||||
if(svcId == 0xFE)
|
||||
svcId = *(u32 *)(pageEnd - 0x110 + 8 * 4); // r12 ; note: max theortical SVC atm: 0x3FFFFFFF. We don't support catching svcIds >= 0x100 atm either
|
||||
switch(svcId)
|
||||
{
|
||||
case 0x01:
|
||||
return ControlMemoryHookWrapper;
|
||||
case 0x17:
|
||||
if(strcmp(codeSetOfProcess(currentProcess)->processName, "pm") == 0) // only called twice in pm, by the same function
|
||||
{
|
||||
*(vu32 *)(configPage + 0x44) += __end__ - __start__;
|
||||
doingVeryShittyPmResLimitWorkaround = true;
|
||||
}
|
||||
return officialSVCs[0x17];
|
||||
case 0x29:
|
||||
return GetHandleInfoHookWrapper;
|
||||
case 0x2A:
|
||||
return GetSystemInfoHookWrapper;
|
||||
case 0x2B:
|
||||
return GetProcessInfoHookWrapper;
|
||||
case 0x2C:
|
||||
return GetThreadInfoHookWrapper;
|
||||
case 0x2D:
|
||||
return ConnectToPortHookWrapper;
|
||||
case 0x2E:
|
||||
return GetCFWInfo; // DEPRECATED
|
||||
case 0x32:
|
||||
return SendSyncRequestHook;
|
||||
case 0x3C:
|
||||
return (debugOfProcess(currentProcess) != NULL) ? officialSVCs[0x3C] : (void *)Break;
|
||||
case 0x59:
|
||||
return SetGpuProt;
|
||||
case 0x5A:
|
||||
return SetWifiEnabled;
|
||||
case 0x79:
|
||||
if(doingVeryShittyPmResLimitWorkaround)
|
||||
{
|
||||
*(vu32 *)(configPage + 0x44) -= __end__ - __start__;
|
||||
doingVeryShittyPmResLimitWorkaround = false;
|
||||
}
|
||||
return officialSVCs[0x79];
|
||||
case 0x7B:
|
||||
return Backdoor;
|
||||
case 0x7C:
|
||||
return KernelSetStateHook;
|
||||
|
||||
|
||||
case 0x80:
|
||||
return CustomBackdoor;
|
||||
|
||||
case 0x90:
|
||||
return convertVAToPA;
|
||||
case 0x91:
|
||||
return flushDataCacheRange;
|
||||
case 0x92:
|
||||
return flushEntireDataCache;
|
||||
case 0x93:
|
||||
return invalidateInstructionCacheRange;
|
||||
case 0x94:
|
||||
return invalidateEntireInstructionCache;
|
||||
|
||||
case 0xA0:
|
||||
return MapProcessMemoryEx;
|
||||
case 0xA1:
|
||||
return UnmapProcessMemoryEx;
|
||||
case 0xA2:
|
||||
return ControlMemoryEx;
|
||||
|
||||
case 0xB0:
|
||||
return ControlService;
|
||||
case 0xB1:
|
||||
return CopyHandleWrapper;
|
||||
case 0xB2:
|
||||
return TranslateHandleWrapper;
|
||||
|
||||
default:
|
||||
return (svcId <= 0x7D) ? officialSVCs[svcId] : NULL;
|
||||
}
|
||||
}
|
||||
43
k11_extension/source/svc/Backdoor.s
Normal file
43
k11_extension/source/svc/Backdoor.s
Normal file
@@ -0,0 +1,43 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.text
|
||||
.arm
|
||||
.balign 4
|
||||
|
||||
.global Backdoor
|
||||
.type Backdoor, %function
|
||||
Backdoor:
|
||||
@ Nintendo's code
|
||||
bic r1, sp, #0xff
|
||||
orr r1, r1, #0xf00
|
||||
add r1, r1, #0x28 @ get user stack.
|
||||
|
||||
ldr r2, [r1]
|
||||
stmdb r2!, {sp, lr}
|
||||
mov sp, r2 @ sp_svc = sp_usr. You'll get nice crashes if an interrupt or context switch occurs during svcBackdoor
|
||||
blx r0
|
||||
pop {r0, r1}
|
||||
mov sp, r0
|
||||
bx r1
|
||||
35
k11_extension/source/svc/Break.s
Normal file
35
k11_extension/source/svc/Break.s
Normal file
@@ -0,0 +1,35 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.text
|
||||
.arm
|
||||
.balign 4
|
||||
|
||||
.global Break
|
||||
.type Break, %function
|
||||
Break:
|
||||
bic r0, sp, #0xf00
|
||||
bic r0, #0xff
|
||||
add r0, #0x1000 @ get page context top
|
||||
bkpt 0xffff
|
||||
56
k11_extension/source/svc/ConnectToPort.c
Normal file
56
k11_extension/source/svc/ConnectToPort.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/ConnectToPort.h"
|
||||
#include "memory.h"
|
||||
#include "ipc.h"
|
||||
|
||||
Result ConnectToPortHook(Handle *out, const char *name)
|
||||
{
|
||||
char portName[12] = {0};
|
||||
Result res = 0;
|
||||
if(name != NULL)
|
||||
{
|
||||
s32 nb = usrToKernelStrncpy(portName, name, 12);
|
||||
if(nb < 0)
|
||||
return 0xD9001814;
|
||||
else if(nb == 12 && portName[11] != 0)
|
||||
return 0xE0E0181E;
|
||||
}
|
||||
res = ConnectToPort(out, name);
|
||||
if(res != 0)
|
||||
return res;
|
||||
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KClientSession *clientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, *out);
|
||||
if(clientSession != NULL)
|
||||
{
|
||||
SessionInfo_Add(clientSession->parentSession, portName);
|
||||
clientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&clientSession->syncObject.autoObject);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
34
k11_extension/source/svc/ControlMemory.c
Normal file
34
k11_extension/source/svc/ControlMemory.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/ControlMemory.h"
|
||||
|
||||
Result ControlMemoryHook(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm)
|
||||
{
|
||||
KProcess *currentProcess = currentCoreContext->objectContext.currentProcess;
|
||||
return ControlMemory(addrOut, addr0, addr1, size, op, perm, idOfProcess(currentProcess) == 1);
|
||||
}
|
||||
|
||||
100
k11_extension/source/svc/ControlService.c
Normal file
100
k11_extension/source/svc/ControlService.c
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/ControlService.h"
|
||||
#include "memory.h"
|
||||
#include "ipc.h"
|
||||
|
||||
Result ControlService(ServiceOp op, u32 varg1, u32 varg2)
|
||||
{
|
||||
Result res = 0;
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
|
||||
switch(op)
|
||||
{
|
||||
case SERVICEOP_GET_NAME:
|
||||
{
|
||||
KSession *session = NULL;
|
||||
SessionInfo *info = NULL;
|
||||
KAutoObject *obj = KProcessHandleTable__ToKAutoObject(handleTable, (Handle)varg2);
|
||||
if(obj == NULL)
|
||||
return 0xD8E007F7; // invalid handle
|
||||
else
|
||||
{
|
||||
// not the exact same tests but it should work
|
||||
if(strcmp(classNameOfAutoObject(obj), "KServerSession") == 0)
|
||||
session = ((KServerSession *)obj)->parentSession;
|
||||
else if(strcmp(classNameOfAutoObject(obj), "KClientSession") == 0)
|
||||
session = ((KClientSession *)obj)->parentSession;
|
||||
}
|
||||
|
||||
if(session != NULL)
|
||||
info = SessionInfo_Lookup(session);
|
||||
|
||||
if(info == NULL)
|
||||
res = 0xD8E007F7;
|
||||
else
|
||||
{
|
||||
// names are limited to 11 characters (for ports)
|
||||
// kernelToUsrStrncpy doesn't clear trailing bytes
|
||||
char name[12] = { 0 };
|
||||
strncpy(name, info->name, 12);
|
||||
res = kernelToUsrMemcpy8((void *)varg1, name, strlen(name) + 1) ? 0 : 0xE0E01BF5;
|
||||
}
|
||||
|
||||
obj->vtable->DecrementReferenceCount(obj);
|
||||
return res;
|
||||
}
|
||||
|
||||
case SERVICEOP_STEAL_CLIENT_SESSION:
|
||||
{
|
||||
char name[12] = { 0 };
|
||||
SessionInfo *info = NULL;
|
||||
if(name != NULL)
|
||||
{
|
||||
s32 nb = usrToKernelStrncpy(name, (const char *)varg2, 12);
|
||||
if(nb < 0)
|
||||
return 0xD9001814;
|
||||
else if(nb == 12 && name[11] != 0)
|
||||
return 0xE0E0181E;
|
||||
}
|
||||
|
||||
info = SessionInfo_FindFirst(name);
|
||||
|
||||
if(info == NULL)
|
||||
return 0x9401BFE; // timeout (the wanted service is likely not initalized)
|
||||
else
|
||||
{
|
||||
Handle out;
|
||||
res = createHandleForThisProcess(&out, &info->session->clientSession.syncObject.autoObject);
|
||||
return (res != 0) ? res : (kernelToUsrMemcpy32((u32 *)varg1, (u32 *)&out, 4) ? 0 : (Result)0xE0E01BF5);
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return 0xF8C007F4;
|
||||
}
|
||||
}
|
||||
76
k11_extension/source/svc/CopyHandle.c
Normal file
76
k11_extension/source/svc/CopyHandle.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/CopyHandle.h"
|
||||
#include "memory.h"
|
||||
|
||||
Result CopyHandle(Handle *outHandle, Handle outProcessHandle, Handle inHandle, Handle inProcessHandle)
|
||||
{
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KProcess *inProcess, *outProcess;
|
||||
Result res;
|
||||
|
||||
if(inProcessHandle == CUR_PROCESS_HANDLE)
|
||||
{
|
||||
inProcess = currentCoreContext->objectContext.currentProcess;
|
||||
KAutoObject__AddReference((KAutoObject *)inProcess);
|
||||
}
|
||||
else
|
||||
inProcess = KProcessHandleTable__ToKProcess(handleTable, inProcessHandle);
|
||||
|
||||
if(inProcess == NULL)
|
||||
return 0xD8E007F7; // invalid handle
|
||||
|
||||
if(outProcessHandle == CUR_PROCESS_HANDLE)
|
||||
{
|
||||
outProcess = currentCoreContext->objectContext.currentProcess;
|
||||
KAutoObject__AddReference((KAutoObject *)outProcess);
|
||||
}
|
||||
else
|
||||
outProcess = KProcessHandleTable__ToKProcess(handleTable, outProcessHandle);
|
||||
|
||||
if(outProcess == NULL)
|
||||
{
|
||||
((KAutoObject *)inProcess)->vtable->DecrementReferenceCount((KAutoObject *)inProcess);
|
||||
return 0xD8E007F7; // invalid handle
|
||||
}
|
||||
|
||||
KAutoObject *obj = KProcessHandleTable__ToKAutoObject(handleTableOfProcess(inProcess), inHandle);
|
||||
if(obj == NULL)
|
||||
{
|
||||
((KAutoObject *)inProcess)->vtable->DecrementReferenceCount((KAutoObject *)inProcess);
|
||||
((KAutoObject *)outProcess)->vtable->DecrementReferenceCount((KAutoObject *)outProcess);
|
||||
return 0xD8E007F7; // invalid handle
|
||||
}
|
||||
|
||||
res = createHandleForProcess(outHandle, outProcess, obj);
|
||||
|
||||
obj->vtable->DecrementReferenceCount(obj);
|
||||
((KAutoObject *)inProcess)->vtable->DecrementReferenceCount((KAutoObject *)inProcess);
|
||||
((KAutoObject *)outProcess)->vtable->DecrementReferenceCount((KAutoObject *)outProcess);
|
||||
|
||||
return res;
|
||||
}
|
||||
38
k11_extension/source/svc/CustomBackdoor.s
Normal file
38
k11_extension/source/svc/CustomBackdoor.s
Normal file
@@ -0,0 +1,38 @@
|
||||
@ This file is part of Luma3DS
|
||||
@ Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
@
|
||||
@ This program is free software: you can redistribute it and/or modify
|
||||
@ it under the terms of the GNU General Public License as published by
|
||||
@ the Free Software Foundation, either version 3 of the License, or
|
||||
@ (at your option) any later version.
|
||||
@
|
||||
@ This program is distributed in the hope that it will be useful,
|
||||
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
@ GNU General Public License for more details.
|
||||
@
|
||||
@ You should have received a copy of the GNU General Public License
|
||||
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@
|
||||
@ Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
@ * Requiring preservation of specified reasonable legal notices or
|
||||
@ author attributions in that material or in the Appropriate Legal
|
||||
@ Notices displayed by works containing it.
|
||||
@ * Prohibiting misrepresentation of the origin of that material,
|
||||
@ or requiring that modified versions of such material be marked in
|
||||
@ reasonable ways as different from the original version.
|
||||
|
||||
.text
|
||||
.arm
|
||||
.balign 4
|
||||
|
||||
.global CustomBackdoor
|
||||
.type CustomBackdoor, %function
|
||||
CustomBackdoor:
|
||||
push {r4, lr}
|
||||
mov r4, r0
|
||||
mov r0, r1
|
||||
mov r1, r2
|
||||
mov r2, r3
|
||||
blx r4
|
||||
pop {r4, pc}
|
||||
33
k11_extension/source/svc/GetCFWInfo.c
Normal file
33
k11_extension/source/svc/GetCFWInfo.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/GetCFWInfo.h"
|
||||
|
||||
// DEPRECATED
|
||||
Result GetCFWInfo(CfwInfo *out)
|
||||
{
|
||||
return kernelToUsrMemcpy8(out, &cfwInfo, 16) ? 0 : 0xE0E01BF5;
|
||||
}
|
||||
62
k11_extension/source/svc/GetHandleInfo.c
Normal file
62
k11_extension/source/svc/GetHandleInfo.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/GetThreadInfo.h"
|
||||
#include "memory.h"
|
||||
|
||||
Result GetHandleInfoHook(s64 *out, Handle handle, u32 type)
|
||||
{
|
||||
if(type == 0x10000) // KDebug and KProcess: get context ID
|
||||
{
|
||||
KProcessHwInfo *hwInfo;
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KAutoObject *obj;
|
||||
if(handle == CUR_PROCESS_HANDLE)
|
||||
{
|
||||
obj = (KAutoObject *)(currentCoreContext->objectContext.currentProcess);
|
||||
KAutoObject__AddReference(obj);
|
||||
}
|
||||
else
|
||||
obj = KProcessHandleTable__ToKAutoObject(handleTable, handle);
|
||||
|
||||
if(obj == NULL)
|
||||
return 0xD8E007F7;
|
||||
|
||||
if(strcmp(classNameOfAutoObject(obj), "KDebug") == 0)
|
||||
hwInfo = hwInfoOfProcess(((KDebug *)obj)->owner);
|
||||
else if(strcmp(classNameOfAutoObject(obj), "KProcess") == 0)
|
||||
hwInfo = hwInfoOfProcess((KProcess *)obj);
|
||||
else
|
||||
hwInfo = NULL;
|
||||
|
||||
*out = hwInfo != NULL ? KPROCESSHWINFO_GET_RVALUE(hwInfo, contextId) : -1;
|
||||
|
||||
obj->vtable->DecrementReferenceCount(obj);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return GetHandleInfo(out, handle, type);
|
||||
}
|
||||
94
k11_extension/source/svc/GetProcessInfo.c
Normal file
94
k11_extension/source/svc/GetProcessInfo.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/GetProcessInfo.h"
|
||||
#include "memory.h"
|
||||
|
||||
Result GetProcessInfoHook(s64 *out, Handle processHandle, u32 type)
|
||||
{
|
||||
Result res = 0;
|
||||
|
||||
if(type >= 0x10000)
|
||||
{
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KProcess *process;
|
||||
if(processHandle == CUR_PROCESS_HANDLE)
|
||||
{
|
||||
process = currentCoreContext->objectContext.currentProcess;
|
||||
KAutoObject__AddReference((KAutoObject *)process);
|
||||
}
|
||||
else
|
||||
process = KProcessHandleTable__ToKProcess(handleTable, processHandle);
|
||||
|
||||
if(process == NULL)
|
||||
return 0xD8E007F7; // invalid handle
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0x10000:
|
||||
memcpy(out, codeSetOfProcess(process)->processName, 8);
|
||||
break;
|
||||
case 0x10001:
|
||||
*(u64 *)out = codeSetOfProcess(process)->titleId;
|
||||
break;
|
||||
case 0x10002:
|
||||
*out = codeSetOfProcess(process)->nbTextPages << 12;
|
||||
break;
|
||||
case 0x10003:
|
||||
*out = codeSetOfProcess(process)->nbRodataPages << 12;
|
||||
break;
|
||||
case 0x10004:
|
||||
*out = codeSetOfProcess(process)->nbRwPages << 12;
|
||||
break;
|
||||
case 0x10005:
|
||||
*out = (s64)(u64)(u32)codeSetOfProcess(process)->textSection.section.loadAddress;
|
||||
break;
|
||||
case 0x10006:
|
||||
*out = (s64)(u64)(u32)codeSetOfProcess(process)->rodataSection.section.loadAddress;
|
||||
break;
|
||||
case 0x10007:
|
||||
*out = (s64)(u64)(u32)codeSetOfProcess(process)->dataSection.section.loadAddress;
|
||||
break;
|
||||
case 0x10008:
|
||||
{
|
||||
KProcessHwInfo *hwInfo = hwInfoOfProcess(process);
|
||||
u32 ttb = KPROCESSHWINFO_GET_RVALUE(hwInfo, translationTableBase);
|
||||
*out = ttb & ~((1 << (14 - TTBCR)) - 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = 0xD8E007ED; // invalid enum value
|
||||
break;
|
||||
}
|
||||
|
||||
((KAutoObject *)process)->vtable->DecrementReferenceCount((KAutoObject *)process);
|
||||
}
|
||||
|
||||
else
|
||||
res = GetProcessInfo(out, processHandle, type);
|
||||
|
||||
return res;
|
||||
}
|
||||
140
k11_extension/source/svc/GetSystemInfo.c
Normal file
140
k11_extension/source/svc/GetSystemInfo.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/GetSystemInfo.h"
|
||||
#include "utils.h"
|
||||
#include "ipc.h"
|
||||
#include "synchronization.h"
|
||||
|
||||
Result GetSystemInfoHook(s64 *out, s32 type, s32 param)
|
||||
{
|
||||
Result res = 0;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0x10000:
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case 0:
|
||||
*out = SYSTEM_VERSION(cfwInfo.versionMajor, cfwInfo.versionMinor, cfwInfo.versionBuild);
|
||||
break;
|
||||
case 1:
|
||||
*out = cfwInfo.commitHash;
|
||||
break;
|
||||
case 2:
|
||||
*out = (cfwInfo.configFormatVersionMajor << 16) | cfwInfo.configFormatVersionMinor;
|
||||
break;
|
||||
case 3:
|
||||
*out = cfwInfo.config;
|
||||
break;
|
||||
case 4:
|
||||
*out = cfwInfo.multiConfig;
|
||||
break;
|
||||
case 5:
|
||||
*out = cfwInfo.bootConfig;
|
||||
break;
|
||||
|
||||
case 0x100:
|
||||
*out = (s64)cfwInfo.hbldr3dsxTitleId;
|
||||
break;
|
||||
case 0x101:
|
||||
*out = cfwInfo.rosalinaMenuCombo;
|
||||
break;
|
||||
|
||||
case 0x200: // isRelease
|
||||
*out = cfwInfo.flags & 1;
|
||||
break;
|
||||
case 0x201: // isN3DS
|
||||
*out = (cfwInfo.flags >> 4) & 1;
|
||||
break;
|
||||
case 0x202: // isSafeMode
|
||||
*out = (cfwInfo.flags >> 5) & 1;
|
||||
break;
|
||||
case 0x203: // isSdMode
|
||||
*out = (cfwInfo.flags >> 6) & 1;
|
||||
break;
|
||||
default:
|
||||
res = 0xF8C007F4; // not implemented
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x10001: // N3DS-related info
|
||||
{
|
||||
if(isN3DS)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case 0: // current clock rate
|
||||
*out = (((CFG11_MPCORE_CLKCNT >> 1) & 3) + 1) * 268;
|
||||
break;
|
||||
case 1: // higher clock rate
|
||||
*out = (((CFG11_MPCORE_CFG >> 2) & 1) + 2) * 268;
|
||||
break;
|
||||
case 2: // L2C enabled status
|
||||
*out = L2C_CTRL & 1;
|
||||
break;
|
||||
default:
|
||||
res = 0xF8C007F4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
res = 0xF8C007F4;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x10002: // MMU config (cached values from booting)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case 0:
|
||||
*out = TTBCR;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if((u32)param <= getNumberOfCores())
|
||||
*out = L1MMUTableAddrs[param - 1];
|
||||
else
|
||||
res = 0xF8C007F4;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
GetSystemInfo(out, type, param);
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
60
k11_extension/source/svc/GetThreadInfo.c
Normal file
60
k11_extension/source/svc/GetThreadInfo.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/GetThreadInfo.h"
|
||||
#include "memory.h"
|
||||
|
||||
Result GetThreadInfoHook(s64 *out, Handle threadHandle, u32 type)
|
||||
{
|
||||
Result res = 0;
|
||||
|
||||
if(type == 0x10000) // Get TLS
|
||||
{
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KThread *thread;
|
||||
|
||||
if(threadHandle == CUR_THREAD_HANDLE)
|
||||
{
|
||||
thread = currentCoreContext->objectContext.currentThread;
|
||||
KAutoObject__AddReference(&thread->syncObject.autoObject);
|
||||
}
|
||||
else
|
||||
thread = KProcessHandleTable__ToKThread(handleTable, threadHandle);
|
||||
|
||||
if(thread == NULL)
|
||||
return 0xD8E007F7; // invalid handle
|
||||
|
||||
*out = (s64)(u64)(u32)thread->threadLocalStorage;
|
||||
|
||||
KAutoObject *obj = (KAutoObject *)thread;
|
||||
obj->vtable->DecrementReferenceCount(obj);
|
||||
}
|
||||
|
||||
else
|
||||
res = GetThreadInfo(out, threadHandle, type);
|
||||
|
||||
return res;
|
||||
}
|
||||
189
k11_extension/source/svc/KernelSetState.c
Normal file
189
k11_extension/source/svc/KernelSetState.c
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/KernelSetState.h"
|
||||
#include "synchronization.h"
|
||||
#include "ipc.h"
|
||||
#include "debug.h"
|
||||
#include "memory.h"
|
||||
|
||||
#define MAX_DEBUG 3
|
||||
|
||||
static u32 nbEnabled = 0;
|
||||
static u32 maskedPids[MAX_DEBUG];
|
||||
static u32 masks[MAX_DEBUG][8] = {0};
|
||||
|
||||
bool shouldSignalSyscallDebugEvent(KProcess *process, u8 svcId)
|
||||
{
|
||||
u32 pid = idOfProcess(process);
|
||||
u32 id;
|
||||
for(id = 0; id < nbEnabled && maskedPids[id] != pid; id++);
|
||||
if(id == MAX_DEBUG)
|
||||
return false;
|
||||
else
|
||||
return ((masks[id][svcId / 32] >> (31 - (svcId % 32))) & 1) != 0;
|
||||
}
|
||||
|
||||
Result SetSyscallDebugEventMask(u32 pid, bool enable, const u32 *mask)
|
||||
{
|
||||
static KRecursiveLock syscallDebugEventMaskLock = { NULL };
|
||||
|
||||
u32 tmpMask[8];
|
||||
if(enable && nbEnabled == MAX_DEBUG)
|
||||
return 0xC86018FF; // Out of resource (255)
|
||||
|
||||
if(enable && !usrToKernelMemcpy8(&tmpMask, mask, 32))
|
||||
return 0xE0E01BF5;
|
||||
|
||||
KRecursiveLock__Lock(criticalSectionLock);
|
||||
KRecursiveLock__Lock(&syscallDebugEventMaskLock);
|
||||
|
||||
if(enable)
|
||||
{
|
||||
maskedPids[nbEnabled] = pid;
|
||||
memcpy(&masks[nbEnabled++], tmpMask, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 id;
|
||||
for(id = 0; id < nbEnabled && maskedPids[id] != pid; id++);
|
||||
if(id == nbEnabled)
|
||||
{
|
||||
KRecursiveLock__Unlock(&syscallDebugEventMaskLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return 0xE0E01BFD; // out of range (it's not fully technically correct but meh)
|
||||
}
|
||||
|
||||
for(u32 i = id; i < nbEnabled - 1; i++)
|
||||
{
|
||||
maskedPids[i] = maskedPids[i + 1];
|
||||
memcpy(&masks[i], &masks[i + 1], 32);
|
||||
}
|
||||
maskedPids[--nbEnabled] = 0;
|
||||
memset(&masks[nbEnabled], 0, 32);
|
||||
}
|
||||
|
||||
KRecursiveLock__Unlock(&syscallDebugEventMaskLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result KernelSetStateHook(u32 type, u32 varg1, u32 varg2, u32 varg3)
|
||||
{
|
||||
Result res = 0;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0x10000:
|
||||
{
|
||||
do
|
||||
{
|
||||
__ldrex((s32 *)&rosalinaState);
|
||||
}
|
||||
while(__strex((s32 *)&rosalinaState, (s32)(rosalinaState ^ varg1)));
|
||||
|
||||
if(rosalinaState & 2)
|
||||
hasStartedRosalinaNetworkFuncsOnce = true;
|
||||
|
||||
if(rosalinaState & 1)
|
||||
rosalinaLockAllThreads();
|
||||
else if(varg1 & 1)
|
||||
rosalinaUnlockAllThreads();
|
||||
|
||||
break;
|
||||
}
|
||||
case 0x10001:
|
||||
{
|
||||
KRecursiveLock__Lock(criticalSectionLock);
|
||||
KRecursiveLock__Lock(&processLangemuLock);
|
||||
|
||||
u32 i;
|
||||
for(i = 0; i < 0x40 && processLangemuAttributes[i].titleId != 0ULL; i++);
|
||||
if(i < 0x40)
|
||||
{
|
||||
processLangemuAttributes[i].titleId = ((u64)varg3 << 32) | (u32)varg2;
|
||||
processLangemuAttributes[i].state = (u8)(varg1 >> 24);
|
||||
processLangemuAttributes[i].country = (u8)(varg1 >> 16);
|
||||
processLangemuAttributes[i].language = (u8)(varg1 >> 8);
|
||||
processLangemuAttributes[i].region = (u8)((varg1 >> 4) & 0xf);
|
||||
processLangemuAttributes[i].mask = (u8)(varg1 & 0xf);
|
||||
}
|
||||
else
|
||||
res = 0xD8609013;
|
||||
|
||||
KRecursiveLock__Unlock(&processLangemuLock);
|
||||
KRecursiveLock__Unlock(criticalSectionLock);
|
||||
break;
|
||||
}
|
||||
case 0x10002:
|
||||
{
|
||||
res = SetSyscallDebugEventMask(varg1, (bool)varg2, (const u32 *)varg3);
|
||||
break;
|
||||
}
|
||||
case 0x10003:
|
||||
{
|
||||
executeFunctionOnCores(enableMonitorModeDebugging, 0xF, 0);
|
||||
break;
|
||||
}
|
||||
case 0x10004:
|
||||
{
|
||||
KRecursiveLock__Lock(&dbgParamsLock);
|
||||
dbgParamWatchpointId = varg1;
|
||||
executeFunctionOnCores(disableWatchpoint, 0xF, 0);
|
||||
KRecursiveLock__Unlock(&dbgParamsLock);
|
||||
break;
|
||||
}
|
||||
case 0x10005:
|
||||
{
|
||||
KRecursiveLock__Lock(&dbgParamsLock);
|
||||
dbgParamWatchpointId = 0;
|
||||
dbgParamDVA = varg1;
|
||||
dbgParamWCR = varg2;
|
||||
dbgParamContextId = varg3;
|
||||
executeFunctionOnCores(setWatchpointWithContextId, 0xF, 0);
|
||||
KRecursiveLock__Unlock(&dbgParamsLock);
|
||||
break;
|
||||
}
|
||||
case 0x10006:
|
||||
{
|
||||
KRecursiveLock__Lock(&dbgParamsLock);
|
||||
dbgParamWatchpointId = 1;
|
||||
dbgParamDVA = varg1;
|
||||
dbgParamWCR = varg2;
|
||||
dbgParamContextId = varg3;
|
||||
executeFunctionOnCores(setWatchpointWithContextId, 0xF, 0);
|
||||
KRecursiveLock__Unlock(&dbgParamsLock);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
res = KernelSetState(type, varg1, varg2, varg3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
44
k11_extension/source/svc/MapProcessMemoryEx.c
Normal file
44
k11_extension/source/svc/MapProcessMemoryEx.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/MapProcessMemoryEx.h"
|
||||
|
||||
Result MapProcessMemoryEx(Handle processHandle, void *dst, void *src, u32 size)
|
||||
{
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KProcessHwInfo *currentHwInfo = hwInfoOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KProcess *process = KProcessHandleTable__ToKProcess(handleTable, processHandle);
|
||||
|
||||
if(process == NULL)
|
||||
return 0xD8E007F7;
|
||||
|
||||
Result res = KProcessHwInfo__MapProcessMemory(currentHwInfo, hwInfoOfProcess(process), dst, src, size >> 12);
|
||||
|
||||
KAutoObject *obj = (KAutoObject *)process;
|
||||
obj->vtable->DecrementReferenceCount(obj);
|
||||
|
||||
return res;
|
||||
}
|
||||
231
k11_extension/source/svc/SendSyncRequest.c
Normal file
231
k11_extension/source/svc/SendSyncRequest.c
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* This file is part of Luma3DS
|
||||
* Copyright (C) 2016-2018 Aurora Wright, TuxSH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
||||
* * Requiring preservation of specified reasonable legal notices or
|
||||
* author attributions in that material or in the Appropriate Legal
|
||||
* Notices displayed by works containing it.
|
||||
* * Prohibiting misrepresentation of the origin of that material,
|
||||
* or requiring that modified versions of such material be marked in
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#include "svc/SendSyncRequest.h"
|
||||
#include "memory.h"
|
||||
#include "ipc.h"
|
||||
|
||||
Result SendSyncRequestHook(Handle handle)
|
||||
{
|
||||
KProcessHandleTable *handleTable = handleTableOfProcess(currentCoreContext->objectContext.currentProcess);
|
||||
KClientSession *clientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, handle);
|
||||
|
||||
u32 *cmdbuf = (u32 *)((u8 *)currentCoreContext->objectContext.currentThread->threadLocalStorage + 0x80);
|
||||
bool skip = false;
|
||||
Result res = 0;
|
||||
|
||||
// not the exact same test but it should work
|
||||
bool isValidClientSession = clientSession != NULL && strcmp(classNameOfAutoObject(&clientSession->syncObject.autoObject), "KClientSession") == 0;
|
||||
|
||||
if(isValidClientSession)
|
||||
{
|
||||
switch (cmdbuf[0])
|
||||
{
|
||||
case 0x10042:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && kernelVersion >= SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0)
|
||||
{
|
||||
res = doPublishToProcessHook(handle, cmdbuf);
|
||||
skip = true;
|
||||
}
|
||||
else if(info != NULL && strcmp(info->name, "ndm:u") == 0 && hasStartedRosalinaNetworkFuncsOnce)
|
||||
{
|
||||
cmdbuf[0] = 0x10040;
|
||||
cmdbuf[1] = 0;
|
||||
skip = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x10082:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && (strcmp(info->name, "cfg:u") == 0 || strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk2
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x10800:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && strcmp(info->name, "err:f") == 0) // Throw
|
||||
skip = doErrfThrowHook(cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x20000:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && (strcmp(info->name, "cfg:u") == 0 || strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // SecureInfoGetRegion
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x20002:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && strcmp(info->name, "ndm:u") == 0 && hasStartedRosalinaNetworkFuncsOnce)
|
||||
{
|
||||
cmdbuf[0] = 0x20040;
|
||||
cmdbuf[1] = 0;
|
||||
skip = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x50100:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && (strcmp(info->name, "srv:") == 0 || (kernelVersion < SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0)))
|
||||
{
|
||||
char name[9] = { 0 };
|
||||
memcpy(name, cmdbuf + 1, 8);
|
||||
|
||||
skip = true;
|
||||
res = SendSyncRequest(handle);
|
||||
if(res == 0)
|
||||
{
|
||||
KClientSession *outClientSession;
|
||||
|
||||
outClientSession = (KClientSession *)KProcessHandleTable__ToKAutoObject(handleTable, (Handle)cmdbuf[3]);
|
||||
if(outClientSession != NULL)
|
||||
{
|
||||
if(strcmp(classNameOfAutoObject(&outClientSession->syncObject.autoObject), "KClientSession") == 0)
|
||||
SessionInfo_Add(outClientSession->parentSession, name);
|
||||
outClientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&outClientSession->syncObject.autoObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x80040:
|
||||
{
|
||||
if(!hasStartedRosalinaNetworkFuncsOnce)
|
||||
break;
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
skip = info != NULL && strcmp(info->name, "ndm:u") == 0; // SuspendScheduler
|
||||
if(skip)
|
||||
cmdbuf[1] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x90000:
|
||||
{
|
||||
if(!hasStartedRosalinaNetworkFuncsOnce)
|
||||
break;
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && strcmp(info->name, "ndm:u") == 0) // ResumeScheduler
|
||||
{
|
||||
cmdbuf[0] = 0x90040;
|
||||
cmdbuf[1] = 0;
|
||||
skip = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x4010042:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && kernelVersion < SYSTEM_VERSION(2, 39, 4) && strcmp(info->name, "srv:pm") == 0)
|
||||
{
|
||||
res = doPublishToProcessHook(handle, cmdbuf);
|
||||
skip = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x4010082:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk4
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x4020082:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk8
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x8010082:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0)) // GetConfigInfoBlk4
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x8020082:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession);
|
||||
if(info != NULL && strcmp(info->name, "cfg:i") == 0) // GetConfigInfoBlk8
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x4060000:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession); // SecureInfoGetRegion
|
||||
if(info != NULL && (strcmp(info->name, "cfg:s") == 0 || strcmp(info->name, "cfg:i") == 0))
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x8160000:
|
||||
{
|
||||
SessionInfo *info = SessionInfo_Lookup(clientSession->parentSession); // SecureInfoGetRegion
|
||||
if(info != NULL && strcmp(info->name, "cfg:i") == 0)
|
||||
skip = doLangEmu(&res, cmdbuf);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(clientSession != NULL)
|
||||
clientSession->syncObject.autoObject.vtable->DecrementReferenceCount(&clientSession->syncObject.autoObject);
|
||||
|
||||
res = skip ? res : SendSyncRequest(handle);
|
||||
|
||||
return res;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user