1/*
2 * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef USERLAND_FS_PORT_H
6#define USERLAND_FS_PORT_H
7
8#include <OS.h>
9
10class KernelDebug;
11
12namespace UserlandFSUtil {
13
14struct PortInfo {
15};
16
17class Port {
18public:
19			struct Info {
20				port_id			owner_port;
21				port_id			client_port;
22				int32			size;
23			};
24
25public:
26								Port(int32 size);
27								Port(const Info* info);
28								~Port();
29
30			void				Close();
31
32			status_t			InitCheck() const;
33
34			const Info*			GetInfo() const;
35
36			void*				GetBuffer() const	{ return fBuffer; }
37			int32				GetCapacity() const	{ return fCapacity; }
38
39			void				Reserve(int32 endOffset);
40			void				Unreserve(int32 endOffset);
41			int32				ReservedSize() const { return fReservedSize; }
42
43			status_t			Send(const void* message, int32 size);
44			status_t			Receive(void** _message, size_t* _size,
45									bigtime_t timeout = -1);
46
47private:
48			friend class ::KernelDebug;
49
50			Info				fInfo;
51			uint8*				fBuffer;
52			int32				fCapacity;
53			int32				fReservedSize;
54			status_t			fInitStatus;
55			bool				fOwner;
56};
57
58}	// namespace UserlandFSUtil
59
60using UserlandFSUtil::PortInfo;
61using UserlandFSUtil::Port;
62
63#endif	// USERLAND_FS_PORT_H
64