home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / kern / makesyscalls.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-07-09  |  7.4 KB  |  284 lines

  1. #! /bin/sh -
  2. # Mach Operating System
  3. # Copyright (c) 1992 Carnegie Mellon University
  4. # All Rights Reserved.
  5. # Permission to use, copy, modify and distribute this software and its
  6. # documentation is hereby granted, provided that both the copyright
  7. # notice and this permission notice appear in all copies of the
  8. # software, derivative works or modified versions, and any portions
  9. # thereof, and that both notices appear in supporting documentation.
  10. # CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  11. # CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  12. # ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  13. # Carnegie Mellon requests users of this software to return to
  14. #  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  15. #  School of Computer Science
  16. #  Carnegie Mellon University
  17. #  Pittsburgh PA 15213-3890
  18. # any improvements or extensions that they make and grant Carnegie Mellon 
  19. # the rights to redistribute these changes.
  20. #
  21. #
  22. # HISTORY
  23. # $Log:    makesyscalls.sh,v $
  24. # Revision 2.3  92/06/25  17:28:53  mrt
  25. #     Corrected include of param.h
  26. #     [92/06/17            mrt]
  27. # Revision 2.2  92/05/25  14:44:02  rwd
  28. #     Fix includes.
  29. #     [92/05/18            rwd]
  30. # Revision 2.1  92/04/21  17:12:50  rwd
  31. # BSDSS
  32. #
  33. #
  34.  
  35. #    @(#)makesyscalls.sh    7.6 (Berkeley) 4/20/91
  36.  
  37. set -e
  38.  
  39. # name of compat option:
  40. compat=COMPAT_43
  41.  
  42. # output files:
  43. sysnames="syscalls.c"
  44. syshdr="../sys/syscall.h"
  45. syssw="init_sysent.c"
  46. syse="../emul_sysent.c"
  47.  
  48. # tmp files:
  49. sysdcl="sysent.dcl"
  50. syscompat="sysent.compat"
  51. sysent="sysent.switch"
  52. emldcl="emlent.dcl"
  53. emlent="emlent.switch"
  54.  
  55. trap "rm $sysdcl $syscompat $sysent $emldcl $emlent" 0
  56.  
  57. case $# in
  58.     0)    echo "Usage: $0 input-file" 1>&2
  59.     exit 1
  60.     ;;
  61. esac
  62.  
  63. awk < $1 "
  64.     BEGIN {
  65.         sysdcl = \"$sysdcl\"
  66.         syscompat = \"$syscompat\"
  67.         sysent = \"$sysent\"
  68.         sysnames = \"$sysnames\"
  69.         syshdr = \"$syshdr\"
  70.         compat = \"$compat\"
  71.         emldcl = \"$emldcl\"
  72.         emlent = \"$emlent\"
  73.         infile = \"$1\"
  74.         "'
  75.  
  76.         printf "/*\n * System call switch table.\n *\n" > sysdcl
  77.         printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
  78.  
  79.         printf "\n#ifdef %s\n", compat > syscompat
  80.         printf "#define compat(n, name) n, __CONCAT(o,name)\n\n" > syscompat
  81.  
  82.         printf "/*\n * System call names.\n *\n" > sysnames
  83.         printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
  84.  
  85.         printf "/*\n * System call numbers.\n *\n" > syshdr
  86.         printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr
  87.  
  88.         printf "/*\n * System call switch table.\n *\n" > emldcl
  89.         printf " * DO NOT EDIT-- this file is automatically generated.\n" > emldcl
  90.  
  91.     }
  92.     NR == 1 {
  93.         printf " * created from%s\n */\n\n", $0 > sysdcl
  94.         printf "#include <sys/param.h>\n" > sysdcl
  95.         printf "#include <sys/systm.h>\n\n" > sysdcl
  96.         printf "int\tnosys();\n\n" > sysdcl
  97.  
  98.         printf "struct sysent sysent[] = {\n" > sysent
  99.  
  100.         printf " * created from%s\n */\n\n", $0 > sysnames
  101.         printf "char *syscallnames[] = {\n" > sysnames
  102.  
  103.         printf " * created from%s\n */\n\n", $0 > syshdr
  104.  
  105.         printf " * created from%s\n */\n\n", $0 > emldcl
  106.         printf "#include <syscall_table.h>\n" > emldcl
  107.         printf "#define syss(routine, nargs)    { nargs, routine }\n" >emldcl
  108.         printf "#define sysg                    { E_GENERIC, emul_generic }\n" > emldcl
  109.         printf "#define sysr(routine)           { E_CHANGE_REGS, routine }\n" > emldcl
  110.         printf "int emul_generic();\n" > emldcl
  111.         printf "int e_htg_syscall();\n" > emldcl
  112.         printf "int bsd_pid_by_task();\n" > emldcl
  113.         printf "int bsd_task_by_pid();\n" > emldcl
  114.         printf "int bsd_init_process();\n" > emldcl
  115.         printf "#define e_setgroups    bsd_setgroups\n" > emldcl
  116.         printf "#define e_sethostname    bsd_sethostname\n" > emldcl
  117.         printf "#define e_connect    bsd_connect\n" > emldcl
  118.         printf "#define e_bind        bsd_bind\n" > emldcl
  119.         printf "#define e_adjtime    bsd_adjtime\n" > emldcl
  120.         printf "#define e_setrlimit    bsd_setrlimit\n" > emldcl
  121.         printf "#define e_vfork        e_fork\n" > emldcl
  122.  
  123.         printf "struct sysent sysent[] = {\n" > emlent
  124.  
  125.         next
  126.     }
  127.     NF == 0 || $1 ~ /^;/ {
  128.         next
  129.     }
  130.     $1 ~ /^#[     ]*if/ {
  131.         print > sysent
  132.         print > sysdcl
  133.         print > syscompat
  134.         print > sysnames
  135.         print > emldcl
  136.         print > emlent
  137.         savesyscall = syscall
  138.         next
  139.     }
  140.     $1 ~ /^#[     ]*else/ {
  141.         print > sysent
  142.         print > sysdcl
  143.         print > syscompat
  144.         print > sysnames
  145.         print > emldcl
  146.         print > emlent
  147.         syscall = savesyscall
  148.         next
  149.     }
  150.     $1 ~ /^#/ {
  151.         print > sysent
  152.         print > sysdcl
  153.         print > syscompat
  154.         print > sysnames
  155.         print > emldcl
  156.         print > emlent
  157.         next
  158.     }
  159.     syscall != $1 {
  160.         printf "%s: line %d: syscall number out of sync at %d\n", \
  161.            infile, NR, syscall
  162.         printf "line is:\n"
  163.         print
  164.         exit 1
  165.     }
  166.     {    comment = $5
  167.         for (i = 6; i <= NF; i++)
  168.             comment = comment " " $i
  169.         if (NF < 6)
  170.             $6 = $5
  171.     }
  172.     $3 == "SYSG" {
  173.         printf("\tsysg,\t\t\t\t/* %d */\n",syscall) > emlent
  174.     }
  175.     $3 == "SYSR" {
  176.         printf("\tsysr(e_%s),\t\t\t/* %d */\n",$5,syscall) > emlent
  177.         printf("int e_%s();\n",$5) > emldcl
  178.     }
  179.     $3 == "SYSS" {
  180.         printf("\tsyss(e_%s, %d),\t\t/* %d */\n",$5,$4,syscall) > emlent
  181.         printf("int e_%s();\n",$5) > emldcl
  182.     }
  183.     $2 == "STD" {
  184.         printf("int\t%s();\n", $5) > sysdcl
  185.         printf("\t%d, %s,\t\t\t/* %d = %s */\n", \
  186.             $3, $5, syscall, $6) > sysent
  187.         printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
  188.             $6, syscall, $6) > sysnames
  189.         printf("#define\tSYS_%s\t%d\n", \
  190.             $6, syscall) > syshdr
  191.         syscall++
  192.         next
  193.     }
  194.     $2 == "COMPAT" {
  195.         printf("int\to%s();\n", $5) > syscompat
  196.         printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \
  197.             $4, $5, syscall, $6) > sysent
  198.         printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
  199.             $6, syscall, $6) > sysnames
  200.         printf("#define\tSYS_o%s\t%d\n", \
  201.             $6, syscall) > syshdr
  202.         printf("\t\t\t\t/* %d is old %s */\n", \
  203.             syscall, comment) > syshdr
  204.         syscall++
  205.         next
  206.     }
  207.     $2 == "LIBCOMPAT" {
  208.         printf("int\to%s();\n", $5) > syscompat
  209.         printf("\tcompat(%d,%s),\t\t/* %d = old %s */\n", \
  210.             $4, $5, syscall, $6) > sysent
  211.         printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
  212.             $6, syscall, $6) > sysnames
  213.         printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \
  214.             $6, syscall) > syshdr
  215.         syscall++
  216.         next
  217.     }
  218.     $2 == "OBSOL" {
  219.         printf("\t0, nosys,\t\t\t/* %d = obsolete %s */\n", \
  220.             syscall, comment) > sysent
  221.         printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \
  222.             $5, syscall, comment) > sysnames
  223.         printf("\t\t\t\t/* %d is obsolete %s */\n", \
  224.             syscall, comment) > syshdr
  225.         syscall++
  226.         next
  227.     }
  228.     $2 == "UNIMPL" {
  229.         printf("\t0, nosys,\t\t\t/* %d = %s */\n", \
  230.             syscall, comment) > sysent
  231.         printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \
  232.             syscall, syscall, comment) > sysnames
  233.         syscall++
  234.         next
  235.     }
  236.     {
  237.         printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
  238.         exit 1
  239.     }
  240.     END {
  241.         printf("\n#else /* %s */\n", compat) > syscompat
  242.         printf("#define compat(n, name) 0, nosys\n") > syscompat
  243.         printf("#endif /* %s */\n\n", compat) > syscompat
  244.  
  245.         printf("};\n\n") > sysent
  246.         printf("int\tnsysent = sizeof(sysent) / sizeof(sysent[0]);\n") > sysent
  247.  
  248.         printf("};\n") > sysnames
  249.     } '
  250.  
  251. cat $sysdcl $syscompat $sysent >$syssw
  252.  
  253. cat $emldcl $emlent > $syse
  254.  
  255. cat >> $syse <<+EOF+ #------------------------------------------------------
  256. };
  257.  
  258. int    nsysent = sizeof(sysent)/sizeof(struct sysent);
  259.  
  260. struct sysent   sysent_task_by_pid =
  261.         syss(bsd_task_by_pid, 1);
  262.  
  263. struct sysent   sysent_pid_by_task =
  264.         syss(bsd_pid_by_task, 4);
  265.  
  266. struct sysent   sysent_htg_ux_syscall =
  267.         sysr(e_htg_syscall);
  268.  
  269. struct sysent   sysent_init_process =
  270.         syss(bsd_init_process, 1);
  271.  
  272. +EOF+
  273.  
  274. chmod 444 $sysnames $syshdr $syssw
  275.