修复tcc编译失败的bug

This commit is contained in:
zhangzheng
2023-12-08 23:55:00 +08:00
parent f3062af123
commit 9e7c1e08ee
12 changed files with 59 additions and 14 deletions

View File

@@ -18,7 +18,7 @@
#include "mm_man.h"
#include "ipc.h"
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]; //!< 全局静态内核对象
/**
* @brief 注册一个全局静态的内核对象

View File

@@ -1,6 +1,6 @@
/**
* @file syscall.c
* @author ATShining (1358745329@qq.com)
* @author zhangzheng (1358745329@qq.com)
* @brief
* @version 0.1
* @date 2023-11-19

View File

@@ -1,7 +1,7 @@
ENTRY(Reset_Handler)
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10M
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32M
FLASH (rx) : ORIGIN = 0x8000000 + 0x2000, LENGTH = 64K - 0x2000
}
SECTIONS

View File

@@ -9,7 +9,7 @@ export INIT_OFFSET=0x10000
export BOOTFS_ADDR_OFFSET=0x20000
export KNL_TEXT=0x8000000
export KNL_DATA=0x20000000
export KNL_DATA_SIZE=10M
export KNL_DATA_SIZE=32M
export BOARD=STM32F2x
export ARCH=cortex-m3
export PYTHON_EXECUTABLE=python3

View File

@@ -3,8 +3,8 @@
typedef struct fd_map_entry
{
uint16_t svr_fd;
uint16_t priv_fd;
uint32_t svr_fd;
uint32_t priv_fd;
uint8_t type;
uint8_t flags;
} fd_map_entry_t;
@@ -15,7 +15,7 @@ enum fd_type
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_free(int fd, fd_map_entry_t *ret_entry);
int fd_map_get(int fd, fd_map_entry_t *new_entry);

View File

@@ -26,7 +26,7 @@ typedef struct 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;

View File

@@ -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)
{
d->data = 0;
d->del_map_flags = 0;
}
//!< end

View File

@@ -52,6 +52,10 @@ static file_desc_t *file_get(int fd)
{
return NULL;
}
if (files[fd].fp.obj.fs == NULL)
{
return NULL;
}
return files + fd;
}
static int fatfs_err_conv(FRESULT res)
@@ -146,8 +150,12 @@ int fs_svr_open(const char *path, int flags, int mode)
// cons_write_str("open file..\n");
}
if (ret != FR_OK)
{
return fatfs_err_conv(ret);
}
return fd;
}
int fs_svr_read(int fd, void *buf, size_t len)
{

View File

@@ -11,14 +11,48 @@
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)\
{\
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);
int wlen = write(fd, tmp, sizeof(tmp)-1);
int i = 1000;
while (i--)
write(fd, tmp, sizeof(tmp) - 1);
// assert(wlen == 4);
// int ret = lseek(fd, 0, SEEK_SET);
// assert(ret >= 0);

View File

@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -DUSE_STDPERIPH_DRIVER=1 \
-DTCC_TARGET_ARM_THUMB -DTCC_ARM_VFP -DTCC_ARM_EABI \
-DCONFIG_TCC_STATIC \
-DCONFIG_TCC_STATIC -DNO_SEMAPHORE_H \
")
# -DTCC_PROFILE
# -DTCC_ARM_HARDFLOAT

View File

@@ -1,5 +1,5 @@
#define HEAP_SIZE 1024*1024*4
#define HEAP_SIZE 1024*1024*3
#define STACK_SIZE 8192
#if defined(__CC_ARM)

View File

@@ -254,6 +254,7 @@ char *fake_argv[] = {
"tcc_armv7m",
"-nostdinc",
"-nostdlib",
"-c",
"/mnt/1.c",
"-o",
"/mnt/a.out"
@@ -271,7 +272,7 @@ int main(int argc0, char **argv0)
redo:
// argc = argc0, argv = argv0;
argc = 6, argv = fake_argv;
argc = 7, argv = fake_argv;
s = s1 = tcc_new();
opt = tcc_parse_args(s, &argc, &argv, 1);