1// Request.h
2
3#ifndef USERLAND_FS_REQUEST_H
4#define USERLAND_FS_REQUEST_H
5
6#include <OS.h>
7
8// address info flags
9enum {
10	ADDRESS_NOT_NULL	= 0x01,
11	ADDRESS_IS_STRING	= 0x02,
12};
13
14namespace UserlandFSUtil {
15
16class RequestAllocator;
17
18// Address
19class Address {
20public:
21								Address();
22
23			void*				GetData() const { return fRelocated; }
24			int32				GetSize() const { return fSize; }
25
26//private:
27			void				SetTo(area_id area, int32 offset, int32 size);
28			void				SetRelocatedAddress(void* address)
29									{ fRelocated = address; }
30
31			area_id				GetArea() const { return fUnrelocated.area; }
32			int32				GetOffset() const
33									{ return fUnrelocated.offset; }
34
35private:
36			friend class RequestAllocator;
37
38			struct Unrelocated {
39				area_id			area;
40				int32			offset;
41			};
42
43			union {
44				Unrelocated		fUnrelocated;
45				void*			fRelocated;
46			};
47			int32				fSize;
48};
49
50// AddressInfo
51struct AddressInfo {
52	Address		*address;
53	uint32		flags;
54	int32		max_size;
55};
56
57// Request
58class Request {
59public:
60								Request(uint32 type);
61
62			uint32				GetType() const;
63
64			status_t			Check() const;
65			status_t			GetAddressInfos(AddressInfo* infos,
66									int32* count);
67
68private:
69			uint32				fType;
70};
71
72// implemented in Requests.cpp
73bool is_kernel_request(uint32 type);
74bool is_userland_request(uint32 type);
75
76}	// namespace UserlandFSUtil
77
78using UserlandFSUtil::Address;
79using UserlandFSUtil::AddressInfo;
80using UserlandFSUtil::Request;
81using UserlandFSUtil::is_kernel_request;
82using UserlandFSUtil::is_userland_request;
83
84#endif	// USERLAND_FS_REQUEST_H
85