From 489615d47f33e66197d94113a6c307b20743c838 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sat, 4 Jan 2025 05:38:38 -0500 Subject: [PATCH] More Changes --- archives | 2 +- dependencies/runtime/CMakeLists.txt | 7 -- dependencies/runtime/src | 2 +- media-layer/trampoline/CMakeLists.txt | 4 +- media-layer/trampoline/src/guest/guest.cpp | 80 ---------------------- media-layer/trampoline/src/guest/guest.h | 5 +- media-layer/trampoline/src/host/host.h | 3 - 7 files changed, 5 insertions(+), 98 deletions(-) delete mode 100644 media-layer/trampoline/src/guest/guest.cpp diff --git a/archives b/archives index a271e6e12..5baa6b194 160000 --- a/archives +++ b/archives @@ -1 +1 @@ -Subproject commit a271e6e12af08e0d21f68db940af968d8e0be981 +Subproject commit 5baa6b1948aeebb5e13af31ff62dc97f00a3b71e diff --git a/dependencies/runtime/CMakeLists.txt b/dependencies/runtime/CMakeLists.txt index 6dd0d8705..be6e58066 100644 --- a/dependencies/runtime/CMakeLists.txt +++ b/dependencies/runtime/CMakeLists.txt @@ -2,13 +2,6 @@ project(runtime) ## Extra Runtime -# QEMU -set(QEMU_VERSION "9.1.1") -force_set(RUNTIME_QEMU_ARCHIVE "${CMAKE_CURRENT_SOURCE_DIR}/../../archives/qemu-${QEMU_VERSION}.tar.xz" FILEPATH) -if(NOT BUILD_NATIVE_COMPONENTS) - force_set(TRAMPOLINE_HEADERS_ONLY TRUE BOOL) -endif() - # Build add_subdirectory(src) diff --git a/dependencies/runtime/src b/dependencies/runtime/src index c1b4b0277..03c9c891b 160000 --- a/dependencies/runtime/src +++ b/dependencies/runtime/src @@ -1 +1 @@ -Subproject commit c1b4b02770dee1f5dfca2ca21a627baf10942cde +Subproject commit 03c9c891b6304d29a9aae662a45ee79b89e76540 diff --git a/media-layer/trampoline/CMakeLists.txt b/media-layer/trampoline/CMakeLists.txt index d15ef9cd2..7b366137f 100644 --- a/media-layer/trampoline/CMakeLists.txt +++ b/media-layer/trampoline/CMakeLists.txt @@ -17,13 +17,13 @@ if(BUILD_NATIVE_COMPONENTS) setup_library(media-layer-trampoline TRUE TRUE) elseif(BUILD_ARM_COMPONENTS) # Guest Component - add_library(media-layer-core SHARED src/guest/guest.cpp ${MEDIA_LAYER_TRAMPOLINE_SRC}) + add_library(media-layer-core SHARED ${MEDIA_LAYER_TRAMPOLINE_SRC}) target_link_libraries(media-layer-core PUBLIC media-layer-headers PRIVATE reborn-util - trampoline-headers + trampoline ) target_compile_definitions(media-layer-core PRIVATE MEDIA_LAYER_TRAMPOLINE_GUEST) # Install diff --git a/media-layer/trampoline/src/guest/guest.cpp b/media-layer/trampoline/src/guest/guest.cpp deleted file mode 100644 index 5ba76b2d9..000000000 --- a/media-layer/trampoline/src/guest/guest.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include - -#include "guest.h" - -// Syscall Method -static uint32_t trampoline_syscall(const uint32_t id, const unsigned char *args) { - // Make Syscall - const long ret = syscall(TRAMPOLINE_SYSCALL, id, args); - if (ret == -1) { - // Error - ERR("Trampoline Error: %s", strerror(errno)); - } - // Return - return *(uint32_t *) args; -} - -// Pipe Method -static int get_pipe(const char *env) { - const char *value = getenv(env); - if (value == nullptr) { - IMPOSSIBLE(); - } - const std::string str = value; - return std::stoi(str); -} -static uint32_t trampoline_pipe(const uint32_t id, const bool allow_early_return, const uint32_t length, const unsigned char *args) { - // Get Pipes - static int arguments_pipe = -1; - static int return_value_pipe = -1; - if (arguments_pipe == -1) { - arguments_pipe = get_pipe(_MCPI_TRAMPOLINE_ARGUMENTS_ENV); - return_value_pipe = get_pipe(_MCPI_TRAMPOLINE_RETURN_VALUE_ENV); - } - // Write Command - const trampoline_pipe_arguments cmd = { - .id = id, - .allow_early_return = allow_early_return, - .length = length - }; - if (write(arguments_pipe, &cmd, sizeof(trampoline_pipe_arguments)) != sizeof(trampoline_pipe_arguments)) { - ERR("Unable To Write Trampoline Command"); - } - // Write Arguments - size_t position = 0; - while (position < length) { - const ssize_t ret = write(arguments_pipe, args + position, length - position); - if (ret == -1) { - ERR("Unable To Write Trampoline Arguments"); - } else { - position += ret; - } - } - if (allow_early_return) { - return 0; - } - // Return - uint32_t ret; - if (read(return_value_pipe, &ret, sizeof(uint32_t)) != sizeof(uint32_t)) { - ERR("Unable To Read Trampoline Return Value"); - } - return ret; -} - -// Main Function -uint32_t _raw_trampoline(const uint32_t id, const bool allow_early_return, const uint32_t length, const unsigned char *args) { - if (length > MAX_TRAMPOLINE_ARGS_SIZE) { - ERR("Command Too Big"); - } - // Configure Method - static bool use_syscall = getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr; - // Use Correct Method - if (use_syscall) { - return trampoline_syscall(id, args); - } else { - return trampoline_pipe(id, allow_early_return, length, args); - } -} diff --git a/media-layer/trampoline/src/guest/guest.h b/media-layer/trampoline/src/guest/guest.h index 00d75fc26..7b228d9b5 100644 --- a/media-layer/trampoline/src/guest/guest.h +++ b/media-layer/trampoline/src/guest/guest.h @@ -5,9 +5,6 @@ #include "../common/common.h" -// Trampoline Function -uint32_t _raw_trampoline(uint32_t id, bool allow_early_return, uint32_t length, const unsigned char *args); - // Compile Trampoline Arguments template void _handle_trampoline_arg(unsigned char *&out, const T &arg) { @@ -64,7 +61,7 @@ unsigned int _trampoline(const unsigned int id, const bool allow_early_return, A unsigned char *end = out; _add_to_trampoline_args(end, args...); const uint32_t length = end - out; - return _raw_trampoline(id, allow_early_return, length, out); + return raw_trampoline(id, allow_early_return, length, out); } #define trampoline(...) _trampoline(_id, ##__VA_ARGS__) diff --git a/media-layer/trampoline/src/host/host.h b/media-layer/trampoline/src/host/host.h index 0c7b4165e..cd7c607b6 100644 --- a/media-layer/trampoline/src/host/host.h +++ b/media-layer/trampoline/src/host/host.h @@ -4,9 +4,6 @@ #include "../common/common.h" -// Trampoline Function -extern "C" std::remove_pointer_t trampoline; - // Macro typedef uint32_t handler_t(trampoline_writer_t writer, const unsigned char *args); __attribute__((visibility("internal"))) void _add_handler(unsigned char id, handler_t *handler);