fdf33e91611b074e3cd252abc09fc516a97d2584
[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_DEBUG       0x100
50
51 #if !defined(__ASSEMBLER__) && !defined(NO_SYSCALL_STRS)
52 static const char *cSYSCALL_NAMES[] = {
53 ";
54
55 $lastid = -1;
56 foreach $call (@calls)
57 {
58         while( $lastid + 1 < $call->[0] )
59         {
60                 print HEADER "\t\"\",\n";
61                 $lastid = $lastid + 1;
62         }
63         print HEADER "\t\"", $call->[1], "\",\n";
64         $lastid = $lastid + 1;
65 }
66 print HEADER  "
67 \t\"\"
68 };
69 #endif
70
71 #endif
72 ";
73
74 close(HEADER);
75
76 # Assembly Header
77 open(ASM, ">include/syscalls.inc.asm");
78 print ASM "; Acess2
79 ; System Calls List
80
81
82 ";
83 foreach $call (@calls)
84 {
85         print ASM "%define ", $call->[1], "\t", $call->[0], "\t ;", $call->[2], "\n";
86 }
87 close(ASM);

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