integration_test_plat_utils.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**************************************************************************************
  2. * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
  3. * *
  4. * This file and the related binary are licensed under the following license: *
  5. * *
  6. * ARM Object Code and Header Files License, v1.0 Redistribution. *
  7. * *
  8. * Redistribution and use of object code, header files, and documentation, without *
  9. * modification, are permitted provided that the following conditions are met: *
  10. * *
  11. * 1) Redistributions must reproduce the above copyright notice and the *
  12. * following disclaimer in the documentation and/or other materials *
  13. * provided with the distribution. *
  14. * *
  15. * 2) Unless to the extent explicitly permitted by law, no reverse *
  16. * engineering, decompilation, or disassembly of is permitted. *
  17. * *
  18. * 3) Redistribution and use is permitted solely for the purpose of *
  19. * developing or executing applications that are targeted for use *
  20. * on an ARM-based product. *
  21. * *
  22. * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
  23. * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
  24. * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
  25. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
  26. * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
  28. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
  33. **************************************************************************************/
  34. #ifdef DX_LINUX_PLATFORM
  35. #include <sys/mman.h>
  36. #include <stdint.h>
  37. #include <unistd.h>
  38. #include <sys/types.h>
  39. #include <sys/stat.h>
  40. #include <fcntl.h>
  41. #include <stdio.h>
  42. #include <errno.h>
  43. #include <pthread.h>
  44. #endif
  45. #include "ssi_pal_types.h"
  46. #include "integration_test_plat_defs.h"
  47. #include "crys_rnd.h"
  48. #include "nrf.h"
  49. #include "SEGGER_RTT.h"
  50. /*Globals*/
  51. uint32_t g_free_mem_addr;
  52. uint32_t *g_test_stack_base_addr;
  53. uint32_t g_rom_base_addr;
  54. uint32_t g_env_rom_base_addr;
  55. CRYS_RND_WorkBuff_t* rndWorkBuff_ptr;
  56. CRYS_RND_State_t* rndState_ptr;
  57. #if defined(__CC_ARM)
  58. CRYS_RND_State_t rndState = {0};
  59. CRYS_RND_WorkBuff_t rndWorkBuff = {0};
  60. #else
  61. CRYS_RND_State_t rndState;
  62. CRYS_RND_WorkBuff_t rndWorkBuff;
  63. #endif
  64. uint32_t* UserSpace = 0;
  65. //initializatoins that need to be done prior to running the integration tests.
  66. SaSiError_t integration_tests_setup(void)
  67. {
  68. SaSiError_t ret = 0;
  69. rndState_ptr = &rndState;
  70. rndWorkBuff_ptr = &rndWorkBuff;
  71. // Initialize Segger RTT logging
  72. (void)SEGGER_RTT_Init();
  73. INTEG_TEST_PRINT("==================== TEST START ====================\r\n");
  74. //NVIC_EnableIRQ(CRYPTOCELL_IRQn);
  75. //NRF_CRYPTOCELL->ENABLE = 1;
  76. return ret;
  77. }
  78. void integration_tests_clear(void)
  79. {
  80. INTEG_TEST_PRINT("==================== TEST END ====================\r\n");
  81. while(1)
  82. {
  83. __WFI();
  84. }
  85. }
  86. void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
  87. {
  88. (void)id;
  89. (void)pc;
  90. (void)info;
  91. while(1);
  92. }
  93. void SaSi_PalAbort(const char *msg)
  94. {
  95. // This function overrides SaSi_PalAbort implemented in the library.
  96. // The library version does a NVIC_SystemReset() and has no logging.
  97. INTEG_TEST_PRINT("CC310 abort called: %s\r\n", msg);
  98. while(1);
  99. }