syscalltbl.sh 1.6 KB

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