xref: /haiku/src/tools/gensyscalls/gensyscalls.h (revision 6f80a9801fedbe7355c4360bd204ba746ec3ec2d)
1 /*
2  * Copyright 2004-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef GENSYSCALLS_H
6 #define GENSYSCALLS_H
7 
8 
9 extern const char* const kReturnTypeAlignmentType;
10 extern const char* const kParameterAlignmentType;
11 extern const char* const kLongParameterAlignmentType;
12 extern const int kReturnTypeAlignmentSize;
13 extern const int kParameterAlignmentSize;
14 extern const int kLongParameterAlignmentSize;
15 
16 
17 // Type
18 class Type {
19 public:
20 								Type(const char* name, int size,
21 									int usedSize,
22 									const char* alignmentTypeName);
23 								~Type() {}
24 
25 			const char*			TypeName() const	{ return fName; }
26 			int					Size() const		{ return fSize; }
27 			int					UsedSize() const	{ return fUsedSize; }
28 			const char*			AlignmentTypeName() const
29 									{ return fAlignmentType; }
30 
31 private:
32 			const char*			fName;
33 			int					fSize;
34 			int					fUsedSize;
35 			const char*			fAlignmentType;
36 };
37 
38 // Parameter
39 class Parameter : public Type {
40 public:
41 								Parameter(const char* typeName,
42 									const char* parameterName, int size,
43 									int usedSize, int offset,
44 									const char* alignmentTypeName);
45 								~Parameter() {}
46 
47 			const char*			ParameterName() const { return fParameterName; }
48 			int					Offset() const		{ return fOffset; }
49 
50 private:
51 			const char*			fParameterName;
52 			int					fOffset;
53 };
54 
55 // Syscall
56 class Syscall {
57 public:
58 								Syscall(const char* name,
59 									const char* kernelName);
60 								~Syscall();
61 
62 			const char*			Name() const		{ return fName; }
63 			const char*			KernelName() const	{ return fKernelName; }
64 			Type*				ReturnType() const	{ return fReturnType; }
65 
66 			int					CountParameters() const;
67 			Parameter*			ParameterAt(int index) const;
68 			Parameter*			LastParameter() const;
69 
70 			 void				SetReturnType(int size, const char* name);
71 			Type*				SetReturnType(const char* name, int size,
72 									int usedSize,
73 									const char* alignmentTypeName);
74 			 void				AddParameter(int size, const char* typeName,
75 									const char* parameterName);
76 			Parameter*			AddParameter(const char* typeName,
77 									const char* parameterName, int size,
78 									int usedSize, int offset,
79 									const char* alignmentTypeName);
80 
81 private:
82 			struct ParameterVector;
83 
84 			const char*			fName;
85 			const char*			fKernelName;
86 			Type*				fReturnType;
87 			ParameterVector*	fParameters;
88 };
89 
90 // SyscallVector
91 class SyscallVector {
92 public:
93 								SyscallVector();
94 								~SyscallVector();
95 
96 	static	SyscallVector*		Create();
97 
98 			int					CountSyscalls() const;
99 			Syscall*			SyscallAt(int index) const;
100 
101 			Syscall*			CreateSyscall(const char* name,
102 									const char* kernelName);
103 
104 private:
105 			struct _SyscallVector;
106 
107 			_SyscallVector*		fSyscalls;
108 };
109 
110 extern SyscallVector* create_syscall_vector();
111 
112 
113 #endif	// GENSYSCALLS_H
114