MCPcopy
hub / github.com/AsahiLinux/m1n1 / exec

Method exec

proxyclient/m1n1/proxyutils.py:186–231  ·  view source on GitHub ↗
(self, op, r0=0, r1=0, r2=0, r3=0, *, silent=False, call=None, ignore_exceptions=False)

Source from the content-addressed store, hash-verified

184 sysl = mrs
185
186 def exec(self, op, r0=0, r1=0, r2=0, r3=0, *, silent=False, call=None, ignore_exceptions=False):
187 if callable(call):
188 region = REGION_RX_EL1
189 elif isinstance(call, tuple):
190 call, region = call
191 else:
192 call, region = self.exec_modes[call]
193
194 if isinstance(op, list):
195 op = tuple(op)
196
197 if op in self.inst_cache:
198 func = self.inst_cache[op]
199 elif isinstance(op, tuple) or isinstance(op, list):
200 func = struct.pack(f"<{len(op)}II", *op, 0xd65f03c0) # ret
201 elif isinstance(op, int):
202 func = struct.pack("<II", op, 0xd65f03c0) # ret
203 elif isinstance(op, str):
204 c = ARMAsm(op + "; ret", self.code_buffer)
205 func = c.data
206 elif isinstance(op, bytes):
207 func = op
208 else:
209 raise ValueError()
210
211 if self.mmu_off:
212 region = 0
213
214 self.inst_cache[op] = func
215
216 assert len(func) < self.CODE_BUFFER_SIZE
217 self.iface.writemem(self.code_buffer, func)
218 self.proxy.dc_cvau(self.code_buffer, len(func))
219 self.proxy.ic_ivau(self.code_buffer, len(func))
220
221 self.proxy.set_exc_guard(GUARD.SKIP | (GUARD.SILENT if silent else 0))
222 ret = call(self.code_buffer | region, r0, r1, r2, r3)
223 if not ignore_exceptions:
224 cnt = self.proxy.get_exc_count()
225 self.proxy.set_exc_guard(GUARD.OFF)
226 if cnt:
227 raise ProxyError("Exception occurred")
228 else:
229 self.proxy.set_exc_guard(GUARD.OFF)
230
231 return ret
232
233 inst = exec
234

Callers 3

mrsMethod · 0.95
msrMethod · 0.95
find_regsFunction · 0.80

Calls 7

ARMAsmClass · 0.85
ProxyErrorClass · 0.85
dc_cvauMethod · 0.80
ic_ivauMethod · 0.80
set_exc_guardMethod · 0.80
get_exc_countMethod · 0.80
writememMethod · 0.45

Tested by

no test coverage detected