xref: /openbmc/linux/arch/arc/kernel/head.S (revision c121c5063c0674fad6811f0b0d86ec3bc6eecbbd)
1*c121c506SVineet Gupta/*
2*c121c506SVineet Gupta * ARC CPU startup Code
3*c121c506SVineet Gupta *
4*c121c506SVineet Gupta * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
5*c121c506SVineet Gupta *
6*c121c506SVineet Gupta * This program is free software; you can redistribute it and/or modify
7*c121c506SVineet Gupta * it under the terms of the GNU General Public License version 2 as
8*c121c506SVineet Gupta * published by the Free Software Foundation.
9*c121c506SVineet Gupta *
10*c121c506SVineet Gupta * Vineetg: Dec 2007
11*c121c506SVineet Gupta *  -Check if we are running on Simulator or on real hardware
12*c121c506SVineet Gupta *      to skip certain things during boot on simulator
13*c121c506SVineet Gupta */
14*c121c506SVineet Gupta
15*c121c506SVineet Gupta#include <asm/asm-offsets.h>
16*c121c506SVineet Gupta#include <asm/entry.h>
17*c121c506SVineet Gupta#include <linux/linkage.h>
18*c121c506SVineet Gupta#include <asm/arcregs.h>
19*c121c506SVineet Gupta
20*c121c506SVineet Gupta	.cpu A7
21*c121c506SVineet Gupta
22*c121c506SVineet Gupta	.section .init.text, "ax",@progbits
23*c121c506SVineet Gupta	.type stext, @function
24*c121c506SVineet Gupta	.globl stext
25*c121c506SVineet Guptastext:
26*c121c506SVineet Gupta	;-------------------------------------------------------------------
27*c121c506SVineet Gupta	; Don't clobber r0-r4 yet. It might have bootloader provided info
28*c121c506SVineet Gupta	;-------------------------------------------------------------------
29*c121c506SVineet Gupta
30*c121c506SVineet Gupta	; Clear BSS before updating any globals
31*c121c506SVineet Gupta	; XXX: use ZOL here
32*c121c506SVineet Gupta	mov	r5, __bss_start
33*c121c506SVineet Gupta	mov	r6, __bss_stop
34*c121c506SVineet Gupta1:
35*c121c506SVineet Gupta	st.ab   0, [r5,4]
36*c121c506SVineet Gupta	brlt    r5, r6, 1b
37*c121c506SVineet Gupta
38*c121c506SVineet Gupta#ifdef CONFIG_CMDLINE_UBOOT
39*c121c506SVineet Gupta	; support for bootloader provided cmdline
40*c121c506SVineet Gupta	;    If cmdline passed by u-boot, then
41*c121c506SVineet Gupta	;    r0 = 1  (because ATAGS parsing, now retired, used to use 0)
42*c121c506SVineet Gupta	;    r1 = magic number (board identity)
43*c121c506SVineet Gupta	;    r2 = addr of cmdline string (somewhere in memory/flash)
44*c121c506SVineet Gupta
45*c121c506SVineet Gupta	brne	r0, 1, .Lother_bootup_chores	; u-boot didn't pass cmdline
46*c121c506SVineet Gupta	breq	r2, 0, .Lother_bootup_chores	; or cmdline is NULL
47*c121c506SVineet Gupta
48*c121c506SVineet Gupta	mov	r5, @command_line
49*c121c506SVineet Gupta1:
50*c121c506SVineet Gupta	ldb.ab  r6, [r2, 1]
51*c121c506SVineet Gupta	breq    r6, 0, .Lother_bootup_chores
52*c121c506SVineet Gupta	b.d     1b
53*c121c506SVineet Gupta	stb.ab  r6, [r5, 1]
54*c121c506SVineet Gupta#endif
55*c121c506SVineet Gupta
56*c121c506SVineet Gupta.Lother_bootup_chores:
57*c121c506SVineet Gupta
58*c121c506SVineet Gupta	; Identify if running on ISS vs Silicon
59*c121c506SVineet Gupta	; 	IDENTITY Reg [ 3  2  1  0 ]
60*c121c506SVineet Gupta	;	(chip-id)      ^^^^^		==> 0xffff for ISS
61*c121c506SVineet Gupta	lr	r0, [identity]
62*c121c506SVineet Gupta	lsr	r3, r0, 16
63*c121c506SVineet Gupta	cmp	r3, 0xffff
64*c121c506SVineet Gupta	mov.z	r4, 0
65*c121c506SVineet Gupta	mov.nz	r4, 1
66*c121c506SVineet Gupta	st	r4, [@running_on_hw]
67*c121c506SVineet Gupta
68*c121c506SVineet Gupta	; setup "current" tsk and optionally cache it in dedicated r25
69*c121c506SVineet Gupta	mov	r9, @init_task
70*c121c506SVineet Gupta	SET_CURR_TASK_ON_CPU  r9, r0	; r9 = tsk, r0 = scratch
71*c121c506SVineet Gupta
72*c121c506SVineet Gupta	; setup stack (fp, sp)
73*c121c506SVineet Gupta	mov	fp, 0
74*c121c506SVineet Gupta
75*c121c506SVineet Gupta	; tsk->thread_info is really a PAGE, whose bottom hoists stack
76*c121c506SVineet Gupta	GET_TSK_STACK_BASE r9, sp	; r9 = tsk, sp = stack base(output)
77*c121c506SVineet Gupta
78*c121c506SVineet Gupta	j	start_kernel	; "C" entry point
79