kernel-entry-init.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2000 Silicon Graphics, Inc.
  7. * Copyright (C) 2005 Ralf Baechle <ralf@linux-mips.org>
  8. */
  9. #ifndef __ASM_MACH_IP27_KERNEL_ENTRY_H
  10. #define __ASM_MACH_IP27_KERNEL_ENTRY_H
  11. #include <asm/sn/addrs.h>
  12. #include <asm/sn/agent.h>
  13. #include <asm/sn/klkernvars.h>
  14. /*
  15. * TLB bits
  16. */
  17. #define PAGE_GLOBAL (1 << 6)
  18. #define PAGE_VALID (1 << 7)
  19. #define PAGE_DIRTY (1 << 8)
  20. #define CACHE_CACHABLE_COW (5 << 9)
  21. /*
  22. * inputs are the text nasid in t1, data nasid in t2.
  23. */
  24. .macro MAPPED_KERNEL_SETUP_TLB
  25. #ifdef CONFIG_MAPPED_KERNEL
  26. /*
  27. * This needs to read the nasid - assume 0 for now.
  28. * Drop in 0xffffffffc0000000 in tlbhi, 0+VG in tlblo_0,
  29. * 0+DVG in tlblo_1.
  30. */
  31. dli t0, 0xffffffffc0000000
  32. dmtc0 t0, CP0_ENTRYHI
  33. li t0, 0x1c000 # Offset of text into node memory
  34. dsll t1, NASID_SHFT # Shift text nasid into place
  35. dsll t2, NASID_SHFT # Same for data nasid
  36. or t1, t1, t0 # Physical load address of kernel text
  37. or t2, t2, t0 # Physical load address of kernel data
  38. dsrl t1, 12 # 4K pfn
  39. dsrl t2, 12 # 4K pfn
  40. dsll t1, 6 # Get pfn into place
  41. dsll t2, 6 # Get pfn into place
  42. li t0, ((PAGE_GLOBAL | PAGE_VALID | CACHE_CACHABLE_COW) >> 6)
  43. or t0, t0, t1
  44. mtc0 t0, CP0_ENTRYLO0 # physaddr, VG, cach exlwr
  45. li t0, ((PAGE_GLOBAL | PAGE_VALID | PAGE_DIRTY | CACHE_CACHABLE_COW) >> 6)
  46. or t0, t0, t2
  47. mtc0 t0, CP0_ENTRYLO1 # physaddr, DVG, cach exlwr
  48. li t0, 0x1ffe000 # MAPPED_KERN_TLBMASK, TLBPGMASK_16M
  49. mtc0 t0, CP0_PAGEMASK
  50. li t0, 0 # KMAP_INX
  51. mtc0 t0, CP0_INDEX
  52. li t0, 1
  53. mtc0 t0, CP0_WIRED
  54. tlbwi
  55. #else
  56. mtc0 zero, CP0_WIRED
  57. #endif
  58. .endm
  59. /*
  60. * Intentionally empty macro, used in head.S. Override in
  61. * arch/mips/mach-xxx/kernel-entry-init.h when necessary.
  62. */
  63. .macro kernel_entry_setup
  64. GET_NASID_ASM t1
  65. move t2, t1 # text and data are here
  66. MAPPED_KERNEL_SETUP_TLB
  67. .endm
  68. /*
  69. * Do SMP slave processor setup necessary before we can safely execute C code.
  70. */
  71. .macro smp_slave_setup
  72. GET_NASID_ASM t1
  73. dli t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \
  74. KLDIR_OFF_POINTER + CAC_BASE
  75. dsll t1, NASID_SHFT
  76. or t0, t0, t1
  77. ld t0, 0(t0) # t0 points to kern_vars struct
  78. lh t1, KV_RO_NASID_OFFSET(t0)
  79. lh t2, KV_RW_NASID_OFFSET(t0)
  80. MAPPED_KERNEL_SETUP_TLB
  81. /*
  82. * We might not get launched at the address the kernel is linked to,
  83. * so we jump there.
  84. */
  85. PTR_LA t0, 0f
  86. jr t0
  87. 0:
  88. .endm
  89. #endif /* __ASM_MACH_IP27_KERNEL_ENTRY_H */