Kernel - Added snprintf function
[tpg/acess2.git] / KernelLand / Kernel / GenSyscalls.php
1 <?php
2 $gLines = file("syscalls.lst");
3
4 $lSyscalls = array();
5 $i = 0;
6 foreach($gLines as $line)
7 {
8         $line = trim($line);
9         if(empty($line))        continue;
10         
11         if( intVal($line) != 0)
12                 $i = $line;
13         else
14                 $lSyscalls[$i++] = explode("\t", $line, 3);
15 }
16 $lMax = $i;
17
18 $lAsmInc = "; Acess2
19 ; System Calls List
20
21
22 ";
23 $lHeader  = "/*
24  * AcessOS Microkernel Version
25  * syscalls.h
26  */
27 #ifndef _SYSCALLS_H
28 #define _SYSCALLS_H
29
30 ";
31 $i = 0;
32 foreach($lSyscalls as $num=>$call)
33 {
34         if($i != $num)  {
35                 $lHeader .= "\n";
36                 $lAsmInc .= "\n";
37         }
38         
39         $lHeader .= "#define {$call[0]}\t{$num}";
40         $lHeader .= "\t// {$num} - {$call[1]}\n";
41         
42         $lAsmInc .= "%define {$call[0]}\t{$num}\t; {$call[1]}\n";
43         
44         
45         if($i != $num)
46                 $i = $num+1;
47         else
48                 $i ++;
49 }
50 $lHeader .= "#define NUM_SYSCALLS\t$i\n";
51 $lHeader .= "#define SYS_DEBUG\t0x100   // 0x100 - Print a debug string\n";
52 $lHeader .= "\n";
53 $lHeader .= "#ifdef __GNUC__\n";
54 $lHeader .= "static const char *cSYSCALL_NAMES[] = {\n\t";
55
56 $j = 0;
57 for($i=0;$i<$lMax;$i++)
58 {
59         if(!isset($lSyscalls[$i]))
60                 $lHeader .= "\"\",";
61         else
62                 $lHeader .= "\"".$lSyscalls[$i][0]."\",";
63         $j ++;
64         if($j == 6) {
65                 $lHeader .= "\n\t";
66                 $j = 0;
67         }
68 }
69 $lHeader .= "\"\"\n};\n"
70 $lHeader .= "#endif\n";
71 $lHeader .= "#endif\n";
72
73 $fp = fopen("include/syscalls.h", "w"); fwrite($fp, $lHeader);  fclose($fp);
74 $fp = fopen("include/syscalls.inc.asm", "w");   fwrite($fp, $lAsmInc);  fclose($fp);
75
76 ?>

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