xref: /netbsd-src/sys/arch/mvmeppc/mvmeppc/locore.S (revision 31c71552cd40ea47d81cc63067c559da5257d3ed)
1/*	$NetBSD: locore.S,v 1.18 2021/02/26 02:18:56 thorpej Exp $	*/
2/*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
3
4/*
5 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
6 * Copyright (C) 1995, 1996 TooLs GmbH.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 *    must display the following acknowledgement:
19 *	This product includes software developed by TooLs GmbH.
20 * 4. The name of TooLs GmbH may not be used to endorse or promote products
21 *    derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include "opt_ddb.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 */
62GLOBAL(startsym)
63	.long	0			/* start symbol table */
64GLOBAL(endsym)
65	.long	0			/* end symbol table */
66
67/* XXX All of this should die */
68GLOBAL(intrnames)
69	.asciz	"clock", "irq1", "irq2", "irq3"
70	.asciz	"irq4", "irq5", "irq6", "irq7"
71	.asciz	"irq8", "irq9", "irq10", "irq11"
72	.asciz	"irq12", "irq13", "irq14", "irq15"
73	.asciz	"irq16", "irq17", "irq18", "irq19"
74	.asciz	"irq20", "irq21", "irq22", "irq23"
75	.asciz	"irq24", "irq25", "irq26", "irq27"
76	.asciz	"irq28", "softnet", "softclock", "softserial"
77GLOBAL(eintrnames)
78	.align	4
79GLOBAL(intrcnt)
80	.long	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
81	.long	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
82GLOBAL(eintrcnt)
83
84/*
85 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
86 * mark the start of kernel text.
87 */
88	.text
89	.globl	_C_LABEL(kernel_text)
90_C_LABEL(kernel_text):
91
92/*
93 * Startup entry.  Note, this must be the first thing in the text
94 * segment!
95 *
96 * The bootloaded passes the following registers:
97 *
98 *  %r3 == start of symbol table
99 *  %r4 == end of symbol table
100 *  %r5 == boot parameters
101 */
102	.text
103	.globl	__start
104__start:
105	li	%r0,0
106	mtmsr	%r0			/* Disable FPU/MMU/exceptions */
107	isync
108
109/* compute end of kernel memory */
110#if NKSYMS || defined(DDB) || defined(MODULAR)
111	lis	%r7,_C_LABEL(startsym)@ha
112	addi	%r7,%r7,_C_LABEL(startsym)@l
113	stw	%r3,0(%r7)
114	lis	%r7,_C_LABEL(endsym)@ha
115	addi	%r7,%r7,_C_LABEL(endsym)@l
116	stw	%r4,0(%r7)		/* end of symbol table */
117#else
118	lis	%r4,_C_LABEL(end)@ha
119	addi	%r4,%r4,_C_LABEL(end)@l
120#endif
121
122	INIT_CPUINFO(%r4,%r1,%r9,%r0)
123
124	lis	%r3,__start@ha
125	addi	%r3,%r3,__start@l
126
127	bl	_C_LABEL(initppc)
128
129/* enable internal i/d-cache */
130	mfpvr	%r9
131	rlwinm	%r9,%r9,16,16,31
132	cmpwi	%cr0,%r9,1
133	beq	3f			/* not needed for 601 */
134	mfspr	%r11,SPR_HID0
135	andi.	%r0,%r11,HID0_DCE
136	ori	%r11,%r11,HID0_ICE|HID0_DCE
137	ori	%r8,%r11,HID0_ICFI
138	bne	1f			/* don't invalidate the D-cache */
139	ori	%r8,%r8,HID0_DCFI		/* unless it wasn't enabled */
1401:
141	sync
142	mtspr	SPR_HID0,%r8		/* enable and invalidate caches */
143	sync
144	mtspr	SPR_HID0,%r11		/* enable caches */
145	sync
146	isync
147	cmpwi	%cr0,%r9,4		/* check for 604 */
148	cmpwi	%cr1,%r9,9		/* or 604e */
149	cmpwi	%cr2,%r9,10		/* or mach5 */
150	cror	2,2,6
151	cror	2,2,10
152	bne	3f
153	ori	%r11,%r11,HID0_SIED|HID0_BHTE /* for 604[e], enable */
154	bne	%cr2,2f
155	ori	%r11,%r11,HID0_BTCD
1562:
157	mtspr	SPR_HID0,%r11
1583:
159	sync
160	isync
161
162	bl	_C_LABEL(main)
163	b	bugret
164
165/*
166 * void _mvmeppc_unsup_board(const char *msg, const char *msgend)
167 *
168 * Print the specified message using ppcbug's console output syscall
169 * before dropping back out to bug.
170 */
171ENTRY(_mvmeppc_unsup_board)
172	addi	%r10,0,0x0022
173	sc
174bugret:	addi	%r10,0,0x0063
175	sc
176	/* NOTREACHED */
177
178	.globl	_C_LABEL(enable_intr)
179_C_LABEL(enable_intr):
180	mfmsr	%r3
181	ori	%r3,%r3,PSL_EE@l
182	mtmsr	%r3
183	blr
184
185	.globl	_C_LABEL(disable_intr)
186_C_LABEL(disable_intr):
187	mfmsr	%r3
188	andi.	%r3,%r3,~PSL_EE@l
189	mtmsr	%r3
190	blr
191
192/*
193 * Pull in common switch / setfault code.
194 */
195#include <powerpc/powerpc/locore_subr.S>
196
197/*
198 * Pull in common trap vector code.
199 */
200#include <powerpc/powerpc/trap_subr.S>
201
202/*
203 * Pull in common pio / bus_space code.
204 */
205#include <powerpc/powerpc/pio_subr.S>
206