baremetal: second try (with i386-elf-gcc)

This commit is contained in:
2026-02-23 17:59:16 +01:00
parent e426ea39e3
commit 20376acee2
3 changed files with 72 additions and 1012 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,17 +5,17 @@
#include <stdbool.h> #include <stdbool.h>
// #include <assert.h> // #include <assert.h>
// #include <time.h> // #include <time.h>
#include <string.h> // #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> // #include <stdlib.h>
#include <math.h> // #include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <ctype.h> // #include <ctype.h>
#include <pthread.h> // #include <pthread.h>
// #include <signal.h> // #include <signal.h>
#include <semaphore.h> // #include <semaphore.h>
// #include <limits.h> // #include <limits.h>
#include <dirent.h> // #include <dirent.h>
// #include <fcntl.h> // #include <fcntl.h>
// #include <unistd.h> // #include <unistd.h>
// #include <poll.h> // #include <poll.h>
@ -42,11 +42,19 @@ extern "C" {
#define BH_APPLET_PRESERVED_STACK_SIZE (8 * 1024) #define BH_APPLET_PRESERVED_STACK_SIZE (8 * 1024)
#define BH_THREAD_DEFAULT_PRIORITY 0 #define BH_THREAD_DEFAULT_PRIORITY 0
typedef pthread_t korp_tid; typedef int korp_tid;
typedef pthread_mutex_t korp_mutex; typedef struct {
typedef pthread_cond_t korp_cond; int dummy;
typedef pthread_t korp_thread; } korp_mutex;
typedef sem_t korp_sem; typedef struct {
int dummy;
} korp_cond;
typedef struct {
int dummy;
} korp_thread;
typedef struct {
int dummy;
} korp_sem;
// typedef pthread_rwlock_t korp_rwlock; // typedef pthread_rwlock_t korp_rwlock;
typedef struct { typedef struct {
@ -55,7 +63,9 @@ typedef struct {
} korp_rwlock; } korp_rwlock;
typedef int os_file_handle; typedef int os_file_handle;
typedef DIR *os_dir_stream; typedef struct {
int dummy;
} *os_dir_stream;
typedef int os_raw_file_handle; typedef int os_raw_file_handle;
static inline os_file_handle static inline os_file_handle
@ -67,10 +77,17 @@ os_get_invalid_handle(void)
static inline int static inline int
os_getpagesize() os_getpagesize()
{ {
// TODO: What pagesize? // TODO: What pagesize? 65536?
return 4096; return 4096;
} }
void *
memcpy(void *restrict dest, const void *restrict src, size_t n);
void *
memmove(void *dest, const void *src, size_t n);
void *
memset(void *dest, int c, size_t n);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -3,10 +3,10 @@ set (PLATFORM_SHARED_DIR ${CMAKE_CURRENT_LIST_DIR})
add_definitions(-DBH_PLATFORM_BAREMETAL) add_definitions(-DBH_PLATFORM_BAREMETAL)
include_directories(${PLATFORM_SHARED_DIR}) include_directories(${PLATFORM_SHARED_DIR})
include_directories(${PLATFORM_SHARED_DIR}/../include) include_directories(${PLATFORM_SHARED_DIR}/../include)
# file (GLOB header ${PLATFORM_SHARED_DIR}/../include/baremetal/*.h)
# list (APPEND RUNTIME_LIB_HEADER_LIST ${header})
file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c) file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)
set (PLATFORM_SHARED_SOURCE ${source_all}) set (PLATFORM_SHARED_SOURCE ${source_all})
file (GLOB header ${PLATFORM_SHARED_DIR}/../include/baremetal/*.h)
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})