head.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. .macro CPU_EARLY_SETUP
  20. ; Setting up Vectror Table (in case exception happens in early boot
  21. sr @_int_vec_base_lds, [AUX_INTR_VEC_BASE]
  22. ; Disable I-cache/D-cache if kernel so configured
  23. lr r5, [ARC_REG_IC_BCR]
  24. breq r5, 0, 1f ; I$ doesn't exist
  25. lr r5, [ARC_REG_IC_CTRL]
  26. #ifdef CONFIG_ARC_HAS_ICACHE
  27. bclr r5, r5, 0 ; 0 - Enable, 1 is Disable
  28. #else
  29. bset r5, r5, 0 ; I$ exists, but is not used
  30. #endif
  31. sr r5, [ARC_REG_IC_CTRL]
  32. 1:
  33. lr r5, [ARC_REG_DC_BCR]
  34. breq r5, 0, 1f ; D$ doesn't exist
  35. lr r5, [ARC_REG_DC_CTRL]
  36. bclr r5, r5, 6 ; Invalidate (discard w/o wback)
  37. #ifdef CONFIG_ARC_HAS_DCACHE
  38. bclr r5, r5, 0 ; Enable (+Inv)
  39. #else
  40. bset r5, r5, 0 ; Disable (+Inv)
  41. #endif
  42. sr r5, [ARC_REG_DC_CTRL]
  43. 1:
  44. .endm
  45. .cpu A7
  46. .section .init.text, "ax",@progbits
  47. .type stext, @function
  48. .globl stext
  49. stext:
  50. ;-------------------------------------------------------------------
  51. ; Don't clobber r0-r2 yet. It might have bootloader provided info
  52. ;-------------------------------------------------------------------
  53. CPU_EARLY_SETUP
  54. #ifdef CONFIG_SMP
  55. ; Ensure Boot (Master) proceeds. Others wait in platform dependent way
  56. ; IDENTITY Reg [ 3 2 1 0 ]
  57. ; (cpu-id) ^^^ => Zero for UP ARC700
  58. ; => #Core-ID if SMP (Master 0)
  59. ; Note that non-boot CPUs might not land here if halt-on-reset and
  60. ; instead breath life from @first_lines_of_secondary, but we still
  61. ; need to make sure only boot cpu takes this path.
  62. GET_CPU_ID r5
  63. cmp r5, 0
  64. mov.ne r0, r5
  65. jne arc_platform_smp_wait_to_boot
  66. #endif
  67. ; Clear BSS before updating any globals
  68. ; XXX: use ZOL here
  69. mov r5, __bss_start
  70. sub r6, __bss_stop, r5
  71. lsr.f lp_count, r6, 2
  72. lpnz 1f
  73. st.ab 0, [r5, 4]
  74. 1:
  75. ; Uboot - kernel ABI
  76. ; r0 = [0] No uboot interaction, [1] cmdline in r2, [2] DTB in r2
  77. ; r1 = magic number (board identity, unused as of now
  78. ; r2 = pointer to uboot provided cmdline or external DTB in mem
  79. ; These are handled later in setup_arch()
  80. st r0, [@uboot_tag]
  81. st r2, [@uboot_arg]
  82. ; Identify if running on ISS vs Silicon
  83. ; IDENTITY Reg [ 3 2 1 0 ]
  84. ; (chip-id) ^^^^^ ==> 0xffff for ISS
  85. lr r0, [identity]
  86. lsr r3, r0, 16
  87. cmp r3, 0xffff
  88. mov.z r4, 0
  89. mov.nz r4, 1
  90. st r4, [@running_on_hw]
  91. ; setup "current" tsk and optionally cache it in dedicated r25
  92. mov r9, @init_task
  93. SET_CURR_TASK_ON_CPU r9, r0 ; r9 = tsk, r0 = scratch
  94. ; setup stack (fp, sp)
  95. mov fp, 0
  96. ; tsk->thread_info is really a PAGE, whose bottom hoists stack
  97. GET_TSK_STACK_BASE r9, sp ; r9 = tsk, sp = stack base(output)
  98. j start_kernel ; "C" entry point
  99. #ifdef CONFIG_SMP
  100. ;----------------------------------------------------------------
  101. ; First lines of code run by secondary before jumping to 'C'
  102. ;----------------------------------------------------------------
  103. .section .text, "ax",@progbits
  104. .type first_lines_of_secondary, @function
  105. .globl first_lines_of_secondary
  106. first_lines_of_secondary:
  107. CPU_EARLY_SETUP
  108. ; setup per-cpu idle task as "current" on this CPU
  109. ld r0, [@secondary_idle_tsk]
  110. SET_CURR_TASK_ON_CPU r0, r1
  111. ; setup stack (fp, sp)
  112. mov fp, 0
  113. ; set it's stack base to tsk->thread_info bottom
  114. GET_TSK_STACK_BASE r0, sp
  115. j start_kernel_secondary
  116. #endif