specialreg.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
  3. * The President and Fellows of Harvard College.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. #ifndef _MIPS_SPECIALREG_H_
  30. #define _MIPS_SPECIALREG_H_
  31. /*
  32. * Coprocessor 0 (system processor) register numbers
  33. */
  34. #define c0_index $0 /* TLB entry index register */
  35. #define c0_random $1 /* TLB random slot register */
  36. #define c0_entrylo $2 /* TLB entry contents (low-order half) */
  37. /* c0_entrylo0 $2 */ /* MIPS-II and up only */
  38. /* c0_entrylo1 $3 */ /* MIPS-II and up only */
  39. #define c0_context $4 /* some precomputed pagetable stuff */
  40. /* c0_pagemask $5 */ /* MIPS-II and up only */
  41. /* c0_wired $6 */ /* MIPS-II and up only */
  42. #define c0_vaddr $8 /* virtual addr of failing memory access */
  43. #define c0_count $9 /* cycle counter (MIPS-II and up) */
  44. #define c0_entryhi $10 /* TLB entry contents (high-order half) */
  45. #define c0_compare $11 /* on-chip timer control (MIPS-II and up) */
  46. #define c0_status $12 /* processor status register */
  47. #define c0_cause $13 /* exception cause register */
  48. #define c0_epc $14 /* exception PC register */
  49. #define c0_prid $15 /* processor ID register */
  50. /* c0_config $16 */ /* MIPS-II and up only */
  51. /* c0_lladdr $17 */ /* MIPS-II and up only */
  52. /* c0_watchlo $18 */ /* MIPS-II and up only */
  53. /* c0_watchhi $19 */ /* MIPS-II and up only */
  54. /*
  55. * Mode bits in c0_status
  56. */
  57. #define CST_IEc 0x00000001 /* current: interrupt enable */
  58. #define CST_KUc 0x00000002 /* current: user mode */
  59. #define CST_IEp 0x00000004 /* previous: interrupt enable */
  60. #define CST_KUp 0x00000008 /* previous: user mode */
  61. #define CST_IEo 0x00000010 /* old: interrupt enable */
  62. #define CST_KUo 0x00000020 /* old: user mode */
  63. #define CST_MODEMASK 0x0000003f /* mask for the above */
  64. #define CST_IRQMASK 0x0000ff00 /* mask for the individual irq enable bits */
  65. #define CST_BEV 0x00400000 /* bootstrap exception vectors flag */
  66. /*
  67. * Fields of the c0_cause register
  68. */
  69. #define CCA_UTLB 0x00000001 /* true if UTLB exception (set by our asm) */
  70. #define CCA_CODE 0x0000003c /* EX_foo in trapframe.h */
  71. #define CCA_IRQS 0x0000ff00 /* Currently pending interrupts */
  72. #define CCA_COPN 0x30000000 /* Coprocessor number for EX_CPU */
  73. #define CCA_JD 0x80000000 /* True if exception happened in jump delay */
  74. #define CCA_CODESHIFT 2 /* shift for CCA_CODE field */
  75. /*
  76. * Fields of the c0_index register
  77. */
  78. #define CIN_P 0x80000000 /* nonzero -> TLB probe found nothing */
  79. #define CIN_INDEX 0x00003f00 /* 6-bit index into TLB */
  80. #define CIN_INDEXSHIFT 8 /* shift for CIN_INDEX field */
  81. /*
  82. * Fields of the c0_context register
  83. *
  84. * The intent of c0_context is that you can manage virtually-mapped
  85. * page tables in kseg2; then you load the base address of the current
  86. * page table into c0_context. On a TLB miss the failing address is
  87. * masked and shifted and appears in the VSHIFT field, and c0_context
  88. * thereby contains the address of the page table entry you need to
  89. * load into the TLB. This can be used to make TLB refill very fast.
  90. *
  91. * However, in OS/161 we use CTX_PTBASE to hold the current CPU
  92. * number. This (or something like it) is fairly important to have and
  93. * there's no other good place in the chip to put it. See discussions
  94. * elsewhere.
  95. */
  96. #define CTX_VSHIFT 0x001ffffc /* shifted/masked copy of c0_vaddr */
  97. #define CTX_PTBASE 0xffe00000 /* page table base address */
  98. #define CTX_PTBASESHIFT 21 /* shift for CTX_PBASE field */
  99. /*
  100. * Hardwired exception handler addresses.
  101. */
  102. #define EXADDR_UTLB 0x80000000
  103. #define EXADDR_GENERAL 0x80000080
  104. #endif /* _MIPS_SPECIALREG_H_ */