frame.inc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* MN10300 Microcontroller core system register definitions -*- asm -*-
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_FRAME_INC
  12. #define _ASM_FRAME_INC
  13. #ifndef __ASSEMBLY__
  14. #error not for use in C files
  15. #endif
  16. #ifndef __ASM_OFFSETS_H__
  17. #include <asm/asm-offsets.h>
  18. #endif
  19. #ifdef CONFIG_SMP
  20. #include <proc/smp-regs.h>
  21. #endif
  22. #define pi break
  23. #define fp a3
  24. ###############################################################################
  25. #
  26. # build a stack frame from the registers
  27. # - the caller has subtracted 4 from SP before coming here
  28. #
  29. ###############################################################################
  30. .macro SAVE_ALL
  31. add -4,sp # next exception frame ptr save area
  32. movm [other],(sp)
  33. mov usp,a1
  34. mov a1,(sp) # USP in MOVM[other] dummy slot
  35. movm [d2,d3,a2,a3,exreg0,exreg1,exother],(sp)
  36. mov sp,fp # FRAME pointer in A3
  37. add -12,sp # allow for calls to be made
  38. #ifdef CONFIG_SMP
  39. #ifdef CONFIG_PREEMPT /* FIXME */
  40. mov epsw,d2
  41. and ~EPSW_IE,epsw
  42. #endif
  43. mov (CPUID),a0
  44. add a0,a0
  45. add a0,a0
  46. mov (___frame,a0),a1
  47. mov a1,(REG_NEXT,fp)
  48. mov fp,(___frame,a0)
  49. #ifdef CONFIG_PREEMPT /* FIXME */
  50. mov d2,epsw
  51. #endif
  52. #else /* CONFIG_SMP */
  53. mov (__frame),a1
  54. mov a1,(REG_NEXT,fp)
  55. mov fp,(__frame)
  56. #endif /* CONFIG_SMP */
  57. and ~EPSW_FE,epsw # disable the FPU inside the kernel
  58. # we may be holding current in E2
  59. #ifdef CONFIG_MN10300_CURRENT_IN_E2
  60. mov (__current),e2
  61. #endif
  62. .endm
  63. ###############################################################################
  64. #
  65. # restore the registers from a stack frame
  66. #
  67. ###############################################################################
  68. .macro RESTORE_ALL
  69. # peel back the stack to the calling frame
  70. # - this permits execve() to discard extra frames due to kernel syscalls
  71. #ifdef CONFIG_SMP
  72. #ifdef CONFIG_PREEMPT /* FIXME */
  73. mov epsw,d2
  74. and ~EPSW_IE,epsw
  75. #endif
  76. mov (CPUID),a0
  77. add a0,a0
  78. add a0,a0
  79. mov (___frame,a0),fp
  80. mov fp,sp
  81. mov (REG_NEXT,fp),d0 # userspace has regs->next == 0
  82. mov d0,(___frame,a0)
  83. #ifdef CONFIG_PREEMPT /* FIXME */
  84. mov d2,epsw
  85. #endif
  86. #else /* CONFIG_SMP */
  87. mov (__frame),fp
  88. mov fp,sp
  89. mov (REG_NEXT,fp),d0 # userspace has regs->next == 0
  90. mov d0,(__frame)
  91. #endif /* CONFIG_SMP */
  92. #ifndef CONFIG_MN10300_USING_JTAG
  93. mov (REG_EPSW,fp),d0
  94. btst EPSW_T,d0
  95. beq 99f
  96. or EPSW_NMID,epsw
  97. movhu (DCR),d1
  98. or 0x0001, d1
  99. movhu d1,(DCR)
  100. 99:
  101. #endif
  102. movm (sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
  103. # must restore usp even if returning to kernel space,
  104. # when CONFIG_PREEMPT is enabled.
  105. mov (sp),a1 # USP in MOVM[other] dummy slot
  106. mov a1,usp
  107. movm (sp),[other]
  108. add 8,sp
  109. rti
  110. .endm
  111. #endif /* _ASM_FRAME_INC */