Skip to content

Commit

Permalink
tools/chainload.py: Properly sleep DCP when chainloading macOS
Browse files Browse the repository at this point in the history
Signed-off-by: Asahi Lina <[email protected]>
  • Loading branch information
asahilina committed Jan 20, 2023
1 parent 7a92257 commit 3d28ac4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions proxyclient/m1n1/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ class M1N1Proxy(Reloadable):
P_DISPLAY_INIT = 0x1100
P_DISPLAY_CONFIGURE = 0x1101
P_DISPLAY_SHUTDOWN = 0x1102
P_DISPLAY_START_DCP = 0x1103
P_DISPLAY_IS_EXTERNAL = 0x1104

P_DAPF_INIT_ALL = 0x1200
P_DAPF_INIT = 0x1201
Expand Down Expand Up @@ -1074,6 +1076,10 @@ def display_configure(self, cfg):
return self.request(self.P_DISPLAY_CONFIGURE, cfg)
def display_shutdown(self, mode):
return self.request(self.P_DISPLAY_SHUTDOWN, mode)
def display_start_dcp(self):
return self.request(self.P_DISPLAY_START_DCP)
def display_is_external(self):
return self.request(self.P_DISPLAY_IS_EXTERNAL)

def dapf_init_all(self):
return self.request(self.P_DAPF_INIT_ALL)
Expand Down
5 changes: 3 additions & 2 deletions proxyclient/tools/chainload.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@

print(f"Entry point: 0x{entry:x}")

if args.xnu:
p.display_shutdown(0)
if args.xnu and p.display_is_external():
if p.display_start_dcp() >= 0:
p.display_shutdown(0)

if args.call:
print(f"Shutting down MMU...")
Expand Down
6 changes: 6 additions & 0 deletions src/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,12 @@ int proxy_process(ProxyRequest *request, ProxyReply *reply)
case P_DISPLAY_SHUTDOWN:
display_shutdown(request->args[0]);
break;
case P_DISPLAY_START_DCP:
display_start_dcp();
break;
case P_DISPLAY_IS_EXTERNAL:
reply->retval = display_is_external;
break;

case P_DAPF_INIT_ALL:
reply->retval = dapf_init_all();
Expand Down
2 changes: 2 additions & 0 deletions src/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ typedef enum {
P_DISPLAY_INIT = 0x1100,
P_DISPLAY_CONFIGURE,
P_DISPLAY_SHUTDOWN,
P_DISPLAY_START_DCP,
P_DISPLAY_IS_EXTERNAL,

P_DAPF_INIT_ALL = 0x1200,
P_DAPF_INIT,
Expand Down

0 comments on commit 3d28ac4

Please sign in to comment.