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
9extern const char* const kReturnTypeAlignmentType;
10extern const char* const kParameterAlignmentType;
11extern const char* const kLongParameterAlignmentType;
12extern const int kReturnTypeAlignmentSize;
13extern const int kParameterAlignmentSize;
14extern const int kLongParameterAlignmentSize;
15
16
17// Type
18class Type {
19public:
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
31private:
32			const char*			fName;
33			int					fSize;
34			int					fUsedSize;
35			const char*			fAlignmentType;
36};
37
38// Parameter
39class Parameter : public Type {
40public:
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
50private:
51			const char*			fParameterName;
52			int					fOffset;
53};
54
55// Syscall
56class Syscall {
57public:
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
81private:
82			struct ParameterVector;
83
84			const char*			fName;
85			const char*			fKernelName;
86			Type*				fReturnType;
87			ParameterVector*	fParameters;
88};
89
90// SyscallVector
91class SyscallVector {
92public:
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
104private:
105			struct _SyscallVector;
106
107			_SyscallVector*		fSyscalls;
108};
109
110extern SyscallVector* create_syscall_vector();
111
112
113#endif	// GENSYSCALLS_H
114