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 int kReturnTypeAlignmentSize; 12 extern const int kParameterAlignmentSize; 13 14 15 // Type 16 class Type { 17 public: 18 Type(const char* name, int size, 19 int usedSize, 20 const char* alignmentTypeName); 21 ~Type() {} 22 23 const char* TypeName() const { return fName; } 24 int Size() const { return fSize; } 25 int UsedSize() const { return fUsedSize; } 26 const char* AlignmentTypeName() const 27 { return fAlignmentType; } 28 29 private: 30 const char* fName; 31 int fSize; 32 int fUsedSize; 33 const char* fAlignmentType; 34 }; 35 36 // Parameter 37 class Parameter : public Type { 38 public: 39 Parameter(const char* typeName, 40 const char* parameterName, int size, 41 int usedSize, int offset, 42 const char* alignmentTypeName); 43 ~Parameter() {} 44 45 const char* ParameterName() const { return fParameterName; } 46 int Offset() const { return fOffset; } 47 48 private: 49 const char* fParameterName; 50 int fOffset; 51 }; 52 53 // Syscall 54 class Syscall { 55 public: 56 Syscall(const char* name, 57 const char* kernelName); 58 ~Syscall(); 59 60 const char* Name() const { return fName; } 61 const char* KernelName() const { return fKernelName; } 62 Type* ReturnType() const { return fReturnType; } 63 64 int CountParameters() const; 65 Parameter* ParameterAt(int index) const; 66 Parameter* LastParameter() const; 67 68 void SetReturnType(int size, const char* name); 69 Type* SetReturnType(const char* name, int size, 70 int usedSize, 71 const char* alignmentTypeName); 72 void AddParameter(int size, const char* typeName, 73 const char* parameterName); 74 Parameter* AddParameter(const char* typeName, 75 const char* parameterName, int size, 76 int usedSize, int offset, 77 const char* alignmentTypeName); 78 79 private: 80 struct ParameterVector; 81 82 const char* fName; 83 const char* fKernelName; 84 Type* fReturnType; 85 ParameterVector* fParameters; 86 }; 87 88 // SyscallVector 89 class SyscallVector { 90 public: 91 SyscallVector(); 92 ~SyscallVector(); 93 94 static SyscallVector* Create(); 95 96 int CountSyscalls() const; 97 Syscall* SyscallAt(int index) const; 98 99 Syscall* CreateSyscall(const char* name, 100 const char* kernelName); 101 102 private: 103 struct _SyscallVector; 104 105 _SyscallVector* fSyscalls; 106 }; 107 108 extern SyscallVector* create_syscall_vector(); 109 110 111 #endif // GENSYSCALLS_H 112