kernel-entry-init.h 2.7 KB

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