1/* 2 * Copyright 2005-2009, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT license. 4 */ 5#ifndef _KERNEL_PORT_H 6#define _KERNEL_PORT_H 7 8 9#include <thread.h> 10#include <iovec.h> 11 12struct kernel_args; 13struct select_info; 14 15 16#define PORT_FLAG_USE_USER_MEMCPY 0x80000000 17 18// port flags 19enum { 20 // read_port_etc() flags 21 B_PEEK_PORT_MESSAGE = 0x100 // read the message, but don't remove it; 22 // kernel-only; memory must be locked 23}; 24 25// port notifications 26#define PORT_MONITOR '_Pm_' 27#define PORT_ADDED 0x01 28#define PORT_REMOVED 0x02 29 30#ifdef __cplusplus 31extern "C" { 32#endif 33 34status_t port_init(struct kernel_args *args); 35void delete_owned_ports(Team* team); 36int32 port_max_ports(void); 37int32 port_used_ports(void); 38 39status_t select_port(int32 object, struct select_info *info, bool kernel); 40status_t deselect_port(int32 object, struct select_info *info, bool kernel); 41 42// currently private API 43status_t writev_port_etc(port_id id, int32 msgCode, const iovec *msgVecs, 44 size_t vecCount, size_t bufferSize, uint32 flags, 45 bigtime_t timeout); 46 47// user syscalls 48port_id _user_create_port(int32 queueLength, const char *name); 49status_t _user_close_port(port_id id); 50status_t _user_delete_port(port_id id); 51port_id _user_find_port(const char *portName); 52status_t _user_get_port_info(port_id id, struct port_info *info); 53status_t _user_get_next_port_info(team_id team, int32 *cookie, 54 struct port_info *info); 55ssize_t _user_port_buffer_size_etc(port_id port, uint32 flags, 56 bigtime_t timeout); 57ssize_t _user_port_count(port_id port); 58ssize_t _user_read_port_etc(port_id port, int32 *msgCode, 59 void *msgBuffer, size_t bufferSize, uint32 flags, 60 bigtime_t timeout); 61status_t _user_set_port_owner(port_id port, team_id team); 62status_t _user_write_port_etc(port_id port, int32 msgCode, 63 const void *msgBuffer, size_t bufferSize, 64 uint32 flags, bigtime_t timeout); 65status_t _user_writev_port_etc(port_id id, int32 msgCode, 66 const iovec *msgVecs, size_t vecCount, 67 size_t bufferSize, uint32 flags, bigtime_t timeout); 68status_t _user_get_port_message_info_etc(port_id port, 69 port_message_info *info, size_t infoSize, uint32 flags, 70 bigtime_t timeout); 71 72#ifdef __cplusplus 73} 74#endif 75 76#endif /* _KERNEL_PORT_H */ 77