bootstrap: switch to ifc-generated ipc interface
This commit is contained in:
@@ -5,7 +5,7 @@ set_property(SOURCE ${arch_sources} PROPERTY LANGUAGE C)
|
|||||||
|
|
||||||
add_executable(bootstrap ${c_sources} ${arch_sources})
|
add_executable(bootstrap ${c_sources} ${arch_sources})
|
||||||
|
|
||||||
target_link_libraries(bootstrap libmango ulibc liblaunch libmsg-fs)
|
target_link_libraries(bootstrap libmango ulibc liblaunch interface::fs)
|
||||||
|
|
||||||
target_compile_options(bootstrap PRIVATE
|
target_compile_options(bootstrap PRIVATE
|
||||||
-fPIC -pie -fno-stack-protector -nostdlib -ffreestanding)
|
-fPIC -pie -fno-stack-protector -nostdlib -ffreestanding)
|
||||||
|
|||||||
@@ -6,10 +6,12 @@
|
|||||||
.extern main
|
.extern main
|
||||||
.type main, @function
|
.type main, @function
|
||||||
|
|
||||||
.extern exit
|
.extern task_exit
|
||||||
.type exit, @function
|
.type task_exit, @function
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
call main
|
call main
|
||||||
|
mov %rax, %rdi
|
||||||
|
call task_exit
|
||||||
1: pause
|
1: pause
|
||||||
jmp 1b
|
jmp 1b
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#define MSG_IMPLEMENTATION
|
||||||
|
#define MSG_NO_MALLOC
|
||||||
#include "tar.h"
|
#include "tar.h"
|
||||||
|
|
||||||
#include <launch.h>
|
#include <launch.h>
|
||||||
@@ -5,8 +7,7 @@
|
|||||||
#include <mango/msg.h>
|
#include <mango/msg.h>
|
||||||
#include <mango/task.h>
|
#include <mango/task.h>
|
||||||
#include <mango/types.h>
|
#include <mango/types.h>
|
||||||
#include <rosetta/msg.h>
|
#include <rosetta/fs.h>
|
||||||
#include <rosetta/msg/fs.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -46,6 +47,31 @@ static enum launch_status resolve_dependency(
|
|||||||
return LAUNCH_OK;
|
return LAUNCH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static kern_status_t open(const char *path, int flags, int *out_err)
|
||||||
|
{
|
||||||
|
kern_logf("received msg: open(%s, %d)", path, flags);
|
||||||
|
*out_err = 13;
|
||||||
|
return KERN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static kern_status_t uppercase(const char *old, struct msg_string *new)
|
||||||
|
{
|
||||||
|
kern_logf("received msg: uppercase(%s)", old);
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; old[i] && i < new->str_max - 1; i++) {
|
||||||
|
char c = old[i];
|
||||||
|
if (c >= 'a' && c <= 'z') {
|
||||||
|
new->str_buf[i] = old[i] - 'a' + 'A';
|
||||||
|
} else {
|
||||||
|
new->str_buf[i] = old[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new->str_len = i - 1;
|
||||||
|
new->str_buf[i] = 0;
|
||||||
|
return KERN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int main(
|
int main(
|
||||||
int argc,
|
int argc,
|
||||||
const char **argv,
|
const char **argv,
|
||||||
@@ -98,48 +124,29 @@ int main(
|
|||||||
= launch_ctx_execute(&launch, ¶ms, LAUNCH_F_NONE, &result);
|
= launch_ctx_execute(&launch, ¶ms, LAUNCH_F_NONE, &result);
|
||||||
kern_logf("launch result: %d", status);
|
kern_logf("launch result: %d", status);
|
||||||
|
|
||||||
|
const struct fs_vtable fs_vtable = {
|
||||||
|
.open = open,
|
||||||
|
.uppercase = uppercase,
|
||||||
|
};
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
msgid_t id;
|
msgid_t id;
|
||||||
struct rosetta_msg msg;
|
struct msg_header hdr;
|
||||||
kern_status_t status = rosetta_msg_recv(channel, &id, &msg);
|
kern_status_t status = msg_recv_generic(channel, &id, &hdr);
|
||||||
if (status != KERN_OK) {
|
if (status != KERN_OK) {
|
||||||
kern_logf("message recv error %d", status);
|
kern_logf("message recv error %d", status);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.msg_protocol != ROSETTA_MSG_FS) {
|
if (hdr.hdr_protocol != PROTOCOL_FS) {
|
||||||
kern_logf(
|
kern_logf(
|
||||||
"unknown message protocol %u",
|
"unknown message protocol %u",
|
||||||
msg.msg_protocol);
|
hdr.hdr_protocol);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.msg_id != ROSETTA_MSG_FS_OPEN) {
|
status = fs_dispatch(channel, &fs_vtable, id, &hdr);
|
||||||
kern_logf("unknown message function %u", msg.msg_id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
char path[4096];
|
|
||||||
int flags;
|
|
||||||
struct rosetta_msg_string path_str = {
|
|
||||||
.s_buf = path,
|
|
||||||
.s_max = sizeof path,
|
|
||||||
};
|
|
||||||
status = rosetta_msg_fs_open_recv(
|
|
||||||
channel,
|
|
||||||
id,
|
|
||||||
&path_str,
|
|
||||||
&flags);
|
|
||||||
if (status != KERN_OK) {
|
|
||||||
kern_logf("rosetta.fs.open recv error %d", status);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
kern_logf("open(%s, %d)", path, flags);
|
|
||||||
|
|
||||||
rosetta_msg_fs_open_reply(channel, id, 0);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user