arcregs.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. /*
  43. * Floating Pt Registers
  44. * Status regs are read-only (build-time) so need not be saved/restored
  45. */
  46. #define ARC_AUX_FP_STAT 0x300
  47. #define ARC_AUX_DPFP_1L 0x301
  48. #define ARC_AUX_DPFP_1H 0x302
  49. #define ARC_AUX_DPFP_2L 0x303
  50. #define ARC_AUX_DPFP_2H 0x304
  51. #define ARC_AUX_DPFP_STAT 0x305
  52. #ifndef __ASSEMBLY__
  53. /*
  54. ******************************************************************
  55. * Inline ASM macros to read/write AUX Regs
  56. * Essentially invocation of lr/sr insns from "C"
  57. */
  58. #if 1
  59. #define read_aux_reg(reg) __builtin_arc_lr(reg)
  60. /* gcc builtin sr needs reg param to be long immediate */
  61. #define write_aux_reg(reg_immed, val) \
  62. __builtin_arc_sr((unsigned int)val, reg_immed)
  63. #else
  64. #define read_aux_reg(reg) \
  65. ({ \
  66. unsigned int __ret; \
  67. __asm__ __volatile__( \
  68. " lr %0, [%1]" \
  69. : "=r"(__ret) \
  70. : "i"(reg)); \
  71. __ret; \
  72. })
  73. /*
  74. * Aux Reg address is specified as long immediate by caller
  75. * e.g.
  76. * write_aux_reg(0x69, some_val);
  77. * This generates tightest code.
  78. */
  79. #define write_aux_reg(reg_imm, val) \
  80. ({ \
  81. __asm__ __volatile__( \
  82. " sr %0, [%1] \n" \
  83. : \
  84. : "ir"(val), "i"(reg_imm)); \
  85. })
  86. /*
  87. * Aux Reg address is specified in a variable
  88. * * e.g.
  89. * reg_num = 0x69
  90. * write_aux_reg2(reg_num, some_val);
  91. * This has to generate glue code to load the reg num from
  92. * memory to a reg hence not recommended.
  93. */
  94. #define write_aux_reg2(reg_in_var, val) \
  95. ({ \
  96. unsigned int tmp; \
  97. \
  98. __asm__ __volatile__( \
  99. " ld %0, [%2] \n\t" \
  100. " sr %1, [%0] \n\t" \
  101. : "=&r"(tmp) \
  102. : "r"(val), "memory"(&reg_in_var)); \
  103. })
  104. #endif
  105. #ifdef CONFIG_ARC_FPU_SAVE_RESTORE
  106. /* These DPFP regs need to be saved/restored across ctx-sw */
  107. struct arc_fpu {
  108. struct {
  109. unsigned int l, h;
  110. } aux_dpfp[2];
  111. };
  112. #endif
  113. #endif /* __ASEMBLY__ */
  114. #endif /* __KERNEL__ */
  115. #endif /* _ASM_ARC_ARCREGS_H */