import serial, os, struct, sys, time from proxy import * from tgtypes import * import malloc CurrentEL = 3,0,4,2,2 DAIF = 3,3,4,2,1 DAIFSet = 0,3,4,2,6 DAIFClr = 0,3,4,2,7 TPIDR_EL0 = 3,3,13,0,2 CNTFRQ_EL0 = 3,3,14,0,0 CNTPCT_EL0 = 3,3,14,0,1 CNTP_TVAL_EL0 = 3,3,14,2,0 CNTP_CTL_EL0 = 3,3,14,2,1 CNTP_CVAL_EL0 = 3,3,14,2,2 SCTLR_EL1 = 3,0,1,0,0 TTBR0_EL1 = 3,0,2,0,0 TTBR0_EL2 = 3,4,2,0,0 TCR_EL1 = 3,0,2,0,2 TCR_EL2 = 3,4,2,0,2 HCR_EL2 = 3,4,1,1,0 MIDR_EL1 = 3,0,0,0,0 MPIDR_EL1 = 3,0,0,0,5 AA64MMFR0_EL1 = 3,0,0,7,0 OSLAR_EL1 = 2,0,1,0,4 ACTLR_EL1 = 3,0,1,0,1 class ProxyUtils(object): def __init__(self, p): self.iface = p.iface self.proxy = p self.base = p.get_base() self.ba_addr = p.get_bootargs() self.ba = self.iface.readstruct(self.ba_addr, BootArgs) self._scratch = self.base + ((self.ba.top_of_kernel_data + 0xffff) & ~0xffff) - self.ba.phys_base self.heap = malloc.Heap(self._scratch, self._scratch + 0x1000000) self.malloc = self.heap.malloc self.free = self.heap.free self.code_buffer = self.malloc(0x10000) def mrs(self, reg): op0, op1, CRn, CRm, op2 = reg op = (((op0 & 1) << 19) | (op1 << 16) | (CRn << 12) | (CRm << 8) | (op2 << 5) | 0xd5300000) func = struct.pack("