m1n1.hv: Add a method to write memory

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
This commit is contained in:
Akihiko Odaki 2022-05-28 00:47:06 +09:00 committed by Hector Martin
parent 0a28817ce2
commit 6babf39184

View file

@ -249,6 +249,26 @@ class HV(Reloadable):
return buffer.getvalue()
def writemem(self, va, data):
'''write to virtual memory'''
written = 0
while written < len(data):
pa = self.p.hv_translate(va, False, True)
if pa == 0:
break
size_in_page = 4096 - (va % 4096)
if len(data) - written < size_in_page:
self.iface.writemem(pa, data[written:])
written = len(data)
break
self.iface.writemem(pa, data[written:written + size_in_page])
va += size_in_page
written += size_in_page
return written
def trace_irq(self, device, num, count, flags):
for n in range(num, num + count):
if flags & self.IRQTRACE_IRQ: