syscalltbl.sh 1.5 KB

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