offload_myo_host.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. Copyright (c) 2014 Intel Corporation. All Rights Reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of Intel Corporation nor the names of its
  12. contributors may be used to endorse or promote products derived
  13. from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  18. HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  20. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef OFFLOAD_MYO_HOST_H_INCLUDED
  27. #define OFFLOAD_MYO_HOST_H_INCLUDED
  28. #include <myotypes.h>
  29. #include <myoimpl.h>
  30. #include <myo.h>
  31. #include "offload.h"
  32. typedef MyoiSharedVarEntry SharedTableEntry;
  33. //typedef MyoiHostSharedFptrEntry FptrTableEntry;
  34. typedef struct {
  35. //! Function Name
  36. const char *funcName;
  37. //! Function Address
  38. void *funcAddr;
  39. //! Local Thunk Address
  40. void *localThunkAddr;
  41. #ifdef TARGET_WINNT
  42. // Dummy to pad up to 32 bytes
  43. void *dummy;
  44. #endif // TARGET_WINNT
  45. } FptrTableEntry;
  46. struct InitTableEntry {
  47. #ifdef TARGET_WINNT
  48. // Dummy to pad up to 16 bytes
  49. // Function Name
  50. const char *funcName;
  51. #endif // TARGET_WINNT
  52. void (*func)(void);
  53. };
  54. #ifdef TARGET_WINNT
  55. #define OFFLOAD_MYO_SHARED_TABLE_SECTION_START ".MyoSharedTable$a"
  56. #define OFFLOAD_MYO_SHARED_TABLE_SECTION_END ".MyoSharedTable$z"
  57. #define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_START ".MyoSharedInitTable$a"
  58. #define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END ".MyoSharedInitTable$z"
  59. #define OFFLOAD_MYO_FPTR_TABLE_SECTION_START ".MyoFptrTable$a"
  60. #define OFFLOAD_MYO_FPTR_TABLE_SECTION_END ".MyoFptrTable$z"
  61. #else // TARGET_WINNT
  62. #define OFFLOAD_MYO_SHARED_TABLE_SECTION_START ".MyoSharedTable."
  63. #define OFFLOAD_MYO_SHARED_TABLE_SECTION_END ".MyoSharedTable."
  64. #define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_START ".MyoSharedInitTable."
  65. #define OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END ".MyoSharedInitTable."
  66. #define OFFLOAD_MYO_FPTR_TABLE_SECTION_START ".MyoFptrTable."
  67. #define OFFLOAD_MYO_FPTR_TABLE_SECTION_END ".MyoFptrTable."
  68. #endif // TARGET_WINNT
  69. #pragma section(OFFLOAD_MYO_SHARED_TABLE_SECTION_START, read, write)
  70. #pragma section(OFFLOAD_MYO_SHARED_TABLE_SECTION_END, read, write)
  71. #pragma section(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_START, read, write)
  72. #pragma section(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END, read, write)
  73. #pragma section(OFFLOAD_MYO_FPTR_TABLE_SECTION_START, read, write)
  74. #pragma section(OFFLOAD_MYO_FPTR_TABLE_SECTION_END, read, write)
  75. extern "C" void __offload_myoRegisterTables(
  76. InitTableEntry *init_table,
  77. SharedTableEntry *shared_table,
  78. FptrTableEntry *fptr_table
  79. );
  80. extern void __offload_myoFini(void);
  81. #endif // OFFLOAD_MYO_HOST_H_INCLUDED