assembler.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * linux/include/asm-arm/assembler.h
  3. *
  4. * Copyright (C) 1996-2000 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This file contains arm architecture specific defines
  11. * for the different processors.
  12. *
  13. * Do not include any C declarations in this file - it is included by
  14. * assembler source.
  15. */
  16. #ifndef __ASSEMBLY__
  17. #error "Only include this from assembly code"
  18. #endif
  19. #include <asm/ptrace.h>
  20. /*
  21. * Endian independent macros for shifting bytes within registers.
  22. */
  23. #ifndef __ARMEB__
  24. #define pull lsr
  25. #define push lsl
  26. #define get_byte_0 lsl #0
  27. #define get_byte_1 lsr #8
  28. #define get_byte_2 lsr #16
  29. #define get_byte_3 lsr #24
  30. #define put_byte_0 lsl #0
  31. #define put_byte_1 lsl #8
  32. #define put_byte_2 lsl #16
  33. #define put_byte_3 lsl #24
  34. #else
  35. #define pull lsl
  36. #define push lsr
  37. #define get_byte_0 lsr #24
  38. #define get_byte_1 lsr #16
  39. #define get_byte_2 lsr #8
  40. #define get_byte_3 lsl #0
  41. #define put_byte_0 lsl #24
  42. #define put_byte_1 lsl #16
  43. #define put_byte_2 lsl #8
  44. #define put_byte_3 lsl #0
  45. #endif
  46. /*
  47. * Data preload for architectures that support it
  48. */
  49. #if __LINUX_ARM_ARCH__ >= 5
  50. #define PLD(code...) code
  51. #else
  52. #define PLD(code...)
  53. #endif
  54. #define MODE_USR USR_MODE
  55. #define MODE_FIQ FIQ_MODE
  56. #define MODE_IRQ IRQ_MODE
  57. #define MODE_SVC SVC_MODE
  58. #define DEFAULT_FIQ MODE_FIQ
  59. /*
  60. * LOADREGS - ldm with PC in register list (eg, ldmfd sp!, {pc})
  61. */
  62. #ifdef __STDC__
  63. #define LOADREGS(cond, base, reglist...)\
  64. ldm##cond base,reglist
  65. #else
  66. #define LOADREGS(cond, base, reglist...)\
  67. ldm/**/cond base,reglist
  68. #endif
  69. /*
  70. * Build a return instruction for this processor type.
  71. */
  72. #define RETINSTR(instr, regs...)\
  73. instr regs
  74. /*
  75. * Enable and disable interrupts
  76. */
  77. #if __LINUX_ARM_ARCH__ >= 6
  78. .macro disable_irq
  79. cpsid i
  80. .endm
  81. .macro enable_irq
  82. cpsie i
  83. .endm
  84. #else
  85. .macro disable_irq
  86. msr cpsr_c, #PSR_I_BIT | SVC_MODE
  87. .endm
  88. .macro enable_irq
  89. msr cpsr_c, #SVC_MODE
  90. .endm
  91. #endif
  92. /*
  93. * Save the current IRQ state and disable IRQs. Note that this macro
  94. * assumes FIQs are enabled, and that the processor is in SVC mode.
  95. */
  96. .macro save_and_disable_irqs, oldcpsr
  97. mrs \oldcpsr, cpsr
  98. disable_irq
  99. .endm
  100. /*
  101. * Restore interrupt state previously stored in a register. We don't
  102. * guarantee that this will preserve the flags.
  103. */
  104. .macro restore_irqs, oldcpsr
  105. msr cpsr_c, \oldcpsr
  106. .endm
  107. /*
  108. * These two are used to save LR/restore PC over a user-based access.
  109. * The old 26-bit architecture requires that we do. On 32-bit
  110. * architecture, we can safely ignore this requirement.
  111. */
  112. .macro save_lr
  113. .endm
  114. .macro restore_pc
  115. mov pc, lr
  116. .endm
  117. #define USER(x...) \
  118. 9999: x; \
  119. .section __ex_table,"a"; \
  120. .align 3; \
  121. .long 9999b,9001f; \
  122. .previous