ld: test sending a simple string message to bootstrap
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include <mango/log.h>
|
||||
#include <mango/msg.h>
|
||||
#include <mango/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(
|
||||
int argc,
|
||||
@@ -9,5 +11,31 @@ int main(
|
||||
uintptr_t bsp_base)
|
||||
{
|
||||
kern_log("ld!");
|
||||
kern_handle_t port;
|
||||
kern_status_t status = port_create(&port);
|
||||
if (status != KERN_OK) {
|
||||
kern_logf("port creation failed %d", status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 1
|
||||
port_connect(port, 0, 0);
|
||||
|
||||
const char msg_buf[] = "Hello!";
|
||||
struct iovec vec = IOVEC(msg_buf, 7);
|
||||
struct msg msg = MSG(&vec, 1, NULL, 0);
|
||||
|
||||
char recv_buf[64];
|
||||
struct iovec recv_vec = IOVEC(recv_buf, sizeof recv_buf);
|
||||
struct msg recv_msg = MSG(&recv_vec, 1, NULL, 0);
|
||||
|
||||
kern_logf("sending message...");
|
||||
status = msg_send(port, 0, &msg, &recv_msg);
|
||||
kern_logf("msg_send: %d", status);
|
||||
|
||||
if (status == KERN_OK) {
|
||||
kern_logf("reply: %s", recv_buf);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user