macro.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * include/asm-arm/macro.h
  3. *
  4. * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef __ASM_ARM_MACRO_H__
  9. #define __ASM_ARM_MACRO_H__
  10. #ifdef __ASSEMBLY__
  11. /*
  12. * These macros provide a convenient way to write 8, 16 and 32 bit data
  13. * to any address.
  14. * Registers r4 and r5 are used, any data in these registers are
  15. * overwritten by the macros.
  16. * The macros are valid for any ARM architecture, they do not implement
  17. * any memory barriers so caution is recommended when using these when the
  18. * caches are enabled or on a multi-core system.
  19. */
  20. .macro write32, addr, data
  21. ldr r4, =\addr
  22. ldr r5, =\data
  23. str r5, [r4]
  24. .endm
  25. .macro write16, addr, data
  26. ldr r4, =\addr
  27. ldrh r5, =\data
  28. strh r5, [r4]
  29. .endm
  30. .macro write8, addr, data
  31. ldr r4, =\addr
  32. ldrb r5, =\data
  33. strb r5, [r4]
  34. .endm
  35. /*
  36. * This macro generates a loop that can be used for delays in the code.
  37. * Register r4 is used, any data in this register is overwritten by the
  38. * macro.
  39. * The macro is valid for any ARM architeture. The actual time spent in the
  40. * loop will vary from CPU to CPU though.
  41. */
  42. .macro wait_timer, time
  43. ldr r4, =\time
  44. 1:
  45. nop
  46. subs r4, r4, #1
  47. bcs 1b
  48. .endm
  49. #endif /* __ASSEMBLY__ */
  50. #endif /* __ASM_ARM_MACRO_H__ */