diff --git a/.gitignore b/.gitignore index b17f6feb..03f8f8ca 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ cscope.* !/**/firmware/*.bin !/**/firmware/*.elf +!/**/ramdisk/*.bin Lab*/build simulate.sh diff --git a/Lab2/filelist.mk b/Lab2/filelist.mk index a8073e6a..34b359f4 100644 --- a/Lab2/filelist.mk +++ b/Lab2/filelist.mk @@ -4,9 +4,10 @@ ARCH := kernel/arch/aarch64 BUDDY := $(MM)/buddy.c SLAB := $(MM)/slab.c +KMALLOC := $(MM)/kmalloc.c PTE := $(MM_ARCH)/page_table.c MAIN := $(ARCH)/main.c PGFAULT := $(ARCH)/irq/pgfault.c $(MM)/pgfault_handler.c VMSPACE := $(MM)/vmspace.c -FILES := $(BUDDY) $(SLAB) $(PTE) $(MAIN) $(PGFAULT) $(VMSPACE) +FILES := $(BUDDY) $(KMALLOC) $(SLAB) $(PTE) $(MAIN) $(PGFAULT) $(VMSPACE) diff --git a/Lab3/ramdisk/chcore_shell.bin b/Lab3/ramdisk/chcore_shell.bin new file mode 100755 index 00000000..3eee782f Binary files /dev/null and b/Lab3/ramdisk/chcore_shell.bin differ diff --git a/Lab3/ramdisk/fsm.srv b/Lab3/ramdisk/fsm.srv index 1280acba..af6cc8ee 100755 Binary files a/Lab3/ramdisk/fsm.srv and b/Lab3/ramdisk/fsm.srv differ diff --git a/Lab3/ramdisk/hdmi.srv b/Lab3/ramdisk/hdmi.srv deleted file mode 100755 index dc010f9f..00000000 Binary files a/Lab3/ramdisk/hdmi.srv and /dev/null differ diff --git a/Lab3/ramdisk/lwip.srv b/Lab3/ramdisk/lwip.srv deleted file mode 100755 index 0102f5b6..00000000 Binary files a/Lab3/ramdisk/lwip.srv and /dev/null differ diff --git a/Lab3/ramdisk/posix_shm.srv b/Lab3/ramdisk/posix_shm.srv deleted file mode 100755 index 3fa1f253..00000000 Binary files a/Lab3/ramdisk/posix_shm.srv and /dev/null differ diff --git a/Lab3/ramdisk/tmpfs.srv b/Lab3/ramdisk/tmpfs.srv deleted file mode 100755 index a41a82ca..00000000 Binary files a/Lab3/ramdisk/tmpfs.srv and /dev/null differ diff --git a/Lab3/ramdisk/userland.bin b/Lab3/ramdisk/userland.bin new file mode 100755 index 00000000..80cd5ef9 Binary files /dev/null and b/Lab3/ramdisk/userland.bin differ diff --git a/Lab3/ramdisk/uspi.srv b/Lab3/ramdisk/uspi.srv deleted file mode 100755 index 17cda317..00000000 Binary files a/Lab3/ramdisk/uspi.srv and /dev/null differ diff --git a/Lab3/scores.json b/Lab3/scores.json index d9a57d7c..8ae2da2a 100644 --- a/Lab3/scores.json +++ b/Lab3/scores.json @@ -5,7 +5,7 @@ "proposed": 20 }, { - "capture": "Thread_create Pretest Ok!" , + "capture": "Thread_create Ok!" , "msg": "Root Thread Pretest", "proposed": 20 }, diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/include/chcore/syscall.h b/Lab3/user/chcore-libc/libchcore/porting/overrides/include/chcore/syscall.h index 504d2912..a4f6b430 100644 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/include/chcore/syscall.h +++ b/Lab3/user/chcore-libc/libchcore/porting/overrides/include/chcore/syscall.h @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -99,7 +100,7 @@ void usys_cache_config(unsigned long option); #endif cap_t usys_create_notifc(void); -int usys_wait(cap_t notifc_cap, bool is_block, void *timeout); +int usys_wait(cap_t notifc_cap, bool is_block, struct timespec *timeout); int usys_notify(cap_t notifc_cap); int usys_register_recycle_thread(cap_t cap, unsigned long buffer); diff --git a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/syscall.c b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/syscall.c index 94ca920b..e2685195 100644 --- a/Lab3/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/syscall.c +++ b/Lab3/user/chcore-libc/libchcore/porting/overrides/src/chcore-port/syscall.c @@ -328,7 +328,7 @@ cap_t usys_create_notifc(void) return chcore_syscall0(CHCORE_SYS_create_notifc); } -int usys_wait(cap_t notifc_cap, bool is_block, void *timeout) +int usys_wait(cap_t notifc_cap, bool is_block, struct timespec *timeout) { return chcore_syscall3( CHCORE_SYS_wait, notifc_cap, is_block, (unsigned long)timeout); diff --git a/Lab3/user/system-services/system-servers/procmgr/CMakeLists.txt b/Lab3/user/system-services/system-servers/procmgr/CMakeLists.txt index e2221ac8..4e278d86 100644 --- a/Lab3/user/system-services/system-servers/procmgr/CMakeLists.txt +++ b/Lab3/user/system-services/system-servers/procmgr/CMakeLists.txt @@ -37,10 +37,14 @@ macro(_procmgr_incbin _target_name _binary_name _binary_path) set(_binary_path ${_binary_path}) configure_file(incbin_basic_srv.tpl.S incbin_${_binary_name}.S) target_sources(procmgr.srv PRIVATE incbin_${_binary_name}.S) + add_dependencies(procmgr.srv ${_target_name}) unset(_binary_name) unset(_binary_path) endmacro() +add_custom_target(fsm.srv + COMMAND touch ${CHCORE_PROJECT_DIR}/ramdisk/fsm.srv) + _procmgr_incbin(fsm.srv fsm_elf ${CHCORE_PROJECT_DIR}/ramdisk/fsm.srv) _procmgr_incbin(tmpfs.srv tmpfs_elf diff --git a/Lab3/user/system-services/system-servers/procmgr/procmgr.c b/Lab3/user/system-services/system-servers/procmgr/procmgr.c index dc46a2ee..f5a24b36 100644 --- a/Lab3/user/system-services/system-servers/procmgr/procmgr.c +++ b/Lab3/user/system-services/system-servers/procmgr/procmgr.c @@ -223,11 +223,18 @@ static void handle_kill(ipc_msg_t *ipc_msg, struct proc_request *pr) goto out; } + if (proc_to_kill->badge < MIN_FREE_APP_BADGE) { + error("kill: Cannot kill system server or driver!\n"); + ret = -EINVAL; + goto out_put_proc_node; + } + proc_cap = proc_to_kill->proc_cap; ret = usys_kill_group(proc_cap); debug("[procmgr] usys_kill_group return value: %d\n", ret); if (ret) { - error("kill: usys_kill_group returns an error value: %d\n", ret); + error("kill: usys_kill_group returns an error value: %d\n", + ret); ret = -EINVAL; goto out_put_proc_node; } @@ -572,6 +579,25 @@ void boot_default_servers(void) return; #endif /* CHCORE_OPENTRUSTEE */ +#if defined(CHCORE_SERVER_LWIP) + printf("User Init: booting network server\n"); + /* Pass the FS cap to NET since it may need to read some config files */ + /* Net gets badge 3 */ + srv_path = "/lwip.srv"; + ret = procmgr_launch_process(1, + &srv_path, + "lwip", + true, + INIT_BADGE, + NULL, + SYSTEM_SERVER, + &proc_node); + if (ret < 0) { + BUG("procmgr_launch_process lwip failed"); + } + lwip_server_cap = proc_node->proc_mt_cap; + put_proc_node(proc_node); +#endif } void *handler_thread_routine(void *arg) @@ -586,7 +612,40 @@ void *handler_thread_routine(void *arg) void boot_default_apps(void) { - char *userland_argv = "userland.bin"; +#ifdef CHCORE_OPENTRUSTEE + char *chanmgr_argv = "/chanmgr.srv"; + char *gtask_argv = "/gtask.elf"; + struct proc_node *gtask_node; + int ret; + + /* Start ipc channel manager for OpenTrustee. */ + ret = procmgr_launch_process(1, + &chanmgr_argv, + "chanmgr", + true, + INIT_BADGE, + NULL, + COMMON_APP, + NULL); + BUG_ON(ret != 0); + /* Start OpenTrustee gtask. */ + ret = procmgr_launch_process(1, + >ask_argv, + "gtask", + true, + INIT_BADGE, + NULL, + SYSTEM_SERVER, + >ask_node); + BUG_ON(ret != 0); + printf("%s: gtask pid %d\n", __func__, gtask_node->pid); + put_proc_node(gtask_node); + return; +#endif /* CHCORE_OPENTRUSTEE */ + + /* Start shell. */ + + char *userland_argv= "userland.bin"; (void)procmgr_launch_process(1, &userland_argv, "userland", @@ -598,14 +657,14 @@ void boot_default_apps(void) char *hello_world_argv= "hello_world.bin"; (void)procmgr_launch_process(1, - &hello_world_argv, - "userland", + &userland_argv, + "hello_world", true, INIT_BADGE, NULL, COMMON_APP, NULL); - /* Start shell. */ + char *shell_argv = "chcore_shell.bin"; (void)procmgr_launch_process(1, &shell_argv, @@ -616,6 +675,17 @@ void boot_default_apps(void) COMMON_APP, NULL); +#if defined(CHCORE_PLAT_RASPI3) && defined(CHCORE_SERVER_GUI) + char *terminal_argv = "terminal.bin"; + (void)procmgr_launch_process(1, + &terminal_argv, + "terminal", + true, + INIT_BADGE, + NULL, + COMMON_APP, + NULL); +#endif } int main(int argc, char *argv[], char *envp[]) diff --git a/Lab3/user/system-services/system-servers/tmpfs/libs/libfs_base.a b/Lab3/user/system-services/system-servers/tmpfs/libs/libfs_base.a index 125b2c8a..3aaaa15c 100644 Binary files a/Lab3/user/system-services/system-servers/tmpfs/libs/libfs_base.a and b/Lab3/user/system-services/system-servers/tmpfs/libs/libfs_base.a differ diff --git a/Lab3/user/system-services/system-servers/tmpfs/main.c.obj b/Lab3/user/system-services/system-servers/tmpfs/main.c.obj index f758452f..1980f135 100644 Binary files a/Lab3/user/system-services/system-servers/tmpfs/main.c.obj and b/Lab3/user/system-services/system-servers/tmpfs/main.c.obj differ diff --git a/Scripts/capturer.py b/Scripts/capturer.py index 62e71494..7cbdee1d 100755 --- a/Scripts/capturer.py +++ b/Scripts/capturer.py @@ -97,7 +97,7 @@ async def main(args: argparse.Namespace): line_capture.actual = line_capture.proposed passed += 1 else: - if args.serial in decoded_line: + if not args.serial or args.serial in decoded_line: line_capture.actual = line_capture.proposed passed += 1 break diff --git a/Scripts/grader.sh b/Scripts/grader.sh index fa89f39a..4993a7f4 100755 --- a/Scripts/grader.sh +++ b/Scripts/grader.sh @@ -19,11 +19,7 @@ bold "===========================================" test -f ${LABDIR}/.config.bak && cp ${LABDIR}/.config.bak ${LABDIR}/.config && rm .config.bak -if [[ $score -gt 100 ]]; then - fatal "Score is greater than 100, something went wrong." -fi - -if [[ ! $score -eq 100 ]]; then +if [[ $score -lt 100 ]]; then exit $? else exit 0