mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-25 08:00:17 +00:00
utils.py: add silent and call arguments to msr/mrs
call allows the caller to override the function used for the function call, e.g. to use EL0. Use silent=True for find_all_regs.py Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
3872b1a7da
commit
d918b066b6
2 changed files with 16 additions and 10 deletions
|
@ -46,9 +46,9 @@ for op1 in range(1 << 3):
|
|||
print("s3_%d_c%d_c%d_%d (3, %d, %d, %d, %d) = 0x%x" % (
|
||||
op1, CRn, CRm, op2, op1, CRn, CRm, op2, v))
|
||||
try:
|
||||
u.msr((3, op1, CRn, CRm, op2), v)
|
||||
u.msr((3, op1, CRn, CRm, op2), v, silent=True)
|
||||
except:
|
||||
pass
|
||||
print(" - READONLY")
|
||||
else:
|
||||
print(" - writable")
|
||||
i += 1
|
||||
|
|
|
@ -41,7 +41,9 @@ class ProxyUtils(object):
|
|||
|
||||
self.code_buffer = self.malloc(0x10000)
|
||||
|
||||
def mrs(self, reg):
|
||||
def mrs(self, reg, silent=False, call=None):
|
||||
if call is None:
|
||||
call = self.proxy.call
|
||||
op0, op1, CRn, CRm, op2 = reg
|
||||
|
||||
op = (((op0 & 1) << 19) | (op1 << 16) | (CRn << 12) |
|
||||
|
@ -53,15 +55,17 @@ class ProxyUtils(object):
|
|||
self.proxy.dc_cvau(self.code_buffer, 8)
|
||||
self.proxy.ic_ivau(self.code_buffer, 8)
|
||||
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_MARK)
|
||||
retval = self.proxy.call(self.code_buffer)
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_MARK | (self.proxy.GUARD_SILENT if silent else 0))
|
||||
retval = call(self.code_buffer)
|
||||
cnt = self.proxy.get_exc_count()
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_OFF)
|
||||
if cnt:
|
||||
raise ProxyError("Exception occurred")
|
||||
return retval
|
||||
|
||||
def msr(self, reg, val):
|
||||
def msr(self, reg, val, silent=False, el0=False, call=None):
|
||||
if call is None:
|
||||
call = self.proxy.call
|
||||
op0, op1, CRn, CRm, op2 = reg
|
||||
|
||||
op = (((op0 & 1) << 19) | (op1 << 16) | (CRn << 12) |
|
||||
|
@ -73,14 +77,16 @@ class ProxyUtils(object):
|
|||
self.proxy.dc_cvau(self.code_buffer, 8)
|
||||
self.proxy.ic_ivau(self.code_buffer, 8)
|
||||
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_SKIP)
|
||||
self.proxy.call(self.code_buffer, val)
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_SKIP | (self.proxy.GUARD_SILENT if silent else 0))
|
||||
call(self.code_buffer, val)
|
||||
cnt = self.proxy.get_exc_count()
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_OFF)
|
||||
if cnt:
|
||||
raise ProxyError("Exception occurred")
|
||||
|
||||
def inst(self, op, r0=0, r1=0, r2=0, r3=0, silent=False):
|
||||
def inst(self, op, r0=0, r1=0, r2=0, r3=0, silent=False, el0=False):
|
||||
if call is None:
|
||||
call = self.proxy.call
|
||||
func = struct.pack("<II", op, 0xd65f03c0)
|
||||
|
||||
self.iface.writemem(self.code_buffer, func)
|
||||
|
@ -88,7 +94,7 @@ class ProxyUtils(object):
|
|||
self.proxy.ic_ivau(self.code_buffer, 8)
|
||||
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_SKIP | (self.proxy.GUARD_SILENT if silent else 0))
|
||||
ret = self.proxy.call(self.code_buffer, r0, r1, r2, r3)
|
||||
ret = call(self.code_buffer, r0, r1, r2, r3)
|
||||
cnt = self.proxy.get_exc_count()
|
||||
self.proxy.set_exc_guard(self.proxy.GUARD_OFF)
|
||||
if cnt:
|
||||
|
|
Loading…
Reference in a new issue