Usermode/ld-acess - Disabled PIC (not needed)
[tpg/acess2.git] / Kernel / GenSyscalls.pl
1 #!/usr/bin/perl
2 #
3 #
4
5 open(FILE, "syscalls.lst");
6
7 $num = 0;
8 @calls = ();
9 while($_ = <FILE>)
10 {
11         if(/(\d+)/)
12         {
13                 $num = $1;
14         }
15         elsif(/([A-Z_]+)\s+(.+)/)
16         {
17                 push @calls, [$num, $1, $2];
18                 $num ++;
19         }
20 }
21
22 close(FILE);
23
24 # C header
25 open(HEADER, ">include/syscalls.h");
26 print HEADER "/*
27  * Acess2
28  * syscalls.h
29  * - System Call List
30  *
31  * NOTE: Generated from Kernel/syscalls.lst
32  */
33 #ifndef _SYSCALLS_H
34 #define _SYSCALLS_H
35
36 enum eSyscalls {
37 ";
38
39 $lastid = -1;
40 foreach my $call (@calls)
41 {
42         if( $lastid + 1 != $call->[0] ) {
43                 print HEADER "\n";
44         }
45         print HEADER "\t", $call->[1];
46         if( $lastid + 1 != $call->[0] ) {
47                 print HEADER " = ", $call->[0];
48         }
49         print HEADER ",\t// ", $call->[2], "\n";
50         $lastid = $call->[0];
51 }
52 print HEADER "
53 \tNUM_SYSCALLS,
54 \tSYS_DEBUG = 0x100
55 };
56
57 static const char *cSYSCALL_NAMES[] = {
58 ";
59
60 $lastid = -1;
61 foreach $call (@calls)
62 {
63         while( $lastid + 1 < $call->[0] )
64         {
65                 print HEADER "\t\"\",\n";
66                 $lastid = $lastid + 1;
67         }
68         print HEADER "\t\"", $call->[1], "\",\n";
69         $lastid = $lastid + 1;
70 }
71 print HEADER  "
72 \t\"\"
73 };
74
75 #endif
76 ";
77
78 close(HEADER);
79
80 # Assembly Header
81 open(ASM, ">include/syscalls.inc.asm");
82 print ASM "; Acess2
83 ; System Calls List
84
85
86 ";
87 foreach $call (@calls)
88 {
89         print ASM "%define ", $call->[1], "\t", $call->[0], "\t ;", $call->[2], "\n";
90 }
91 close(ASM);

UCC git Repository :: git.ucc.asn.au