We do now also generate a header file that defines macros for the syscall numbers.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9133 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
89e53cea26
commit
1f90f9aa63
|
@ -44,6 +44,7 @@ UseArchObjectHeaders gensyscalls.cpp : $(OBOS_ARCH) ;
|
||||||
# place them where there are needed
|
# place them where there are needed
|
||||||
MakeLocate <syscalls>syscalls.S.inc : [ FObjectsDir src kernel libroot os ] ;
|
MakeLocate <syscalls>syscalls.S.inc : [ FObjectsDir src kernel libroot os ] ;
|
||||||
MakeLocate <syscalls>syscall_dispatcher.h : [ FObjectsDir src kernel core ] ;
|
MakeLocate <syscalls>syscall_dispatcher.h : [ FObjectsDir src kernel core ] ;
|
||||||
|
MakeLocate <syscalls>syscall_numbers.h : [ FObjectsDir src kernel core ] ;
|
||||||
|
|
||||||
Depends <dir>objects/x86.R1/kernel/core : <dir>objects/x86.R1/kernel ;
|
Depends <dir>objects/x86.R1/kernel/core : <dir>objects/x86.R1/kernel ;
|
||||||
|
|
||||||
|
@ -65,8 +66,18 @@ actions GenSyscallsDispatcher1 {
|
||||||
$(2[1]) -d $(1)
|
$(2[1]) -d $(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rule GenSyscallsNumbers {
|
||||||
|
Depends $(1) : gensyscalls ;
|
||||||
|
GenSyscallsNumbers1 $(1) : gensyscalls ;
|
||||||
|
}
|
||||||
|
|
||||||
|
actions GenSyscallsNumbers1 {
|
||||||
|
$(2[1]) -n $(1)
|
||||||
|
}
|
||||||
|
|
||||||
GenSyscallsFile <syscalls>syscalls.S.inc ;
|
GenSyscallsFile <syscalls>syscalls.S.inc ;
|
||||||
GenSyscallsDispatcher <syscalls>syscall_dispatcher.h ;
|
GenSyscallsDispatcher <syscalls>syscall_dispatcher.h ;
|
||||||
|
GenSyscallsNumbers <syscalls>syscall_numbers.h ;
|
||||||
|
|
||||||
|
|
||||||
# preprocess the syscalls header
|
# preprocess the syscalls header
|
||||||
|
|
|
@ -14,7 +14,7 @@ extern "C" gensyscall_syscall_info *gensyscall_get_infos(int *count);
|
||||||
|
|
||||||
// usage
|
// usage
|
||||||
const char *kUsage =
|
const char *kUsage =
|
||||||
"Usage: gensyscalls [ -c <calls> ] [ -d <dispatcher> ]\n"
|
"Usage: gensyscalls [ -c <calls> ] [ -d <dispatcher> ] [ -n <numbers> ]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"The command generates a piece of assembly source file that defines the\n"
|
"The command generates a piece of assembly source file that defines the\n"
|
||||||
"actual syscalls and a piece of C source (cases of a switch statement) for"
|
"actual syscalls and a piece of C source (cases of a switch statement) for"
|
||||||
|
@ -24,7 +24,9 @@ const char *kUsage =
|
||||||
" <calls> - Output: The assembly source file implementing the\n"
|
" <calls> - Output: The assembly source file implementing the\n"
|
||||||
" actual syscalls."
|
" actual syscalls."
|
||||||
" <dispatcher> - Output: The C source file to be included by the\n"
|
" <dispatcher> - Output: The C source file to be included by the\n"
|
||||||
" syscall dispatcher source file.\n";
|
" syscall dispatcher source file.\n"
|
||||||
|
" <numbers> - Output: The C/assembly include files defining the\n"
|
||||||
|
" syscall numbers.\n";
|
||||||
|
|
||||||
// print_usage
|
// print_usage
|
||||||
static
|
static
|
||||||
|
@ -47,6 +49,7 @@ public:
|
||||||
// parse arguments
|
// parse arguments
|
||||||
const char *syscallsFile = NULL;
|
const char *syscallsFile = NULL;
|
||||||
const char *dispatcherFile = NULL;
|
const char *dispatcherFile = NULL;
|
||||||
|
const char *numbersFile = 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") {
|
||||||
|
@ -64,6 +67,12 @@ public:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
dispatcherFile = argv[++argi];
|
dispatcherFile = argv[++argi];
|
||||||
|
} else if (arg == "-n") {
|
||||||
|
if (argi + 1 >= argc) {
|
||||||
|
print_usage(true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
numbersFile = argv[++argi];
|
||||||
} else {
|
} else {
|
||||||
print_usage(true);
|
print_usage(true);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -71,7 +80,7 @@ public:
|
||||||
}
|
}
|
||||||
fSyscallInfos = gensyscall_get_infos(&fSyscallCount);
|
fSyscallInfos = gensyscall_get_infos(&fSyscallCount);
|
||||||
_UpdateSyscallInfos();
|
_UpdateSyscallInfos();
|
||||||
if (!syscallsFile && !dispatcherFile) {
|
if (!syscallsFile && !dispatcherFile && !numbersFile) {
|
||||||
printf("Found %d syscalls.\n", fSyscallCount);
|
printf("Found %d syscalls.\n", fSyscallCount);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +89,8 @@ public:
|
||||||
_WriteSyscallsFile(syscallsFile);
|
_WriteSyscallsFile(syscallsFile);
|
||||||
if (dispatcherFile)
|
if (dispatcherFile)
|
||||||
_WriteDispatcherFile(dispatcherFile);
|
_WriteDispatcherFile(dispatcherFile);
|
||||||
|
if (numbersFile)
|
||||||
|
_WriteNumbersFile(numbersFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +160,30 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _WriteNumbersFile(const char *filename)
|
||||||
|
{
|
||||||
|
// open the syscall numbers output file
|
||||||
|
ofstream file(filename, ofstream::out | ofstream::trunc);
|
||||||
|
if (!file.is_open())
|
||||||
|
throw IOException(string("Failed to open `") + filename + "'.");
|
||||||
|
// output the defines
|
||||||
|
const char *prefix = "_user_";
|
||||||
|
size_t prefixLen = strlen(prefix);
|
||||||
|
for (int i = 0; i < fSyscallCount; i++) {
|
||||||
|
const gensyscall_syscall_info &syscall = fSyscallInfos[i];
|
||||||
|
string name(syscall.kernel_name);
|
||||||
|
// drop the leading "_user_" prefix
|
||||||
|
if (name.find(prefix) != 0)
|
||||||
|
throw Exception(string("Bad kernel name: `") + name + "'.");
|
||||||
|
name = string(name, prefixLen);
|
||||||
|
// convert to upper case (is there no function for that?)
|
||||||
|
string defineName;
|
||||||
|
for (int k = 0; k < (int)name.length(); k++)
|
||||||
|
defineName += toupper(name[k]);
|
||||||
|
file << "#define SYSCALL_" << defineName << " " << i << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static string _GetPointerType(const char *type)
|
static string _GetPointerType(const char *type)
|
||||||
{
|
{
|
||||||
char *parenthesis = strchr(type, ')');
|
char *parenthesis = strchr(type, ')');
|
||||||
|
|
Loading…
Reference in New Issue