Usermode/ld-acess - Clean up loadlib.c, improved debug
[tpg/acess2.git] / KernelLand / 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 Kernel
28  * - By John Hodge (thePowersGang)
29  *
30  * syscalls.h
31  * - System Call List
32  *
33  * NOTE: Generated from Kernel/syscalls.lst
34  */
35 #ifndef _SYSCALLS_H
36 #define _SYSCALLS_H
37
38 ";
39
40 $lastid = -1;
41 $i = 0;
42 foreach my $call (@calls)
43 {
44         print HEADER "#define ", $call->[1], "\t", $call->[0], "\t// ", $call->[2], "\n";
45         $i = $call->[0] + 1;
46 }
47 print HEADER "
48 #define NUM_SYSCALLS    ",$i,"
49 #define SYS_DEBUGS      0x100
50 #define SYS_DEBUGF      0x101
51 #define SYS_DEBUGHEX    0x102
52
53 #if !defined(__ASSEMBLER__) && !defined(NO_SYSCALL_STRS)
54 static const char *cSYSCALL_NAMES[] = {
55 ";
56
57 $lastid = -1;
58 foreach $call (@calls)
59 {
60         while( $lastid + 1 < $call->[0] )
61         {
62                 print HEADER "\t\"\",\n";
63                 $lastid = $lastid + 1;
64         }
65         print HEADER "\t\"", $call->[1], "\",\n";
66         $lastid = $lastid + 1;
67 }
68 print HEADER  "
69 \t\"\"
70 };
71 #endif
72
73 #endif
74 ";
75
76 close(HEADER);
77
78 # Assembly Header
79 open(ASM, ">include/syscalls.inc.asm");
80 print ASM "; Acess2
81 ; System Calls List
82
83
84 ";
85 foreach $call (@calls)
86 {
87         print ASM "%define ", $call->[1], "\t", $call->[0], "\t ;", $call->[2], "\n";
88 }
89 close(ASM);

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