tlb-mmu1.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_TLB_MMU_V1_H__
  9. #define __ASM_TLB_MMU_V1_H__
  10. #include <asm/mmu.h>
  11. #include <asm/tlb.h>
  12. #if defined(__ASSEMBLY__) && (CONFIG_ARC_MMU_VER == 1)
  13. .macro TLB_WRITE_HEURISTICS
  14. #define JH_HACK1
  15. #undef JH_HACK2
  16. #undef JH_HACK3
  17. #ifdef JH_HACK3
  18. ; Calculate set index for 2-way MMU
  19. ; -avoiding use of GetIndex from MMU
  20. ; and its unpleasant LFSR pseudo-random sequence
  21. ;
  22. ; r1 = TLBPD0 from TLB_RELOAD above
  23. ;
  24. ; -- jh_ex_way_set not cleared on startup
  25. ; didn't want to change setup.c
  26. ; hence extra instruction to clean
  27. ;
  28. ; -- should be in cache since in same line
  29. ; as r0/r1 saves above
  30. ;
  31. ld r0,[jh_ex_way_sel] ; victim pointer
  32. and r0,r0,1 ; clean
  33. xor.f r0,r0,1 ; flip
  34. st r0,[jh_ex_way_sel] ; store back
  35. asr r0,r1,12 ; get set # <<1, note bit 12=R=0
  36. or.nz r0,r0,1 ; set way bit
  37. and r0,r0,0xff ; clean
  38. sr r0,[ARC_REG_TLBINDEX]
  39. #endif
  40. #ifdef JH_HACK2
  41. ; JH hack #2
  42. ; Faster than hack #1 in non-thrash case, but hard-coded for 2-way MMU
  43. ; Slower in thrash case (where it matters) because more code is executed
  44. ; Inefficient due to two-register paradigm of this miss handler
  45. ;
  46. /* r1 = data TLBPD0 at this point */
  47. lr r0,[eret] /* instruction address */
  48. xor r0,r0,r1 /* compare set # */
  49. and.f r0,r0,0x000fe000 /* 2-way MMU mask */
  50. bne 88f /* not in same set - no need to probe */
  51. lr r0,[eret] /* instruction address */
  52. and r0,r0,PAGE_MASK /* VPN of instruction address */
  53. ; lr r1,[ARC_REG_TLBPD0] /* Data VPN+ASID - already in r1 from TLB_RELOAD*/
  54. and r1,r1,0xff /* Data ASID */
  55. or r0,r0,r1 /* Instruction address + Data ASID */
  56. lr r1,[ARC_REG_TLBPD0] /* save TLBPD0 containing data TLB*/
  57. sr r0,[ARC_REG_TLBPD0] /* write instruction address to TLBPD0 */
  58. sr TLBProbe, [ARC_REG_TLBCOMMAND] /* Look for instruction */
  59. lr r0,[ARC_REG_TLBINDEX] /* r0 = index where instruction is, if at all */
  60. sr r1,[ARC_REG_TLBPD0] /* restore TLBPD0 */
  61. xor r0,r0,1 /* flip bottom bit of data index */
  62. b.d 89f
  63. sr r0,[ARC_REG_TLBINDEX] /* and put it back */
  64. 88:
  65. sr TLBGetIndex, [ARC_REG_TLBCOMMAND]
  66. 89:
  67. #endif
  68. #ifdef JH_HACK1
  69. ;
  70. ; Always checks whether instruction will be kicked out by dtlb miss
  71. ;
  72. mov_s r3, r1 ; save PD0 prepared by TLB_RELOAD in r3
  73. lr r0,[eret] /* instruction address */
  74. and r0,r0,PAGE_MASK /* VPN of instruction address */
  75. bmsk r1,r3,7 /* Data ASID, bits 7-0 */
  76. or_s r0,r0,r1 /* Instruction address + Data ASID */
  77. sr r0,[ARC_REG_TLBPD0] /* write instruction address to TLBPD0 */
  78. sr TLBProbe, [ARC_REG_TLBCOMMAND] /* Look for instruction */
  79. lr r0,[ARC_REG_TLBINDEX] /* r0 = index where instruction is, if at all */
  80. sr r3,[ARC_REG_TLBPD0] /* restore TLBPD0 */
  81. sr TLBGetIndex, [ARC_REG_TLBCOMMAND]
  82. lr r1,[ARC_REG_TLBINDEX] /* r1 = index where MMU wants to put data */
  83. cmp r0,r1 /* if no match on indices, go around */
  84. xor.eq r1,r1,1 /* flip bottom bit of data index */
  85. sr r1,[ARC_REG_TLBINDEX] /* and put it back */
  86. #endif
  87. .endm
  88. #endif
  89. #endif