binfmt.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /****************************************************************************
  2. * binfmt/binfmt.h
  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. #ifndef __BINFMT_BINFMT_H
  21. #define __BINFMT_BINFMT_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include <nuttx/binfmt/binfmt.h>
  27. /****************************************************************************
  28. * Pre-processor Definitions
  29. ****************************************************************************/
  30. /****************************************************************************
  31. * Public Data
  32. ****************************************************************************/
  33. #undef EXTERN
  34. #if defined(__cplusplus)
  35. #define EXTERN extern "C"
  36. extern "C"
  37. {
  38. #else
  39. #define EXTERN extern
  40. #endif
  41. /* This is a list of registered handlers for different binary formats.
  42. * This list should only be accessed by normal user programs. It should be
  43. * sufficient protection to simply disable pre-emption when accessing this
  44. * list.
  45. */
  46. EXTERN FAR struct binfmt_s *g_binfmts;
  47. /****************************************************************************
  48. * Public Function Prototypes
  49. ****************************************************************************/
  50. /****************************************************************************
  51. * Name: dump_module
  52. *
  53. * Description:
  54. * Dump the contents of struct binary_s.
  55. *
  56. * Input Parameters:
  57. * bin - Load structure
  58. *
  59. * Returned Value:
  60. * Zero (OK) on success; a negated errno value on failure
  61. *
  62. ****************************************************************************/
  63. #if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_DEBUG_BINFMT)
  64. int dump_module(FAR const struct binary_s *bin);
  65. #else
  66. # define dump_module(bin)
  67. #endif
  68. /****************************************************************************
  69. * Name: binfmt_copyargv
  70. *
  71. * Description:
  72. * In the kernel build, the argv list will likely lie in the caller's
  73. * address environment and, hence, be inaccessible when we switch to the
  74. * address environment of the new process address environment. So we
  75. * do not have any real option other than to copy the callers argv[] list.
  76. *
  77. * Input Parameters:
  78. * bin - Load structure
  79. * argv - Argument list
  80. *
  81. * Returned Value:
  82. * Zero (OK) on success; a negated errno value on failure.
  83. *
  84. ****************************************************************************/
  85. int binfmt_copyargv(FAR struct binary_s *bin, FAR char * const *argv);
  86. /****************************************************************************
  87. * Name: binfmt_freeargv
  88. *
  89. * Description:
  90. * Release the copied argv[] list.
  91. *
  92. * Input Parameters:
  93. * bin - Load structure
  94. *
  95. * Returned Value:
  96. * None
  97. *
  98. ****************************************************************************/
  99. #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
  100. void binfmt_freeargv(FAR struct binary_s *bin);
  101. #else
  102. # define binfmt_freeargv(bin)
  103. #endif
  104. /****************************************************************************
  105. * Name: builtin_initialize
  106. *
  107. * Description:
  108. * In order to use the builtin binary format, this function must be called
  109. * during system initialize to register the builtin binary format.
  110. *
  111. * Returned Value:
  112. * This is a NuttX internal function so it follows the convention that
  113. * 0 (OK) is returned on success and a negated errno is returned on
  114. * failure.
  115. *
  116. ****************************************************************************/
  117. #ifdef CONFIG_FS_BINFS
  118. int builtin_initialize(void);
  119. #endif
  120. /****************************************************************************
  121. * Name: builtin_uninitialize
  122. *
  123. * Description:
  124. * Unregister the builtin binary loader
  125. *
  126. * Returned Value:
  127. * None
  128. *
  129. ****************************************************************************/
  130. #ifdef CONFIG_FS_BINFS
  131. void builtin_uninitialize(void);
  132. #endif
  133. #undef EXTERN
  134. #if defined(__cplusplus)
  135. }
  136. #endif
  137. #endif /* __BINFMT_BINFMT_H */