1 /* -*-C++-*- $NetBSD: mips_arch.h,v 1.5 2008/03/08 02:26:03 rafal Exp $ */
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _HPCBOOT_MIPS_ARCH_H_
33 #define _HPCBOOT_MIPS_ARCH_H_
40 class MIPSArchitecture
: public Architecture
{
42 typedef void(*boot_func_t
)(struct BootArgs
*, struct PageTag
*);
45 boot_func_t _boot_func
;
48 MIPSArchitecture(Console
*&, MemoryManager
*&);
49 virtual ~MIPSArchitecture(void);
51 virtual BOOL
init(void);
52 BOOL
setupLoader(void);
53 virtual void systemInfo(void);
54 virtual void cacheFlush(void) = 0;
55 void jump(paddr_t info
, paddr_t pvec
);
59 __asm(".set noreorder;" \
62 "nop;nop;nop;" /* CP0 hazard for R4000 */ \
66 __asm(".set noreorder;" \
69 ".set reorder", &(x));
72 __asm(".set noreorder;" \
76 "nop;nop;nop;" /* CP0 hazard for R4000 */ \
77 ".set reorder", &(x));
80 * 2nd-bootloader. make sure that PIC and its size is lower than page size.
81 * and can't call subroutine.
82 * naked funciton can't use stack. if you want to use, remove its declare.
83 * interrupts are disabled. but if access kuseg,(should not occur)
84 * it causes TLB exception and then Windows CE enable interrupts again.
86 #define BOOT_FUNC_(x) \
87 __declspec(naked) void \
88 x##::boot_func(struct BootArgs *bi, struct PageTag *p) \
90 /* disable interrupt */ \
92 /* set kernel image */ \
93 __asm(".set noreorder;" \
94 "move t6, a1;" /* p */ \
95 "li t1, 0xffffffff;" \
97 "beq t6, t1, page_end;" \
99 "lw t6, 0(t7);" /* p = next */ \
100 "lw t0, 4(t7);" /* src */ \
101 "lw t4, 8(t7);" /* dst */ \
102 "lw t2, 12(t7);" /* sz */ \
103 "beq t0, t1, page_clear;" \
104 "addu t5, t4, t2;" /* dst + sz */ \
106 "lw t3, 0(t0);" /* bcopy */ \
109 "bltu t4, t5, page_copy;" \
114 "sw zero, 0(t4);" /* bzero */ \
116 "bltu t4, t5, page_clear;" \
124 /* Cache flush for kernel */ \
125 MIPS_##x##_CACHE_FLUSH(); \
127 /* jump to kernel entry */ \
128 __asm(".set noreorder;" \
139 #endif // _HPCBOOT_MIPS_ARCH_H_