m1n1.fw.asc.oslog: Implement properly

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2023-04-16 20:23:36 +09:00
parent d5267123c1
commit 36bcc36173

View file

@ -5,26 +5,36 @@ from ...utils import *
## OSLog endpoint
class OSLogMessage(Register64):
TYPE = 63, 56
TYPE = 63, 56
class OSLog_Init(OSLogMessage):
TYPE = 63, 56, Constant(1)
UNK = 51, 0
class OSLog_Ack(OSLogMessage):
TYPE = 63, 56, Constant(3)
class OSLog_GetBuf(OSLogMessage):
TYPE = 63, 56, Constant(1)
SIZE = 55, 48
DVA = 47, 0
class ASCOSLogEndpoint(ASCBaseEndpoint):
BASE_MESSAGE = OSLogMessage
SHORT = "oslog"
SHORT = "iorep"
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.started = False
self.iobuffer = None
self.iobuffer_dva = None
@msg_handler(1, OSLog_GetBuf)
def GetBuf(self, msg):
if self.iobuffer:
self.log("WARNING: trying to reset iobuffer!")
if msg.DVA != 0:
self.bufsize = 0x1000 * msg.SIZE
self.iobuffer = self.iobuffer_dva = msg.DVA << 12
self.log(f"buf prealloc {self.iobuffer:#x} / {self.iobuffer_dva:#x}")
else:
self.bufsize = align(0x1000 * msg.SIZE, 0x4000)
self.iobuffer, self.iobuffer_dva = self.asc.ioalloc(self.bufsize)
self.log(f"buf {self.iobuffer:#x} / {self.iobuffer_dva:#x}")
self.send(OSLog_GetBuf(DVA=self.iobuffer_dva >> 12, SIZE=self.bufsize // 0x1000))
@msg_handler(1, OSLog_Init)
def Init(self, msg):
self.log(f"oslog init: {msg.UNK:#x}")
self.send(OSLog_Ack())
self.started = True
return True