frame.inc 2.2 KB

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