1/* $NetBSD: kloader_vr41.S,v 1.4 2008/04/28 20:23:21 martin Exp $ */ 2 3/*- 4 * Copyright (c) 2002, 2004 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <mips/asm.h> 30#include <mips/cpuregs.h> 31 32 .set noreorder 33 .text 34/* 35 * void kloader_vr_boot(struct kloader_bootinfo *kbi, kloader_page_tag *p) 36 * must be PIC. 37 */ 38EXPORT(kloader_vr_boot) 39LEAF_NOPROFILE(kloader_vr_boot) 40 lui t0, 0x1040 # Cu0 | BEV 41 mtc0 t0, $12 42 /* 43 * 1. load kernel image. 44 */ 45 move t6, a1 # p 461: 47 beqz t6, 3f 48 move t7, t6 49 lw t6, 0(t7) # p = next 50 lw t0, 4(t7) # src 51 lw t4, 8(t7) # dst 52 lw t2, 12(t7) # sz 53 addu t5, t4, t2 # dst + sz 542: 55 lw t3, 0(t0) # copy 56 sw t3, 0(t4) 57 addiu t4, t4, 4 58 addiu t0, t0, 4 59 bltu t4, t5, 2b 60 nop 61 b 1b 62 nop 633: 64 nop 65 66 /* 67 * 2. Cache flush 68 */ 69 /* Flush I-cache */ 70 li t0, 0x80000000 71 addu t1, t0, 1024 * 128 72 subu t1, t1, 128 731: 74 .set push 75 .set mips3 76 cache 0, 0(t0) 77 cache 0, 16(t0) 78 cache 0, 32(t0) 79 cache 0, 48(t0) 80 cache 0, 64(t0) 81 cache 0, 80(t0) 82 cache 0, 96(t0) 83 cache 0, 112(t0) 84 .set pop 85 bne t0, t1, 1b 86 addu t0, t0, 128 87 88 /* Flush D-cache */ 89 li t0, 0x80000000 90 addu t1, t0, 1024 * 128 91 subu t1, t1, 128 922: 93 .set push 94 .set mips3 95 cache 1, 0(t0) 96 cache 1, 16(t0) 97 cache 1, 32(t0) 98 cache 1, 48(t0) 99 cache 1, 64(t0) 100 cache 1, 80(t0) 101 cache 1, 96(t0) 102 cache 1, 112(t0) 103 .set pop 104 bne t0, t1, 2b 105 addu t0, t0, 128 106 107 /* 108 * 3. jump to kernel entry 109 */ 110 move t0, a0 111 lw t1, 0(a0) # kbi->entry 112 lw a0, 4(t0) # kbi->argc 113 lw a1, 8(t0) # kbi->argv 114 addiu a2, t0, 12 # &kbi->bootinfo 115 jr t1 116 move sp, t1 1171: b 1b 118 nop 119 /* NOTREACHED */ 120END(kloader_vr_boot) 121