head.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. ;----------------------------------------------------------------
  47. ; Default Reset Handler (jumped into from Reset vector)
  48. ; - Don't clobber r0,r1,r2 as they might have u-boot provided args
  49. ; - Platforms can override this weak version if needed
  50. ;----------------------------------------------------------------
  51. WEAK(res_service)
  52. j stext
  53. END(res_service)
  54. ;----------------------------------------------------------------
  55. ; Kernel Entry point
  56. ;----------------------------------------------------------------
  57. ENTRY(stext)
  58. CPU_EARLY_SETUP
  59. #ifdef CONFIG_SMP
  60. GET_CPU_ID r5
  61. cmp r5, 0
  62. mov.nz r0, r5
  63. bz .Lmaster_proceed
  64. ; Non-Masters wait for Master to boot enough and bring them up
  65. ; when they resume, tail-call to entry point
  66. mov blink, @first_lines_of_secondary
  67. j arc_platform_smp_wait_to_boot
  68. .Lmaster_proceed:
  69. #endif
  70. ; Clear BSS before updating any globals
  71. ; XXX: use ZOL here
  72. mov r5, __bss_start
  73. sub r6, __bss_stop, r5
  74. lsr.f lp_count, r6, 2
  75. lpnz 1f
  76. st.ab 0, [r5, 4]
  77. 1:
  78. #ifdef CONFIG_ARC_UBOOT_SUPPORT
  79. ; Uboot - kernel ABI
  80. ; r0 = [0] No uboot interaction, [1] cmdline in r2, [2] DTB in r2
  81. ; r1 = magic number (board identity, unused as of now
  82. ; r2 = pointer to uboot provided cmdline or external DTB in mem
  83. ; These are handled later in setup_arch()
  84. st r0, [@uboot_tag]
  85. st r2, [@uboot_arg]
  86. #endif
  87. ; setup "current" tsk and optionally cache it in dedicated r25
  88. mov r9, @init_task
  89. SET_CURR_TASK_ON_CPU r9, r0 ; r9 = tsk, r0 = scratch
  90. ; setup stack (fp, sp)
  91. mov fp, 0
  92. ; tsk->thread_info is really a PAGE, whose bottom hoists stack
  93. GET_TSK_STACK_BASE r9, sp ; r9 = tsk, sp = stack base(output)
  94. j start_kernel ; "C" entry point
  95. END(stext)
  96. #ifdef CONFIG_SMP
  97. ;----------------------------------------------------------------
  98. ; First lines of code run by secondary before jumping to 'C'
  99. ;----------------------------------------------------------------
  100. .section .text, "ax",@progbits
  101. ENTRY(first_lines_of_secondary)
  102. ; setup per-cpu idle task as "current" on this CPU
  103. ld r0, [@secondary_idle_tsk]
  104. SET_CURR_TASK_ON_CPU r0, r1
  105. ; setup stack (fp, sp)
  106. mov fp, 0
  107. ; set it's stack base to tsk->thread_info bottom
  108. GET_TSK_STACK_BASE r0, sp
  109. j start_kernel_secondary
  110. END(first_lines_of_secondary)
  111. #endif