This commit is contained in:
TheBrokenRail 2024-06-08 14:45:39 -04:00
parent fb5508e369
commit 5751a5a0c1
5 changed files with 31 additions and 19 deletions

View File

@ -11,20 +11,22 @@ target_include_directories(trampoline-headers INTERFACE include)
if(NOT TRAMPOLINE_HEADERS_ONLY)
# Check Architecture
include(CheckSymbolExists)
check_symbol_exists("__aarch64__" "" USE_NATIVE_RUNTIME)
check_symbol_exists("__x86_64__" "" USE_QEMU_RUNTIME)
# Include Correct Sub-Project
set(RUNTIME_RPATH "$ORIGIN/../lib/native")
set(RUNTIME_EXTRA_LINK_FLAG "--disable-new-dtags")
target_compile_definitions(trampoline-headers INTERFACE MCPI_BUILD_RUNTIME)
if(USE_NATIVE_RUNTIME)
add_subdirectory(native)
elseif(USE_QEMU_RUNTIME)
add_subdirectory(qemu)
target_compile_definitions(trampoline-headers INTERFACE MCPI_RUNTIME_IS_QEMU)
else()
message(FATAL_ERROR "Unsupported Architecture")
check_symbol_exists("__arm__" "" NO_RUNTIME_NEEDED)
if(NOT NO_RUNTIME_NEEDED)
check_symbol_exists("__aarch64__" "" USE_NATIVE_RUNTIME)
check_symbol_exists("__x86_64__" "" USE_QEMU_RUNTIME)
# Include Correct Sub-Project
set(RUNTIME_RPATH "$ORIGIN/../lib/native")
set(RUNTIME_EXTRA_LINK_FLAG "--disable-new-dtags")
target_compile_definitions(trampoline-headers INTERFACE MCPI_BUILD_RUNTIME)
if(USE_NATIVE_RUNTIME)
add_subdirectory(native)
elseif(USE_QEMU_RUNTIME)
add_subdirectory(qemu)
target_compile_definitions(trampoline-headers INTERFACE MCPI_RUNTIME_IS_QEMU)
else()
message(FATAL_ERROR "Unsupported Architecture")
endif()
endif()
else()
# No-Op Install Function

View File

@ -1,5 +1,5 @@
# MCPI Runtime
**Fact:** MCPI is a 32-bit ARM binary.
# MCPI-Reborn Runtime
**Fact:** Minecraft: Pi Edition is a 32-bit ARM program.
**Another fact:** Most modern computers do not use 32-bit ARM and therefore cannot run MCPI natively.
@ -16,4 +16,10 @@ QEMU emulates ARM code so MCPI can run on x86 hardware. And the patch adds a sys
### 64-Bit ARM Host
QEMU is not necessary on this platform because it can already run 32-bit ARM code natively.
Instead, the runtime is implemented as two processes: a parent and a child. The child becomes MCPI and can send graphics commands to the parent. And because the parent is 64-bit, 32-bit drivers are not needed.
Instead, the runtime is implemented as two processes: a parent and a child. The child becomes MCPI and can send graphics commands to the parent. And because the parent is 64-bit, 32-bit drivers are not needed.
### 32-Bit ARM Host
This project is unnecessary on this platform.
### Other Architectures
Any unlisted platforms are unsupported.

View File

@ -6,7 +6,6 @@
#include "log.h"
#include "memory.h"
#include "trampoline.h"
#include "pipe.h"
#include "signals.h"
@ -37,7 +36,6 @@ int main(__attribute__((unused)) int argc, char *argv[]) {
// Setup Trampoline
init_signals(pid);
init_memory(pid);
init_trampoline();
// Start Pipes
init_pipe_host(pid);

View File

@ -46,6 +46,7 @@ void init_pipe_host(pid_t guest_pid) {
// Wait For Commands
trampoline_pipe_arguments cmd = {};
while (read(arguments_pipe[PIPE_READ], &cmd, sizeof(trampoline_pipe_arguments)) > 0) {
init_trampoline(); // Only Init If Needed
static unsigned char args[MAX_TRAMPOLINE_ARGS_SIZE];
size_t position = 0;
while (position < cmd.length) {

View File

@ -13,6 +13,11 @@ uint32_t trampoline(uint32_t id, const unsigned char *args) {
// Init
void init_trampoline() {
static bool is_setup = false;
if (is_setup) {
return;
}
is_setup = true;
// Open Library
void *handle = dlopen("libmedia-layer-trampoline.so", RTLD_NOW);
if (handle != nullptr) {