1/* $NetBSD: kloader_tx39.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_tx_boot(struct kloader_bootinfo *kbi, kloader_page_tag *p) 36 * must be PIC. 37 */ 38EXPORT(kloader_tx_boot) 39LEAF_NOPROFILE(kloader_tx_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 li t1, 16384 70 li t2, 8192 71 72 /* Disable I-cache */ 73 li t5, ~0x00000020 74 mfc0 t6, $3 75 and t5, t5, t6 76 nop 77 mtc0 t5, $3 78 79 /* Stop streaming */ 80 beq zero, zero, 1f 81 nop 821: 83 /* Flush I-cache */ 84 li t0, 0x80000000 85 addu t1, t0, t1 86 subu t1, t1, 128 872: 88 .set push 89 .set mips3 90 cache 0x0, 0($0) 91 cache 0x0, 16(t0) 92 cache 0x0, 32(t0) 93 cache 0x0, 48(t0) 94 cache 0x0, 64(t0) 95 cache 0x0, 80(t0) 96 cache 0x0, 96(t0) 97 cache 0x0, 112(t0) 98 .set pop 99 bne t0, t1, 2b 100 addu t0, t0, 128 101 102 /* Flush D-cache */ 103 li t0, 0x80000000 104 addu t1, t0, t2 105 1063: 107 lw t2, 0(t0) 108 bne t1, t0, 3b 109 addiu t0, t0, 4 110 111 /* Enable I-cache */ 112 nop 113 mtc0 t6, $3 114 nop 115 116 /* 117 * 3. jump to kernel entry 118 */ 119 move t0, a0 120 lw t1, 0(a0) # kbi->entry 121 lw a0, 4(t0) # kbi->argc 122 lw a1, 8(t0) # kbi->argv 123 addiu a2, t0, 12 # &kbi->bootinfo 124 jr t1 125 move sp, t1 1261: b 1b 127 nop 128 /* NOTREACHED */ 129END(kloader_tx_boot) 130