mmu.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_MMU_H
  9. #define _ASM_ARC_MMU_H
  10. #ifndef __ASSEMBLY__
  11. #include <linux/threads.h> /* NR_CPUS */
  12. #endif
  13. #if defined(CONFIG_ARC_MMU_V1)
  14. #define CONFIG_ARC_MMU_VER 1
  15. #elif defined(CONFIG_ARC_MMU_V2)
  16. #define CONFIG_ARC_MMU_VER 2
  17. #elif defined(CONFIG_ARC_MMU_V3)
  18. #define CONFIG_ARC_MMU_VER 3
  19. #elif defined(CONFIG_ARC_MMU_V4)
  20. #define CONFIG_ARC_MMU_VER 4
  21. #endif
  22. /* MMU Management regs */
  23. #define ARC_REG_MMU_BCR 0x06f
  24. #if (CONFIG_ARC_MMU_VER < 4)
  25. #define ARC_REG_TLBPD0 0x405
  26. #define ARC_REG_TLBPD1 0x406
  27. #define ARC_REG_TLBPD1HI 0 /* Dummy: allows code sharing with ARC700 */
  28. #define ARC_REG_TLBINDEX 0x407
  29. #define ARC_REG_TLBCOMMAND 0x408
  30. #define ARC_REG_PID 0x409
  31. #define ARC_REG_SCRATCH_DATA0 0x418
  32. #else
  33. #define ARC_REG_TLBPD0 0x460
  34. #define ARC_REG_TLBPD1 0x461
  35. #define ARC_REG_TLBPD1HI 0x463
  36. #define ARC_REG_TLBINDEX 0x464
  37. #define ARC_REG_TLBCOMMAND 0x465
  38. #define ARC_REG_PID 0x468
  39. #define ARC_REG_SCRATCH_DATA0 0x46c
  40. #endif
  41. /* Bits in MMU PID register */
  42. #define __TLB_ENABLE (1 << 31)
  43. #define __PROG_ENABLE (1 << 30)
  44. #define MMU_ENABLE (__TLB_ENABLE | __PROG_ENABLE)
  45. /* Error code if probe fails */
  46. #define TLB_LKUP_ERR 0x80000000
  47. #if (CONFIG_ARC_MMU_VER < 4)
  48. #define TLB_DUP_ERR (TLB_LKUP_ERR | 0x00000001)
  49. #else
  50. #define TLB_DUP_ERR (TLB_LKUP_ERR | 0x40000000)
  51. #endif
  52. /* TLB Commands */
  53. #define TLBWrite 0x1
  54. #define TLBRead 0x2
  55. #define TLBGetIndex 0x3
  56. #define TLBProbe 0x4
  57. #if (CONFIG_ARC_MMU_VER >= 2)
  58. #define TLBWriteNI 0x5 /* write JTLB without inv uTLBs */
  59. #define TLBIVUTLB 0x6 /* explicitly inv uTLBs */
  60. #endif
  61. #if (CONFIG_ARC_MMU_VER >= 4)
  62. #define TLBInsertEntry 0x7
  63. #define TLBDeleteEntry 0x8
  64. #endif
  65. #ifndef __ASSEMBLY__
  66. typedef struct {
  67. unsigned long asid[NR_CPUS]; /* 8 bit MMU PID + Generation cycle */
  68. } mm_context_t;
  69. #ifdef CONFIG_ARC_DBG_TLB_PARANOIA
  70. void tlb_paranoid_check(unsigned int mm_asid, unsigned long address);
  71. #else
  72. #define tlb_paranoid_check(a, b)
  73. #endif
  74. void arc_mmu_init(void);
  75. extern char *arc_mmu_mumbojumbo(int cpu_id, char *buf, int len);
  76. void read_decode_mmu_bcr(void);
  77. static inline int is_pae40_enabled(void)
  78. {
  79. return IS_ENABLED(CONFIG_ARC_HAS_PAE40);
  80. }
  81. extern int pae40_exist_but_not_enab(void);
  82. #endif /* !__ASSEMBLY__ */
  83. #endif