arcregs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  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_ARC_ARCREGS_H
  9. #define _ASM_ARC_ARCREGS_H
  10. #ifdef __KERNEL__
  11. /* Build Configuration Registers */
  12. #define ARC_REG_VECBASE_BCR 0x68
  13. /* status32 Bits Positions */
  14. #define STATUS_H_BIT 0 /* CPU Halted */
  15. #define STATUS_E1_BIT 1 /* Int 1 enable */
  16. #define STATUS_E2_BIT 2 /* Int 2 enable */
  17. #define STATUS_A1_BIT 3 /* Int 1 active */
  18. #define STATUS_A2_BIT 4 /* Int 2 active */
  19. #define STATUS_AE_BIT 5 /* Exception active */
  20. #define STATUS_DE_BIT 6 /* PC is in delay slot */
  21. #define STATUS_U_BIT 7 /* User/Kernel mode */
  22. #define STATUS_L_BIT 12 /* Loop inhibit */
  23. /* These masks correspond to the status word(STATUS_32) bits */
  24. #define STATUS_H_MASK (1<<STATUS_H_BIT)
  25. #define STATUS_E1_MASK (1<<STATUS_E1_BIT)
  26. #define STATUS_E2_MASK (1<<STATUS_E2_BIT)
  27. #define STATUS_A1_MASK (1<<STATUS_A1_BIT)
  28. #define STATUS_A2_MASK (1<<STATUS_A2_BIT)
  29. #define STATUS_AE_MASK (1<<STATUS_AE_BIT)
  30. #define STATUS_DE_MASK (1<<STATUS_DE_BIT)
  31. #define STATUS_U_MASK (1<<STATUS_U_BIT)
  32. #define STATUS_L_MASK (1<<STATUS_L_BIT)
  33. /* Auxiliary registers */
  34. #define AUX_IDENTITY 4
  35. #define AUX_INTR_VEC_BASE 0x25
  36. #define AUX_IRQ_LEV 0x200 /* IRQ Priority: L1 or L2 */
  37. #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
  38. #define AUX_IRQ_LV12 0x43 /* interrupt level register */
  39. #define AUX_IENABLE 0x40c
  40. #define AUX_ITRIGGER 0x40d
  41. #define AUX_IPULSE 0x415
  42. /* Timer related Aux registers */
  43. #define ARC_REG_TIMER0_LIMIT 0x23 /* timer 0 limit */
  44. #define ARC_REG_TIMER0_CTRL 0x22 /* timer 0 control */
  45. #define ARC_REG_TIMER0_CNT 0x21 /* timer 0 count */
  46. #define ARC_REG_TIMER1_LIMIT 0x102 /* timer 1 limit */
  47. #define ARC_REG_TIMER1_CTRL 0x101 /* timer 1 control */
  48. #define ARC_REG_TIMER1_CNT 0x100 /* timer 1 count */
  49. #define TIMER_CTRL_IE (1 << 0) /* Interupt when Count reachs limit */
  50. #define TIMER_CTRL_NH (1 << 1) /* Count only when CPU NOT halted */
  51. /*
  52. * Floating Pt Registers
  53. * Status regs are read-only (build-time) so need not be saved/restored
  54. */
  55. #define ARC_AUX_FP_STAT 0x300
  56. #define ARC_AUX_DPFP_1L 0x301
  57. #define ARC_AUX_DPFP_1H 0x302
  58. #define ARC_AUX_DPFP_2L 0x303
  59. #define ARC_AUX_DPFP_2H 0x304
  60. #define ARC_AUX_DPFP_STAT 0x305
  61. #ifndef __ASSEMBLY__
  62. /*
  63. ******************************************************************
  64. * Inline ASM macros to read/write AUX Regs
  65. * Essentially invocation of lr/sr insns from "C"
  66. */
  67. #if 1
  68. #define read_aux_reg(reg) __builtin_arc_lr(reg)
  69. /* gcc builtin sr needs reg param to be long immediate */
  70. #define write_aux_reg(reg_immed, val) \
  71. __builtin_arc_sr((unsigned int)val, reg_immed)
  72. #else
  73. #define read_aux_reg(reg) \
  74. ({ \
  75. unsigned int __ret; \
  76. __asm__ __volatile__( \
  77. " lr %0, [%1]" \
  78. : "=r"(__ret) \
  79. : "i"(reg)); \
  80. __ret; \
  81. })
  82. /*
  83. * Aux Reg address is specified as long immediate by caller
  84. * e.g.
  85. * write_aux_reg(0x69, some_val);
  86. * This generates tightest code.
  87. */
  88. #define write_aux_reg(reg_imm, val) \
  89. ({ \
  90. __asm__ __volatile__( \
  91. " sr %0, [%1] \n" \
  92. : \
  93. : "ir"(val), "i"(reg_imm)); \
  94. })
  95. /*
  96. * Aux Reg address is specified in a variable
  97. * * e.g.
  98. * reg_num = 0x69
  99. * write_aux_reg2(reg_num, some_val);
  100. * This has to generate glue code to load the reg num from
  101. * memory to a reg hence not recommended.
  102. */
  103. #define write_aux_reg2(reg_in_var, val) \
  104. ({ \
  105. unsigned int tmp; \
  106. \
  107. __asm__ __volatile__( \
  108. " ld %0, [%2] \n\t" \
  109. " sr %1, [%0] \n\t" \
  110. : "=&r"(tmp) \
  111. : "r"(val), "memory"(&reg_in_var)); \
  112. })
  113. #endif
  114. #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
  115. /* These DPFP regs need to be saved/restored across ctx-sw */
  116. struct arc_fpu {
  117. struct {
  118. unsigned int l, h;
  119. } aux_dpfp[2];
  120. };
  121. #endif
  122. #endif /* __ASEMBLY__ */
  123. #endif /* __KERNEL__ */
  124. #endif /* _ASM_ARC_ARCREGS_H */