mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-17 23:12:17 +00:00
f66b41c027
exo2: Implement uncompressor stub and boot code up to Main(). exo2: implement some more init (uart/gic) exo2: implement more of init exo2: improve reg api, add keyslot flag setters exo2: implement se aes decryption/enc exo2: fix bugs in loader stub/mmu mappings exo2: start skeletoning bootconfig/global context types arch: fix makefile flags exo2: implement through master key derivation exo2: implement device master keygen exo2: more init through start of SetupSocSecurity exo2: implement pmc secure scratch management se: implement sticky bit validation libexosphere: fix building for arm32 libexo: fix makefile flags libexo: support building for arm64/arm sc7fw: skeleton binary sc7fw: skeleton a little more sc7fw: implement all non-dram functionality exo2: fix DivideUp error sc7fw: implement more dram code, fix reg library errors sc7fw: complete sc7fw impl. exo2: skeleton the rest of SetupSocSecurity exo2: implement fiq interrupt handler exo2: implement all exception handlers exo2: skeleton the entire smc api, implement the svc invoker exo2: implement rest of SetupSocSecurity exo2: correct slave security errors exo2: fix register definition exo2: minor fixes
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
import sys, lz4
|
|
from struct import unpack as up
|
|
|
|
def lz4_compress(data):
|
|
return lz4.block.compress(data, 'high_compression', store_size=False)
|
|
|
|
def split_binary(data):
|
|
A, B, START, BOOT_CODE_START, BOOT_CODE_END, PROGRAM_START, C, D = up('<QQQQQQQQ', data[:0x40])
|
|
assert A == 0xAAAAAAAAAAAAAAAA
|
|
assert B == 0xBBBBBBBBBBBBBBBB
|
|
assert C == 0xCCCCCCCCCCCCCCCC
|
|
assert D == 0xDDDDDDDDDDDDDDDD
|
|
data = data[0x40:]
|
|
|
|
boot_code = data[BOOT_CODE_START - START:BOOT_CODE_END - BOOT_CODE_START]
|
|
program = data[PROGRAM_START - START:]
|
|
return [('boot_code.lz4', lz4_compress(boot_code)), ('program.lz4', lz4_compress(program))]
|
|
|
|
def main(argc, argv):
|
|
if argc != 3:
|
|
print 'Usage: %s in outdir' % argv[0]
|
|
return 1
|
|
with open(argv[1], 'rb') as f:
|
|
data = f.read()
|
|
assert len(data) >= 0x40
|
|
for (fn, fdata) in split_binary(data):
|
|
with open('%s/%s' % (argv[2], fn), 'wb') as f:
|
|
f.write(fdata)
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(len(sys.argv), sys.argv)) |