Skip to content

Commit

Permalink
Merge pull request #36 from ToolmanP/bugfix
Browse files Browse the repository at this point in the history
fix: regression fixes for infra, lab2, lab3
  • Loading branch information
ToolmanP authored Oct 3, 2024
2 parents a42fdb0 + 5a126a1 commit ac9d541
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cscope.*

!/**/firmware/*.bin
!/**/firmware/*.elf
!/**/ramdisk/*.bin

Lab*/build
simulate.sh
Expand Down
3 changes: 2 additions & 1 deletion Lab2/filelist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Binary file added Lab3/ramdisk/chcore_shell.bin
Binary file not shown.
Binary file modified Lab3/ramdisk/fsm.srv
Binary file not shown.
Binary file removed Lab3/ramdisk/hdmi.srv
Binary file not shown.
Binary file removed Lab3/ramdisk/lwip.srv
Binary file not shown.
Binary file removed Lab3/ramdisk/posix_shm.srv
Binary file not shown.
Binary file removed Lab3/ramdisk/tmpfs.srv
Binary file not shown.
Binary file added Lab3/ramdisk/userland.bin
Binary file not shown.
Binary file removed Lab3/ramdisk/uspi.srv
Binary file not shown.
2 changes: 1 addition & 1 deletion Lab3/scores.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"proposed": 20
},
{
"capture": "Thread_create Pretest Ok!" ,
"capture": "Thread_create Ok!" ,
"msg": "Root Thread Pretest",
"proposed": 20
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <stdio.h>
#include <chcore/memory.h>
#include <uapi/object.h>
#include <time.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
80 changes: 75 additions & 5 deletions Lab3/user/system-services/system-servers/procmgr/procmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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,
&gtask_argv,
"gtask",
true,
INIT_BADGE,
NULL,
SYSTEM_SERVER,
&gtask_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",
Expand All @@ -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,
Expand All @@ -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[])
Expand Down
Binary file modified Lab3/user/system-services/system-servers/tmpfs/libs/libfs_base.a
Binary file not shown.
Binary file modified Lab3/user/system-services/system-servers/tmpfs/main.c.obj
Binary file not shown.
2 changes: 1 addition & 1 deletion Scripts/capturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions Scripts/grader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ac9d541

Please sign in to comment.