kernel: re-implement sending handles via port messages
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define MANGO_LOG_H_
|
||||
|
||||
#include <mango/status.h>
|
||||
#include <mango/types.h>
|
||||
|
||||
#undef TRACE
|
||||
|
||||
@@ -9,18 +10,18 @@ extern kern_status_t kern_log(const char *s);
|
||||
|
||||
#define kern_logf(...) \
|
||||
do { \
|
||||
char s[128]; \
|
||||
snprintf(s, sizeof s, __VA_ARGS__); \
|
||||
kern_log(s); \
|
||||
char __logbuf[128]; \
|
||||
snprintf(__logbuf, sizeof __logbuf, __VA_ARGS__); \
|
||||
kern_log(__logbuf); \
|
||||
} while (0)
|
||||
|
||||
#ifdef TRACE
|
||||
#define kern_trace(...) kern_log(__VA_ARGS__)
|
||||
#define kern_tracef(...) \
|
||||
do { \
|
||||
char s[128]; \
|
||||
snprintf(s, sizeof s, __VA_ARGS__); \
|
||||
kern_log(s); \
|
||||
char __logbuf[128]; \
|
||||
snprintf(__logbuf, sizeof __logbuf, __VA_ARGS__); \
|
||||
kern_log(__logbuf); \
|
||||
} while (0)
|
||||
#else
|
||||
#define kern_trace(...)
|
||||
|
||||
@@ -14,28 +14,21 @@ extern kern_status_t port_disconnect(kern_handle_t port);
|
||||
|
||||
extern kern_status_t msg_send(
|
||||
kern_handle_t port,
|
||||
const struct iovec *req_data,
|
||||
size_t req_data_count,
|
||||
struct iovec *resp_data,
|
||||
size_t resp_data_count);
|
||||
const kern_msg_t *msg,
|
||||
kern_msg_t *out_response);
|
||||
|
||||
extern kern_status_t msg_recv(
|
||||
kern_handle_t channel,
|
||||
msgid_t *out_id,
|
||||
struct iovec *out_data,
|
||||
size_t out_data_count);
|
||||
extern kern_status_t msg_recv(kern_handle_t channel, kern_msg_t *out);
|
||||
|
||||
extern kern_status_t msg_reply(
|
||||
kern_handle_t channel,
|
||||
msgid_t id,
|
||||
const struct iovec *reply_data,
|
||||
size_t reply_data_count);
|
||||
const kern_msg_t *response);
|
||||
|
||||
extern kern_status_t msg_read(
|
||||
kern_handle_t channel,
|
||||
msgid_t id,
|
||||
size_t offset,
|
||||
struct iovec *out,
|
||||
kern_iovec_t *out,
|
||||
size_t out_count,
|
||||
size_t *nr_read);
|
||||
|
||||
@@ -43,7 +36,7 @@ extern kern_status_t msg_write(
|
||||
kern_handle_t channel,
|
||||
msgid_t id,
|
||||
size_t offset,
|
||||
const struct iovec *in,
|
||||
const kern_iovec_t *in,
|
||||
size_t nr_in,
|
||||
size_t *nr_written);
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef MANGO_STATUS_H_
|
||||
#define MANGO_STATUS_H_
|
||||
|
||||
typedef unsigned int kern_status_t;
|
||||
|
||||
#define KERN_OK (0)
|
||||
#define KERN_UNIMPLEMENTED (1)
|
||||
#define KERN_NAME_EXISTS (2)
|
||||
|
||||
@@ -4,29 +4,24 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define VM_PROT_READ 0x01u
|
||||
#define VM_PROT_WRITE 0x02u
|
||||
#define VM_PROT_EXEC 0x04u
|
||||
#define VM_PROT_USER 0x08u
|
||||
#define VM_PROT_SVR 0x10u
|
||||
#define VM_PROT_NOCACHE 0x10u
|
||||
#define VM_PROT_MAP_SPECIFIC 0x40u
|
||||
#define VM_PROT_READ 0x01u
|
||||
#define VM_PROT_WRITE 0x02u
|
||||
#define VM_PROT_EXEC 0x04u
|
||||
#define VM_PROT_USER 0x08u
|
||||
#define VM_PROT_SVR 0x10u
|
||||
#define VM_PROT_NOCACHE 0x10u
|
||||
#define VM_PROT_MAP_SPECIFIC 0x40u
|
||||
|
||||
/* if this flag is set, other tasks can connect to this channel using
|
||||
* the port_connect_* syscalls.
|
||||
* if this flag is NOT set, only threads in the task that owns the channel
|
||||
* can create ports connecting to it. */
|
||||
#define CHANNEL_F_ALLOW_DIRECT_CONNECTIONS 0x01u
|
||||
#define VM_REGION_ANY_OFFSET ((off_t) - 1)
|
||||
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
|
||||
|
||||
/* msg_reply: once the reply has been sent, disconnect the port that sent the
|
||||
* original message */
|
||||
#define MSG_F_DISCONNECT_AFTER_REPLY 0x01u
|
||||
#define KERN_CFG_INVALID 0x00u
|
||||
#define KERN_CFG_PAGE_SIZE 0x01u
|
||||
|
||||
#define VM_REGION_ANY_OFFSET ((off_t) - 1)
|
||||
#define KERN_HANDLE_INVALID ((kern_handle_t)0xFFFFFFFF)
|
||||
|
||||
#define KERN_CFG_INVALID 0x00u
|
||||
#define KERN_CFG_PAGE_SIZE 0x01u
|
||||
#define KERN_MSG_MAX_HANDLES 64
|
||||
#define KERN_MSG_HANDLE_IGNORE 0
|
||||
#define KERN_MSG_HANDLE_MOVE 1
|
||||
#define KERN_MSG_HANDLE_COPY 2
|
||||
|
||||
#define IOVEC(p, len) \
|
||||
{ \
|
||||
@@ -47,15 +42,30 @@ typedef uint64_t msgid_t;
|
||||
typedef uint64_t off_t;
|
||||
typedef uint64_t koid_t;
|
||||
typedef unsigned int tid_t;
|
||||
typedef unsigned int kern_status_t;
|
||||
typedef uint32_t kern_handle_t;
|
||||
typedef uint32_t kern_config_key_t;
|
||||
typedef uint32_t vm_prot_t;
|
||||
|
||||
typedef unsigned int umode_t;
|
||||
|
||||
struct iovec {
|
||||
typedef struct {
|
||||
virt_addr_t io_base;
|
||||
size_t io_len;
|
||||
};
|
||||
} kern_iovec_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int hnd_mode;
|
||||
kern_handle_t hnd_value;
|
||||
kern_status_t hnd_result;
|
||||
} kern_msg_handle_t;
|
||||
|
||||
typedef struct {
|
||||
msgid_t msg_id;
|
||||
kern_iovec_t *msg_data;
|
||||
size_t msg_data_count;
|
||||
kern_msg_handle_t *msg_handles;
|
||||
size_t msg_handles_count;
|
||||
} kern_msg_t;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user