"""Enumerate the SVC numbers each TA actually issues (function-accurate disassembly), then map them to the sOS handler side. TA-reachable SVCs are the host->TA->kernel privilege boundary.""" import struct, json, sys from capstone import * BASE = '/Users/user/dev/amd-psp-re/psp_out/handover/' def load(mod): raw = open(BASE + 'elf/%s2.elf' % mod, 'rb').read() ph = struct.unpack(' 0x4000: end = ea + 0x40 off = ea - vaddr if off < 0 or off >= len(body): continue for i in md.disasm(body[off:off + (end - ea)], ea): if i.mnemonic.startswith('svc'): try: n = int(i.op_str.replace('#', ''), 0) except Exception: continue out.setdefault(n, []).append(f['name']) return out if __name__ == '__main__': allsvc = {} for mod in ('hdcp', 'asd', 'dtm', 'ras'): s = svcs_of(mod) print("%-5s : %s" % (mod, sorted(hex(k) for k in s))) for k, v in s.items(): allsvc.setdefault(k, set()).update([mod]) print("\n=== union of TA-reachable SVC numbers ===") for k in sorted(allsvc): print(" %#04x used by %s" % (k, sorted(allsvc[k])))