More Changes
Some checks failed
CI / Build (AMD64) (push) Failing after 22m43s
CI / Build (ARM64) (push) Failing after 24m45s
CI / Build (ARMHF) (push) Failing after 14m6s
CI / Test (AMD64, Client) (push) Has been skipped
CI / Test (AMD64, Server) (push) Has been skipped
CI / Test (ARM64, Client) (push) Has been skipped
CI / Test (ARM64, Server) (push) Has been skipped
CI / Test (ARMHF, Client) (push) Has been skipped
CI / Test (ARMHF, Server) (push) Has been skipped
CI / Build Example Mods (push) Has been skipped
CI / Release (push) Has been skipped
Some checks failed
CI / Build (AMD64) (push) Failing after 22m43s
CI / Build (ARM64) (push) Failing after 24m45s
CI / Build (ARMHF) (push) Failing after 14m6s
CI / Test (AMD64, Client) (push) Has been skipped
CI / Test (AMD64, Server) (push) Has been skipped
CI / Test (ARM64, Client) (push) Has been skipped
CI / Test (ARM64, Server) (push) Has been skipped
CI / Test (ARMHF, Client) (push) Has been skipped
CI / Test (ARMHF, Server) (push) Has been skipped
CI / Build Example Mods (push) Has been skipped
CI / Release (push) Has been skipped
This commit is contained in:
parent
00fee9c410
commit
489615d47f
2
archives
2
archives
@ -1 +1 @@
|
|||||||
Subproject commit a271e6e12af08e0d21f68db940af968d8e0be981
|
Subproject commit 5baa6b1948aeebb5e13af31ff62dc97f00a3b71e
|
7
dependencies/runtime/CMakeLists.txt
vendored
7
dependencies/runtime/CMakeLists.txt
vendored
@ -2,13 +2,6 @@ project(runtime)
|
|||||||
|
|
||||||
## Extra 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
|
# Build
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
2
dependencies/runtime/src
vendored
2
dependencies/runtime/src
vendored
@ -1 +1 @@
|
|||||||
Subproject commit c1b4b02770dee1f5dfca2ca21a627baf10942cde
|
Subproject commit 03c9c891b6304d29a9aae662a45ee79b89e76540
|
@ -17,13 +17,13 @@ if(BUILD_NATIVE_COMPONENTS)
|
|||||||
setup_library(media-layer-trampoline TRUE TRUE)
|
setup_library(media-layer-trampoline TRUE TRUE)
|
||||||
elseif(BUILD_ARM_COMPONENTS)
|
elseif(BUILD_ARM_COMPONENTS)
|
||||||
# Guest Component
|
# 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
|
target_link_libraries(media-layer-core
|
||||||
PUBLIC
|
PUBLIC
|
||||||
media-layer-headers
|
media-layer-headers
|
||||||
PRIVATE
|
PRIVATE
|
||||||
reborn-util
|
reborn-util
|
||||||
trampoline-headers
|
trampoline
|
||||||
)
|
)
|
||||||
target_compile_definitions(media-layer-core PRIVATE MEDIA_LAYER_TRAMPOLINE_GUEST)
|
target_compile_definitions(media-layer-core PRIVATE MEDIA_LAYER_TRAMPOLINE_GUEST)
|
||||||
# Install
|
# Install
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
#include <unistd.h>
|
|
||||||
#include <libreborn/log.h>
|
|
||||||
#include <string>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,9 +5,6 @@
|
|||||||
|
|
||||||
#include "../common/common.h"
|
#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
|
// Compile Trampoline Arguments
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void _handle_trampoline_arg(unsigned char *&out, const T &arg) {
|
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;
|
unsigned char *end = out;
|
||||||
_add_to_trampoline_args(end, args...);
|
_add_to_trampoline_args(end, args...);
|
||||||
const uint32_t length = end - out;
|
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__)
|
#define trampoline(...) _trampoline(_id, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
|
|
||||||
// Trampoline Function
|
|
||||||
extern "C" std::remove_pointer_t<trampoline_t> trampoline;
|
|
||||||
|
|
||||||
// Macro
|
// Macro
|
||||||
typedef uint32_t handler_t(trampoline_writer_t writer, const unsigned char *args);
|
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);
|
__attribute__((visibility("internal"))) void _add_handler(unsigned char id, handler_t *handler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user