From 3d28ac4d6f15e80fda14ce464f463a9cdc52a08a Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Fri, 16 Dec 2022 18:37:25 +0900 Subject: [PATCH] tools/chainload.py: Properly sleep DCP when chainloading macOS Signed-off-by: Asahi Lina --- proxyclient/m1n1/proxy.py | 6 ++++++ proxyclient/tools/chainload.py | 5 +++-- src/proxy.c | 6 ++++++ src/proxy.h | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/proxyclient/m1n1/proxy.py b/proxyclient/m1n1/proxy.py index f0239a7a9..1869f3e55 100644 --- a/proxyclient/m1n1/proxy.py +++ b/proxyclient/m1n1/proxy.py @@ -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 @@ -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) diff --git a/proxyclient/tools/chainload.py b/proxyclient/tools/chainload.py index d3068a30d..691a78a8f 100755 --- a/proxyclient/tools/chainload.py +++ b/proxyclient/tools/chainload.py @@ -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...") diff --git a/src/proxy.c b/src/proxy.c index cc89cb13e..3925d7e83 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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(); diff --git a/src/proxy.h b/src/proxy.h index 037ec082c..27a3f8eaa 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -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,