head.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* Boot entry point for a compressed MN10300 kernel
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. .section .text
  12. #define DEBUG
  13. #include <linux/linkage.h>
  14. #include <asm/cpu-regs.h>
  15. #include <asm/cache.h>
  16. #ifdef CONFIG_SMP
  17. #include <proc/smp-regs.h>
  18. #endif
  19. .globl startup_32
  20. startup_32:
  21. #ifdef CONFIG_SMP
  22. #
  23. # Secondary CPUs jump directly to the kernel entry point
  24. #
  25. # Must save primary CPU's D0-D2 registers as they hold boot parameters
  26. #
  27. mov (CPUID), d3
  28. and CPUID_MASK,d3
  29. beq startup_primary
  30. mov CONFIG_KERNEL_TEXT_ADDRESS,a0
  31. jmp (a0)
  32. startup_primary:
  33. #endif /* CONFIG_SMP */
  34. # first save parameters from bootloader
  35. mov param_save_area,a0
  36. mov d0,(a0)
  37. mov d1,(4,a0)
  38. mov d2,(8,a0)
  39. mov sp,a3
  40. mov decomp_stack+0x2000-4,a0
  41. mov a0,sp
  42. # invalidate and enable both of the caches
  43. mov CHCTR,a0
  44. clr d0
  45. movhu d0,(a0) # turn off first
  46. mov CHCTR_ICINV|CHCTR_DCINV,d0
  47. movhu d0,(a0)
  48. setlb
  49. mov (a0),d0
  50. btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy
  51. lne
  52. #ifdef CONFIG_MN10300_CACHE_ENABLED
  53. #ifdef CONFIG_MN10300_CACHE_WBACK
  54. mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0
  55. #else
  56. mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0
  57. #endif /* WBACK */
  58. movhu d0,(a0) # enable
  59. #endif /* !ENABLED */
  60. # clear the BSS area
  61. mov __bss_start,a0
  62. mov _end,a1
  63. clr d0
  64. bssclear:
  65. cmp a1,a0
  66. bge bssclear_end
  67. movbu d0,(a0)
  68. inc a0
  69. bra bssclear
  70. bssclear_end:
  71. # decompress the kernel
  72. call decompress_kernel[],0
  73. #ifdef CONFIG_MN10300_CACHE_WBACK
  74. call mn10300_dcache_flush_inv[],0
  75. #endif
  76. # disable caches again
  77. mov CHCTR,a0
  78. clr d0
  79. movhu d0,(a0)
  80. setlb
  81. mov (a0),d0
  82. btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy
  83. lne
  84. mov param_save_area,a0
  85. mov (a0),d0
  86. mov (4,a0),d1
  87. mov (8,a0),d2
  88. # jump to the kernel proper entry point
  89. mov a3,sp
  90. mov CONFIG_KERNEL_TEXT_ADDRESS,a0
  91. jmp (a0)
  92. ###############################################################################
  93. #
  94. # Cache flush routines
  95. #
  96. ###############################################################################
  97. #ifdef CONFIG_MN10300_CACHE_WBACK
  98. mn10300_dcache_flush_inv:
  99. movhu (CHCTR),d0
  100. btst CHCTR_DCEN,d0
  101. beq mn10300_dcache_flush_inv_end
  102. mov L1_CACHE_NENTRIES,d1
  103. clr a1
  104. mn10300_dcache_flush_inv_loop:
  105. mov (DCACHE_PURGE_WAY0(0),a1),d0 # unconditional purge
  106. mov (DCACHE_PURGE_WAY1(0),a1),d0 # unconditional purge
  107. mov (DCACHE_PURGE_WAY2(0),a1),d0 # unconditional purge
  108. mov (DCACHE_PURGE_WAY3(0),a1),d0 # unconditional purge
  109. add L1_CACHE_BYTES,a1
  110. add -1,d1
  111. bne mn10300_dcache_flush_inv_loop
  112. mn10300_dcache_flush_inv_end:
  113. ret [],0
  114. #endif /* CONFIG_MN10300_CACHE_WBACK */
  115. ###############################################################################
  116. #
  117. # Data areas
  118. #
  119. ###############################################################################
  120. .data
  121. .align 4
  122. param_save_area:
  123. .rept 3
  124. .word 0
  125. .endr
  126. .section .bss
  127. .align 4
  128. decomp_stack:
  129. .space 0x2000