xref: /netbsd/sys/arch/hpcmips/hpcmips/kloader_vr41.S (revision bf9ec67e)
1/*	$NetBSD: kloader_vr41.S,v 1.1 2002/01/29 18:47:25 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_vr_boot(struct kloader_bootinfo *kbi, kloader_page_tag *p)
43 *	must be PIC.
44 */
45EXPORT(kloader_vr_boot)
46LEAF_NOPROFILE(kloader_vr_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	/* Flush I-cache */
75	li	t0, 0x80000000
76	addu	t1, t0, 1024 * 128
77	subu	t1, t1, 128
781:
79	.set push
80	.set mips3
81	cache	0, 0(t0)
82	cache	0, 16(t0)
83	cache	0, 32(t0)
84	cache	0, 48(t0)
85	cache	0, 64(t0)
86	cache	0, 80(t0)
87	cache	0, 96(t0)
88	cache	0, 112(t0)
89	.set pop
90	bne	t0, t1, 1b
91	 addu	t0, t0, 128
92
93	/* Flush D-cache */
94	li	t0, 0x80000000
95	addu	t1, t0, 1024 * 128
96	subu	t1, t1, 128
972:
98	.set push
99	.set mips3
100	cache   1, 0(t0)
101	cache   1, 16(t0)
102	cache   1, 32(t0)
103	cache   1, 48(t0)
104	cache   1, 64(t0)
105	cache   1, 80(t0)
106	cache   1, 96(t0)
107	cache   1, 112(t0)
108	.set pop
109	bne     t0, t1, 2b
110	 addu    t0, t0, 128
111
112	/*
113	 * 3. jump to kernel entry
114	 */
115	move	t0, a0
116	lw	t1, 0(a0)	# kbi->entry
117	lw	a0, 4(t0)	# kbi->argc
118	lw	a1, 8(t0)	# kbi->argv
119	j	t1
120	 addiu	a2, t0, 12	# &kbi->bootinfo
121	/* NOTREACHED */
122END(kloader_vr_boot)
123