Update Runtime
This commit is contained in:
parent
b339b53f42
commit
23b3cbe72f
14
dependencies/runtime/CMakeLists.txt
vendored
14
dependencies/runtime/CMakeLists.txt
vendored
@ -3,16 +3,12 @@ project(runtime)
|
||||
## Extra Runtime
|
||||
|
||||
# QEMU
|
||||
set(QEMU_VERSION "9.0.2")
|
||||
set(RUNTIME_QEMU_ARCHIVE "${CMAKE_CURRENT_SOURCE_DIR}/../../archives/qemu-${QEMU_VERSION}.tar.xz")
|
||||
set(QEMU_VERSION "9.1.1")
|
||||
file(REAL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../archives/qemu-${QEMU_VERSION}.tar.xz" QEMU_PATH)
|
||||
set(RUNTIME_QEMU_ARCHIVE "${QEMU_PATH}" CACHE FILEPATH "" FORCE)
|
||||
if(NOT BUILD_NATIVE_COMPONENTS)
|
||||
set(TRAMPOLINE_HEADERS_ONLY TRUE)
|
||||
set(TRAMPOLINE_HEADERS_ONLY TRUE CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
# Build
|
||||
add_subdirectory(src)
|
||||
|
||||
# Install
|
||||
if(COMMAND install_runtime)
|
||||
install_runtime("${MCPI_BIN_DIR}" "${MCPI_LEGAL_DIR}")
|
||||
endif()
|
||||
add_subdirectory(src)
|
2
dependencies/runtime/src
vendored
2
dependencies/runtime/src
vendored
@ -1 +1 @@
|
||||
Subproject commit 377f9ddbc4747ca3a640231d259c0e6fcc71b4b0
|
||||
Subproject commit f8b56c50bab051f7f2a1fb47be4101f0e2099f2f
|
@ -4,7 +4,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include <libreborn/libreborn.h>
|
||||
#include <trampoline/types.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "bootstrap.h"
|
||||
@ -61,7 +60,7 @@ void bootstrap(const options_t &options) {
|
||||
// Debug Information
|
||||
print_debug_information();
|
||||
|
||||
// Check Page Size (Not Needed When Using QEMU)
|
||||
// Check Page Size
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
if (page_size != REQUIRED_PAGE_SIZE) {
|
||||
CONDITIONAL_ERR(!options.skip_pagesize_check, "Invalid page size! A page size of %ld bytes is required, but the system size is %ld bytes.", (long) REQUIRED_PAGE_SIZE, page_size);
|
||||
@ -177,11 +176,6 @@ void bootstrap(const options_t &options) {
|
||||
#ifdef MCPI_BUILD_RUNTIME
|
||||
args.push_back("runtime");
|
||||
#endif
|
||||
// Fix QEMU Bug
|
||||
#ifdef MCPI_RUNTIME_IS_QEMU
|
||||
args.push_back("-B");
|
||||
args.push_back(std::to_string(QEMU_GUEST_BASE));
|
||||
#endif
|
||||
|
||||
// Specify MCPI Binary
|
||||
args.push_back(new_mcpi_exe_path);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <argp.h>
|
||||
|
||||
#include <trampoline/types.h>
|
||||
#include "parser.h"
|
||||
|
||||
// Globals
|
||||
@ -17,6 +18,9 @@ static argp_option options_data[] = {
|
||||
{nullptr, 0, nullptr, 0, "Environmental Variables:", 0},
|
||||
#define ENV(name, doc) {#name, env_key--, nullptr, OPTION_DOC | OPTION_NO_USAGE | (is_env_var_internal(name##_ENV) ? OPTION_HIDDEN : 0), doc, 0},
|
||||
#include <libreborn/env-list.h>
|
||||
#ifdef MCPI_BUILD_RUNTIME
|
||||
#include <trampoline/env-list.h>
|
||||
#endif
|
||||
#undef ENV
|
||||
{nullptr, 0, nullptr, 0, "Help Options:", -1},
|
||||
{nullptr, 0, nullptr, 0, nullptr, 0}
|
||||
|
@ -19,7 +19,7 @@ int reborn_get_debug_fd();
|
||||
#define WARN(format, ...) fprintf(stderr, "[WARN]: " format "\n", ##__VA_ARGS__)
|
||||
#define RAW_DEBUG(tag, format, ...) dprintf(reborn_get_debug_fd(), "[DEBUG]: %s" format "\n", tag, ##__VA_ARGS__)
|
||||
#define DEBUG(format, ...) RAW_DEBUG(reborn_debug_tag, format, ##__VA_ARGS__)
|
||||
#define ERR(format, ...) { fprintf(stderr, "[ERR]: (%s:%i): " format "\n", __FILE__, __LINE__, ##__VA_ARGS__); exit(EXIT_FAILURE); }
|
||||
#define ERR(format, ...) { fprintf(stderr, "[ERR]: (%s:%i): " format "\n", __FILE__, __LINE__, ##__VA_ARGS__); _exit(EXIT_FAILURE); }
|
||||
#define IMPOSSIBLE() ERR("This Should Never Be Called")
|
||||
#define CONDITIONAL_ERR(is_error, ...) \
|
||||
{ \
|
||||
|
@ -201,25 +201,12 @@ CALL(17, media_glClear, void, (GLbitfield mask))
|
||||
|
||||
CALL(18, media_glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage))
|
||||
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
|
||||
static bool use_syscall = getenv(TRAMPOLINE_ARGUMENTS_PIPE_ENV) == nullptr;
|
||||
if (use_syscall) {
|
||||
trampoline(false, gl_state.bound_array_buffer, target, int32_t(size), uint32_t(data), usage);
|
||||
} else {
|
||||
trampoline(true, gl_state.bound_array_buffer, target, int32_t(size), copy_array(size, (unsigned char *) data), usage);
|
||||
}
|
||||
trampoline(true, gl_state.bound_array_buffer, target, int32_t(size), copy_array(size, (unsigned char *) data), usage);
|
||||
#else
|
||||
media_glBindBuffer(GL_ARRAY_BUFFER, args.next<GLuint>());
|
||||
GLenum target = args.next<GLenum>();
|
||||
int32_t size = args.next<int32_t>();
|
||||
#ifdef MCPI_RUNTIME_IS_QEMU
|
||||
const unsigned char *data = nullptr;
|
||||
uint32_t data_addr = args.next<uint32_t>();
|
||||
if (data_addr != 0) {
|
||||
data = (const unsigned char *) (uintptr_t) (QEMU_GUEST_BASE + data_addr);
|
||||
}
|
||||
#else
|
||||
const unsigned char *data = args.next_arr<unsigned char>();
|
||||
#endif
|
||||
GLenum usage = args.next<GLenum>();
|
||||
func(target, size, data, usage);
|
||||
return 0;
|
||||
@ -798,24 +785,13 @@ CALL(67, media_glGenBuffers, void, (GLsizei n, GLuint *buffers))
|
||||
|
||||
CALL(69, media_glBufferSubData, void, (GLenum target, GLintptr offset, GLsizeiptr size, const void *data))
|
||||
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
|
||||
static bool use_syscall = getenv(TRAMPOLINE_ARGUMENTS_PIPE_ENV) == nullptr;
|
||||
if (use_syscall) {
|
||||
trampoline(false, gl_state.bound_array_buffer, target, int32_t(offset), int32_t(size), uint32_t(data));
|
||||
} else {
|
||||
trampoline(true, gl_state.bound_array_buffer, target, int32_t(offset), copy_array(size, (unsigned char *) data));
|
||||
}
|
||||
trampoline(true, gl_state.bound_array_buffer, target, int32_t(offset), copy_array(size, (unsigned char *) data));
|
||||
#else
|
||||
media_glBindBuffer(GL_ARRAY_BUFFER, args.next<GLuint>());
|
||||
GLenum target = args.next<GLenum>();
|
||||
int32_t offset = args.next<int32_t>();
|
||||
#ifdef MCPI_RUNTIME_IS_QEMU
|
||||
int32_t size = args.next<int32_t>();
|
||||
uint32_t data_addr = args.next<uint32_t>();
|
||||
const unsigned char *data = (const unsigned char *) (uintptr_t) (QEMU_GUEST_BASE + data_addr);
|
||||
#else
|
||||
uint32_t size;
|
||||
const unsigned char *data = args.next_arr<unsigned char>(&size);
|
||||
#endif
|
||||
func(target, offset, size, data);
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include "guest.h"
|
||||
|
||||
// Syscall Method
|
||||
static uint32_t trampoline_syscall(const uint32_t id, const uint32_t length, const unsigned char *args) {
|
||||
static uint32_t trampoline_syscall(const uint32_t id, const unsigned char *args) {
|
||||
// Make Syscall
|
||||
const long ret = syscall(TRAMPOLINE_SYSCALL, id, length, args);
|
||||
const long ret = syscall(TRAMPOLINE_SYSCALL, id, args);
|
||||
if (ret == -1) {
|
||||
// Error
|
||||
ERR("Trampoline Error: %s", strerror(errno));
|
||||
@ -17,7 +17,7 @@ static uint32_t trampoline_syscall(const uint32_t id, const uint32_t length, con
|
||||
return *(uint32_t *) args;
|
||||
}
|
||||
|
||||
// Pipe Method (Native Trampoline Only)
|
||||
// Pipe Method
|
||||
static int get_pipe(const char *env) {
|
||||
const char *value = getenv(env);
|
||||
if (value == nullptr) {
|
||||
@ -31,8 +31,8 @@ static uint32_t trampoline_pipe(const uint32_t id, const bool allow_early_return
|
||||
static int arguments_pipe = -1;
|
||||
static int return_value_pipe = -1;
|
||||
if (arguments_pipe == -1) {
|
||||
arguments_pipe = get_pipe(TRAMPOLINE_ARGUMENTS_PIPE_ENV);
|
||||
return_value_pipe = get_pipe(TRAMPOLINE_RETURN_VALUE_PIPE_ENV);
|
||||
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 = {
|
||||
@ -66,11 +66,14 @@ static uint32_t trampoline_pipe(const uint32_t id, const bool allow_early_return
|
||||
|
||||
// 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(TRAMPOLINE_ARGUMENTS_PIPE_ENV) == nullptr;
|
||||
static bool use_syscall = getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr;
|
||||
// Use Correct Method
|
||||
if (use_syscall) {
|
||||
return trampoline_syscall(id, length, args);
|
||||
return trampoline_syscall(id, args);
|
||||
} else {
|
||||
return trampoline_pipe(id, allow_early_return, length, args);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../common/common.h"
|
||||
|
||||
@ -34,11 +35,17 @@ struct copy_array {
|
||||
};
|
||||
template <>
|
||||
inline void _handle_trampoline_arg<copy_array>(unsigned char *&out, const copy_array &arg) {
|
||||
*(uint32_t *) out = arg.size;
|
||||
out += sizeof(uint32_t);
|
||||
// Send Size
|
||||
_handle_trampoline_arg(out, arg.size);
|
||||
// Send Data
|
||||
if (arg.size > 0) {
|
||||
memcpy(out, arg.data, arg.size);
|
||||
out += arg.size;
|
||||
static bool just_send_pointer = getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr;
|
||||
if (just_send_pointer) {
|
||||
_handle_trampoline_arg(out, uint32_t(arg.data));
|
||||
} else {
|
||||
memcpy(out, arg.data, arg.size);
|
||||
out += arg.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Variadic Templates
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "../common/common.h"
|
||||
|
||||
// Trampoline Function
|
||||
@ -38,12 +40,16 @@ struct TrampolineArguments {
|
||||
if (length != nullptr) {
|
||||
*length = size / sizeof(T);
|
||||
}
|
||||
static bool just_read_pointer = getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr;
|
||||
if (size == 0) {
|
||||
return nullptr;
|
||||
} else if (just_read_pointer) {
|
||||
return (const T *) (uintptr_t) (QEMU_GUEST_BASE + next<uint32_t>());
|
||||
} else {
|
||||
const T *ret = (const T *) raw_args;
|
||||
raw_args += size;
|
||||
return ret;
|
||||
}
|
||||
const T *ret = (const T *) raw_args;
|
||||
raw_args += size;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user