frame.inc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include <asm/thread_info.h>
  20. #define pi break
  21. #define fp a3
  22. ###############################################################################
  23. #
  24. # build a stack frame from the registers
  25. # - the caller has subtracted 4 from SP before coming here
  26. #
  27. ###############################################################################
  28. .macro SAVE_ALL
  29. add -4,sp # next exception frame ptr save area
  30. movm [other],(sp)
  31. mov usp,a1
  32. mov a1,(sp) # USP in MOVM[other] dummy slot
  33. movm [d2,d3,a2,a3,exreg0,exreg1,exother],(sp)
  34. mov sp,fp # FRAME pointer in A3
  35. add -12,sp # allow for calls to be made
  36. # push the exception frame onto the front of the list
  37. GET_THREAD_INFO a1
  38. mov (TI_frame,a1),a0
  39. mov a0,(REG_NEXT,fp)
  40. mov fp,(TI_frame,a1)
  41. # disable the FPU inside the kernel
  42. and ~EPSW_FE,epsw
  43. # we may be holding current in E2
  44. #ifdef CONFIG_MN10300_CURRENT_IN_E2
  45. mov (__current),e2
  46. #endif
  47. .endm
  48. ###############################################################################
  49. #
  50. # restore the registers from a stack frame
  51. #
  52. ###############################################################################
  53. .macro RESTORE_ALL
  54. # peel back the stack to the calling frame
  55. # - we need that when returning from interrupts to kernel mode
  56. GET_THREAD_INFO a0
  57. mov (TI_frame,a0),fp
  58. mov fp,sp
  59. mov (REG_NEXT,fp),d0
  60. mov d0,(TI_frame,a0) # userspace has regs->next == 0
  61. #ifndef CONFIG_MN10300_USING_JTAG
  62. mov (REG_EPSW,fp),d0
  63. btst EPSW_T,d0
  64. beq 99f
  65. or EPSW_NMID,epsw
  66. movhu (DCR),d1
  67. or 0x0001, d1
  68. movhu d1,(DCR)
  69. 99:
  70. #endif
  71. movm (sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
  72. # must restore usp even if returning to kernel space,
  73. # when CONFIG_PREEMPT is enabled.
  74. mov (sp),a1 # USP in MOVM[other] dummy slot
  75. mov a1,usp
  76. movm (sp),[other]
  77. add 8,sp
  78. rti
  79. .endm
  80. #endif /* _ASM_FRAME_INC */