macro.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * include/asm-arm/macro.h
  3. *
  4. * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #ifndef __ASM_ARM_MACRO_H__
  25. #define __ASM_ARM_MACRO_H__
  26. #ifdef __ASSEMBLY__
  27. /*
  28. * These macros provide a convenient way to write 8, 16 and 32 bit data
  29. * to any address.
  30. * Registers r4 and r5 are used, any data in these registers are
  31. * overwritten by the macros.
  32. * The macros are valid for any ARM architecture, they do not implement
  33. * any memory barriers so caution is recommended when using these when the
  34. * caches are enabled or on a multi-core system.
  35. */
  36. .macro write32, addr, data
  37. ldr r4, =\addr
  38. ldr r5, =\data
  39. str r5, [r4]
  40. .endm
  41. .macro write16, addr, data
  42. ldr r4, =\addr
  43. ldrh r5, =\data
  44. strh r5, [r4]
  45. .endm
  46. .macro write8, addr, data
  47. ldr r4, =\addr
  48. ldrb r5, =\data
  49. strb r5, [r4]
  50. .endm
  51. /*
  52. * This macro generates a loop that can be used for delays in the code.
  53. * Register r4 is used, any data in this register is overwritten by the
  54. * macro.
  55. * The macro is valid for any ARM architeture. The actual time spent in the
  56. * loop will vary from CPU to CPU though.
  57. */
  58. .macro wait_timer, time
  59. ldr r4, =\time
  60. 1:
  61. nop
  62. subs r4, r4, #1
  63. bcs 1b
  64. .endm
  65. #endif /* __ASSEMBLY__ */
  66. #endif /* __ASM_ARM_MACRO_H__ */