* Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34237 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -74,10 +74,10 @@ static int dump_syscall_tracing(int argc, char** argv);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static generic_syscall *
|
static generic_syscall*
|
||||||
find_generic_syscall(const char *subsystem)
|
find_generic_syscall(const char* subsystem)
|
||||||
{
|
{
|
||||||
generic_syscall *syscall = NULL;
|
generic_syscall* syscall = NULL;
|
||||||
|
|
||||||
ASSERT_LOCKED_MUTEX(&sGenericSyscallLock);
|
ASSERT_LOCKED_MUTEX(&sGenericSyscallLock);
|
||||||
|
|
||||||
@@ -98,8 +98,8 @@ find_generic_syscall(const char *subsystem)
|
|||||||
All other return codes are depending on the generic syscall implementation.
|
All other return codes are depending on the generic syscall implementation.
|
||||||
*/
|
*/
|
||||||
static inline status_t
|
static inline status_t
|
||||||
_user_generic_syscall(const char *userSubsystem, uint32 function,
|
_user_generic_syscall(const char* userSubsystem, uint32 function,
|
||||||
void *buffer, size_t bufferSize)
|
void* buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
char subsystem[B_FILE_NAME_LENGTH];
|
char subsystem[B_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ _user_generic_syscall(const char *userSubsystem, uint32 function,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (syscall != NULL) {
|
while (syscall != NULL) {
|
||||||
generic_syscall *next;
|
generic_syscall* next;
|
||||||
|
|
||||||
syscall->use_count++;
|
syscall->use_count++;
|
||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
@@ -185,28 +185,28 @@ _user_restore_signal_frame()
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
syscall_dispatcher(uint32 call_num, void *args, uint64 *call_ret)
|
syscall_dispatcher(uint32 callIndex, void* args, uint64* _returnValue)
|
||||||
{
|
{
|
||||||
bigtime_t startTime;
|
bigtime_t startTime;
|
||||||
|
|
||||||
// dprintf("syscall_dispatcher: thread 0x%x call 0x%x, arg0 0x%x, arg1 0x%x arg2 0x%x arg3 0x%x arg4 0x%x\n",
|
// dprintf("syscall_dispatcher: thread 0x%x call 0x%x, arg0 0x%x, arg1 0x%x arg2 0x%x arg3 0x%x arg4 0x%x\n",
|
||||||
// thread_get_current_thread_id(), call_num, arg0, arg1, arg2, arg3, arg4);
|
// thread_get_current_thread_id(), call_num, arg0, arg1, arg2, arg3, arg4);
|
||||||
|
|
||||||
user_debug_pre_syscall(call_num, args);
|
user_debug_pre_syscall(callIndex, args);
|
||||||
|
|
||||||
startTime = system_time();
|
startTime = system_time();
|
||||||
|
|
||||||
switch (call_num) {
|
switch (callIndex) {
|
||||||
// the cases are auto-generated
|
// the cases are auto-generated
|
||||||
#include "syscall_dispatcher.h"
|
#include "syscall_dispatcher.h"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
*call_ret = (uint64)B_BAD_VALUE;
|
*_returnValue = (uint64)B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
user_debug_post_syscall(call_num, args, *call_ret, startTime);
|
user_debug_post_syscall(callIndex, args, *_returnValue, startTime);
|
||||||
|
|
||||||
// dprintf("syscall_dispatcher: done with syscall 0x%x\n", call_num);
|
// dprintf("syscall_dispatcher: done with syscall 0x%x\n", callIndex);
|
||||||
|
|
||||||
return B_HANDLED_INTERRUPT;
|
return B_HANDLED_INTERRUPT;
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ generic_syscall_init(void)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
register_generic_syscall(const char *subsystem, syscall_hook hook,
|
register_generic_syscall(const char* subsystem, syscall_hook hook,
|
||||||
uint32 version, uint32 flags)
|
uint32 version, uint32 flags)
|
||||||
{
|
{
|
||||||
if (hook == NULL)
|
if (hook == NULL)
|
||||||
@@ -275,7 +275,7 @@ register_generic_syscall(const char *subsystem, syscall_hook hook,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
unregister_generic_syscall(const char *subsystem, uint32 version)
|
unregister_generic_syscall(const char* subsystem, uint32 version)
|
||||||
{
|
{
|
||||||
// TODO: we should only remove the syscall with the matching version
|
// TODO: we should only remove the syscall with the matching version
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Don't include arch_gensyscalls.h. It's only needed when creating the
|
// Don't include arch_gensyscalls.h. It's only needed when creating the
|
||||||
// syscall vector.
|
// syscall vector.
|
||||||
#define DONT_INCLUDE_ARCH_GENSYSCALLS_H 1
|
#define DONT_INCLUDE_ARCH_GENSYSCALLS_H 1
|
||||||
|
|
||||||
|
#include "gensyscalls.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -14,7 +17,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "gensyscalls.h"
|
|
||||||
#include "gensyscalls_common.h"
|
#include "gensyscalls_common.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@@ -49,47 +51,50 @@ print_usage(bool error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Type
|
// #pragma mark - Type
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
Type::Type(const char* name, int size, int usedSize,
|
Type::Type(const char* name, int size, int usedSize,
|
||||||
const char* alignmentTypeName)
|
const char* alignmentTypeName)
|
||||||
: fName(name),
|
:
|
||||||
fSize(size),
|
fName(name),
|
||||||
fUsedSize(usedSize),
|
fSize(size),
|
||||||
fAlignmentType(alignmentTypeName)
|
fUsedSize(usedSize),
|
||||||
|
fAlignmentType(alignmentTypeName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Parameter
|
// #pragma mark - Parameter
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
Parameter::Parameter(const char* typeName, const char* parameterName,
|
Parameter::Parameter(const char* typeName, const char* parameterName,
|
||||||
int size, int usedSize, int offset, const char* alignmentTypeName)
|
int size, int usedSize, int offset, const char* alignmentTypeName)
|
||||||
: Type(typeName, size, usedSize, alignmentTypeName),
|
:
|
||||||
fParameterName(parameterName),
|
Type(typeName, size, usedSize, alignmentTypeName),
|
||||||
fOffset(offset)
|
fParameterName(parameterName),
|
||||||
|
fOffset(offset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Syscall
|
// #pragma mark - Syscall
|
||||||
|
|
||||||
|
|
||||||
// ParameterVector
|
|
||||||
struct Syscall::ParameterVector : public vector<Parameter*> {
|
struct Syscall::ParameterVector : public vector<Parameter*> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// constructor
|
|
||||||
Syscall::Syscall(const char* name, const char* kernelName)
|
Syscall::Syscall(const char* name, const char* kernelName)
|
||||||
: fName(name),
|
:
|
||||||
fKernelName(kernelName),
|
fName(name),
|
||||||
fReturnType(NULL),
|
fKernelName(kernelName),
|
||||||
fParameters(new ParameterVector)
|
fReturnType(NULL),
|
||||||
|
fParameters(new ParameterVector)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
Syscall::~Syscall()
|
Syscall::~Syscall()
|
||||||
{
|
{
|
||||||
delete fReturnType;
|
delete fReturnType;
|
||||||
@@ -100,14 +105,14 @@ Syscall::~Syscall()
|
|||||||
delete fParameters;
|
delete fParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParameterAt
|
|
||||||
int
|
int
|
||||||
Syscall::CountParameters() const
|
Syscall::CountParameters() const
|
||||||
{
|
{
|
||||||
return fParameters->size();
|
return fParameters->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParameterAt
|
|
||||||
Parameter*
|
Parameter*
|
||||||
Syscall::ParameterAt(int index) const
|
Syscall::ParameterAt(int index) const
|
||||||
{
|
{
|
||||||
@@ -117,14 +122,14 @@ Syscall::ParameterAt(int index) const
|
|||||||
return (*fParameters)[index];
|
return (*fParameters)[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// LastParameter
|
|
||||||
Parameter*
|
Parameter*
|
||||||
Syscall::LastParameter() const
|
Syscall::LastParameter() const
|
||||||
{
|
{
|
||||||
return ParameterAt(CountParameters() - 1);
|
return ParameterAt(CountParameters() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetReturnType
|
|
||||||
Type*
|
Type*
|
||||||
Syscall::SetReturnType(const char* name, int size, int usedSize,
|
Syscall::SetReturnType(const char* name, int size, int usedSize,
|
||||||
const char* alignmentTypeName)
|
const char* alignmentTypeName)
|
||||||
@@ -133,7 +138,7 @@ Syscall::SetReturnType(const char* name, int size, int usedSize,
|
|||||||
return fReturnType = new Type(name, size, usedSize, alignmentTypeName);
|
return fReturnType = new Type(name, size, usedSize, alignmentTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddParameter
|
|
||||||
Parameter*
|
Parameter*
|
||||||
Syscall::AddParameter(const char* typeName, const char* parameterName,
|
Syscall::AddParameter(const char* typeName, const char* parameterName,
|
||||||
int size, int usedSize, int offset, const char* alignmentTypeName)
|
int size, int usedSize, int offset, const char* alignmentTypeName)
|
||||||
@@ -145,19 +150,21 @@ Syscall::AddParameter(const char* typeName, const char* parameterName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SyscallVector
|
// #pragma mark - SyscallVector
|
||||||
|
|
||||||
|
|
||||||
struct SyscallVector::_SyscallVector : public vector<Syscall*> {
|
struct SyscallVector::_SyscallVector : public vector<Syscall*> {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
SyscallVector::SyscallVector()
|
SyscallVector::SyscallVector()
|
||||||
: fSyscalls(new _SyscallVector)
|
:
|
||||||
|
fSyscalls(new _SyscallVector)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
SyscallVector::~SyscallVector()
|
SyscallVector::~SyscallVector()
|
||||||
{
|
{
|
||||||
int count = CountSyscalls();
|
int count = CountSyscalls();
|
||||||
@@ -166,21 +173,21 @@ SyscallVector::~SyscallVector()
|
|||||||
delete fSyscalls;
|
delete fSyscalls;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create
|
|
||||||
SyscallVector*
|
SyscallVector*
|
||||||
SyscallVector::Create()
|
SyscallVector::Create()
|
||||||
{
|
{
|
||||||
return new SyscallVector;
|
return new SyscallVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CountSyscalls
|
|
||||||
int
|
int
|
||||||
SyscallVector::CountSyscalls() const
|
SyscallVector::CountSyscalls() const
|
||||||
{
|
{
|
||||||
return fSyscalls->size();
|
return fSyscalls->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyscallAt
|
|
||||||
Syscall*
|
Syscall*
|
||||||
SyscallVector::SyscallAt(int index) const
|
SyscallVector::SyscallAt(int index) const
|
||||||
{
|
{
|
||||||
@@ -190,7 +197,7 @@ SyscallVector::SyscallAt(int index) const
|
|||||||
return (*fSyscalls)[index];
|
return (*fSyscalls)[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSyscall
|
|
||||||
Syscall*
|
Syscall*
|
||||||
SyscallVector::CreateSyscall(const char* name, const char* kernelName)
|
SyscallVector::CreateSyscall(const char* name, const char* kernelName)
|
||||||
{
|
{
|
||||||
@@ -202,18 +209,18 @@ SyscallVector::CreateSyscall(const char* name, const char* kernelName)
|
|||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
// Main
|
|
||||||
class Main {
|
class Main {
|
||||||
public:
|
public:
|
||||||
|
int Run(int argc, char** argv)
|
||||||
int Run(int argc, char **argv)
|
|
||||||
{
|
{
|
||||||
// parse arguments
|
// parse arguments
|
||||||
const char *syscallsFile = NULL;
|
const char* syscallsFile = NULL;
|
||||||
const char *dispatcherFile = NULL;
|
const char* dispatcherFile = NULL;
|
||||||
const char *numbersFile = NULL;
|
const char* numbersFile = NULL;
|
||||||
const char *tableFile = NULL;
|
const char* tableFile = NULL;
|
||||||
const char *straceFile = NULL;
|
const char* straceFile = NULL;
|
||||||
|
|
||||||
for (int argi = 1; argi < argc; argi++) {
|
for (int argi = 1; argi < argc; argi++) {
|
||||||
string arg(argv[argi]);
|
string arg(argv[argi]);
|
||||||
if (arg == "-h" || arg == "--help") {
|
if (arg == "-h" || arg == "--help") {
|
||||||
@@ -275,7 +282,7 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _WriteSyscallsFile(const char *filename)
|
void _WriteSyscallsFile(const char* filename)
|
||||||
{
|
{
|
||||||
// open the syscalls output file
|
// open the syscalls output file
|
||||||
ofstream file(filename, ofstream::out | ofstream::trunc);
|
ofstream file(filename, ofstream::out | ofstream::trunc);
|
||||||
@@ -299,7 +306,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _WriteDispatcherFile(const char *filename)
|
void _WriteDispatcherFile(const char* filename)
|
||||||
{
|
{
|
||||||
// open the dispatcher output file
|
// open the dispatcher output file
|
||||||
ofstream file(filename, ofstream::out | ofstream::trunc);
|
ofstream file(filename, ofstream::out | ofstream::trunc);
|
||||||
@@ -312,7 +319,7 @@ public:
|
|||||||
file << "case " << i << ":" << endl;
|
file << "case " << i << ":" << endl;
|
||||||
file << "\t";
|
file << "\t";
|
||||||
if (string(syscall->ReturnType()->TypeName()) != "void")
|
if (string(syscall->ReturnType()->TypeName()) != "void")
|
||||||
file << "*call_ret = ";
|
file << "*_returnValue = ";
|
||||||
file << syscall->KernelName() << "(";
|
file << syscall->KernelName() << "(";
|
||||||
int paramCount = syscall->CountParameters();
|
int paramCount = syscall->CountParameters();
|
||||||
if (paramCount > 0) {
|
if (paramCount > 0) {
|
||||||
@@ -344,7 +351,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _WriteNumbersFile(const char *filename)
|
void _WriteNumbersFile(const char* filename)
|
||||||
{
|
{
|
||||||
// open the syscall numbers output file
|
// open the syscall numbers output file
|
||||||
ofstream file(filename, ofstream::out | ofstream::trunc);
|
ofstream file(filename, ofstream::out | ofstream::trunc);
|
||||||
@@ -352,7 +359,7 @@ public:
|
|||||||
throw IOException(string("Failed to open `") + filename + "'.");
|
throw IOException(string("Failed to open `") + filename + "'.");
|
||||||
|
|
||||||
// output the defines
|
// output the defines
|
||||||
const char *prefix = "_user_";
|
const char* prefix = "_user_";
|
||||||
size_t prefixLen = strlen(prefix);
|
size_t prefixLen = strlen(prefix);
|
||||||
for (int i = 0; i < fSyscallCount; i++) {
|
for (int i = 0; i < fSyscallCount; i++) {
|
||||||
const Syscall* syscall = fSyscallVector->SyscallAt(i);
|
const Syscall* syscall = fSyscallVector->SyscallAt(i);
|
||||||
@@ -371,7 +378,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _WriteTableFile(const char *filename)
|
void _WriteTableFile(const char* filename)
|
||||||
{
|
{
|
||||||
// open the syscall table output file
|
// open the syscall table output file
|
||||||
ofstream file(filename, ofstream::out | ofstream::trunc);
|
ofstream file(filename, ofstream::out | ofstream::trunc);
|
||||||
@@ -452,7 +459,7 @@ public:
|
|||||||
file << "#endif // _ASSEMBLER" << endl;
|
file << "#endif // _ASSEMBLER" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _WriteSTraceFile(const char *filename)
|
void _WriteSTraceFile(const char* filename)
|
||||||
{
|
{
|
||||||
// open the syscall table output file
|
// open the syscall table output file
|
||||||
ofstream file(filename, ofstream::out | ofstream::trunc);
|
ofstream file(filename, ofstream::out | ofstream::trunc);
|
||||||
@@ -522,9 +529,9 @@ public:
|
|||||||
file << "}" << endl;
|
file << "}" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string _GetPointerType(const char *type)
|
static string _GetPointerType(const char* type)
|
||||||
{
|
{
|
||||||
const char *parenthesis = strchr(type, ')');
|
const char* parenthesis = strchr(type, ')');
|
||||||
if (!parenthesis)
|
if (!parenthesis)
|
||||||
return string(type) + "*";
|
return string(type) + "*";
|
||||||
// function pointer type
|
// function pointer type
|
||||||
@@ -605,9 +612,9 @@ private:
|
|||||||
int fSyscallCount;
|
int fSyscallCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
// main
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return Main().Run(argc, argv);
|
return Main().Run(argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user