1 #ifndef GENSYSCALLS_H 2 #define GENSYSCALLS_H 3 4 // Type 5 class Type { 6 public: 7 Type(const char* name, int size, 8 int usedSize, 9 const char* alignmentTypeName); 10 ~Type() {} 11 12 const char* TypeName() const { return fName; } 13 int Size() const { return fSize; } 14 int UsedSize() const { return fUsedSize; } 15 const char* AlignmentTypeName() const 16 { return fAlignmentType; } 17 18 private: 19 const char* fName; 20 int fSize; 21 int fUsedSize; 22 const char* fAlignmentType; 23 }; 24 25 // Parameter 26 class Parameter : public Type { 27 public: 28 Parameter(const char* typeName, 29 const char* parameterName, int size, 30 int usedSize, int offset, 31 const char* alignmentTypeName); 32 ~Parameter() {} 33 34 const char* ParameterName() const { return fParameterName; } 35 int Offset() const { return fOffset; } 36 37 private: 38 const char* fParameterName; 39 int fOffset; 40 }; 41 42 // Syscall 43 class Syscall { 44 public: 45 Syscall(const char* name, 46 const char* kernelName); 47 ~Syscall(); 48 49 const char* Name() const { return fName; } 50 const char* KernelName() const { return fKernelName; } 51 Type* ReturnType() const { return fReturnType; } 52 53 int CountParameters() const; 54 Parameter* ParameterAt(int index) const; 55 Parameter* LastParameter() const; 56 57 template<typename T> void SetReturnType(const char* name); 58 template<typename T> void AddParameter(const char* typeName, 59 const char* parameterName); 60 61 Type* SetReturnType(const char* name, int size, 62 int usedSize, 63 const char* alignmentTypeName); 64 Parameter* AddParameter(const char* typeName, 65 const char* parameterName, int size, 66 int usedSize, int offset, 67 const char* alignmentTypeName); 68 69 private: 70 struct ParameterVector; 71 72 const char* fName; 73 const char* fKernelName; 74 Type* fReturnType; 75 ParameterVector* fParameters; 76 }; 77 78 // SyscallVector 79 class SyscallVector { 80 public: 81 SyscallVector(); 82 ~SyscallVector(); 83 84 static SyscallVector* Create(); 85 86 int CountSyscalls() const; 87 Syscall* SyscallAt(int index) const; 88 89 Syscall* CreateSyscall(const char* name, 90 const char* kernelName); 91 92 private: 93 struct _SyscallVector; 94 95 _SyscallVector* fSyscalls; 96 }; 97 98 extern SyscallVector* create_syscall_vector(); 99 100 101 #ifndef DONT_INCLUDE_ARCH_GENSYSCALLS_H 102 103 // align_to_type 104 template<typename T> 105 int 106 align_to_type(int size) 107 { 108 return (size + sizeof(T) - 1) / sizeof(T) * sizeof(T); 109 } 110 111 #include "arch_gensyscalls.h" 112 113 // SetReturnType 114 template<typename T> 115 void 116 Syscall::SetReturnType(const char* name) 117 { 118 ReturnTypeCreator<T>::Create(this, name); 119 } 120 121 // AddParameter 122 template<typename T> 123 void 124 Syscall::AddParameter(const char* typeName, const char* parameterName) 125 { 126 ParameterCreator<T>::Create(this, typeName, parameterName); 127 } 128 129 #endif // !DONT_INCLUDE_ARCH_GENSYSCALLS_H 130 131 #endif // GENSYSCALLS_H 132