lib: delete hand-written msg interface libraries
This commit is contained in:
@@ -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)
|
||||
@@ -1,111 +0,0 @@
|
||||
#include <rosetta/msg/fs.h>
|
||||
#include <string.h>
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
#ifndef ROSETTA_MSG_FS_H_
|
||||
#define ROSETTA_MSG_FS_H_
|
||||
|
||||
#include <rosetta/msg.h>
|
||||
|
||||
/* 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
|
||||
@@ -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)
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef ROSETTA_MSG_LD_H_
|
||||
#define ROSETTA_MSG_LD_H_
|
||||
|
||||
#include <rosetta/msg.h>
|
||||
|
||||
/* 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
|
||||
@@ -1,3 +0,0 @@
|
||||
void msg_ld_tmp(void)
|
||||
{
|
||||
}
|
||||
@@ -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)
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef ROSETTA_MSG_H_
|
||||
#define ROSETTA_MSG_H_
|
||||
|
||||
#define ROSETTA_MSG_MAGIC 0x9AB07D10U
|
||||
|
||||
#include <mango/msg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
||||
@@ -1,33 +0,0 @@
|
||||
#include <rosetta/msg.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user