支持Os编译

This commit is contained in:
zhangzheng
2023-12-02 20:18:32 +08:00
parent ebde91c418
commit 8c4692ac39
8 changed files with 26 additions and 21 deletions

View File

@@ -35,10 +35,10 @@ target_link_libraries(
PUBLIC
--whole-archive
knl
--no-whole-archive
arch
drv
lib
drv
--no-whole-archive
)
add_dependencies(mkrtos.elf arch)
add_dependencies(mkrtos.elf drv)
@@ -76,4 +76,10 @@ add_custom_target(
${CMAKE_SIZE} mkrtos.elf
)
add_dependencies(mkrtos.elf link_file_dump)
add_dependencies(mkrtos_dump mkrtos.elf)
add_dependencies(mkrtos_dump mkrtos.elf)
add_dependencies(mkrtos_dump knl)
add_dependencies(mkrtos_dump arch)
add_dependencies(mkrtos_dump lib)
add_dependencies(mkrtos_dump drv)

View File

@@ -4,17 +4,17 @@ typedef void (*init_func)(void);
void sys_call_init(void);
#define INIT_LOW_HARD(f) USED __attribute__((__section__(".init_array." \
#define INIT_LOW_HARD(f) static USED __attribute__((__section__(".init_array." \
"102"))) init_func init_##f = f
#define INIT_HIGH_HAD(f) USED __attribute__((__section__(".init_array." \
#define INIT_HIGH_HAD(f) static USED __attribute__((__section__(".init_array." \
"103"))) init_func init_##f = f
#define INIT_MEM(f) USED __attribute__((__section__(".init_array." \
#define INIT_MEM(f) static USED __attribute__((__section__(".init_array." \
"104"))) init_func init_##f = f
#define INIT_KOBJ_MEM(f) USED __attribute__((__section__(".init_array." \
#define INIT_KOBJ_MEM(f) static USED __attribute__((__section__(".init_array." \
"105"))) init_func init_##f = f
#define INIT_KOBJ(f) USED __attribute__((__section__(".init_array." \
#define INIT_KOBJ(f) static USED __attribute__((__section__(".init_array." \
"106"))) init_func init_##f = f
#define INIT_STAGE1(f) USED __attribute__((__section__(".init_array." \
#define INIT_STAGE1(f) static USED __attribute__((__section__(".init_array." \
"107"))) init_func init_##f = f
#define INIT_STAGE2(f) USED __attribute__((__section__(".init_array." \
#define INIT_STAGE2(f) static USED __attribute__((__section__(".init_array." \
"108"))) init_func init_##f = f

View File

@@ -18,7 +18,7 @@
#include "mm_man.h"
#include "ipc.h"
static mem_t global_mem; //!< 全局内存管理块
static uint8_t mem_block[55 * 1024]; //!< 内核内存分配堆 TODO:自动识别大小或者从bootstrap中读取
static uint8_t mem_block[59 * 1024]; //!< 内核内存分配堆 TODO:自动识别大小或者从bootstrap中读取
static kobject_t *kobj_ls[FACTORY_FUNC_MAX]; //!< 全局静态内核对象
void global_reg_kobj(kobject_t *kobj, int inx)

View File

@@ -73,6 +73,7 @@ static void thread_timeout_init(void)
slist_init(&wait_send_queue);
slist_init(&wait_recv_queue);
}
INIT_KOBJ(thread_timeout_init);
/**
@@ -433,6 +434,7 @@ static int thread_ipc_recv(msg_tag_t *ret_msg, ipc_timeout_t timeout, umword_t *
assert(ret_user_id);
thread_t *cur_th = thread_get_current();
umword_t lock_status;
thread_wait_entry_t wait;
lock_status = cpulock_lock();
cur_th->ipc_status = THREAD_RECV; //!< 因为接收挂起
@@ -454,7 +456,6 @@ static int thread_ipc_recv(msg_tag_t *ret_msg, ipc_timeout_t timeout, umword_t *
//!< 加入等待队列
if (timeout.recv_timeout)
{
thread_wait_entry_t wait;
thread_wait_entry_init(&wait, cur_th, timeout.recv_timeout);
slist_add_append(&wait_recv_queue, &wait.node); //!< 放到等待队列中
@@ -855,7 +856,7 @@ static kobject_t *thread_create_func(ram_limit_t *lim, umword_t arg0, umword_t a
* @brief 工厂注册函数
*
*/
void thread_factory_register(void)
static void thread_factory_register(void)
{
factory_register(thread_create_func, THREAD_PROT);
}

View File

@@ -38,10 +38,8 @@ signed short userShellWrite(char *data, unsigned short len)
*/
signed short userShellRead(char *data, unsigned short len)
{
int ret = 0;
while (ret <= 0)
while (cons_read((uint8_t *)data, len) <= 0)
{
ret = cons_read((uint8_t *)data, len);
u_sleep_ms(5);
}
}

View File

@@ -8,7 +8,7 @@
* @copyright Copyright (c) 2023
*
*/
#define HEAP_SIZE 8192
#define HEAP_SIZE 512
#define STACK_SIZE 1024 * 2
#if defined(__CC_ARM)

View File

@@ -1,5 +1,5 @@
#define HEAP_SIZE 1024
#define HEAP_SIZE 512
#define STACK_SIZE 2048
#if defined(__CC_ARM)

View File

@@ -21,20 +21,20 @@ set(CMAKE_SIZE "${CROSS_COMPILE}size" CACHE PATH "" FORCE)
set(MKRTOS_ARCH $ENV{ARCH})
# -mfloat-abi=soft -u _printf_float
set(CMAKE_C_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -O0 -g3 -lc -lrdimon -msoft-float -u _printf_float -D=MKRTOS \
set(CMAKE_C_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -Os -g3 -lc -lrdimon -msoft-float -u _printf_float -D=MKRTOS \
-std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -mfix-cortex-m3-ldrd \
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
-fno-stack-protector -Wl,--gc-sections \
" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "-mcpu=${MKRTOS_ARCH}-mthumb -mno-thumb-interwork -D=MKRTOS \
-mfix-cortex-m3-ldrd -O0 -g -std=c++11 \
-mfix-cortex-m3-ldrd -Os -g3 -std=c++11 \
-fmessage-length=0 -Xlinker --print-map -Wall -W -fno-stack-protector -g \
-mfloat-abi=soft -lc -lrdimon -u _printf_float \
-ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
" CACHE STRING "" FORCE)
set(CMAKE_ASM_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -O0 -g -mfloat-abi=soft -lc -lrdimon -D=MKRTOS \
set(CMAKE_ASM_FLAGS "-mcpu=${MKRTOS_ARCH} -mthumb -Os -g3 -mfloat-abi=soft -lc -lrdimon -D=MKRTOS \
-u _printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector \
" CACHE STRING "" FORCE)