Kernel - Slight reworks to timer code
[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 ";
37
38 $lastid = -1;
39 $i = 0;
40 foreach my $call (@calls)
41 {
42         print HEADER "#define ", $call->[1], "\t", $call->[0], "\t// ", $call->[2], "\n";
43         $i = $call->[0] + 1;
44 }
45 print HEADER "
46 #define NUM_SYSCALLS    ",$i,"
47 #define SYS_DEBUG       0x100
48
49 #ifndef __ASSEMBLER__
50 static const char *cSYSCALL_NAMES[] = {
51 ";
52
53 $lastid = -1;
54 foreach $call (@calls)
55 {
56         while( $lastid + 1 < $call->[0] )
57         {
58                 print HEADER "\t\"\",\n";
59                 $lastid = $lastid + 1;
60         }
61         print HEADER "\t\"", $call->[1], "\",\n";
62         $lastid = $lastid + 1;
63 }
64 print HEADER  "
65 \t\"\"
66 };
67 #endif
68
69 #endif
70 ";
71
72 close(HEADER);
73
74 # Assembly Header
75 open(ASM, ">include/syscalls.inc.asm");
76 print ASM "; Acess2
77 ; System Calls List
78
79
80 ";
81 foreach $call (@calls)
82 {
83         print ASM "%define ", $call->[1], "\t", $call->[0], "\t ;", $call->[2], "\n";
84 }
85 close(ASM);

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