40 lines
917 B
C
40 lines
917 B
C
|
|
#ifndef KERNEL_PORT_H_
|
||
|
|
#define KERNEL_PORT_H_
|
||
|
|
|
||
|
|
#include <kernel/object.h>
|
||
|
|
#include <kernel/sched.h>
|
||
|
|
|
||
|
|
enum port_status {
|
||
|
|
/* port is not connected */
|
||
|
|
PORT_OFFLINE = 0,
|
||
|
|
/* port is connected and ready to send messages */
|
||
|
|
PORT_READY,
|
||
|
|
/* port has sent a message, and is waiting for the remote to receive it
|
||
|
|
*/
|
||
|
|
PORT_SEND_BLOCKED,
|
||
|
|
/* port has sent a message, and the remote has received it. waiting for
|
||
|
|
* the remote to reply. */
|
||
|
|
PORT_REPLY_BLOCKED,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct port {
|
||
|
|
struct object p_base;
|
||
|
|
enum port_status p_status;
|
||
|
|
struct channel *p_remote;
|
||
|
|
};
|
||
|
|
|
||
|
|
extern kern_status_t port_type_init(void);
|
||
|
|
extern struct port *port_cast(struct object *obj);
|
||
|
|
|
||
|
|
extern struct port *port_create(void);
|
||
|
|
|
||
|
|
extern kern_status_t port_connect(struct port *port, struct channel *remote);
|
||
|
|
extern kern_status_t port_send_msg(
|
||
|
|
struct port *port,
|
||
|
|
const struct msg *req,
|
||
|
|
struct msg *resp);
|
||
|
|
|
||
|
|
DEFINE_OBJECT_LOCK_FUNCTION(port, p_base)
|
||
|
|
|
||
|
|
#endif
|