add WAMR to build
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(Nova64 VERSION 1.0.0 LANGUAGES C)
|
project(Nova64 VERSION 1.0.0 LANGUAGES C)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
option(BUILD_CORE "Build the Nova64 native core library" ON)
|
option(BUILD_CORE "Build the Nova64 native core library" ON)
|
||||||
option(BUILD_ESP32 "Build the ESP32 firmware project" OFF)
|
option(BUILD_ESP32 "Build the ESP32 firmware project" OFF)
|
||||||
option(BUILD_SIMULATOR "Build the C# simulator project" OFF)
|
option(BUILD_SIMULATOR "Build the C# simulator project" OFF)
|
||||||
|
|||||||
+41
-5
@@ -6,10 +6,9 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
|||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(ESP_PLATFORM)
|
if(ESP_PLATFORM)
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# 1. ESP-IDF BUILD MODE (Target: ESP32-P4)
|
# 1. ESP-IDF BUILD MODE (Target: ESP32-P4)
|
||||||
@@ -48,10 +47,11 @@ else()
|
|||||||
projCOVERAGE_TEST=0
|
projCOVERAGE_TEST=0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# FreeRTOS Kernel via FetchContent
|
# FreeRTOS Kernel via FetchContent
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
# Download FreeRTOS-Kernel Repository
|
# Download FreeRTOS-Kernel Repository
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
@@ -70,8 +70,36 @@ else()
|
|||||||
# Disable FreeRTOS Demos/Tests
|
# Disable FreeRTOS Demos/Tests
|
||||||
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# WAMR (WebAssembly Micro Runtime) via FetchContent
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
wamr_runtime
|
||||||
|
GIT_REPOSITORY https://github.com/bytecodealliance/wasm-micro-runtime.git
|
||||||
|
GIT_TAG WAMR-2.4.5
|
||||||
|
)
|
||||||
|
|
||||||
|
# WAMR Desktop-Konfiguration
|
||||||
|
set(WAMR_BUILD_INTERP 1 CACHE BOOL "" FORCE)
|
||||||
|
set(WAMR_BUILD_FAST_INTERP 1 CACHE BOOL "" FORCE)
|
||||||
|
set(WAMR_BUILD_JIT 0 CACHE BOOL "" FORCE)
|
||||||
|
set(WAMR_BUILD_AOT 0 CACHE BOOL "" FORCE)
|
||||||
|
set(WAMR_BUILD_LIBC_BUILTIN 1 CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
# Disable WASI
|
||||||
|
set(WAMR_BUILD_LIBC_WASI 0 CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(WAMR_BUILD_PLATFORM "windows" CACHE STRING "" FORCE)
|
||||||
|
elseif(APPLE)
|
||||||
|
set(WAMR_BUILD_PLATFORM "darwin" CACHE STRING "" FORCE)
|
||||||
|
else()
|
||||||
|
set(WAMR_BUILD_PLATFORM "linux" CACHE STRING "" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# define Target 'freertos_kernel'
|
# define Target 'freertos_kernel'
|
||||||
FetchContent_MakeAvailable(FreeRTOS_Kernel)
|
FetchContent_MakeAvailable(FreeRTOS_Kernel wamr_runtime)
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Nova64 Core Target
|
# Nova64 Core Target
|
||||||
@@ -85,10 +113,18 @@ else()
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Link FreeRTOS Kernel to the nova64_core library
|
# Link FreeRTOS Kernel to the nova64_core library
|
||||||
target_link_libraries(nova64_core PRIVATE freertos_kernel freertos_config)
|
target_link_libraries(nova64_core PRIVATE freertos_kernel freertos_config vmlib)
|
||||||
|
|
||||||
target_compile_definitions(nova64_core PRIVATE NOVA64_EXPORTS)
|
target_compile_definitions(nova64_core PRIVATE NOVA64_EXPORTS)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_definitions(
|
||||||
|
COMPILING_WASM_RUNTIME_API
|
||||||
|
alignof=__alignof
|
||||||
|
_Alignof=__alignof
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set_target_properties(nova64_core PROPERTIES
|
set_target_properties(nova64_core PROPERTIES
|
||||||
C_VISIBILITY_PRESET hidden
|
C_VISIBILITY_PRESET hidden
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
// Cross-platform DLL export/import visibility macros
|
// Cross-platform DLL export/import visibility macros
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef NOVA64_INTERNAL_H
|
||||||
|
#define NOVA64_INTERNAL_H
|
||||||
|
|
||||||
|
void nova64_log(const char *format, ...);
|
||||||
|
|
||||||
|
#endif // NOVA64_INTERNAL_H
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef WASM_RUNNER_H
|
||||||
|
#define WASM_RUNNER_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
wasm_runner_role_main = 0,
|
||||||
|
wasm_runner_role_status,
|
||||||
|
wasm_runner_role_background,
|
||||||
|
} wasm_runner_role_t;
|
||||||
|
|
||||||
|
typedef struct wasm_runner_instance wasm_runner_instance_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool enabled;
|
||||||
|
uint16_t x;
|
||||||
|
uint16_t y;
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
} wasm_runner_framebuffer_config_t;
|
||||||
|
|
||||||
|
bool wasm_runner_initialize(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starts a WASM program with optional framebuffer access.
|
||||||
|
*
|
||||||
|
* @param module_path Path to the WASM module to start.
|
||||||
|
* @param framebuffer_config Optional framebuffer configuration. If NULL,
|
||||||
|
* framebuffer access is disabled.
|
||||||
|
* @param out_instance Optional output pointer that receives a handle to the
|
||||||
|
* running WAMR instance.
|
||||||
|
* @return True on success, false on failure.
|
||||||
|
*/
|
||||||
|
bool wasm_runner_start_program(
|
||||||
|
const char *module_path,
|
||||||
|
const wasm_runner_framebuffer_config_t *framebuffer_config,
|
||||||
|
wasm_runner_instance_t **out_instance);
|
||||||
|
|
||||||
|
#endif // WASM_RUNNER_H
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
#include "nova64_core.h"
|
#include "nova64_core.h"
|
||||||
|
#include "nova64_internal.h"
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
#include "wasm_runner.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined(ESP_PLATFORM)
|
#if defined(ESP_PLATFORM)
|
||||||
/* ESP32-spezifische Header für Low-Power & Watchdog */
|
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
/* Windows API für Schlafen im Desktop-Thread */
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
/* POSIX / Linux / macOS Sleep */
|
/* POSIX / Linux / macOS Sleep */
|
||||||
@@ -30,7 +31,7 @@ static volatile bool shutdown_requested = false;
|
|||||||
|
|
||||||
static const char *const kInternalLauncherPath = "SYS:/launcher.wasm";
|
static const char *const kInternalLauncherPath = "SYS:/launcher.wasm";
|
||||||
|
|
||||||
static void nova64_log(const char *format, ...) {
|
void nova64_log(const char *format, ...) {
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
@@ -46,6 +47,7 @@ static void nova64_log(const char *format, ...) {
|
|||||||
|
|
||||||
static bool initialize_wasm_runtime(void) {
|
static bool initialize_wasm_runtime(void) {
|
||||||
nova64_log("Initializing WASM runtime...\n");
|
nova64_log("Initializing WASM runtime...\n");
|
||||||
|
wasm_runner_initialize();
|
||||||
// TODO: Replace this stub with real WAMR initialization.
|
// TODO: Replace this stub with real WAMR initialization.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -174,8 +176,7 @@ NOVA64_API int32_t nova64_main() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nova64_log(
|
nova64_log("Entering main runtime and starting FreeRTOS scheduler...\n");
|
||||||
"Entering main runtime and starting FreeRTOS scheduler...\n");
|
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|
||||||
// vTaskStartScheduler only returns if the scheduler fails to start or if
|
// vTaskStartScheduler only returns if the scheduler fails to start or if
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "wasm_runner.h"
|
||||||
|
#include "nova64_internal.h"
|
||||||
|
#include "wasm_export.h"
|
||||||
|
|
||||||
|
struct wasm_runner_instance {
|
||||||
|
void *native_instance;
|
||||||
|
char *module_path;
|
||||||
|
wasm_runner_framebuffer_config_t framebuffer_config;
|
||||||
|
wasm_runner_instance_t *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool wasm_runner_initialize(void) {
|
||||||
|
wasm_runtime_init();
|
||||||
|
nova64_log("WASM runtime initialized successfully.\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user