xref: /haiku/headers/private/kernel/port.h (revision b46615c55ad2c8fe6de54412055a0713da3d610a)
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 void delete_owned_ports(Team* team);
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 // user syscalls
48 port_id		_user_create_port(int32 queueLength, const char *name);
49 status_t	_user_close_port(port_id id);
50 status_t	_user_delete_port(port_id id);
51 port_id		_user_find_port(const char *portName);
52 status_t	_user_get_port_info(port_id id, struct port_info *info);
53 status_t 	_user_get_next_port_info(team_id team, int32 *cookie,
54 				struct port_info *info);
55 ssize_t		_user_port_buffer_size_etc(port_id port, uint32 flags,
56 				bigtime_t timeout);
57 ssize_t		_user_port_count(port_id port);
58 ssize_t		_user_read_port_etc(port_id port, int32 *msgCode,
59 				void *msgBuffer, size_t bufferSize, uint32 flags,
60 				bigtime_t timeout);
61 status_t	_user_set_port_owner(port_id port, team_id team);
62 status_t	_user_write_port_etc(port_id port, int32 msgCode,
63 				const void *msgBuffer, size_t bufferSize,
64 				uint32 flags, bigtime_t timeout);
65 status_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);
68 status_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