head.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #ifdef CONFIG_SMP
  27. ; Only Boot (Master) proceeds. Others wait in platform dependent way
  28. ; IDENTITY Reg [ 3 2 1 0 ]
  29. ; (cpu-id) ^^^ => Zero for UP ARC700
  30. ; => #Core-ID if SMP (Master 0)
  31. GET_CPU_ID r5
  32. cmp r5, 0
  33. jnz arc_platform_smp_wait_to_boot
  34. #endif
  35. ; Clear BSS before updating any globals
  36. ; XXX: use ZOL here
  37. mov r5, __bss_start
  38. mov r6, __bss_stop
  39. 1:
  40. st.ab 0, [r5,4]
  41. brlt r5, r6, 1b
  42. #ifdef CONFIG_CMDLINE_UBOOT
  43. ; support for bootloader provided cmdline
  44. ; If cmdline passed by u-boot, then
  45. ; r0 = 1 (because ATAGS parsing, now retired, used to use 0)
  46. ; r1 = magic number (board identity)
  47. ; r2 = addr of cmdline string (somewhere in memory/flash)
  48. brne r0, 1, .Lother_bootup_chores ; u-boot didn't pass cmdline
  49. breq r2, 0, .Lother_bootup_chores ; or cmdline is NULL
  50. mov r5, @command_line
  51. 1:
  52. ldb.ab r6, [r2, 1]
  53. breq r6, 0, .Lother_bootup_chores
  54. b.d 1b
  55. stb.ab r6, [r5, 1]
  56. #endif
  57. .Lother_bootup_chores:
  58. ; Identify if running on ISS vs Silicon
  59. ; IDENTITY Reg [ 3 2 1 0 ]
  60. ; (chip-id) ^^^^^ ==> 0xffff for ISS
  61. lr r0, [identity]
  62. lsr r3, r0, 16
  63. cmp r3, 0xffff
  64. mov.z r4, 0
  65. mov.nz r4, 1
  66. st r4, [@running_on_hw]
  67. ; setup "current" tsk and optionally cache it in dedicated r25
  68. mov r9, @init_task
  69. SET_CURR_TASK_ON_CPU r9, r0 ; r9 = tsk, r0 = scratch
  70. ; setup stack (fp, sp)
  71. mov fp, 0
  72. ; tsk->thread_info is really a PAGE, whose bottom hoists stack
  73. GET_TSK_STACK_BASE r9, sp ; r9 = tsk, sp = stack base(output)
  74. j start_kernel ; "C" entry point
  75. #ifdef CONFIG_SMP
  76. ;----------------------------------------------------------------
  77. ; First lines of code run by secondary before jumping to 'C'
  78. ;----------------------------------------------------------------
  79. .section .init.text, "ax",@progbits
  80. .type first_lines_of_secondary, @function
  81. .globl first_lines_of_secondary
  82. first_lines_of_secondary:
  83. ; setup per-cpu idle task as "current" on this CPU
  84. ld r0, [@secondary_idle_tsk]
  85. SET_CURR_TASK_ON_CPU r0, r1
  86. ; setup stack (fp, sp)
  87. mov fp, 0
  88. ; set it's stack base to tsk->thread_info bottom
  89. GET_TSK_STACK_BASE r0, sp
  90. j start_kernel_secondary
  91. #endif