syscall_stublookup.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /****************************************************************************
  2. * syscall/syscall_stublookup.c
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. /****************************************************************************
  21. * Included Files
  22. ****************************************************************************/
  23. #include <nuttx/config.h>
  24. #include <sys/types.h>
  25. #include <syscall.h>
  26. /* The content of this file is only meaningful during the kernel phase of
  27. * a kernel build.
  28. */
  29. #if defined(CONFIG_LIB_SYSCALL)
  30. /****************************************************************************
  31. * Pre-processor Definitions
  32. ****************************************************************************/
  33. #define CAT(p,f) CAT_(p, f)
  34. #define CAT_(p,f) p##f
  35. #define STUB_NAME(f) CAT(STUB_, f)
  36. #define STUB_PROT0(f) \
  37. uintptr_t STUB_NAME(f)(int nbr)
  38. #define STUB_PROT1(f) \
  39. uintptr_t STUB_NAME(f)(int nbr, uintptr_t parm1)
  40. #define STUB_PROT2(f) \
  41. uintptr_t STUB_NAME(f)(int nbr, uintptr_t parm1, uintptr_t parm2)
  42. #define STUB_PROT3(f) \
  43. uintptr_t STUB_NAME(f)(int nbr, uintptr_t parm1, uintptr_t parm2, \
  44. uintptr_t parm3)
  45. #define STUB_PROT4(f) \
  46. uintptr_t STUB_NAME(f)(int nbr, uintptr_t parm1, uintptr_t parm2, \
  47. uintptr_t parm3, uintptr_t parm4)
  48. #define STUB_PROT5(f) \
  49. uintptr_t STUB_NAME(f)(int nbr, uintptr_t parm1, uintptr_t parm2, \
  50. uintptr_t parm3, uintptr_t parm4, uintptr_t parm5)
  51. #define STUB_PROT6(f) \
  52. uintptr_t STUB_NAME(f)(int nbr, uintptr_t parm1, uintptr_t parm2, \
  53. uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, \
  54. uintptr_t parm6)
  55. #define STUB_PROT(f, n) CAT(STUB_PROT, n)(f)
  56. /****************************************************************************
  57. * Stub Function Prototypes
  58. ****************************************************************************/
  59. #define SYSCALL_LOOKUP1(f,n) STUB_PROT(f, n);
  60. #define SYSCALL_LOOKUP(f,n) STUB_PROT(f, n);
  61. #include <sys/syscall_lookup.h>
  62. #undef SYSCALL_LOOKUP1
  63. #undef SYSCALL_LOOKUP
  64. /****************************************************************************
  65. * Public Data
  66. ****************************************************************************/
  67. /* Stub lookup tables. This table is indexed by the system call number.
  68. * Given the system call number, the corresponding entry in this table
  69. * provides the address of the stub function.
  70. */
  71. const uintptr_t g_stublookup[SYS_nsyscalls] =
  72. {
  73. # define SYSCALL_LOOKUP1(f,n) (uintptr_t)STUB_NAME(f)
  74. # define SYSCALL_LOOKUP(f,n) , (uintptr_t)STUB_NAME(f)
  75. # include <sys/syscall_lookup.h>
  76. # undef SYSCALL_LOOKUP1
  77. # undef SYSCALL_LOOKUP
  78. };
  79. /****************************************************************************
  80. * Public Functions
  81. ****************************************************************************/
  82. #endif /* CONFIG_LIB_SYSCALL */