xref: /netbsd/sys/arch/hpcmips/hpcmips/kloader_tx39.S (revision bf9ec67e)
1/*	$NetBSD: kloader_tx39.S,v 1.1 2002/01/29 18:47:26 uch Exp $	*/
2
3/*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 *    must display the following acknowledgement:
17 *        This product includes software developed by the NetBSD
18 *        Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 *    contributors may be used to endorse or promote products derived
21 *    from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <mips/asm.h>
37#include <mips/cpuregs.h>
38
39	.set	noreorder
40	.text
41/*
42 * void kloader_tx_boot(struct kloader_bootinfo *kbi, kloader_page_tag *p)
43 *	must be PIC.
44 */
45EXPORT(kloader_tx_boot)
46LEAF_NOPROFILE(kloader_tx_boot)
47	/*
48	 * 1. load kernel image.
49	 */
50	move	t6, a1		# p
511:
52	beqz	t6, 3f
53	 move	t7, t6
54	lw	t6, 0(t7)	# p = next
55	lw	t0, 4(t7)	# src
56	lw	t4, 8(t7)	# dst
57	lw	t2, 12(t7)	# sz
58	addu	t5, t4, t2	# dst + sz
592:
60	lw	t3, 0(t0)	# copy
61	sw	t3, 0(t4)
62	addiu	t4, t4, 4
63	addiu	t0, t0, 4
64	bltu	t4, t5, 2b
65	 nop
66	b	1b
67	 nop
683:
69	nop
70
71	/*
72	 * 2. Cache flush
73	 */
74	li	t1, 16384
75	li	t2, 8192
76
77	/* Disable I-cache */
78	li	t5, ~0x00000020
79	mfc0	t6, $3
80	and	t5, t5, t6
81	nop
82	mtc0	t5, $3
83
84	/* Stop streaming */
85	beq	zero, zero, 1f
86	 nop
871:
88	/* Flush I-cache */
89	li	t0, 0x80000000
90	addu	t1, t0, t1
91	subu	t1, t1, 128
922:
93	.set push
94	.set mips3
95	cache	0x0, 0($0)
96	cache	0x0, 16(t0)
97	cache	0x0, 32(t0)
98	cache	0x0, 48(t0)
99	cache	0x0, 64(t0)
100	cache	0x0, 80(t0)
101	cache	0x0, 96(t0)
102	cache	0x0, 112(t0)
103	.set pop
104	bne	t0, t1, 2b
105	 addu	t0, t0, 128
106
107	/* Flush D-cache */
108	li	t0, 0x80000000
109	addu	t1, t0, t2
110
1113:
112	lw	t2, 0(t0)
113	bne	t1, t0, 3b
114	 addiu	t0, t0, 4
115
116	/* Enable I-cache */
117	nop
118	mtc0	t6, $3
119	nop
120
121	/*
122	 * 3. jump to kernel entry
123	 */
124	move	t0, a0
125	lw	t1, 0(a0)	# kbi->entry
126	lw	a0, 4(t0)	# kbi->argc
127	lw	a1, 8(t0)	# kbi->argv
128	j	t1
129	 addiu	a2, t0, 12	# &kbi->bootinfo
130	/* NOTREACHED */
131END(kloader_tx_boot)
132