This also fixes#958
Original commits:
* initial work on cart save crypto/wearleveling
* add support for n3ds only save crypto
* use existing crc16 impl for save blockmap
* fix missing aeskey select for card2 save decrypt
* fix old/new cart media being swapped
* fix 1 MiB save chips / blockmap type 2
* move cart save wearleveling/crypto to separate file
* try 2nd wearlevel header on fail + minor fixes
* save_ctr: zero out savectx before reading fallback header
* Correct installable address whitelist
blacklist is stored at 0xb088~0xb0bf, which is ulong[14] in
{start(inclusive), end(exclusive)} pair.
one thing to note is that boot9 use inclusive comparing with
blacklist start for both section load address and
section load address + section size (comparing logic is
at 0xa42e~0xa449), so if the firm fits perfectly at the end
of the space right before the blacklisted range,
it'll also be rejected.
* shrink vram drive size to avoid bleeding into blacklisted range
This commit looks a lot bigger than it really is, I noticed a couple spots where with these issues so I ran a regex to find all possible occurrences and switched all that could be, after manually ensuring it was actually correct
Using sizeof on the buffer (as long as the buffer is a char *array*, not a pointer!!) greatly reduces the chance of something having the wrong size because of a later change to the buffer, notably a couple snprintfs were missed in the UTF_BUFFER_BYTESIZE change
* Fixed inability to install a larger ticket when a smaller one is installed
* improved AddBDRIEntry checks, formatting and added define for REPLACE_SIZE_MISMATCH
Fixes#703 and is only active with `make LARGEDLC=1` and will break compatibility with other titles and CIAs. Thanks @luigoalma for new ticket builder code!
Since in all cases that LoadCertFromCertDb is called
is always twice, one for sysnand and another for emunand
just make it a single call and quit early when cert found.
At least in the caller perspective.
Also break down some functionalities into separate funcs,
interally calling them on cert.c to avoid too many checks.
And tried to avoid too much repeated code.
- properly performs gpu/backlight reset
- nukes vram so the initrd had to be moved to arm9 memory, and have its size (at least temporarily) limited to 256k