xref: /netbsd-src/sys/arch/ofppc/ofppc/locore.S (revision 213144e1de7024d4193d04aa51005ba3a5ad95e7)
1/*	$NetBSD: locore.S,v 1.46 2011/01/17 08:23:56 matt 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/pmap.h>
46#include <machine/psl.h>
47#include <machine/trap.h>
48#include <machine/asm.h>
49#include <machine/vmparam.h>
50
51#include <powerpc/spr.h>
52#include <powerpc/oea/spr.h>
53
54#include "ksyms.h"
55
56/*
57 * Some instructions gas doesn't understand (yet?)
58 */
59#define	bdneq	bdnzf 2,
60
61/*
62 * Globals
63 */
64	.data
65GLOBAL(esym)
66	.long	0			/* end of symbol table */
67GLOBAL(oeacpufeat)
68	.long	0			/* cpu features */
69
70/*
71 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
72 * mark the start of kernel text.
73 */
74	.text
75	.globl	_C_LABEL(kernel_text)
76_C_LABEL(kernel_text):
77
78/*
79 * Startup entry.  Note, this must be the first thing in the text
80 * segment!
81 */
82	.text
83	.globl	__start
84__start:
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	cmpwi	%r6,0
110	beq	1f
111	add	%r9,%r6,%r7			/* r9 = args + l */
112	lwz	%r9,-8(%r9)			/* esym */
113	cmpwi	%r9,0
114	beq	1f
115	mr	%r4,%r9
1161:
117#endif
118
119
120	/*
121	 * Initialize cpu_info[0]
122	 */
123	INIT_CPUINFO(%r4,%r1,%r9,%r0)
124
125	lis	%r3,__start@ha
126	addi	%r3,%r3,__start@l
127	mr	%r5,%r6			/* args string */
128	bl	_C_LABEL(initppc)
129	bl	_C_LABEL(main)
130	b	_C_LABEL(OF_exit)
131
132/*
133 * Pull in common OFW code.
134 */
135#include <powerpc/oea/ofw_subr.S>
136
137/*
138 * Pull in common switch / setfault code.
139 */
140#include <powerpc/powerpc/locore_subr.S>
141
142/*
143 * Pull in common trap vector code.
144 */
145#include <powerpc/powerpc/trap_subr.S>
146
147/*
148 * Pull in common pio / bus_space code.
149 */
150#include <powerpc/powerpc/pio_subr.S>
151