xref: /netbsd-src/sys/arch/ofppc/ofppc/locore.S (revision c34236556bea94afcaca1782d7d228301edc3ea0)
1/*	$NetBSD: locore.S,v 1.49 2014/11/09 00:05:06 chs Exp $	*/
2
3/*
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *	This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 *    derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include "opt_ddb.h"
35#include "opt_ipkdb.h"
36#include "opt_lockdebug.h"
37#include "opt_modular.h"
38#include "opt_multiprocessor.h"
39#include "opt_ppcparam.h"
40#include "assym.h"
41
42#include <sys/syscall.h>
43
44#include <machine/param.h>
45#include <machine/psl.h>
46#include <machine/trap.h>
47#include <machine/asm.h>
48
49#include <powerpc/spr.h>
50#include <powerpc/oea/spr.h>
51
52#include "ksyms.h"
53
54/*
55 * Some instructions gas doesn't understand (yet?)
56 */
57#define	bdneq	bdnzf 2,
58
59/*
60 * Globals
61 */
62	.data
63GLOBAL(esym)
64	.long	0			/* end of symbol table */
65GLOBAL(oeacpufeat)
66	.long	0			/* cpu features */
67
68/*
69 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
70 * mark the start of kernel text.
71 */
72	.text
73	.globl	_C_LABEL(kernel_text)
74_C_LABEL(kernel_text):
75
76/*
77 * Startup entry.  Note, this must be the first thing in the text
78 * segment!
79 */
80	.text
81	.globl	__start
82__start:
83	mr	%r13,%r6
84	mr	%r14,%r7
85	bl	_C_LABEL(ofwinit)	/* init our OF hooks */
86
87	li	%r0,0
88	mtmsr	%r0			/* Disable FPU/MMU/exceptions */
89
90	bl	_C_LABEL(cpu_model_init)
91	lis	%r12,oeacpufeat@ha
92	lwz	%r12,oeacpufeat@l(%r12)
93	andi.	%r12,%r12,OEACPU_64_BRIDGE	/* Compare against OEACPU_64_BRIDGE */
94	beq	2f			/* skip if this is a 32bit part */
95	li	%r0,0
96	sync
97	slbia				/* invalidate the slb table */
98	sync
99	clrldi	%r0,%r0,32		/* clear SF/ISF (high order bits) */
100	mtmsrd	%r0
101	mtspr	0x118,0		/* clear ASR[V] to enable segregs */
1022:
103	isync
104	/* compute end of kernel memory */
105        lis	%r4,_C_LABEL(end)@ha
106        addi	%r4,%r4,_C_LABEL(end)@l
107#if NKSYMS || defined(DDB) || defined(MODULAR)
108	/* skip symbol table */
109	mr	%r6,%r13
110	mr	%r7,%r14
111	cmpwi	%r6,0
112	beq	1f
113	add	%r9,%r6,%r7			/* r9 = args + l */
114	lwz	%r9,-8(%r9)			/* esym */
115	cmpwi	%r9,0
116	beq	1f
117	mr	%r4,%r9
1181:
119#endif
120
121
122	/*
123	 * Initialize cpu_info[0]
124	 */
125	INIT_CPUINFO(%r4,%r1,%r9,%r0)
126
127	lis	%r3,__start@ha
128	addi	%r3,%r3,__start@l
129	mr	%r5,%r6			/* args string */
130	bl	_C_LABEL(initppc)
131	bl	_C_LABEL(main)
132	b	_C_LABEL(OF_exit)
133
134/*
135 * Pull in common OFW code.
136 */
137#include <powerpc/oea/ofw_subr.S>
138
139/*
140 * Pull in common switch / setfault code.
141 */
142#include <powerpc/powerpc/locore_subr.S>
143
144/*
145 * Pull in common trap vector code.
146 */
147#include <powerpc/powerpc/trap_subr.S>
148
149/*
150 * Pull in common pio / bus_space code.
151 */
152#include <powerpc/powerpc/pio_subr.S>
153