head.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * ARC CPU startup Code
  3. *
  4. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Vineetg: Dec 2007
  11. * -Check if we are running on Simulator or on real hardware
  12. * to skip certain things during boot on simulator
  13. */
  14. #include <linux/linkage.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/entry.h>
  17. #include <asm/arcregs.h>
  18. #include <asm/cache.h>
  19. #include <asm/irqflags.h>
  20. .macro CPU_EARLY_SETUP
  21. ; Setting up Vectror Table (in case exception happens in early boot
  22. sr @_int_vec_base_lds, [AUX_INTR_VEC_BASE]
  23. ; Disable I-cache/D-cache if kernel so configured
  24. lr r5, [ARC_REG_IC_BCR]
  25. breq r5, 0, 1f ; I$ doesn't exist
  26. lr r5, [ARC_REG_IC_CTRL]
  27. #ifdef CONFIG_ARC_HAS_ICACHE
  28. bclr r5, r5, 0 ; 0 - Enable, 1 is Disable
  29. #else
  30. bset r5, r5, 0 ; I$ exists, but is not used
  31. #endif
  32. sr r5, [ARC_REG_IC_CTRL]
  33. 1:
  34. lr r5, [ARC_REG_DC_BCR]
  35. breq r5, 0, 1f ; D$ doesn't exist
  36. lr r5, [ARC_REG_DC_CTRL]
  37. bclr r5, r5, 6 ; Invalidate (discard w/o wback)
  38. #ifdef CONFIG_ARC_HAS_DCACHE
  39. bclr r5, r5, 0 ; Enable (+Inv)
  40. #else
  41. bset r5, r5, 0 ; Disable (+Inv)
  42. #endif
  43. sr r5, [ARC_REG_DC_CTRL]
  44. 1:
  45. #ifdef CONFIG_ISA_ARCV2
  46. ; Unaligned access is disabled at reset, so re-enable early as
  47. ; gcc 7.3.1 (ARC GNU 2018.03) onwards generates unaligned access
  48. ; by default
  49. lr r5, [status32]
  50. bset r5, r5, STATUS_AD_BIT
  51. kflag r5
  52. #endif
  53. .endm
  54. .section .init.text, "ax",@progbits
  55. ;----------------------------------------------------------------
  56. ; Default Reset Handler (jumped into from Reset vector)
  57. ; - Don't clobber r0,r1,r2 as they might have u-boot provided args
  58. ; - Platforms can override this weak version if needed
  59. ;----------------------------------------------------------------
  60. WEAK(res_service)
  61. j stext
  62. END(res_service)
  63. ;----------------------------------------------------------------
  64. ; Kernel Entry point
  65. ;----------------------------------------------------------------
  66. ENTRY(stext)
  67. CPU_EARLY_SETUP
  68. #ifdef CONFIG_SMP
  69. GET_CPU_ID r5
  70. cmp r5, 0
  71. mov.nz r0, r5
  72. #ifdef CONFIG_ARC_SMP_HALT_ON_RESET
  73. ; Non-Master can proceed as system would be booted sufficiently
  74. jnz first_lines_of_secondary
  75. #else
  76. ; Non-Masters wait for Master to boot enough and bring them up
  77. jnz arc_platform_smp_wait_to_boot
  78. #endif
  79. ; Master falls thru
  80. #endif
  81. ; Clear BSS before updating any globals
  82. ; XXX: use ZOL here
  83. mov r5, __bss_start
  84. sub r6, __bss_stop, r5
  85. lsr.f lp_count, r6, 2
  86. lpnz 1f
  87. st.ab 0, [r5, 4]
  88. 1:
  89. #ifdef CONFIG_ARC_UBOOT_SUPPORT
  90. ; Uboot - kernel ABI
  91. ; r0 = [0] No uboot interaction, [1] cmdline in r2, [2] DTB in r2
  92. ; r1 = magic number (board identity, unused as of now
  93. ; r2 = pointer to uboot provided cmdline or external DTB in mem
  94. ; These are handled later in setup_arch()
  95. st r0, [@uboot_tag]
  96. st r2, [@uboot_arg]
  97. #endif
  98. ; setup "current" tsk and optionally cache it in dedicated r25
  99. mov r9, @init_task
  100. SET_CURR_TASK_ON_CPU r9, r0 ; r9 = tsk, r0 = scratch
  101. ; setup stack (fp, sp)
  102. mov fp, 0
  103. ; tsk->thread_info is really a PAGE, whose bottom hoists stack
  104. GET_TSK_STACK_BASE r9, sp ; r9 = tsk, sp = stack base(output)
  105. j start_kernel ; "C" entry point
  106. END(stext)
  107. #ifdef CONFIG_SMP
  108. ;----------------------------------------------------------------
  109. ; First lines of code run by secondary before jumping to 'C'
  110. ;----------------------------------------------------------------
  111. .section .text, "ax",@progbits
  112. ENTRY(first_lines_of_secondary)
  113. ; setup per-cpu idle task as "current" on this CPU
  114. ld r0, [@secondary_idle_tsk]
  115. SET_CURR_TASK_ON_CPU r0, r1
  116. ; setup stack (fp, sp)
  117. mov fp, 0
  118. ; set it's stack base to tsk->thread_info bottom
  119. GET_TSK_STACK_BASE r0, sp
  120. j start_kernel_secondary
  121. END(first_lines_of_secondary)
  122. #endif