• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15#include <asm/asm-offsets.h>
16#include <asm/entry.h>
17#include <linux/linkage.h>
18#include <asm/arcregs.h>
19
20	.cpu A7
21
22	.section .init.text, "ax",@progbits
23	.type stext, @function
24	.globl stext
25stext:
26	;-------------------------------------------------------------------
27	; Don't clobber r0-r4 yet. It might have bootloader provided info
28	;-------------------------------------------------------------------
29
30#ifdef CONFIG_SMP
31	; Only Boot (Master) proceeds. Others wait in platform dependent way
32	;	IDENTITY Reg [ 3  2  1  0 ]
33	;	(cpu-id)             ^^^	=> Zero for UP ARC700
34	;					=> #Core-ID if SMP (Master 0)
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
431:
44	st.ab   0, [r5,4]
45	brlt    r5, r6, 1b
46
47#ifdef CONFIG_CMDLINE_UBOOT
48	; support for bootloader provided cmdline
49	;    If cmdline passed by u-boot, then
50	;    r0 = 1  (because ATAGS parsing, now retired, used to use 0)
51	;    r1 = magic number (board identity)
52	;    r2 = addr of cmdline string (somewhere in memory/flash)
53
54	brne	r0, 1, .Lother_bootup_chores	; u-boot didn't pass cmdline
55	breq	r2, 0, .Lother_bootup_chores	; or cmdline is NULL
56
57	mov	r5, @command_line
581:
59	ldb.ab  r6, [r2, 1]
60	breq    r6, 0, .Lother_bootup_chores
61	b.d     1b
62	stb.ab  r6, [r5, 1]
63#endif
64
65.Lother_bootup_chores:
66
67	; Identify if running on ISS vs Silicon
68	; 	IDENTITY Reg [ 3  2  1  0 ]
69	;	(chip-id)      ^^^^^		==> 0xffff for ISS
70	lr	r0, [identity]
71	lsr	r3, r0, 16
72	cmp	r3, 0xffff
73	mov.z	r4, 0
74	mov.nz	r4, 1
75	st	r4, [@running_on_hw]
76
77	; setup "current" tsk and optionally cache it in dedicated r25
78	mov	r9, @init_task
79	SET_CURR_TASK_ON_CPU  r9, r0	; r9 = tsk, r0 = scratch
80
81	; setup stack (fp, sp)
82	mov	fp, 0
83
84	; tsk->thread_info is really a PAGE, whose bottom hoists stack
85	GET_TSK_STACK_BASE r9, sp	; r9 = tsk, sp = stack base(output)
86
87	j	start_kernel	; "C" entry point
88
89#ifdef CONFIG_SMP
90;----------------------------------------------------------------
91;     First lines of code run by secondary before jumping to 'C'
92;----------------------------------------------------------------
93	.section .init.text, "ax",@progbits
94	.type first_lines_of_secondary, @function
95	.globl first_lines_of_secondary
96
97first_lines_of_secondary:
98
99	; setup per-cpu idle task as "current" on this CPU
100	ld	r0, [@secondary_idle_tsk]
101	SET_CURR_TASK_ON_CPU  r0, r1
102
103	; setup stack (fp, sp)
104	mov	fp, 0
105
106	; set it's stack base to tsk->thread_info bottom
107	GET_TSK_STACK_BASE r0, sp
108
109	j	start_kernel_secondary
110
111#endif
112