Skip to content

Commit 36bcc36

Browse files
committed
m1n1.fw.asc.oslog: Implement properly
Signed-off-by: Hector Martin <[email protected]>
1 parent d526712 commit 36bcc36

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

proxyclient/m1n1/fw/asc/oslog.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,36 @@
55
## OSLog endpoint
66

77
class OSLogMessage(Register64):
8-
TYPE = 63, 56
8+
TYPE = 63, 56
99

10-
class OSLog_Init(OSLogMessage):
11-
TYPE = 63, 56, Constant(1)
12-
UNK = 51, 0
13-
14-
class OSLog_Ack(OSLogMessage):
15-
TYPE = 63, 56, Constant(3)
10+
class OSLog_GetBuf(OSLogMessage):
11+
TYPE = 63, 56, Constant(1)
12+
SIZE = 55, 48
13+
DVA = 47, 0
1614

1715
class ASCOSLogEndpoint(ASCBaseEndpoint):
1816
BASE_MESSAGE = OSLogMessage
19-
SHORT = "oslog"
17+
SHORT = "iorep"
2018

2119
def __init__(self, *args, **kwargs):
2220
super().__init__(*args, **kwargs)
23-
self.started = False
21+
self.iobuffer = None
22+
self.iobuffer_dva = None
23+
24+
@msg_handler(1, OSLog_GetBuf)
25+
def GetBuf(self, msg):
26+
if self.iobuffer:
27+
self.log("WARNING: trying to reset iobuffer!")
28+
29+
30+
if msg.DVA != 0:
31+
self.bufsize = 0x1000 * msg.SIZE
32+
self.iobuffer = self.iobuffer_dva = msg.DVA << 12
33+
self.log(f"buf prealloc {self.iobuffer:#x} / {self.iobuffer_dva:#x}")
34+
else:
35+
self.bufsize = align(0x1000 * msg.SIZE, 0x4000)
36+
self.iobuffer, self.iobuffer_dva = self.asc.ioalloc(self.bufsize)
37+
self.log(f"buf {self.iobuffer:#x} / {self.iobuffer_dva:#x}")
38+
self.send(OSLog_GetBuf(DVA=self.iobuffer_dva >> 12, SIZE=self.bufsize // 0x1000))
2439

25-
@msg_handler(1, OSLog_Init)
26-
def Init(self, msg):
27-
self.log(f"oslog init: {msg.UNK:#x}")
28-
self.send(OSLog_Ack())
29-
self.started = True
3040
return True

0 commit comments

Comments
 (0)