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