asm.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_AVR32_ASM_H__
  9. #define __ASM_AVR32_ASM_H__
  10. #include <asm/sysreg.h>
  11. #include <asm/asm-offsets.h>
  12. #include <asm/thread_info.h>
  13. #define mask_interrupts ssrf SYSREG_GM_OFFSET
  14. #define mask_exceptions ssrf SYSREG_EM_OFFSET
  15. #define unmask_interrupts csrf SYSREG_GM_OFFSET
  16. #define unmask_exceptions csrf SYSREG_EM_OFFSET
  17. #ifdef CONFIG_FRAME_POINTER
  18. .macro save_fp
  19. st.w --sp, r7
  20. .endm
  21. .macro restore_fp
  22. ld.w r7, sp++
  23. .endm
  24. .macro zero_fp
  25. mov r7, 0
  26. .endm
  27. #else
  28. .macro save_fp
  29. .endm
  30. .macro restore_fp
  31. .endm
  32. .macro zero_fp
  33. .endm
  34. #endif
  35. .macro get_thread_info reg
  36. mov \reg, sp
  37. andl \reg, ~(THREAD_SIZE - 1) & 0xffff
  38. .endm
  39. /* Save and restore registers */
  40. .macro save_min sr, tmp=lr
  41. pushm lr
  42. mfsr \tmp, \sr
  43. zero_fp
  44. st.w --sp, \tmp
  45. .endm
  46. .macro restore_min sr, tmp=lr
  47. ld.w \tmp, sp++
  48. mtsr \sr, \tmp
  49. popm lr
  50. .endm
  51. .macro save_half sr, tmp=lr
  52. save_fp
  53. pushm r8-r9,r10,r11,r12,lr
  54. zero_fp
  55. mfsr \tmp, \sr
  56. st.w --sp, \tmp
  57. .endm
  58. .macro restore_half sr, tmp=lr
  59. ld.w \tmp, sp++
  60. mtsr \sr, \tmp
  61. popm r8-r9,r10,r11,r12,lr
  62. restore_fp
  63. .endm
  64. .macro save_full_user sr, tmp=lr
  65. stmts --sp, r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,sp,lr
  66. st.w --sp, lr
  67. zero_fp
  68. mfsr \tmp, \sr
  69. st.w --sp, \tmp
  70. .endm
  71. .macro restore_full_user sr, tmp=lr
  72. ld.w \tmp, sp++
  73. mtsr \sr, \tmp
  74. ld.w lr, sp++
  75. ldmts sp++, r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,sp,lr
  76. .endm
  77. /* uaccess macros */
  78. .macro branch_if_kernel scratch, label
  79. get_thread_info \scratch
  80. ld.w \scratch, \scratch[TI_flags]
  81. bld \scratch, TIF_USERSPACE
  82. brcc \label
  83. .endm
  84. .macro ret_if_privileged scratch, addr, size, ret
  85. sub \scratch, \size, 1
  86. add \scratch, \addr
  87. retcs \ret
  88. retmi \ret
  89. .endm
  90. #endif /* __ASM_AVR32_ASM_H__ */