head.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 <asm/asm-offsets.h>
  15. #include <asm/entry.h>
  16. #include <linux/linkage.h>
  17. #include <asm/arcregs.h>
  18. .cpu A7
  19. .section .init.text, "ax",@progbits
  20. .type stext, @function
  21. .globl stext
  22. stext:
  23. ;-------------------------------------------------------------------
  24. ; Don't clobber r0-r4 yet. It might have bootloader provided info
  25. ;-------------------------------------------------------------------
  26. sr @_int_vec_base_lds, [AUX_INTR_VEC_BASE]
  27. #ifdef CONFIG_SMP
  28. ; Only Boot (Master) proceeds. Others wait in platform dependent way
  29. ; IDENTITY Reg [ 3 2 1 0 ]
  30. ; (cpu-id) ^^^ => Zero for UP ARC700
  31. ; => #Core-ID if SMP (Master 0)
  32. ; Note that non-boot CPUs might not land here if halt-on-reset and
  33. ; instead breath life from @first_lines_of_secondary, but we still
  34. ; need to make sure only boot cpu takes this path.
  35. GET_CPU_ID r5
  36. cmp r5, 0
  37. jnz arc_platform_smp_wait_to_boot
  38. #endif
  39. ; Clear BSS before updating any globals
  40. ; XXX: use ZOL here
  41. mov r5, __bss_start
  42. mov r6, __bss_stop
  43. 1:
  44. st.ab 0, [r5,4]
  45. brlt r5, r6, 1b
  46. ; Uboot - kernel ABI
  47. ; r0 = [0] No uboot interaction, [1] cmdline in r2, [2] DTB in r2
  48. ; r1 = magic number (board identity, unused as of now
  49. ; r2 = pointer to uboot provided cmdline or external DTB in mem
  50. ; These are handled later in setup_arch()
  51. st r0, [@uboot_tag]
  52. st r2, [@uboot_arg]
  53. ; Identify if running on ISS vs Silicon
  54. ; IDENTITY Reg [ 3 2 1 0 ]
  55. ; (chip-id) ^^^^^ ==> 0xffff for ISS
  56. lr r0, [identity]
  57. lsr r3, r0, 16
  58. cmp r3, 0xffff
  59. mov.z r4, 0
  60. mov.nz r4, 1
  61. st r4, [@running_on_hw]
  62. ; setup "current" tsk and optionally cache it in dedicated r25
  63. mov r9, @init_task
  64. SET_CURR_TASK_ON_CPU r9, r0 ; r9 = tsk, r0 = scratch
  65. ; setup stack (fp, sp)
  66. mov fp, 0
  67. ; tsk->thread_info is really a PAGE, whose bottom hoists stack
  68. GET_TSK_STACK_BASE r9, sp ; r9 = tsk, sp = stack base(output)
  69. j start_kernel ; "C" entry point
  70. #ifdef CONFIG_SMP
  71. ;----------------------------------------------------------------
  72. ; First lines of code run by secondary before jumping to 'C'
  73. ;----------------------------------------------------------------
  74. .section .text, "ax",@progbits
  75. .type first_lines_of_secondary, @function
  76. .globl first_lines_of_secondary
  77. first_lines_of_secondary:
  78. sr @_int_vec_base_lds, [AUX_INTR_VEC_BASE]
  79. ; setup per-cpu idle task as "current" on this CPU
  80. ld r0, [@secondary_idle_tsk]
  81. SET_CURR_TASK_ON_CPU r0, r1
  82. ; setup stack (fp, sp)
  83. mov fp, 0
  84. ; set it's stack base to tsk->thread_info bottom
  85. GET_TSK_STACK_BASE r0, sp
  86. j start_kernel_secondary
  87. #endif