From 966b29a6426842acaa1bf49cf0d917cf9e571361 Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Mon, 14 Nov 2022 23:18:40 +0800 Subject: [PATCH 1/3] feat(fs): add fs romdisk config --- src/fs/Kconfig | 6 +++--- src/fs/cpio/Kconfig | 1 - src/init/init.c | 6 +++++- src/kernel/debug.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/fs/Kconfig b/src/fs/Kconfig index 1524e4c..fc6ef9e 100644 --- a/src/fs/Kconfig +++ b/src/fs/Kconfig @@ -5,13 +5,13 @@ source "$NXOS_SRC_DIR/fs/fat/Kconfig" config NX_ENABLE_EXECUTE_USER bool "Enable execute first user process" select NX_ENABLE_MOUNT_TABLE - default n + default y if NX_ENABLE_EXECUTE_USER config NX_FIRST_USER_PATH string "first user process file path" - default "/uinit" + default "/System/Service/UserLand.xapp" endif @@ -35,7 +35,7 @@ config NX_ENABLE_MOUNT_TABLE if NX_FS_DEVFS config NX_DEVFS_PATH_DEFAULT string "default devfs mount path" - default "/dev" + default "/System/Device" config NX_DEVFS_FSNAME_DEFAULT string "default devfs fsname" diff --git a/src/fs/cpio/Kconfig b/src/fs/cpio/Kconfig index 9f1d6b0..46ba91d 100644 --- a/src/fs/cpio/Kconfig +++ b/src/fs/cpio/Kconfig @@ -1,4 +1,3 @@ config NX_FS_CPIO bool "Enable cpio file system" - select NX_DRIVER_ROMDISK default n diff --git a/src/init/init.c b/src/init/init.c index 75ee5d4..a7647c4 100644 --- a/src/init/init.c +++ b/src/init/init.c @@ -78,7 +78,11 @@ NX_PRIVATE void CallsEntry(void *arg) #ifdef CONFIG_NX_ENABLE_EXECUTE_USER { NX_Error err = NX_ProcessLaunch(CONFIG_NX_FIRST_USER_PATH, NX_PROC_FLAG_NOWAIT, NX_NULL, NX_NULL, NX_NULL); - NX_LOG_I("execute first user on path:%s with state %d", CONFIG_NX_FIRST_USER_PATH, err); + NX_LOG_I("execute first user on path:%s with state %s", CONFIG_NX_FIRST_USER_PATH, NX_ErrorToString(err)); + if (err != NX_EOK) + { + NX_PANIC("start user process failed!"); + } } #endif /* CONFIG_NX_ENABLE_EXECUTE_USER */ diff --git a/src/kernel/debug.c b/src/kernel/debug.c index 04a3ddf..dfe3b08 100644 --- a/src/kernel/debug.c +++ b/src/kernel/debug.c @@ -25,7 +25,7 @@ void NX_DebugAssertionFailure(char *exp, char *file, char *baseFile, int line) void NX_DebugSpin(const char *str) { - NX_LOG_I(str, NX_Endln "FILE:%s\nFUNCTION:%s\nLINE:%d", __FILE__, __FUNCTION__, __LINE__); + NX_LOG_E(str, NX_Endln "FILE:%s\nFUNCTION:%s\nLINE:%d", __FILE__, __FUNCTION__, __LINE__); while (1); } -- Gitee From 203d69824a0013b2c75a996ae41769cd95d50fcf Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Mon, 14 Nov 2022 23:19:03 +0800 Subject: [PATCH 2/3] fix(syscall): wanring on file fd --- src/process/syscall.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/process/syscall.c b/src/process/syscall.c index 4deab1b..7cb91d6 100644 --- a/src/process/syscall.c +++ b/src/process/syscall.c @@ -84,7 +84,7 @@ NX_PRIVATE NX_Error SysFileSystemSync(void) return NX_FileSystemSync(); } -NX_PRIVATE NX_Error SoltToFile(NX_Solt solt, int * fd) +NX_PRIVATE NX_Error SoltToFile(NX_Solt solt, NX_SSize * fd) { NX_Process * process; NX_ExposedObject * exobj; @@ -105,7 +105,7 @@ NX_PRIVATE NX_Error SoltToFile(NX_Solt solt, int * fd) return NX_ENORES; } - *fd = (int)exobj->object; + *fd = (NX_SSize)exobj->object; NX_ASSERT(*fd); return NX_EOK; @@ -113,14 +113,14 @@ NX_PRIVATE NX_Error SoltToFile(NX_Solt solt, int * fd) NX_PRIVATE NX_Error FileCloseSolt(void * object, NX_ExposedObjectType type) { - int fd; + NX_SSize fd; if (type != NX_EXOBJ_FILE) { return NX_ENORES; } - fd = (int) object; + fd = (NX_SSize)object; NX_ASSERT(fd); return NX_FileClose(fd); @@ -128,7 +128,7 @@ NX_PRIVATE NX_Error FileCloseSolt(void * object, NX_ExposedObjectType type) NX_PRIVATE NX_Error SysFileOpen(const char * path, NX_U32 flags, NX_U32 mode, NX_Solt * outSolt) { - int fd; + NX_SSize fd; NX_Error err = NX_EOK; NX_Solt solt = NX_SOLT_INVALID_VALUE; NX_Process * process; @@ -144,7 +144,7 @@ NX_PRIVATE NX_Error SysFileOpen(const char * path, NX_U32 flags, NX_U32 mode, NX } process = NX_ProcessCurrent(); - if ((err = NX_ProcessInstallSolt(process, (void *)fd, NX_EXOBJ_FILE, FileCloseSolt, &solt)) != NX_EOK) + if ((err = NX_ProcessInstallSolt(process, (NX_SSize *)fd, NX_EXOBJ_FILE, FileCloseSolt, &solt)) != NX_EOK) { NX_FileClose(fd); return err; @@ -159,7 +159,7 @@ NX_PRIVATE NX_Error SysFileRead(NX_Solt solt, void * buf, NX_Size len, NX_Size * { NX_Error err; NX_Size size; - int fd = -1; + NX_SSize fd = -1; err = SoltToFile(solt, &fd); if (err != NX_EOK) @@ -182,7 +182,7 @@ NX_PRIVATE NX_Error SysFileWrite(NX_Solt solt, void * buf, NX_Size len, NX_Size { NX_Error err; NX_Size size; - int fd = -1; + NX_SSize fd = -1; err = SoltToFile(solt, &fd); if (err != NX_EOK) @@ -204,7 +204,7 @@ NX_PRIVATE NX_Error SysFileWrite(NX_Solt solt, void * buf, NX_Size len, NX_Size NX_Error SysFileIoctl(NX_Solt solt, NX_U32 cmd, void *arg) { NX_Error err; - int fd = -1; + NX_SSize fd = -1; err = SoltToFile(solt, &fd); if (err != NX_EOK) @@ -218,7 +218,7 @@ NX_Error SysFileIoctl(NX_Solt solt, NX_U32 cmd, void *arg) NX_PRIVATE NX_Offset SysFileSetPointer(NX_Solt solt, NX_Offset off, int whence, NX_Error *outErr) { NX_Error err; - int fd = -1; + NX_SSize fd = -1; err = SoltToFile(solt, &fd); if (err != NX_EOK) @@ -232,7 +232,7 @@ NX_PRIVATE NX_Offset SysFileSetPointer(NX_Solt solt, NX_Offset off, int whence, NX_PRIVATE NX_Error SysFileSync(NX_Solt solt) { NX_Error err; - int fd = -1; + NX_SSize fd = -1; err = SoltToFile(solt, &fd); if (err != NX_EOK) @@ -246,7 +246,7 @@ NX_PRIVATE NX_Error SysFileSync(NX_Solt solt) NX_PRIVATE NX_Error SysFileSetMode(NX_Solt solt, NX_U32 mode) { NX_Error err; - int fd = -1; + NX_SSize fd = -1; err = SoltToFile(solt, &fd); if (err != NX_EOK) @@ -260,7 +260,7 @@ NX_PRIVATE NX_Error SysFileSetMode(NX_Solt solt, NX_U32 mode) NX_PRIVATE NX_Error SysFileGetStat(NX_Solt solt, NX_FileStatInfo * st) { NX_Error err; - int fd = -1; + NX_SSize fd = -1; err = SoltToFile(solt, &fd); if (err != NX_EOK) @@ -271,7 +271,7 @@ NX_PRIVATE NX_Error SysFileGetStat(NX_Solt solt, NX_FileStatInfo * st) return NX_FileGetStat(fd, st); } -NX_PRIVATE NX_Error SoltToDir(NX_Solt solt, int * fd) +NX_PRIVATE NX_Error SoltToDir(NX_Solt solt, NX_SSize * fd) { NX_Process * process; NX_ExposedObject * exobj; @@ -292,7 +292,7 @@ NX_PRIVATE NX_Error SoltToDir(NX_Solt solt, int * fd) return NX_ENORES; } - *fd = (int)exobj->object; + *fd = (NX_SSize)exobj->object; NX_ASSERT(*fd); return NX_EOK; @@ -300,14 +300,14 @@ NX_PRIVATE NX_Error SoltToDir(NX_Solt solt, int * fd) NX_PRIVATE NX_Error DirCloseSolt(void * object, NX_ExposedObjectType type) { - int fd; + NX_SSize fd; if (type != NX_EXOBJ_DIR) { return NX_ENORES; } - fd = (int) object; + fd = (NX_SSize) object; NX_ASSERT(fd); return NX_DirClose(fd); @@ -315,7 +315,7 @@ NX_PRIVATE NX_Error DirCloseSolt(void * object, NX_ExposedObjectType type) NX_PRIVATE NX_Error SysDirOpen(const char * path, NX_Solt * outSolt) { - int fd; + NX_SSize fd; NX_Error err = NX_EOK; NX_Solt solt = NX_SOLT_INVALID_VALUE; NX_Process * process; @@ -345,7 +345,7 @@ NX_PRIVATE NX_Error SysDirOpen(const char * path, NX_Solt * outSolt) NX_PRIVATE NX_Error SysDirRead(NX_Solt solt, NX_Dirent * dir) { NX_Error err; - int fd = -1; + NX_SSize fd = -1; err = SoltToDir(solt, &fd); if (err != NX_EOK) @@ -359,7 +359,7 @@ NX_PRIVATE NX_Error SysDirRead(NX_Solt solt, NX_Dirent * dir) NX_PRIVATE NX_Error SysDirResetPointer(NX_Solt solt) { NX_Error err; - int fd = -1; + NX_SSize fd = -1; err = SoltToDir(solt, &fd); if (err != NX_EOK) -- Gitee From 79f0df5cbe73caa51d11bd390aefcea519e37fa5 Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Mon, 14 Nov 2022 23:21:36 +0800 Subject: [PATCH 3/3] feeat: update platforms fs config --- src/platform/d1 | 2 +- src/platform/hifive_unmached | 2 +- src/platform/i386 | 2 +- src/platform/k210 | 2 +- src/platform/qemu_riscv64 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/platform/d1 b/src/platform/d1 index debbfef..0149e64 160000 --- a/src/platform/d1 +++ b/src/platform/d1 @@ -1 +1 @@ -Subproject commit debbfef0dde94f29e15e4eb7fb57f8cc8d62e862 +Subproject commit 0149e64e29ec48b0f986848a91ec8e5cdf92240b diff --git a/src/platform/hifive_unmached b/src/platform/hifive_unmached index 8217e27..1132ace 160000 --- a/src/platform/hifive_unmached +++ b/src/platform/hifive_unmached @@ -1 +1 @@ -Subproject commit 8217e275f5825c0b36e631c4f6aaa0b33fcbcbfb +Subproject commit 1132ace3f9d223c038d8fc7d417698ae48cd9dea diff --git a/src/platform/i386 b/src/platform/i386 index 15b33f8..f3cd8bb 160000 --- a/src/platform/i386 +++ b/src/platform/i386 @@ -1 +1 @@ -Subproject commit 15b33f830b67fae26c43a9e4b3af2ad410840a0d +Subproject commit f3cd8bb3b9d3f10571fad771ad39181f9daed899 diff --git a/src/platform/k210 b/src/platform/k210 index a02b123..8256c65 160000 --- a/src/platform/k210 +++ b/src/platform/k210 @@ -1 +1 @@ -Subproject commit a02b1237e93ff7de32c38e9f5ef78fb64b29359d +Subproject commit 8256c65a189c4c4742f5e3de8d9f2600c9956328 diff --git a/src/platform/qemu_riscv64 b/src/platform/qemu_riscv64 index 5c63c2f..60dd151 160000 --- a/src/platform/qemu_riscv64 +++ b/src/platform/qemu_riscv64 @@ -1 +1 @@ -Subproject commit 5c63c2f212a425caeeeac7e73f645376cdb83cf4 +Subproject commit 60dd151d5066b5930f3cadc61cbcd542e6180272 -- Gitee