修复tcc编译失败的bug
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
#include "mm_man.h"
|
#include "mm_man.h"
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
static mem_t global_mem; //!< 全局内存管理块
|
static mem_t global_mem; //!< 全局内存管理块
|
||||||
static uint8_t mem_block[9*1024 * 1024]; //!< 内核内存分配堆 TODO:自动识别大小,或者从bootstrap中读取
|
static uint8_t mem_block[31*1024 * 1024]; //!< 内核内存分配堆 TODO:自动识别大小,或者从bootstrap中读取
|
||||||
static kobject_t *kobj_ls[FACTORY_FUNC_MAX]; //!< 全局静态内核对象
|
static kobject_t *kobj_ls[FACTORY_FUNC_MAX]; //!< 全局静态内核对象
|
||||||
/**
|
/**
|
||||||
* @brief 注册一个全局静态的内核对象
|
* @brief 注册一个全局静态的内核对象
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @file syscall.c
|
* @file syscall.c
|
||||||
* @author ATShining (1358745329@qq.com)
|
* @author zhangzheng (1358745329@qq.com)
|
||||||
* @brief
|
* @brief
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @date 2023-11-19
|
* @date 2023-11-19
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
ENTRY(Reset_Handler)
|
ENTRY(Reset_Handler)
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10M
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32M
|
||||||
FLASH (rx) : ORIGIN = 0x8000000 + 0x2000, LENGTH = 64K - 0x2000
|
FLASH (rx) : ORIGIN = 0x8000000 + 0x2000, LENGTH = 64K - 0x2000
|
||||||
}
|
}
|
||||||
SECTIONS
|
SECTIONS
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export INIT_OFFSET=0x10000
|
|||||||
export BOOTFS_ADDR_OFFSET=0x20000
|
export BOOTFS_ADDR_OFFSET=0x20000
|
||||||
export KNL_TEXT=0x8000000
|
export KNL_TEXT=0x8000000
|
||||||
export KNL_DATA=0x20000000
|
export KNL_DATA=0x20000000
|
||||||
export KNL_DATA_SIZE=10M
|
export KNL_DATA_SIZE=32M
|
||||||
export BOARD=STM32F2x
|
export BOARD=STM32F2x
|
||||||
export ARCH=cortex-m3
|
export ARCH=cortex-m3
|
||||||
export PYTHON_EXECUTABLE=python3
|
export PYTHON_EXECUTABLE=python3
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
typedef struct fd_map_entry
|
typedef struct fd_map_entry
|
||||||
{
|
{
|
||||||
uint16_t svr_fd;
|
uint32_t svr_fd;
|
||||||
uint16_t priv_fd;
|
uint32_t priv_fd;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
} fd_map_entry_t;
|
} fd_map_entry_t;
|
||||||
@@ -15,7 +15,7 @@ enum fd_type
|
|||||||
FD_FS,
|
FD_FS,
|
||||||
};
|
};
|
||||||
|
|
||||||
int fd_map_alloc(uint16_t svr_fd, uint16_t priv_fd, enum fd_type type);
|
int fd_map_alloc(uint32_t svr_fd, uint32_t priv_fd, enum fd_type type);
|
||||||
int fd_map_update(int fd, fd_map_entry_t *new_entry);
|
int fd_map_update(int fd, fd_map_entry_t *new_entry);
|
||||||
int fd_map_free(int fd, fd_map_entry_t *ret_entry);
|
int fd_map_free(int fd, fd_map_entry_t *ret_entry);
|
||||||
int fd_map_get(int fd, fd_map_entry_t *new_entry);
|
int fd_map_get(int fd, fd_map_entry_t *new_entry);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ typedef struct fd_map
|
|||||||
|
|
||||||
static fd_map_t fd_map;
|
static fd_map_t fd_map;
|
||||||
|
|
||||||
int fd_map_alloc(uint16_t svr_fd, uint16_t priv_fd, enum fd_type type)
|
int fd_map_alloc(uint32_t svr_fd, uint32_t priv_fd, enum fd_type type)
|
||||||
{
|
{
|
||||||
int alloc_fd = 0;
|
int alloc_fd = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -434,6 +434,8 @@ RPC_SVR_BUF_TO_MSG_WITHOUT_IMPL(rpc_obj_handler_t_t, int)
|
|||||||
*/
|
*/
|
||||||
RPC_TYPE_INIT_WITHOUT_IMPL(rpc_obj_handler_t_t)
|
RPC_TYPE_INIT_WITHOUT_IMPL(rpc_obj_handler_t_t)
|
||||||
{
|
{
|
||||||
|
d->data = 0;
|
||||||
|
d->del_map_flags = 0;
|
||||||
}
|
}
|
||||||
//!< end
|
//!< end
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ static file_desc_t *file_get(int fd)
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (files[fd].fp.obj.fs == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return files + fd;
|
return files + fd;
|
||||||
}
|
}
|
||||||
static int fatfs_err_conv(FRESULT res)
|
static int fatfs_err_conv(FRESULT res)
|
||||||
@@ -146,7 +150,11 @@ int fs_svr_open(const char *path, int flags, int mode)
|
|||||||
// cons_write_str("open file..\n");
|
// cons_write_str("open file..\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return fatfs_err_conv(ret);
|
if (ret != FR_OK)
|
||||||
|
{
|
||||||
|
return fatfs_err_conv(ret);
|
||||||
|
}
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fs_svr_read(int fd, void *buf, size_t len)
|
int fs_svr_read(int fd, void *buf, size_t len)
|
||||||
|
|||||||
@@ -11,14 +11,48 @@
|
|||||||
|
|
||||||
void fs_test(void)
|
void fs_test(void)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
static char tmp[] = "\
|
||||||
|
int a=2;\
|
||||||
|
int b=2;\
|
||||||
|
\
|
||||||
|
int add(int a, int b)\
|
||||||
|
{\
|
||||||
|
return a+b;\
|
||||||
|
}\
|
||||||
|
int sub(int a, int b)\
|
||||||
|
{\
|
||||||
|
return a-b;\
|
||||||
|
}\
|
||||||
|
int _start(void)\
|
||||||
|
{\
|
||||||
|
sub(10, 2);\
|
||||||
|
add(10, 2);\
|
||||||
|
return a+b;\
|
||||||
|
}\
|
||||||
|
";
|
||||||
|
int fd = open("/mnt/1.c", O_CREAT | O_RDWR, 0777);
|
||||||
|
assert(fd >= 0);
|
||||||
|
int wlen = write(fd, tmp, sizeof(tmp) - 1);
|
||||||
|
// assert(wlen == 4);
|
||||||
|
// int ret = lseek(fd, 0, SEEK_SET);
|
||||||
|
// assert(ret >= 0);
|
||||||
|
// int rlen = read(fd, tmp, 4);
|
||||||
|
// assert(rlen == 4);
|
||||||
|
// assert(strcmp(tmp, "123") == 0);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
char tmp[] = "int _start(void)\
|
char tmp[] = "int _start(void)\
|
||||||
{\
|
{\
|
||||||
return 3;\
|
return 3;\
|
||||||
}";
|
}";
|
||||||
int fd = open("/mnt/1.c", O_CREAT | O_RDWR, 0777);
|
int fd = open("/mnt/2.c", O_CREAT | O_RDWR, 0777);
|
||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
int wlen = write(fd, tmp, sizeof(tmp)-1);
|
int i = 1000;
|
||||||
|
|
||||||
|
while (i--)
|
||||||
|
write(fd, tmp, sizeof(tmp) - 1);
|
||||||
// assert(wlen == 4);
|
// assert(wlen == 4);
|
||||||
// int ret = lseek(fd, 0, SEEK_SET);
|
// int ret = lseek(fd, 0, SEEK_SET);
|
||||||
// assert(ret >= 0);
|
// assert(ret >= 0);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.13)
|
|||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -DUSE_STDPERIPH_DRIVER=1 \
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -DUSE_STDPERIPH_DRIVER=1 \
|
||||||
-DTCC_TARGET_ARM_THUMB -DTCC_ARM_VFP -DTCC_ARM_EABI \
|
-DTCC_TARGET_ARM_THUMB -DTCC_ARM_VFP -DTCC_ARM_EABI \
|
||||||
-DCONFIG_TCC_STATIC \
|
-DCONFIG_TCC_STATIC -DNO_SEMAPHORE_H \
|
||||||
")
|
")
|
||||||
# -DTCC_PROFILE
|
# -DTCC_PROFILE
|
||||||
# -DTCC_ARM_HARDFLOAT
|
# -DTCC_ARM_HARDFLOAT
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#define HEAP_SIZE 1024*1024*4
|
#define HEAP_SIZE 1024*1024*3
|
||||||
#define STACK_SIZE 8192
|
#define STACK_SIZE 8192
|
||||||
|
|
||||||
#if defined(__CC_ARM)
|
#if defined(__CC_ARM)
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ char *fake_argv[] = {
|
|||||||
"tcc_armv7m",
|
"tcc_armv7m",
|
||||||
"-nostdinc",
|
"-nostdinc",
|
||||||
"-nostdlib",
|
"-nostdlib",
|
||||||
|
"-c",
|
||||||
"/mnt/1.c",
|
"/mnt/1.c",
|
||||||
"-o",
|
"-o",
|
||||||
"/mnt/a.out"
|
"/mnt/a.out"
|
||||||
@@ -271,7 +272,7 @@ int main(int argc0, char **argv0)
|
|||||||
|
|
||||||
redo:
|
redo:
|
||||||
// argc = argc0, argv = argv0;
|
// argc = argc0, argv = argv0;
|
||||||
argc = 6, argv = fake_argv;
|
argc = 7, argv = fake_argv;
|
||||||
s = s1 = tcc_new();
|
s = s1 = tcc_new();
|
||||||
opt = tcc_parse_args(s, &argc, &argv, 1);
|
opt = tcc_parse_args(s, &argc, &argv, 1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user