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 39size_t port_team_link_offset(); 40 41status_t select_port(int32 object, struct select_info *info, bool kernel); 42status_t deselect_port(int32 object, struct select_info *info, bool kernel); 43 44// currently private API 45status_t writev_port_etc(port_id id, int32 msgCode, const iovec *msgVecs, 46 size_t vecCount, size_t bufferSize, uint32 flags, 47 bigtime_t timeout); 48 49// user syscalls 50port_id _user_create_port(int32 queueLength, const char *name); 51status_t _user_close_port(port_id id); 52status_t _user_delete_port(port_id id); 53port_id _user_find_port(const char *portName); 54status_t _user_get_port_info(port_id id, struct port_info *info); 55status_t _user_get_next_port_info(team_id team, int32 *cookie, 56 struct port_info *info); 57ssize_t _user_port_buffer_size_etc(port_id port, uint32 flags, 58 bigtime_t timeout); 59ssize_t _user_port_count(port_id port); 60ssize_t _user_read_port_etc(port_id port, int32 *msgCode, 61 void *msgBuffer, size_t bufferSize, uint32 flags, 62 bigtime_t timeout); 63status_t _user_set_port_owner(port_id port, team_id team); 64status_t _user_write_port_etc(port_id port, int32 msgCode, 65 const void *msgBuffer, size_t bufferSize, 66 uint32 flags, bigtime_t timeout); 67status_t _user_writev_port_etc(port_id id, int32 msgCode, 68 const iovec *msgVecs, size_t vecCount, 69 size_t bufferSize, uint32 flags, bigtime_t timeout); 70status_t _user_get_port_message_info_etc(port_id port, 71 port_message_info *info, size_t infoSize, uint32 flags, 72 bigtime_t timeout); 73 74#ifdef __cplusplus 75} 76#endif 77 78#endif /* _KERNEL_PORT_H */ 79