syscalltbl.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. in="$1"
  3. out="$2"
  4. syscall_macro() {
  5. abi="$1"
  6. nr="$2"
  7. entry="$3"
  8. # Entry can be either just a function name or "function/qualifier"
  9. real_entry="${entry%%/*}"
  10. if [ "$entry" = "$real_entry" ]; then
  11. qualifier=
  12. else
  13. qualifier=${entry#*/}
  14. fi
  15. echo "__SYSCALL_${abi}($nr, $real_entry, $qualifier)"
  16. }
  17. emit() {
  18. abi="$1"
  19. nr="$2"
  20. entry="$3"
  21. compat="$4"
  22. if [ "$abi" = "64" -a -n "$compat" ]; then
  23. echo "a compat entry for a 64-bit syscall makes no sense" >&2
  24. exit 1
  25. fi
  26. if [ -z "$compat" ]; then
  27. if [ -n "$entry" ]; then
  28. syscall_macro "$abi" "$nr" "$entry"
  29. fi
  30. else
  31. echo "#ifdef CONFIG_X86_32"
  32. if [ -n "$entry" ]; then
  33. syscall_macro "$abi" "$nr" "$entry"
  34. fi
  35. echo "#else"
  36. syscall_macro "$abi" "$nr" "$compat"
  37. echo "#endif"
  38. fi
  39. }
  40. grep '^[0-9]' "$in" | sort -n | (
  41. while read nr abi name entry compat; do
  42. abi=`echo "$abi" | tr '[a-z]' '[A-Z]'`
  43. if [ "$abi" = "COMMON" -o "$abi" = "64" ]; then
  44. # COMMON is the same as 64, except that we don't expect X32
  45. # programs to use it. Our expectation has nothing to do with
  46. # any generated code, so treat them the same.
  47. emit 64 "$nr" "$entry" "$compat"
  48. elif [ "$abi" = "X32" ]; then
  49. # X32 is equivalent to 64 on an X32-compatible kernel.
  50. echo "#ifdef CONFIG_X86_X32_ABI"
  51. emit 64 "$nr" "$entry" "$compat"
  52. echo "#endif"
  53. elif [ "$abi" = "I386" ]; then
  54. emit "$abi" "$nr" "$entry" "$compat"
  55. else
  56. echo "Unknown abi $abi" >&2
  57. exit 1
  58. fi
  59. done
  60. ) > "$out"