or1k-asm-test-env.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Testsuite macros for OpenRISC.
  2. Copyright (C) 2017-2022 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #ifndef OR1K_ASM_TEST_ENV_H
  14. #define OR1K_ASM_TEST_ENV_H
  15. #include "or1k-asm.h"
  16. #include "or1k-asm-test.h"
  17. .macro STANDARD_TEST_HEADER
  18. /* Without the "a" (allocatable) flag, this section gets some
  19. default flags and is discarded by objcopy when flattening to
  20. the binary file. */
  21. .section .exception_vectors, "ax"
  22. .org 0x100
  23. .global _start
  24. _start:
  25. /* Clear R0 on start-up. There is no guarantee that R0 is hardwired
  26. to zero and indeed it is not when simulating. */
  27. CLEAR_REG r0
  28. OR1K_DELAYED_NOP(l.j test_startup)
  29. .section .text
  30. test_startup:
  31. .endm
  32. .macro STANDARD_TEST_BODY
  33. LOAD_IMMEDIATE STACK_POINTER_R1, stack_begin
  34. CLEAR_BSS r3, r4
  35. CALL r3, start_tests
  36. EXIT_SIMULATION_WITH_IMMEDIATE_EXIT_CODE SEC_SUCCESS
  37. .section .stack
  38. .space 4096 /* We need more than EXCEPTION_STACK_SKIP_SIZE bytes. */
  39. stack_begin:
  40. .endm
  41. .macro STANDARD_TEST_ENVIRONMENT
  42. /* One of the test cases needs to do some tests before setting up
  43. the stack and so on. That's the reason this macro is split into
  44. 2 parts allowing the caller to inject code between the 2
  45. initialisation phases. */
  46. STANDARD_TEST_HEADER
  47. STANDARD_TEST_BODY
  48. .endm
  49. #endif /* OR1K_ASM_TEST_ENV_H */