entry.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * include/asm-v850/entry.h -- Definitions used by low-level trap handlers
  3. *
  4. * Copyright (C) 2001,02,03 NEC Electronics Corporation
  5. * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General
  8. * Public License. See the file COPYING in the main directory of this
  9. * archive for more details.
  10. *
  11. * Written by Miles Bader <miles@gnu.org>
  12. */
  13. #ifndef __V850_ENTRY_H__
  14. #define __V850_ENTRY_H__
  15. #include <asm/ptrace.h>
  16. #include <asm/machdep.h>
  17. /* These are special variables using by the kernel trap/interrupt code
  18. to save registers in, at a time when there are no spare registers we
  19. can use to do so, and we can't depend on the value of the stack
  20. pointer. This means that they must be within a signed 16-bit
  21. displacement of 0x00000000. */
  22. #define KERNEL_VAR_SPACE_ADDR R0_RAM_ADDR
  23. #ifdef __ASSEMBLY__
  24. #define KERNEL_VAR(addr) addr[r0]
  25. #else
  26. #define KERNEL_VAR(addr) (*(volatile unsigned long *)(addr))
  27. #endif
  28. /* Kernel stack pointer, 4 bytes. */
  29. #define KSP_ADDR (KERNEL_VAR_SPACE_ADDR + 0)
  30. #define KSP KERNEL_VAR (KSP_ADDR)
  31. /* 1 if in kernel-mode, 0 if in user mode, 1 byte. */
  32. #define KM_ADDR (KERNEL_VAR_SPACE_ADDR + 4)
  33. #define KM KERNEL_VAR (KM_ADDR)
  34. /* Temporary storage for interrupt handlers, 4 bytes. */
  35. #define INT_SCRATCH_ADDR (KERNEL_VAR_SPACE_ADDR + 8)
  36. #define INT_SCRATCH KERNEL_VAR (INT_SCRATCH_ADDR)
  37. /* Where the stack-pointer is saved when jumping to various sorts of
  38. interrupt handlers. ENTRY_SP is used by everything except NMIs,
  39. which have their own location. Higher-priority NMIs can clobber the
  40. value written by a lower priority NMI, since they can't be disabled,
  41. but that's OK, because only NMI0 (the lowest-priority one) is allowed
  42. to return. */
  43. #define ENTRY_SP_ADDR (KERNEL_VAR_SPACE_ADDR + 12)
  44. #define ENTRY_SP KERNEL_VAR (ENTRY_SP_ADDR)
  45. #define NMI_ENTRY_SP_ADDR (KERNEL_VAR_SPACE_ADDR + 16)
  46. #define NMI_ENTRY_SP KERNEL_VAR (NMI_ENTRY_SP_ADDR)
  47. #ifdef CONFIG_RESET_GUARD
  48. /* Used to detect unexpected resets (since the v850 has no MMU, any call
  49. through a null pointer will jump to the reset vector). We detect
  50. such resets by checking for a magic value, RESET_GUARD_ACTIVE, in
  51. this location. Properly resetting the machine stores zero there, so
  52. it shouldn't trigger the guard; the power-on value is uncertain, but
  53. it's unlikely to be RESET_GUARD_ACTIVE. */
  54. #define RESET_GUARD_ADDR (KERNEL_VAR_SPACE_ADDR + 28)
  55. #define RESET_GUARD KERNEL_VAR (RESET_GUARD_ADDR)
  56. #define RESET_GUARD_ACTIVE 0xFAB4BEEF
  57. #endif /* CONFIG_RESET_GUARD */
  58. #ifdef CONFIG_V850E_HIGHRES_TIMER
  59. #define HIGHRES_TIMER_SLOW_TICKS_ADDR (KERNEL_VAR_SPACE_ADDR + 32)
  60. #define HIGHRES_TIMER_SLOW_TICKS KERNEL_VAR (HIGHRES_TIMER_SLOW_TICKS_ADDR)
  61. #endif /* CONFIG_V850E_HIGHRES_TIMER */
  62. #ifndef __ASSEMBLY__
  63. #ifdef CONFIG_RESET_GUARD
  64. /* Turn off reset guard, so that resetting the machine works normally.
  65. This should be called in the various machine_halt, etc., functions. */
  66. static inline void disable_reset_guard (void)
  67. {
  68. RESET_GUARD = 0;
  69. }
  70. #endif /* CONFIG_RESET_GUARD */
  71. #endif /* !__ASSEMBLY__ */
  72. /* A `state save frame' is a struct pt_regs preceded by some extra space
  73. suitable for a function call stack frame. */
  74. /* Amount of room on the stack reserved for arguments and to satisfy the
  75. C calling conventions, in addition to the space used by the struct
  76. pt_regs that actually holds saved values. */
  77. #define STATE_SAVE_ARG_SPACE (6*4) /* Up to six arguments. */
  78. #ifdef __ASSEMBLY__
  79. /* The size of a state save frame. */
  80. #define STATE_SAVE_SIZE (PT_SIZE + STATE_SAVE_ARG_SPACE)
  81. #else /* !__ASSEMBLY__ */
  82. /* The size of a state save frame. */
  83. #define STATE_SAVE_SIZE (sizeof (struct pt_regs) + STATE_SAVE_ARG_SPACE)
  84. #endif /* __ASSEMBLY__ */
  85. /* Offset of the struct pt_regs in a state save frame. */
  86. #define STATE_SAVE_PT_OFFSET STATE_SAVE_ARG_SPACE
  87. #endif /* __V850_ENTRY_H__ */