diff --git a/lib/libmsg-fs/CMakeLists.txt b/lib/libmsg-fs/CMakeLists.txt deleted file mode 100644 index 90c2127..0000000 --- a/lib/libmsg-fs/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -file(GLOB sources - ${CMAKE_CURRENT_SOURCE_DIR}/*.c) -file(GLOB headers - ${CMAKE_CURRENT_SOURCE_DIR}/include/rosetta/msg/fs.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.h) - -set(public_include_dirs - ${CMAKE_CURRENT_SOURCE_DIR}/include) - -rosetta_add_library( - NAME libmsg-fs STATIC - PUBLIC_INCLUDE_DIRS ${public_include_dirs} - SOURCES ${sources} - HEADERS ${headers}) - -sysroot_add_library( - NAME libmsg-fs - HEADER_DIR /usr/include - LIB_DIR /usr/lib) - -target_link_libraries(libmsg-fs libmsg libmango ulibc) diff --git a/lib/libmsg-fs/fs.c b/lib/libmsg-fs/fs.c deleted file mode 100644 index 33cf939..0000000 --- a/lib/libmsg-fs/fs.c +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include - -kern_status_t rosetta_msg_fs_open_send( - kern_handle_t port, - const char *path, - int flags, - int *out_err) -{ - size_t path_len = strlen(path); - - struct rosetta_msg_fs_open msg = {0}; - rosetta_msg_init(&msg.msg_base, ROSETTA_MSG_FS, ROSETTA_MSG_FS_OPEN); - uint16_t offset = sizeof msg; - msg.msg_request.o_path = offset; - msg.msg_request.o_path_len = path_len; - msg.msg_request.o_flags = flags; - - struct iovec send_vec[] = { - IOVEC(&msg, sizeof msg), - IOVEC(path, path_len), - }; - - struct iovec reply_vec[] = { - IOVEC(&msg, sizeof msg), - }; - - struct msg req = { - .msg_data = send_vec, - .msg_data_count = sizeof send_vec / sizeof send_vec[0], - }; - - struct msg resp = { - .msg_data = reply_vec, - .msg_data_count = sizeof reply_vec / sizeof reply_vec[0], - }; - - kern_status_t status = msg_send(port, 0, &req, &resp); - if (status != KERN_OK) { - return status; - } - - *out_err = msg.msg_response.o_err; - - return KERN_OK; -} - -kern_status_t rosetta_msg_fs_open_recv( - kern_handle_t channel, - msgid_t id, - struct rosetta_msg_string *out_path, - int *out_flags) -{ - struct rosetta_msg_fs_open msg; - struct iovec vec = IOVEC(&msg, sizeof msg); - size_t r = 0; - - kern_status_t status = msg_read(channel, id, 0, &vec, 1, &r); - if (status != KERN_OK) { - return status; - } - - if (r != sizeof msg) { - /* TODO better error code for malformed messages */ - return KERN_INVALID_ARGUMENT; - } - - out_path->s_len = msg.msg_request.o_path_len; - if (out_path->s_max > 0) { - vec.io_base = (virt_addr_t)out_path->s_buf; - vec.io_len = out_path->s_max - 1; - - if (vec.io_len > out_path->s_len) { - vec.io_len = out_path->s_len; - } - - status = msg_read( - channel, - id, - msg.msg_request.o_path, - &vec, - 1, - &r); - if (status != KERN_OK) { - return status; - } - - if (r != out_path->s_len) { - return KERN_INVALID_ARGUMENT; - } - - out_path->s_buf[out_path->s_len] = 0; - } - - *out_flags = msg.msg_request.o_flags; - - return KERN_OK; -} - -kern_status_t rosetta_msg_fs_open_reply( - kern_handle_t channel, - msgid_t id, - int err) -{ - struct rosetta_msg_fs_open msg = {0}; - msg.msg_response.o_err = err; - struct iovec vec = IOVEC(&msg, sizeof msg); - - struct msg kmsg = {.msg_data = &vec, .msg_data_count = 1}; - return msg_reply(channel, 0, id, &kmsg); -} diff --git a/lib/libmsg-fs/include/rosetta/msg/fs.h b/lib/libmsg-fs/include/rosetta/msg/fs.h deleted file mode 100644 index 8c6c1b7..0000000 --- a/lib/libmsg-fs/include/rosetta/msg/fs.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef ROSETTA_MSG_FS_H_ -#define ROSETTA_MSG_FS_H_ - -#include - -/* rosetta.msg.fs protocol ID */ -#define ROSETTA_MSG_FS 0x01409DD2U - -/* rosetta.msg.fs.open message ID */ -#define ROSETTA_MSG_FS_OPEN 0x7778U - -struct rosetta_msg_fs_open { - struct rosetta_msg msg_base; - union { - struct { - uint16_t o_path; - uint16_t o_path_len; - uint16_t o_flags; - } msg_request; - - struct { - int o_err; - } msg_response; - }; -}; - -extern kern_status_t rosetta_msg_fs_open_send( - kern_handle_t port, - const char *path, - int flags, - int *out_err); -extern kern_status_t rosetta_msg_fs_open_recv( - kern_handle_t channel, - msgid_t id, - struct rosetta_msg_string *out_path, - int *out_flags); -extern kern_status_t rosetta_msg_fs_open_reply( - kern_handle_t channel, - msgid_t id, - int err); - -#endif diff --git a/lib/libmsg-ld/CMakeLists.txt b/lib/libmsg-ld/CMakeLists.txt deleted file mode 100644 index f34af92..0000000 --- a/lib/libmsg-ld/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -file(GLOB sources - ${CMAKE_CURRENT_SOURCE_DIR}/*.c) -file(GLOB headers - ${CMAKE_CURRENT_SOURCE_DIR}/include/rosetta/msg/ld.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.h) - -set(public_include_dirs - ${CMAKE_CURRENT_SOURCE_DIR}/include) - -rosetta_add_library( - NAME libmsg-ld STATIC - PUBLIC_INCLUDE_DIRS ${public_include_dirs} - SOURCES ${sources} - HEADERS ${headers}) - -sysroot_add_library( - NAME libmsg-ld - HEADER_DIR /usr/include - LIB_DIR /usr/lib) - -target_link_libraries(libmsg-ld libmsg libmango) diff --git a/lib/libmsg-ld/include/rosetta/msg/ld.h b/lib/libmsg-ld/include/rosetta/msg/ld.h deleted file mode 100644 index 35ac104..0000000 --- a/lib/libmsg-ld/include/rosetta/msg/ld.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef ROSETTA_MSG_LD_H_ -#define ROSETTA_MSG_LD_H_ - -#include - -/* rosetta.msg.ld protocol ID */ -#define ROSETTA_MSG_LD 0x5563D896U - -/* rosetta.msg.ld.get-object message ID */ -#define ROSETTA_MSG_LD_GET_OBJECT 1 - -struct rosetta_msg_ld_get_object { - struct rosetta_msg msg_base; - union { - struct { - uint16_t go_object_name; - } msg_request; - - struct { - int go_err; - uint16_t go_object_index; - } msg_response; - }; -}; - -#endif diff --git a/lib/libmsg-ld/ld.c b/lib/libmsg-ld/ld.c deleted file mode 100644 index ef53832..0000000 --- a/lib/libmsg-ld/ld.c +++ /dev/null @@ -1,3 +0,0 @@ -void msg_ld_tmp(void) -{ -} diff --git a/lib/libmsg/CMakeLists.txt b/lib/libmsg/CMakeLists.txt deleted file mode 100644 index 71d8544..0000000 --- a/lib/libmsg/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -file(GLOB sources - ${CMAKE_CURRENT_SOURCE_DIR}/*.c) -file(GLOB headers - ${CMAKE_CURRENT_SOURCE_DIR}/include/rosetta/msg.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.h) - -set(public_include_dirs - ${CMAKE_CURRENT_SOURCE_DIR}/include) - -rosetta_add_library( - NAME libmsg STATIC - PUBLIC_INCLUDE_DIRS ${public_include_dirs} - SOURCES ${sources} - HEADERS ${headers}) - -sysroot_add_library( - NAME libmsg - HEADER_DIR /usr/include - LIB_DIR /usr/lib) - -target_link_libraries(libmsg libmango ulibc) diff --git a/lib/libmsg/include/rosetta/msg.h b/lib/libmsg/include/rosetta/msg.h deleted file mode 100644 index 7f67c18..0000000 --- a/lib/libmsg/include/rosetta/msg.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef ROSETTA_MSG_H_ -#define ROSETTA_MSG_H_ - -#define ROSETTA_MSG_MAGIC 0x9AB07D10U - -#include -#include - -struct rosetta_msg { - uint32_t msg_magic; - uint32_t msg_protocol; - uint16_t msg_id; - uint16_t msg_reserved; -}; - -struct rosetta_msg_string { - char *s_buf; - size_t s_len; - size_t s_max; -}; - -extern void rosetta_msg_init( - struct rosetta_msg *msg, - uint32_t protocol_id, - uint16_t msg_id); -extern kern_status_t rosetta_msg_recv( - kern_handle_t channel, - msgid_t *out_id, - struct rosetta_msg *out_msg); - -#endif diff --git a/lib/libmsg/msg.c b/lib/libmsg/msg.c deleted file mode 100644 index 324b492..0000000 --- a/lib/libmsg/msg.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -void rosetta_msg_init( - struct rosetta_msg *msg, - uint32_t protocol_id, - uint16_t msg_id) -{ - memset(msg, 0x0, sizeof *msg); - - msg->msg_magic = ROSETTA_MSG_MAGIC; - msg->msg_protocol = protocol_id; - msg->msg_id = msg_id; -} - -kern_status_t rosetta_msg_recv( - kern_handle_t channel, - msgid_t *out_id, - struct rosetta_msg *out_msg) -{ - struct iovec iov = IOVEC(out_msg, sizeof *out_msg); - struct msg kmsg = MSG(&iov, 1, NULL, 0); - kern_status_t status = msg_recv(channel, 0, out_id, &kmsg); - if (status != KERN_OK) { - return status; - } - - if (out_msg->msg_magic != ROSETTA_MSG_MAGIC) { - return KERN_INVALID_ARGUMENT; - } - - return KERN_OK; -}