libnxflat.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /****************************************************************************
  2. * binfmt/libnxflat/libnxflat.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_LIBNXFLAT_LIBNXFLAT_H
  21. #define __BINFMT_LIBNXFLAT_LIBNXFLAT_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include <sys/types.h>
  27. #include <nuttx/arch.h>
  28. #include <nuttx/binfmt/nxflat.h>
  29. /****************************************************************************
  30. * Pre-processor Definitions
  31. ****************************************************************************/
  32. /****************************************************************************
  33. * Public Types
  34. ****************************************************************************/
  35. /****************************************************************************
  36. * Name: nxflat_addrenv_alloc
  37. *
  38. * Description:
  39. * Allocate data memory for the NXFLAT image. If CONFIG_ARCH_ADDRENV=n,
  40. * memory will be allocated using kmm_zalloc(). If CONFIG_ARCH_ADDRENV-y,
  41. * then memory will be allocated using up_addrenv_create().
  42. *
  43. * Input Parameters:
  44. * loadinfo - Load state information
  45. * envsize - The size (in bytes) of the address environment needed for the
  46. * ELF image.
  47. *
  48. * Returned Value:
  49. * Zero (OK) on success; a negated errno value on failure.
  50. *
  51. ****************************************************************************/
  52. int nxflat_addrenv_alloc(FAR struct nxflat_loadinfo_s *loadinfo,
  53. size_t envsize);
  54. /****************************************************************************
  55. * Name: nxflat_addrenv_select
  56. *
  57. * Description:
  58. * Temporarity select the task's address environment.
  59. *
  60. * Input Parameters:
  61. * loadinfo - Load state information
  62. *
  63. * Returned Value:
  64. * Zero (OK) on success; a negated errno value on failure.
  65. *
  66. ****************************************************************************/
  67. #ifdef CONFIG_ARCH_ADDRENV
  68. # define nxflat_addrenv_select(l) up_addrenv_select(&(l)->addrenv, &(l)->oldenv)
  69. #endif
  70. /****************************************************************************
  71. * Name: nxflat_addrenv_restore
  72. *
  73. * Description:
  74. * Restore the address environment before nxflat_addrenv_select() was
  75. * called..
  76. *
  77. * Input Parameters:
  78. * loadinfo - Load state information
  79. *
  80. * Returned Value:
  81. * Zero (OK) on success; a negated errno value on failure.
  82. *
  83. ****************************************************************************/
  84. #ifdef CONFIG_ARCH_ADDRENV
  85. # define nxflat_addrenv_restore(l) up_addrenv_restore(&(l)->oldenv)
  86. #endif
  87. /****************************************************************************
  88. * Name: nxflat_addrenv_free
  89. *
  90. * Description:
  91. * Release the address environment previously created by
  92. * nxflat_addrenv_alloc(). This function is called only under certain
  93. * error conditions after the module has been loaded but not yet
  94. * started. After the module has been started, the address environment
  95. * will automatically be freed when the module exits.
  96. *
  97. * Input Parameters:
  98. * loadinfo - Load state information
  99. *
  100. * Returned Value:
  101. * None.
  102. *
  103. ****************************************************************************/
  104. void nxflat_addrenv_free(FAR struct nxflat_loadinfo_s *loadinfo);
  105. #endif /* __BINFMT_LIBNXFLAT_LIBNXFLAT_H */