head.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. .section .init.text, "ax",@progbits
  46. .type stext, @function
  47. .globl stext
  48. stext:
  49. ;-------------------------------------------------------------------
  50. ; Don't clobber r0-r2 yet. It might have bootloader provided info
  51. ;-------------------------------------------------------------------
  52. CPU_EARLY_SETUP
  53. #ifdef CONFIG_SMP
  54. ; Ensure Boot (Master) proceeds. Others wait in platform dependent way
  55. ; IDENTITY Reg [ 3 2 1 0 ]
  56. ; (cpu-id) ^^^ => Zero for UP ARC700
  57. ; => #Core-ID if SMP (Master 0)
  58. ; Note that non-boot CPUs might not land here if halt-on-reset and
  59. ; instead breath life from @first_lines_of_secondary, but we still
  60. ; need to make sure only boot cpu takes this path.
  61. GET_CPU_ID r5
  62. cmp r5, 0
  63. mov.ne r0, r5
  64. jne arc_platform_smp_wait_to_boot
  65. #endif
  66. ; Clear BSS before updating any globals
  67. ; XXX: use ZOL here
  68. mov r5, __bss_start
  69. sub r6, __bss_stop, r5
  70. lsr.f lp_count, r6, 2
  71. lpnz 1f
  72. st.ab 0, [r5, 4]
  73. 1:
  74. #ifdef CONFIG_ARC_UBOOT_SUPPORT
  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. #endif
  83. ; setup "current" tsk and optionally cache it in dedicated r25
  84. mov r9, @init_task
  85. SET_CURR_TASK_ON_CPU r9, r0 ; r9 = tsk, r0 = scratch
  86. ; setup stack (fp, sp)
  87. mov fp, 0
  88. ; tsk->thread_info is really a PAGE, whose bottom hoists stack
  89. GET_TSK_STACK_BASE r9, sp ; r9 = tsk, sp = stack base(output)
  90. j start_kernel ; "C" entry point
  91. #ifdef CONFIG_SMP
  92. ;----------------------------------------------------------------
  93. ; First lines of code run by secondary before jumping to 'C'
  94. ;----------------------------------------------------------------
  95. .section .text, "ax",@progbits
  96. .type first_lines_of_secondary, @function
  97. .globl first_lines_of_secondary
  98. first_lines_of_secondary:
  99. CPU_EARLY_SETUP
  100. ; setup per-cpu idle task as "current" on this CPU
  101. ld r0, [@secondary_idle_tsk]
  102. SET_CURR_TASK_ON_CPU r0, r1
  103. ; setup stack (fp, sp)
  104. mov fp, 0
  105. ; set it's stack base to tsk->thread_info bottom
  106. GET_TSK_STACK_BASE r0, sp
  107. j start_kernel_secondary
  108. #endif