From 36bcc36173a0278918e2c8db5a1ab4c841a8ba49 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Sun, 16 Apr 2023 20:23:36 +0900 Subject: [PATCH] m1n1.fw.asc.oslog: Implement properly Signed-off-by: Hector Martin --- proxyclient/m1n1/fw/asc/oslog.py | 38 ++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/proxyclient/m1n1/fw/asc/oslog.py b/proxyclient/m1n1/fw/asc/oslog.py index b1a360be..4b733898 100644 --- a/proxyclient/m1n1/fw/asc/oslog.py +++ b/proxyclient/m1n1/fw/asc/oslog.py @@ -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