head.S 3.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * ARC CPU startup Code
 *
 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * Vineetg: Dec 2007
 *  -Check if we are running on Simulator or on real hardware
 *      to skip certain things during boot on simulator
 */

15
#include <linux/linkage.h>
16 17 18
#include <asm/asm-offsets.h>
#include <asm/entry.h>
#include <asm/arcregs.h>
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#include <asm/cache.h>

.macro CPU_EARLY_SETUP

	; Setting up Vectror Table (in case exception happens in early boot
	sr	@_int_vec_base_lds, [AUX_INTR_VEC_BASE]

	; Disable I-cache/D-cache if kernel so configured
	lr	r5, [ARC_REG_IC_BCR]
	breq    r5, 0, 1f		; I$ doesn't exist
	lr	r5, [ARC_REG_IC_CTRL]
#ifdef CONFIG_ARC_HAS_ICACHE
	bclr	r5, r5, 0		; 0 - Enable, 1 is Disable
#else
	bset	r5, r5, 0		; I$ exists, but is not used
#endif
	sr	r5, [ARC_REG_IC_CTRL]

1:
	lr	r5, [ARC_REG_DC_BCR]
	breq    r5, 0, 1f		; D$ doesn't exist
	lr	r5, [ARC_REG_DC_CTRL]
	bclr	r5, r5, 6		; Invalidate (discard w/o wback)
#ifdef CONFIG_ARC_HAS_DCACHE
	bclr	r5, r5, 0		; Enable (+Inv)
#else
	bset	r5, r5, 0		; Disable (+Inv)
#endif
	sr	r5, [ARC_REG_DC_CTRL]

1:
.endm
51 52

	.section .init.text, "ax",@progbits
53 54 55 56 57 58 59 60 61 62 63 64 65 66

;----------------------------------------------------------------
; Default Reset Handler (jumped into from Reset vector)
; - Don't clobber r0,r1,r2 as they might have u-boot provided args
; - Platforms can override this weak version if needed
;----------------------------------------------------------------
WEAK(res_service)
	j	stext
END(res_service)

;----------------------------------------------------------------
; Kernel Entry point
;----------------------------------------------------------------
ENTRY(stext)
67

68
	CPU_EARLY_SETUP
69

V
Vineet Gupta 已提交
70 71 72
#ifdef CONFIG_SMP
	GET_CPU_ID  r5
	cmp	r5, 0
73
	mov.nz	r0, r5
74 75
	bz	.Lmaster_proceed

76
	; Non-Masters wait for Master to boot enough and bring them up
77 78 79 80 81
	; when they resume, tail-call to entry point
	mov	blink, @first_lines_of_secondary
	j	arc_platform_smp_wait_to_boot

.Lmaster_proceed:
V
Vineet Gupta 已提交
82
#endif
83

84 85 86
	; Clear BSS before updating any globals
	; XXX: use ZOL here
	mov	r5, __bss_start
87 88 89 90
	sub	r6, __bss_stop, r5
	lsr.f	lp_count, r6, 2
	lpnz	1f
	st.ab   0, [r5, 4]
91 92
1:

V
Vineet Gupta 已提交
93
#ifdef CONFIG_ARC_UBOOT_SUPPORT
94 95 96 97 98 99 100
	; Uboot - kernel ABI
	;    r0 = [0] No uboot interaction, [1] cmdline in r2, [2] DTB in r2
	;    r1 = magic number (board identity, unused as of now
	;    r2 = pointer to uboot provided cmdline or external DTB in mem
	; These are handled later in setup_arch()
	st	r0, [@uboot_tag]
	st	r2, [@uboot_arg]
V
Vineet Gupta 已提交
101
#endif
102 103 104 105 106 107 108 109 110 111 112 113

	; setup "current" tsk and optionally cache it in dedicated r25
	mov	r9, @init_task
	SET_CURR_TASK_ON_CPU  r9, r0	; r9 = tsk, r0 = scratch

	; setup stack (fp, sp)
	mov	fp, 0

	; tsk->thread_info is really a PAGE, whose bottom hoists stack
	GET_TSK_STACK_BASE r9, sp	; r9 = tsk, sp = stack base(output)

	j	start_kernel	; "C" entry point
114
END(stext)
V
Vineet Gupta 已提交
115 116 117 118 119

#ifdef CONFIG_SMP
;----------------------------------------------------------------
;     First lines of code run by secondary before jumping to 'C'
;----------------------------------------------------------------
120
	.section .text, "ax",@progbits
121
ENTRY(first_lines_of_secondary)
V
Vineet Gupta 已提交
122 123 124 125 126 127 128 129 130 131 132 133

	; setup per-cpu idle task as "current" on this CPU
	ld	r0, [@secondary_idle_tsk]
	SET_CURR_TASK_ON_CPU  r0, r1

	; setup stack (fp, sp)
	mov	fp, 0

	; set it's stack base to tsk->thread_info bottom
	GET_TSK_STACK_BASE r0, sp

	j	start_kernel_secondary
134
END(first_lines_of_secondary)
V
Vineet Gupta 已提交
135
#endif