Skip to content

Commit

Permalink
Rename: related to #5
Browse files Browse the repository at this point in the history
  • Loading branch information
r1ru committed Feb 3, 2024
1 parent 9fdd2cc commit 82153e5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions kernel/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static task_t sys_hinavm(__user const char *name, __user hinavm_inst_t *insts,
return hinavm_create(namebuf, instsbuf, num_insts, pager_task);
}

// create WASMVM task
// create WasmVM task
static task_t sys_wasmvm(__user const char *name, __user uint8_t *wasm,
size_t size, task_t pager) {
// get task name
Expand All @@ -125,18 +125,18 @@ static task_t sys_wasmvm(__user const char *name, __user uint8_t *wasm,

// validate size
if (size > WASMVM_CODE_SIZE_MAX) {
WARN("wasm too big: %u (max=%u)", size, WASMVM_CODE_SIZE_MAX);
WARN("Wasm too big: %u (max=%u)", size, WASMVM_CODE_SIZE_MAX);
return ERR_INVALID_ARG;
}

// copy wasm binary
// copy Wasm binary
uint8_t wasmbuf[WASMVM_CODE_SIZE_MAX];
err = memcpy_from_user(wasmbuf, wasm, size);
if (err != OK) {
return err;
}

// create WASMVM task
// create WasmVM task
return wasmvm_create(namebuf, wasmbuf, size, pager_task);
}

Expand Down
6 changes: 3 additions & 3 deletions kernel/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ task_t hinavm_create(const char *name, hinavm_inst_t *insts, uint32_t num_insts,
return tid;
}

// Create WASMVM task
// Create WasmVM task
task_t wasmvm_create(const char *name, uint8_t *wasm, uint32_t size,
struct task *pager) {
task_t tid = alloc_tid();
Expand All @@ -210,7 +210,7 @@ task_t wasmvm_create(const char *name, uint8_t *wasm, uint32_t size,
return ERR_NO_MEMORY;
}

// copy wasm binary
// copy Wasm binary
struct wasmvm *wasmvm = (struct wasmvm *) arch_paddr_to_vaddr(wasmvm_paddr);
memcpy(&wasmvm->code, wasm, size);
wasmvm->size = size;
Expand All @@ -226,7 +226,7 @@ task_t wasmvm_create(const char *name, uint8_t *wasm, uint32_t size,
pm_own_page(wasmvm_paddr, task);
list_push_back(&active_tasks, &task->next);
task_resume(task);
TRACE("created a WASMVM task \"%s\" (tid=%d)", name, tid);
TRACE("created a WasmVM task \"%s\" (tid=%d)", name, tid);
return tid;
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/wasmvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static error_t __ipc(task_t dst, task_t src, struct message *m, unsigned flags)
return ipc(dst_task, src, (__user struct message *) m, flags | IPC_KERNEL | IPC_WASMVM);
}

// host functions exported to WASM
// host functions exported to Wasm
static void __ipc_reply(wasm_exec_env_t exec_env, task_t dst, struct message *m) {
error_t err = __ipc(dst, 0, m, IPC_SEND | IPC_NOBLOCK);
OOPS_OK(err);
Expand Down Expand Up @@ -129,7 +129,7 @@ __noreturn void wasmvm_run(struct wasmvm *wasmvm) {
sizeof(error_buf)
);
if (!module) {
ERROR("load wasm module failed");
ERROR("load Wasm module failed");
goto fail_1;
}

Expand Down
2 changes: 1 addition & 1 deletion servers/shell/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void main(void) {
ipc_recv(IPC_ANY, &m);
ASSERT(m.type == NOTIFY_TIMER_MSG);

printf("\nWelcome to WASMOS!\n\n");
printf("\nWelcome to WasmOS!\n\n");
while (true) {
printf("\x1b[1mshell> \x1b[0m");
printf_flush();
Expand Down
10 changes: 5 additions & 5 deletions servers/vm/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,34 @@ struct task *task_find(task_t tid) {
return tasks[tid - 1];
}

// create task from WASM binary
// create task from Wasm binary
static task_t task_spawn_from_wasm(struct bootfs_file *file) {
struct task *task = malloc(sizeof(*task));
if (!task) {
PANIC("too many tasks");
}

// copy wasm binary
// copy Wasm binary
// todo: validate size here?
size_t size = file->len;
wasm_hdr *wasm = malloc(size);
bootfs_read(file, 0, wasm, size);

// validate version
if (wasm->version != WASM_VERSION) {
WARN("%s: invalid WASM version: %x", file->name, wasm->version);
WARN("%s: invalid Wasm version: %x", file->name, wasm->version);
free(wasm);
return ERR_INVALID_ARG;
}

// create WASMVM task
// create WasmVM task
error_t tid_or_err = sys_wasmvm(file->name, (uint8_t *) wasm, size, task_self());
if (IS_ERROR(tid_or_err)) {
return tid_or_err;
}

// init task struct
// WASMVM task runs in kernel mode, so page faults do not occur(maybe)
// WasmVM task runs in kernel mode, so page faults do not occur(maybe)
task->tid = tid_or_err;
task->pager = task_self();
task->file_header = wasm;
Expand Down
2 changes: 1 addition & 1 deletion servers/wasm_webapi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static task_t tcpip_server;
" <meta charset=\"utf-8\">" \
"</head>" \
"<body>" \
"<h1>Hello from WASM OS!</h1>" \
"<h1>Hello from WasmOS!</h1>" \
"</body>" \
"</html>\n"

Expand Down

0 comments on commit 82153e5

Please sign in to comment.