xref: /netbsd-src/sys/arch/evbppc/obs405/obs200_locore.S (revision 179b12252ecaf3553d9c2b7458ce62b6a2203d0c)
1/*	$NetBSD: obs200_locore.S,v 1.9 2010/03/18 13:47:04 kiyohara Exp $	*/
2/*	Original Tag: locore.S,v 1.1 2003/09/23 15:21:58 shige Exp	*/
3/*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
4
5/*
6 * Copyright 2001 Wasabi Systems, Inc.
7 * All rights reserved.
8 *
9 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 *    must display the following acknowledgement:
21 *      This product includes software developed for the NetBSD Project by
22 *      Wasabi Systems, Inc.
23 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
24 *    or promote products derived from this software without specific prior
25 *    written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40/*
41 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
42 * Copyright (C) 1995, 1996 TooLs GmbH.
43 * All rights reserved.
44 *
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions
47 * are met:
48 * 1. Redistributions of source code must retain the above copyright
49 *    notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 *    notice, this list of conditions and the following disclaimer in the
52 *    documentation and/or other materials provided with the distribution.
53 * 3. All advertising materials mentioning features or use of this software
54 *    must display the following acknowledgement:
55 *	This product includes software developed by TooLs GmbH.
56 * 4. The name of TooLs GmbH may not be used to endorse or promote products
57 *    derived from this software without specific prior written permission.
58 *
59 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
60 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
61 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
62 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
64 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
65 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
66 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
67 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
68 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69 */
70
71#undef PPC_4XX_NOCACHE
72#define _NOREGNAMES
73
74#include "opt_ddb.h"
75#include "opt_ipkdb.h"
76#include "opt_lockdebug.h"
77#include "opt_modular.h"
78#include "opt_multiprocessor.h"
79#include "opt_ppcarch.h"
80#include "opt_ppcparam.h"
81#include "assym.h"
82#include "ksyms.h"
83
84#include <sys/syscall.h>
85
86#include <machine/param.h>
87#include <machine/psl.h>
88#include <machine/trap.h>
89#include <machine/asm.h>
90
91#include <powerpc/spr.h>
92#include <powerpc/ibm4xx/spr.h>
93#include <powerpc/ibm4xx/dcr4xx.h>
94#include <powerpc/ibm4xx/pmap.h>
95
96/* Function pointer for requesting board_config_data from OpenBlockS S/R BIOS */
97#define BOARD_CFG_FP	(0x00100000)
98
99/*
100 * Some instructions gas doesn't understand (yet?)
101 */
102#define	bdneq	bdnzf 2,
103
104/*
105 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
106 * mark the start of kernel text.
107 */
108	.text
109	.globl	_C_LABEL(kernel_text)
110_C_LABEL(kernel_text):
111
112/*
113 * Startup entry.  Note, this must be the first thing in the text
114 * segment!
115 */
116	.text
117	.globl	__start
118__start:
119	b	1f
120	/* Reserve some space for info_block required for IBM eval board bootloader */
121	nop
122	nop
123	nop
124	nop
125	nop
126	nop
127	nop
128	nop
129	nop
130	nop
131
1321:
133	/* Get the board_config_data from openbios */
134	lis	%r3,BOARD_CFG_FP@h
135	ori	%r3,%r3,BOARD_CFG_FP@l
136	mr	%r31,%r3		/* Save value in r31 */
137
138	li	%r0,0
139	mtmsr	%r0			/* Disable FPU/MMU/exceptions */
140	isync
141
142	/* PPC405GP errata, item #58.
143	 * Load string instructions may write incorrect data into the last GPR
144	 * targeted in the operation.
145	 * Workaround: set OCM0_DSCNTL[DSEN]=0 and OCM0_DSCNTL[DOF]=0 */
146	mtdcr	DCR_OCM0_DSCNTL, %r0  	/* Disable Data access to OCM */
147	mtdcr	DCR_OCM0_ISCNTL, %r0  	/* Disable Instruction access to OCM. Just in case */
148/*
149 * Cpu detect.
150 *
151 */
152__start_cpu0:
153#ifdef PPC_4XX_NOCACHE
154	/* Disable all caches for physical addresses */
155	li	%r0,0
156#else
157	/* Allow cacheing for only the first 2GB of RAM */
158	lis	%r0,0xffff
159#endif
160	mtdccr	%r0
161	mticcr	%r0
162
163	/* Invalidate all TLB entries */
164	tlbia
165	sync
166	isync
167/* get start of bss */
168	lis	%r3,_C_LABEL(_edata)-4@ha
169	addi	%r3,%r3,_C_LABEL(_edata)-4@l
170/* get end of kernel memory */
171	lis	%r8,_C_LABEL(end)@ha
172	addi	%r8,%r8,_C_LABEL(end)@l
173/* zero bss */
174	li	%r4,0
1752:	stwu	%r4,%r4(3)
176	cmpw	%r3,%r8
177	bne+	2b
178
179#if NKSYMS || defined(DDB) || defined(MODULAR)
180	/* If we had symbol table location we'd store it here and would've adjusted r8 here */
181	lis	%r7,_C_LABEL(startsym)@ha
182	addi	%r7,%r7,_C_LABEL(startsym)@l
183	stw	%r8,0(%r7)
184	lis	%r7,_C_LABEL(endsym)@ha
185	addi	%r7,%r7,_C_LABEL(endsym)@l
186	stw	%r8,0(%r7)
187#endif
188
189	/* Set kernel MMU context. */
190	li	%r0,KERNEL_PID
191	mtpid	%r0
192	sync
193
194	INIT_CPUINFO(8,1,9,0)
195	mr	%r4,%r8
196
197	lis	%r3,__start@ha
198	addi	%r3,%r3,__start@l
199
200	mr	%r6,%r31		/* info_block address */
201	bl	_C_LABEL(initppc)
202	bl	_C_LABEL(main)
203
204loop:	b	loop			/* XXX not reached */
205
206#include <powerpc/ibm4xx/4xx_locore.S>
207