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 12 struct kernel_args; 13 struct select_info; 14 15 16 #define PORT_FLAG_USE_USER_MEMCPY 0x80000000 17 18 // port flags 19 enum { 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 31 extern "C" { 32 #endif 33 34 status_t port_init(struct kernel_args *args); 35 int delete_owned_ports(team_id owner); 36 int32 port_max_ports(void); 37 int32 port_used_ports(void); 38 39 status_t select_port(int32 object, struct select_info *info, bool kernel); 40 status_t deselect_port(int32 object, struct select_info *info, bool kernel); 41 42 // currently private API 43 status_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 // temp: test 48 void port_test(void); 49 50 // user syscalls 51 port_id _user_create_port(int32 queueLength, const char *name); 52 status_t _user_close_port(port_id id); 53 status_t _user_delete_port(port_id id); 54 port_id _user_find_port(const char *portName); 55 status_t _user_get_port_info(port_id id, struct port_info *info); 56 status_t _user_get_next_port_info(team_id team, int32 *cookie, 57 struct port_info *info); 58 ssize_t _user_port_buffer_size_etc(port_id port, uint32 flags, 59 bigtime_t timeout); 60 ssize_t _user_port_count(port_id port); 61 ssize_t _user_read_port_etc(port_id port, int32 *msgCode, 62 void *msgBuffer, size_t bufferSize, uint32 flags, 63 bigtime_t timeout); 64 status_t _user_set_port_owner(port_id port, team_id team); 65 status_t _user_write_port_etc(port_id port, int32 msgCode, 66 const void *msgBuffer, size_t bufferSize, 67 uint32 flags, bigtime_t timeout); 68 status_t _user_writev_port_etc(port_id id, int32 msgCode, 69 const iovec *msgVecs, size_t vecCount, 70 size_t bufferSize, uint32 flags, bigtime_t timeout); 71 status_t _user_get_port_message_info_etc(port_id port, 72 port_message_info *info, size_t infoSize, uint32 flags, 73 bigtime_t timeout); 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* _KERNEL_PORT_H */ 80