修复用户态ipc错误&修改hello为uvmm

This commit is contained in:
zhangzheng
2024-08-04 14:35:25 +08:00
parent 83d4f88de6
commit 1132f9997e
48 changed files with 568 additions and 136 deletions

6
.vscode/launch.json vendored
View File

@@ -48,13 +48,13 @@
"externalConsole": false,
// "miDebuggerPath": "/opt/homebrew/bin/arm-none-eabi-gdb",
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
"miDebuggerPath": "/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/aarch64-none-elf-gdb",
// "miDebuggerPath": "/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/aarch64-none-elf-gdb",
// "miDebuggerPath": "/home/zhangzheng/gcc-arm/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
// "miDebuggerPath": "/home/mkrtos-smart/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
// "miDebuggerPath": "/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
"miDebuggerServerAddress": "127.0.0.1:3333",
"miDebuggerPath": "/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
"miDebuggerServerAddress": "127.0.0.1:33333",
"MIMode": "gdb",
"setupCommands": [
{

View File

@@ -95,7 +95,8 @@
"uvmm_devtree.h": "c",
"vgic.h": "c",
"aarch64_emul.h": "c",
"uvmm_host_irqs.h": "c"
"uvmm_host_irqs.h": "c",
"stdio.h": "c"
},
"cortex-debug.showRTOS": false,
"cortex-debug.variableUseNaturalFormat": false,

View File

@@ -125,7 +125,7 @@ if ((DEFINED CONFIG_MMU) AND (CONFIG_MMU STREQUAL "y"))
sh_dump_elf
cpiofs_dump_elf
net_dump_elf
hello_dump_elf
uvmm_dump_elf
)
set_source_files_properties(${CMAKE_SOURCE_DIR}/build/output/rootfs.cpio.elf PROPERTIES EXTERNAL_OBJECT true)
add_executable(bootstrap.elf

View File

@@ -30,9 +30,9 @@ typedef struct thread thread_t;
#define MSG_BUF_RECV_R_FLAGS 0x02U //!< 接收来自recv_th的消息
#define MSG_BUF_REPLY_FLAGS 0x04U //!< 回复消息给send_th
#define IPC_MSG_SIZE CONFIG_THREAD_IPC_MSG_LEN
#define MAP_BUF_SIZE CONFIG_THREAD_MAP_BUF_LEN
#define IPC_USER_SIZE CONFIG_THREAD_USER_BUF_LEN
#define IPC_MSG_SIZE (CONFIG_THREAD_IPC_MSG_LEN * sizeof(void*))
#define MAP_BUF_SIZE (CONFIG_THREAD_MAP_BUF_LEN * sizeof(void*))
#define IPC_USER_SIZE (CONFIG_THREAD_USER_BUF_LEN * sizeof(void*))
#if IS_ENABLED(CONFIG_VCPU)
#define IPC_VPUC_MSG_OFFSET (3 * 1024) //!< vcpu 传递消息的偏移量
@@ -48,9 +48,9 @@ typedef struct ipc_msg
{
struct
{
umword_t msg_buf[IPC_MSG_SIZE];
umword_t map_buf[MAP_BUF_SIZE];
umword_t user[IPC_USER_SIZE]; //!< 0:pthread使用 1:存放私有信息 2:源端的PID号 3:存放私有信息
umword_t msg_buf[CONFIG_THREAD_IPC_MSG_LEN];
umword_t map_buf[CONFIG_THREAD_MAP_BUF_LEN];
umword_t user[CONFIG_THREAD_USER_BUF_LEN]; //!< 0:pthread使用 1:存放私有信息 2:源端的PID号 3:存放私有信息
};
uint8_t data[THREAD_MSG_BUG_LEN];
};

View File

@@ -2,14 +2,14 @@
# export TOOLCHAIN=/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
export TOOLCHAIN=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/
export TOOLCHAIN_LIB=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/lib/gcc/aarch64-none-elf/11.3.1
# export TOOLCHAIN=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/Applications/ArmGNUToolchain/11.3.rel1/aarch64-none-elf/lib/gcc/aarch64-none-elf/11.3.1
# export TOOLCHAIN=/home/zhangzheng/arm-gnu-toolchain-13.3.rel1-aarch64-aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/arm-gnu-toolchain-13.3.rel1-aarch64-aarch64-none-elf/lib/gcc/aarch64-none-elf/13.3.1
# export TOOLCHAIN=/home/mkrtos-smart/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/mkrtos-smart/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
# export TOOLCHAIN=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
# export TOOLCHAIN_LIB=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
export TOOLCHAIN=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/
export TOOLCHAIN_LIB=/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/10.3.1
export BOARD=aarch64_qemu
export CROSS_COMPILE_NAME=aarch64-none-elf-

View File

@@ -7,9 +7,9 @@
#define MSG_BUF_RECV_R_FLAGS 0x02U //!< 接收上次发送数据的接收者
#define MSG_BUF_REPLY_FLAGS 0x04U //!<
#define IPC_MSG_SIZE CONFIG_THREAD_IPC_MSG_LEN //!< IPC消息大小
#define MAP_BUF_SIZE CONFIG_THREAD_MAP_BUF_LEN //!< 映射消息大小
#define IPC_USER_SIZE CONFIG_THREAD_USER_BUF_LEN //!< 用户态消息大小
#define IPC_MSG_SIZE (CONFIG_THREAD_IPC_MSG_LEN * sizeof(void*))
#define MAP_BUF_SIZE (CONFIG_THREAD_MAP_BUF_LEN * sizeof(void*))
#define IPC_USER_SIZE (CONFIG_THREAD_USER_BUF_LEN * sizeof(void*))
#if IS_ENABLED(CONFIG_VCPU)
#define IPC_VPUC_MSG_OFFSET (3 * 1024) //!< vcpu 传递消息的偏移量
@@ -21,9 +21,9 @@ typedef struct ipc_msg
{
struct
{
umword_t msg_buf[IPC_MSG_SIZE];
umword_t map_buf[MAP_BUF_SIZE];
umword_t user[IPC_USER_SIZE]; // 0 pthread使用 1驱动使用 2 ipc通信时存储目标的pid
umword_t msg_buf[CONFIG_THREAD_IPC_MSG_LEN];
umword_t map_buf[CONFIG_THREAD_MAP_BUF_LEN];
umword_t user[CONFIG_THREAD_USER_BUF_LEN]; // 0 pthread使用 1驱动使用 2 ipc通信时存储目标的pid
};
uint8_t data[MSG_BUG_LEN];
};

View File

@@ -0,0 +1,12 @@
#pragma once
#include <u_rpc.h>
#include <u_thread.h>
#if CONFIG_THREAD_MSG_BUG_LEN == 128
#define rpc_ref_file_array_t rpc_ref_array_uint32_t_uint8_t_400_t
#define rpc_file_array_t rpc_array_uint32_t_uint8_t_400_t
#else
#define rpc_ref_file_array_t rpc_ref_array_uint32_t_uint8_t_32_t
#define rpc_file_array_t rpc_array_uint32_t_uint8_t_32_t
#endif

View File

@@ -6,13 +6,15 @@
#include "u_prot.h"
#include "u_hd_man.h"
#include "ns_cli.h"
#include "u_rpc.h"
#include "fs_types.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
/*open*/
RPC_GENERATION_CALL3(fs_t, FS_PROT, FS_OPEN, open,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, flags,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, mode)
sd_t fs_open(const char *path, int flags, int mode)
@@ -25,7 +27,7 @@ sd_t fs_open(const char *path, int flags, int mode)
return ret;
}
rpc_ref_array_uint32_t_uint8_t_32_t rpc_path = {
rpc_ref_file_array_t rpc_path = {
.data = (uint8_t *)(&path[ret]),
.len = strlen(&path[ret]) + 1,
};
@@ -47,7 +49,7 @@ sd_t fs_open(const char *path, int flags, int mode)
/*read*/
RPC_GENERATION_CALL3(fs_t, FS_PROT, FS_READ, read,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, fd,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_OUT, RPC_TYPE_DATA, buf,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_OUT, RPC_TYPE_DATA, buf,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, len)
int fs_read(sd_t _fd, void *buf, size_t len)
@@ -65,7 +67,7 @@ int fs_read(sd_t _fd, void *buf, size_t len)
int r_once_len = 0;
r_once_len = MIN(32, len - rlen);
rpc_ref_array_uint32_t_uint8_t_32_t rpc_buf = {
rpc_ref_file_array_t rpc_buf = {
.data = buf + rlen,
.len = r_once_len,
};
@@ -90,7 +92,7 @@ int fs_read(sd_t _fd, void *buf, size_t len)
/*write*/
RPC_GENERATION_CALL3(fs_t, FS_PROT, FS_WRITE, write,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, fd,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, buf,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, buf,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, len)
int fs_write(sd_t _fd, void *buf, size_t len)
@@ -107,7 +109,7 @@ int fs_write(sd_t _fd, void *buf, size_t len)
int w_once_len = 0;
w_once_len = MIN(32, len - wlen);
rpc_ref_array_uint32_t_uint8_t_32_t rpc_buf = {
rpc_ref_file_array_t rpc_buf = {
.data = buf + wlen,
.len = w_once_len,
};
@@ -207,16 +209,16 @@ int fs_readdir(sd_t _fd, dirent_t *dirent)
return msg_tag_get_val(tag);
}
RPC_GENERATION_CALL2(fs_t, FS_PROT, FS_SYMLINK, symlink,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, src,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, dst)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, src,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, dst)
int fs_symlink(const char *src, const char *dst)
{
rpc_ref_array_uint32_t_uint8_t_32_t rpc_src = {
rpc_ref_file_array_t rpc_src = {
.data = (uint8_t *)src,
.len = strlen(src) + 1,
};
rpc_ref_array_uint32_t_uint8_t_32_t rpc_dst = {
rpc_ref_file_array_t rpc_dst = {
.data = (uint8_t *)dst,
.len = strlen(dst) + 1,
};

View File

@@ -3,11 +3,13 @@
#include "u_rpc_svr.h"
#include "u_hd_man.h"
#include "fs_svr.h"
#include "u_rpc.h"
#include "fs_types.h"
#include <stdio.h>
/*open*/
RPC_GENERATION_OP3(fs_t, FS_PROT, FS_OPEN, open,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, flags,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, mode)
{
@@ -17,13 +19,13 @@ RPC_GENERATION_OP3(fs_t, FS_PROT, FS_OPEN, open,
}
RPC_GENERATION_DISPATCH3(fs_t, FS_PROT, FS_OPEN, open,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, flags,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, mode)
/*read*/
RPC_GENERATION_OP3(fs_t, FS_PROT, FS_READ, read,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, fd,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_OUT, RPC_TYPE_DATA, buf,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_OUT, RPC_TYPE_DATA, buf,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, len)
{
int ret = fs_svr_read(fd->data, buf->data, len->data);
@@ -37,13 +39,13 @@ RPC_GENERATION_OP3(fs_t, FS_PROT, FS_READ, read,
RPC_GENERATION_DISPATCH3(fs_t, FS_PROT, FS_READ, read,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, fd,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_OUT, RPC_TYPE_DATA, buf,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_OUT, RPC_TYPE_DATA, buf,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, len)
/*write*/
RPC_GENERATION_OP3(fs_t, FS_PROT, FS_WRITE, write,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, fd,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, buf,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, buf,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, len)
{
int ret = fs_svr_write(fd->data, buf->data, len->data);
@@ -52,7 +54,7 @@ RPC_GENERATION_OP3(fs_t, FS_PROT, FS_WRITE, write,
RPC_GENERATION_DISPATCH3(fs_t, FS_PROT, FS_WRITE, write,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, fd,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, buf,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, buf,
rpc_int_t, rpc_int_t, RPC_DIR_IN, RPC_TYPE_DATA, len)
/*close*/
@@ -118,28 +120,28 @@ RPC_GENERATION_DISPATCH2(fs_t, FS_PROT, FS_READDIR, readdir,
/*mkdir*/
RPC_GENERATION_OP1(fs_t, FS_PROT, FS_MKDIR, mkdir,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
{
path->data[path->len - 1] = 0;
return fs_svr_mkdir(path->data);
}
RPC_GENERATION_DISPATCH1(fs_t, FS_PROT, FS_MKDIR, mkdir,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
/*unlink*/
RPC_GENERATION_OP1(fs_t, FS_PROT, FS_UNLINK, unlink,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
{
path->data[path->len - 1] = 0;
return fs_svr_unlink(path->data);
}
RPC_GENERATION_DISPATCH1(fs_t, FS_PROT, FS_UNLINK, unlink,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, path)
/*rename*/
RPC_GENERATION_OP2(fs_t, FS_PROT, FS_RENAME, rename,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, oldpath,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, newpath)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, oldpath,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, newpath)
{
oldpath->data[oldpath->len - 1] = 0;
newpath->data[newpath->len - 1] = 0;
@@ -147,8 +149,8 @@ RPC_GENERATION_OP2(fs_t, FS_PROT, FS_RENAME, rename,
}
RPC_GENERATION_DISPATCH2(fs_t, FS_PROT, FS_RENAME, rename,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, oldpath,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, newpath)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, oldpath,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, newpath)
/*fstat*/
RPC_GENERATION_OP2(fs_t, FS_PROT, FS_STAT, fstat,
@@ -164,8 +166,8 @@ RPC_GENERATION_DISPATCH2(fs_t, FS_PROT, FS_STAT, fstat,
/*symlink*/
RPC_GENERATION_OP2(fs_t, FS_PROT, FS_SYMLINK, symlink,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, src,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, dst)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, src,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, dst)
{
src->data[src->len - 1] = 0;
dst->data[dst->len - 1] = 0;
@@ -173,8 +175,8 @@ RPC_GENERATION_OP2(fs_t, FS_PROT, FS_SYMLINK, symlink,
}
RPC_GENERATION_DISPATCH2(fs_t, FS_PROT, FS_SYMLINK, symlink,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, src,
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, dst)
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, src,
rpc_ref_file_array_t, rpc_file_array_t, RPC_DIR_IN, RPC_TYPE_DATA, dst)
/*dispatch*/
RPC_DISPATCH13(fs_t, FS_PROT, typeof(FS_OPEN), FS_OPEN, open, FS_READ, read,

View File

@@ -301,6 +301,11 @@ RPC_TYPE_DEF_ALL(stat_t)
*
*/
RPC_ARRAY_DEF(uint32_t, uint8_t, 32)
RPC_ARRAY_DEF(uint32_t, uint8_t, 64)
RPC_ARRAY_DEF(uint32_t, uint8_t, 128)
RPC_ARRAY_DEF(uint32_t, uint8_t, 256)
RPC_ARRAY_DEF(uint32_t, uint8_t, 400)
RPC_ARRAY_DEF(uint32_t, uint8_t, 512)
/**
* @brief 引用类型的数组定义,数组的数据来自其它地方
@@ -373,6 +378,8 @@ RPC_REF_ARRAY_DEF(uint32_t, uint8_t, 48)
RPC_REF_ARRAY_DEF(uint32_t, uint8_t, 64)
RPC_REF_ARRAY_DEF(uint32_t, uint8_t, 128)
RPC_REF_ARRAY_DEF(uint32_t, uint8_t, 256)
RPC_REF_ARRAY_DEF(uint32_t, uint8_t, 400)
RPC_REF_ARRAY_DEF(uint32_t, uint8_t, 512)
/**
* @brief Construct a new rpc type def object

View File

@@ -28,7 +28,7 @@ elseif(${CONFIG_ARCH} STREQUAL "aarch64" )
${CMAKE_SOURCE_DIR}/build/libc/output/lib/crtn.o
)
add_subdirectory(hello)
add_subdirectory(uvmm)
add_subdirectory(test)
endif()
add_subdirectory(init)

View File

@@ -2,4 +2,4 @@ cmake_minimum_required(VERSION 3.13)
add_subdirectory(cpiofs)
# add_subdirectory(fatfs)
add_subdirectory(fatfs)

View File

@@ -7,6 +7,7 @@
#include "u_rpc.h"
#include "u_rpc_svr.h"
#include "u_sys.h"
#include "fs_rpc.h"
#include <assert.h>
#include <dirent.h>
#include <errno.h>
@@ -15,7 +16,8 @@
#include <string.h>
static fs_t fs;
typedef struct file_desc {
typedef struct file_desc
{
pid_t pid;
addr_t file_addr;
size_t file_size;
@@ -24,46 +26,58 @@ typedef struct file_desc {
char open_name[32];
} file_desc_t;
#define FD_OFFSET_INX 4
#define CPIO_FS_FD_NR 8
static file_desc_t fds[CPIO_FS_FD_NR];
static file_desc_t *fd_alloc(addr_t file_addr, size_t file_size, ssize_t offset, int *fd, int type)
static file_desc_t *fd_alloc(int pid, addr_t file_addr, size_t file_size, ssize_t offset, int *fd, int type)
{
for (int i = 0; i < CPIO_FS_FD_NR; i++) {
if (fds[i].file_addr == 0) {
fds[i].pid = thread_get_src_pid();
for (int i = 0; i < CPIO_FS_FD_NR; i++)
{
if (fds[i].file_addr == 0)
{
fds[i].pid = pid;
fds[i].file_addr = file_addr;
fds[i].file_size = file_size;
fds[i].offset = offset;
fds[i].type = type;
if (fd) {
*fd = i;
if (fd)
{
*fd = i + FD_OFFSET_INX;
}
return fds + i;
}
}
return NULL;
}
static file_desc_t *fd_get(int fd)
static file_desc_t *fd_get(int pid, int fd)
{
if (fd < 0 || fd >= CPIO_FS_FD_NR) {
fd -= FD_OFFSET_INX;
if (fd < 0 || fd >= CPIO_FS_FD_NR)
{
return NULL;
}
if (fds[fd].file_addr == 0) {
if (fds[fd].file_addr == 0)
{
return NULL;
}
if (fds[fd].pid != thread_get_src_pid()) {
if (fds[fd].pid != pid)
{
return NULL;
}
return &fds[fd];
}
static void fd_free(int fd)
{
if (fd < 0 || fd >= CPIO_FS_FD_NR) {
fd -= FD_OFFSET_INX;
if (fd < 0 || fd >= CPIO_FS_FD_NR)
{
return;
}
if (fds[fd].file_addr) {
if (fds[fd].pid == thread_get_src_pid()) {
if (fds[fd].file_addr)
{
if (fds[fd].pid == thread_get_src_pid())
{
fds[fd].file_addr = 0;
fds[fd].pid = -1;
}
@@ -81,55 +95,74 @@ void fs_svr_init(void)
}
int fs_svr_open(const char *path, int flags, int mode)
{
int pid = thread_get_src_pid();
msg_tag_t tag;
char *o_path;
if (flags & O_RDWR) {
if (flags & O_RDWR)
{
return -EACCES;
}
if (flags & O_WRONLY) {
if (flags & O_WRONLY)
{
return -EACCES;
}
if (path[0] == '/') {
if (path[0] == '/')
{
path++;
}
#if FS_DEBUG
printf("[cpiofs][%d] open %s.\n", pid, path);
#endif
umword_t size;
int type;
umword_t addr;
int ret = cpio_find_file((umword_t)sys_info.bootfs_start_addr,
(umword_t)(-1), path, &size, &type, &addr);
if (ret < 0) {
if (ret < 0)
{
#if FS_DEBUG
printf("[cpiofs] not find %s.\n", path);
#endif
return -ENOENT;
}
int fd;
// 找到指定文件
file_desc_t *fdp = fd_alloc(addr, size, 0, &fd, type);
file_desc_t *fdp = fd_alloc(pid, addr, size, 0, &fd, type);
if (!fdp) {
if (!fdp)
{
#if FS_DEBUG
printf("[cpiofs] not fd %s.\n", path);
#endif
return -ENOMEM;
}
strncpy(fdp->open_name, path, 32);
fdp->open_name[32 - 1] = 0;
#if FS_DEBUG
printf("[cpiofs] open success %s, fd is %d.\n", path, fd);
#endif
return fd;
}
int fs_svr_read(int fd, void *buf, size_t len)
{
file_desc_t *fdp = fd_get(fd);
file_desc_t *fdp = fd_get(thread_get_src_pid(), fd);
if (!fdp) {
if (!fdp)
{
return -ENOENT;
}
if (fdp->type != 0) {
if (fdp->type != 0)
{
return -EACCES;
}
size_t remain_size = fdp->file_size - fdp->offset;
size_t read_size = 0;
read_size = MIN(remain_size, len);
if (read_size) {
if (read_size)
{
memcpy(buf, (void *)(fdp->file_addr + fdp->offset), read_size);
fdp->offset += read_size;
}
@@ -137,9 +170,10 @@ int fs_svr_read(int fd, void *buf, size_t len)
}
int fs_svr_write(int fd, void *buf, size_t len)
{
file_desc_t *fdp = fd_get(fd);
file_desc_t *fdp = fd_get(thread_get_src_pid(), fd);
if (!fdp) {
if (!fdp)
{
return -ENOENT;
}
return -EACCES;
@@ -150,32 +184,41 @@ void fs_svr_close(int fd)
}
int fs_svr_lseek(int fd, int offs, int whence)
{
file_desc_t *file = fd_get(fd);
file_desc_t *file = fd_get(thread_get_src_pid(), fd);
int new_offs = 0;
if (!file) {
if (!file)
{
return -ENOENT;
}
if (file->type != 0) {
if (file->type != 0)
{
return -EACCES;
}
switch (whence) {
switch (whence)
{
case SEEK_SET:
new_offs = offs;
break;
case SEEK_END: {
case SEEK_END:
{
new_offs = file->file_size + offs;
} break;
case SEEK_CUR: {
}
break;
case SEEK_CUR:
{
new_offs = offs + file->offset;
} break;
}
break;
default:
return -EINVAL;
}
if (new_offs > file->file_size) {
if (new_offs > file->file_size)
{
new_offs = file->file_size;
}
if (new_offs < 0) {
if (new_offs < 0)
{
new_offs = 0;
}
file->offset = new_offs;
@@ -192,24 +235,36 @@ void fs_svr_sync(int fd)
int fs_svr_readdir(int fd, dirent_t *dir)
{
file_desc_t *file = fd_get(fd);
int pid = thread_get_src_pid();
file_desc_t *file = fd_get(pid ,fd);
int new_offs = 0;
if (!file) {
#if FS_DEBUG
printf("[cpiofs] readdir fd is %d.\n", fd);
#endif
if (!file)
{
return -ENOENT;
}
if (file->type != 1) {
if (file->type != 1)
{
return -EACCES;
}
umword_t size;
int type;
umword_t next_addr;
const char *next_path;
int ret = cpio_find_next(file->file_addr, file->open_name, &size, &type, &next_addr, &next_path);
if (ret < 0) {
if (ret < 0)
{
return -ENOENT;
}
#if FS_DEBUG
printf("[cpiofs] readdir %s.\n", next_path);
#endif
file->file_addr = next_addr;
dir->d_reclen = sizeof(*dir);
strncpy(dir->d_name, next_path, sizeof(dir->d_name));
@@ -232,9 +287,10 @@ int fs_svr_renmae(char *oldname, char *newname)
}
int fs_svr_fstat(int fd, stat_t *stat)
{
file_desc_t *file = fd_get(fd);
file_desc_t *file = fd_get(thread_get_src_pid(), fd);
if (!file) {
if (!file)
{
return -ENOENT;
}
stat->st_size = file->file_size;

View File

@@ -1,4 +1,6 @@
#pragma once
#define FS_DEBUG 0
void fs_svr_init(void);
void fs_svr_loop(void);

View File

@@ -22,7 +22,6 @@ int main(int argv, char *args[])
fs_svr_init();
ns_register("/bin", hd, MOUNT_NODE);
cons_write_str("cpiofs mount success\n");
// *((char *)0) = 0;
fs_svr_loop();
return 0;

View File

@@ -15,16 +15,18 @@ file(
add_executable(
fatfs.elf
${deps}
${START_SRC}
)
target_link_libraries(
fatfs.elf
PUBLIC
start
muslc
-Bstatic
${LIBC_NAME}
${START_LIB}
sys
sys_util
sys_svr
stm32f1_bsp
# stm32f1_bsp
${GCC_LIB_PATH}/libgcc.a
)
target_include_directories(
@@ -33,14 +35,6 @@ target_include_directories(
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/inc
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/arm/
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/generic
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/src/internal
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/include
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/internal
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/include
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/include
${CMAKE_SOURCE_DIR}/mkrtos_user/server/fs/fatfs/ff15/source
${CMAKE_SOURCE_DIR}/mkrtos_user/server/fs/fatfs
@@ -50,15 +44,14 @@ target_include_directories(
)
add_dependencies(
fatfs.elf
start
muslc
${START_LIB}
sys
sys_util
stm32f1_bsp
# stm32f1_bsp
)
set_target_properties(
fatfs.elf PROPERTIES LINK_FLAGS
"-T ${CMAKE_CURRENT_LIST_DIR}/link.lds -pie --gc-section -no-dynamic-linker "
"-T ${CMAKE_CURRENT_LIST_DIR}/${ARCH_NAME}/link.lds ${CORTEX_M_LINK_FLAGS} --gc-section -no-dynamic-linker "
#--no-warn-rwx-segments
)
add_custom_target(
@@ -73,10 +66,10 @@ add_custom_target(
${CMAKE_SIZE} fatfs.elf
COMMAND
mkdir -p ${CMAKE_SOURCE_DIR}/build/output/cpio
# COMMAND
# cp fatfs.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs
COMMAND
cp fatfs.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs
COMMAND
cp fatfs.elf ${CMAKE_SOURCE_DIR}/build/output/fatfs.elf
cp fatfs.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/fatfs.elf
)
add_dependencies(fatfs_dump fatfs.elf)

View File

@@ -0,0 +1,233 @@
/* Script for -z combreloc */
/* Copyright (C) 2014-2021 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64",
"elf64-littleaarch64")
OUTPUT_ARCH(aarch64)
ENTRY(_start)
SEARCH_DIR("//aarch64-none-elf/lib");
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x02000000)); . = SEGMENT_START("text-segment", 0x02000000);
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
*(.rela.ifunc)
}
.rela.plt :
{
*(.rela.plt)
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
.init :
{
KEEP (*(SORT_NONE(.init)))
} =0x1f2003d5
.plt : { *(.plt) *(.iplt) }
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(SORT(.text.sorted.*))
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf.em. */
*(.gnu.warning)
. = ALIGN(4);
_shell_command_start = .;
KEEP(*(shellCommand))
_shell_command_end = .;
} =0x1f2003d5
.fini :
{
KEEP (*(SORT_NONE(.fini)))
} =0x1f2003d5
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
.gnu_extab : ONLY_IF_RO { *(.gnu_extab*) }
/* These sections are generated by the Sun/Oracle C++ compiler. */
.exception_ranges : ONLY_IF_RO { *(.exception_ranges*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
.exception_ranges : ONLY_IF_RW { *(.exception_ranges*) }
/* Thread Local Storage sections */
.tdata :
{
PROVIDE_HIDDEN (__tdata_start = .);
*(.tdata .tdata.* .gnu.linkonce.td.*)
}
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
.got : { *(.got) *(.igot) }
.got.plt : { *(.got.plt) *(.igot.plt) }
.data :
{
__data_start = .;
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
. = .;
__bss_start = .;
__bss_start__ = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we do not
pad the .data section. */
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
_bss_end__ = .; __bss_end__ = .;
. = ALIGN(64 / 8);
. = SEGMENT_START("ldata-segment", .);
. = ALIGN(64 / 8);
__end__ = .;
_end = .; PROVIDE (end = .);
.stack 0x80000 :
{
_stack = .;
*(.stack)
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1. */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions. */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2. */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2. */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions. */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3. */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/* DWARF 5. */
.debug_addr 0 : { *(.debug_addr) }
.debug_line_str 0 : { *(.debug_line_str) }
.debug_loclists 0 : { *(.debug_loclists) }
.debug_macro 0 : { *(.debug_macro) }
.debug_names 0 : { *(.debug_names) }
.debug_rnglists 0 : { *(.debug_rnglists) }
.debug_str_offsets 0 : { *(.debug_str_offsets) }
.debug_sup 0 : { *(.debug_sup) }
.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}

View File

@@ -0,0 +1,124 @@
ENTRY(_start_)
SECTIONS
{
.text : {
. = ALIGN(4);
__text_start__ = .;
KEEP(*(.first))
*(.text)
*(.text.*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(SORT(.rodata.*))
*(.rodata)
KEEP(*(.eh_frame*))
. = ALIGN(4);
__rel_start__ = .;
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
__rel_end__ = .;
}
.ARM.exidx : {
. = ALIGN(4);
__exdix_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
/* This is used by the startup in order to initialize the .data secion */
__exdix_end = .;
}
.permissions_table : {
. = ALIGN(4);
__permissions_table_start__ = .;
KEEP(*(.permissions_table))
__permissions_table_end__ = .;
}
PROVIDE(__ram_size__ = __bss_end__ - __data_start__);
.data : {
. = ALIGN(4);
__data_start__ = .;
__got_start__ = .;
*(.got)
__got_end__ = .;
. = ALIGN(4);
*(.data)
*(.data.*)
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4);
_shell_command_start = .;
KEEP(*(shellCommand))
_shell_command_end = .;
. = ALIGN(4);
/* All data end */
__data_end__ = .;
}
PROVIDE(__heap_size__ = __heap_end__ - __heap_start__);
PROVIDE(__stack_size__ = __stack_end__ - __stack_start__);
.bss : {
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
__bss_start__ = .;
*(.bss)
*(COMMON)
. = ALIGN(4);
__heap_start__ = .;
KEEP(*(.bss.heap))
__heap_end__ = .;
. = ALIGN(4);
__stack_start__ = .;
KEEP(*(.bss.stack))
__stack_end__ = .;
*(.bss.*)
/* This is used by the startup in order to initialize the .bss secion */
. = ALIGN(4);
__bss_end__ = .;
}
_end = .;
}

View File

@@ -5,5 +5,6 @@
# net
# lcd_drv
cpiofs
hello.elf
fatfs.elf
# hello.elf
sh

View File

@@ -4,11 +4,11 @@ file(GLOB_RECURSE deps *.c *.S)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror" )
add_executable(hello.elf
add_executable(uvmm.elf
${deps}
${START_SRC}
)
target_link_libraries(hello.elf
target_link_libraries(uvmm.elf
PUBLIC
-Bstatic
${LIBC_NAME}
@@ -24,48 +24,48 @@ target_link_libraries(hello.elf
${GCC_LIB_PATH}/libgcc.a
)
target_include_directories(
hello.elf
uvmm.elf
PUBLIC
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_util/inc
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/inc
${CMAKE_SOURCE_DIR}/mkrtos_user/server/hello/src
${CMAKE_SOURCE_DIR}/mkrtos_user/server/uvmm/src
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/cJSON
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/printf/src/printf
)
set_target_properties(hello.elf PROPERTIES LINK_FLAGS
set_target_properties(uvmm.elf PROPERTIES LINK_FLAGS
"-T ${CMAKE_CURRENT_LIST_DIR}/${ARCH_NAME}/link.lds ${CORTEX_M_LINK_FLAGS} --gc-section -no-dynamic-linker "
)
add_custom_target(
hello_dump ALL
uvmm_dump ALL
COMMAND
${CMAKE_OBJDUMP} -s -S hello.elf > ${CMAKE_SOURCE_DIR}/build/output/hello.S
${CMAKE_OBJDUMP} -s -S uvmm.elf > ${CMAKE_SOURCE_DIR}/build/output/uvmm.S
COMMAND
${CMAKE_READELF} -a hello.elf > ${CMAKE_SOURCE_DIR}/build/output/hello.txt
${CMAKE_READELF} -a uvmm.elf > ${CMAKE_SOURCE_DIR}/build/output/uvmm.txt
COMMAND
${CMAKE_OBJCOPY} -O binary -S hello.elf hello.bin
${CMAKE_OBJCOPY} -O binary -S uvmm.elf uvmm.bin
COMMAND
${CMAKE_SIZE} hello.elf
${CMAKE_SIZE} uvmm.elf
COMMAND
mkdir -p ${CMAKE_SOURCE_DIR}/build/output/cpio
COMMAND
cp hello.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/hello
cp uvmm.bin ${CMAKE_SOURCE_DIR}/build/output/cpio/uvmm
COMMAND
cp hello.elf ${CMAKE_SOURCE_DIR}/build/output/hello.elf
cp uvmm.elf ${CMAKE_SOURCE_DIR}/build/output/uvmm.elf
)
if ((DEFINED CONFIG_ELF_LAUNCH) AND (CONFIG_ELF_LAUNCH STREQUAL "y"))
add_custom_target(
hello_dump_elf ALL
uvmm_dump_elf ALL
COMMAND
cp hello.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/hello.elf
cp uvmm.elf ${CMAKE_SOURCE_DIR}/build/output/cpio/uvmm.elf
)
add_dependencies(hello_dump_elf hello_dump)
add_dependencies(uvmm_dump_elf uvmm_dump)
endif()
add_dependencies(hello_dump hello.elf)
add_dependencies(hello_dump sys)
add_dependencies(hello_dump sys_util)
add_dependencies(hello_dump sys_svr)
add_dependencies(uvmm_dump uvmm.elf)
add_dependencies(uvmm_dump sys)
add_dependencies(uvmm_dump sys_util)
add_dependencies(uvmm_dump sys_svr)

View File

@@ -72,7 +72,7 @@ int guest_os_create(guest_os_t *gos, char *cfg, addr_t st_addr, void *entry, voi
goto end;
}
ret = uvmm_devtree_scan(gos, cfg);
ret = uvmm_devtree_scan(gos, cfg); //扫描设备树,并进行初始化
if (ret < 0)
{
goto end;

View File

@@ -8,6 +8,6 @@ os_bin:
os_bin_end:
.quad 0
uvmm_dev_json:
.incbin "/home/mkrtos-real/mkrtos_user/server/hello/src/vm_benos.json"
.incbin "/home/mkrtos-real/mkrtos_user/server/uvmm/src/vm_benos.json"
uvmm_dev_json_end:
.quad 0