bootstrap: create a channel to receive/reply to simple string messages
This commit is contained in:
@@ -87,13 +87,40 @@ int main(
|
||||
.p_resolver_arg = &bsp,
|
||||
};
|
||||
|
||||
kern_handle_t channel;
|
||||
channel_create(0, 0, &channel);
|
||||
|
||||
launch_ctx_init(&launch);
|
||||
launch.ctx_resolve_library = resolve_dependency;
|
||||
|
||||
enum launch_status status
|
||||
= launch_ctx_execute(&launch, ¶ms, LAUNCH_F_NONE, &result);
|
||||
kern_logf("launch result: %d", status);
|
||||
|
||||
kern_tracef("launch result: %d", status);
|
||||
#if 1
|
||||
char msg_buf[512];
|
||||
struct iovec vec = {
|
||||
.io_base = (virt_addr_t)msg_buf,
|
||||
.io_len = sizeof msg_buf,
|
||||
};
|
||||
struct msg msg = {.msg_data = &vec, .msg_data_count = 1};
|
||||
|
||||
while (1) {
|
||||
msgid_t id = 0;
|
||||
kern_status_t kstatus = msg_recv(channel, 0, &id, &msg);
|
||||
if (kstatus != KERN_OK) {
|
||||
kern_logf("msg_recv failed %d", kstatus);
|
||||
break;
|
||||
}
|
||||
|
||||
kern_logf("received message %zx: %s", id, msg_buf);
|
||||
|
||||
size_t len = snprintf(msg_buf, sizeof msg_buf, "Goodbye!");
|
||||
vec.io_len = len + 1;
|
||||
|
||||
msg_reply(channel, 0, id, &msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 102;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user