Division bug hidden, now only shows when 64-bit division is needed
[tpg/acess2.git] / 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 enum eSyscalls {
31 ";
32 $i = 0;
33 foreach($lSyscalls as $num=>$call)
34 {
35         if($i != $num)  {
36                 $lHeader .= "\n";
37                 $lAsmInc .= "\n";
38         }
39         
40         $lHeader .= "\t{$call[0]}";
41         if($i != $num)  $lHeader .= " = {$num}";
42         $lHeader .= ",\t// {$num} - {$call[1]}\n";
43         
44         $lAsmInc .= "%define {$call[0]}\t{$num}\t; {$call[1]}\n";
45         
46         
47         if($i != $num)
48                 $i = $num+1;
49         else
50                 $i ++;
51 }
52 $lHeader .= "\tNUM_SYSCALLS,\n";
53 $lHeader .= "\tSYS_DEBUG = 0x100        // 0x100 - Print a debug string\n";
54 $lHeader .= "};\n\n";
55 $lHeader .= "static const char *cSYSCALL_NAMES[] = {\n\t";
56
57 $j = 0;
58 for($i=0;$i<$lMax;$i++)
59 {
60         if(!isset($lSyscalls[$i]))
61                 $lHeader .= "\"\",";
62         else
63                 $lHeader .= "\"".$lSyscalls[$i][0]."\",";
64         $j ++;
65         if($j == 6) {
66                 $lHeader .= "\n\t";
67                 $j = 0;
68         }
69 }
70 $lHeader .= "\"\"\n};\n#endif\n";
71
72 $fp = fopen("include/syscalls.h", "w"); fwrite($fp, $lHeader);  fclose($fp);
73 $fp = fopen("include/syscalls.inc.asm", "w");   fwrite($fp, $lAsmInc);  fclose($fp);
74
75 ?>

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