1 /* $NetBSD: 4xx_trap_subr.S,v 1.3.2.3 2004/09/21 13:20:34 skrll Exp $ */
4 * Copyright 2001 Wasabi Systems, Inc.
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
38 /* This file provides necessary handlers for 405GP CPU
39 * It should be included in locore.S after powerpc/powerpc/trap_subr.S
43 .globl _C_LABEL(pitfitwdog),_C_LABEL(pitfitwdogsize)
55 _C_LABEL(pitfitwdogsize) = .-_C_LABEL(pitfitwdog)
59 ba . /* Protect against prefetch */
63 ba . /* Protect against prefetch */
65 #define tlbstacksize 0x1000
66 #define tlbsave 0x3000
67 #define tlbstack tlbsave+tlbstacksize
69 /* If an unaligned excception (0x600) and DTLB miss exception (0x1100)
70 occur at the same time, the interrupt vector offsets of the two
71 exceptions are logically OR'ed together to produce 0x1700.
72 See PPC405GP Rev D/E Errata item 51 */
74 .globl _C_LABEL(errata51handler),_C_LABEL(errata51size)
75 _C_LABEL(errata51handler):
77 _C_LABEL(errata51size) = .-_C_LABEL(errata51handler)
79 .globl _C_LABEL(tlbdmiss4xx),_C_LABEL(tlbdm4size)
80 _C_LABEL(tlbdmiss4xx):
81 STANDARD_PROLOG(tlbsave)
82 mfdear %r30 /* Get fault address */
84 stmw %r30,16+tlbsave(0)
86 _C_LABEL(tlbdm4size) = .-_C_LABEL(tlbdmiss4xx)
88 .globl _C_LABEL(tlbimiss4xx),_C_LABEL(tlbim4size)
89 _C_LABEL(tlbimiss4xx):
90 STANDARD_PROLOG(tlbsave)
91 mfsrr0 %r30 /* XXX Get fault address */
93 stmw %r30,16+tlbsave(0)
95 _C_LABEL(tlbim4size) = .-_C_LABEL(tlbimiss4xx)
98 .globl _C_LABEL(pmap_tlbmiss)
100 /* If the kernel stack would fault, don't use it. */
110 * The kernel we want to switch to is not in the TLB.
111 * To solve this problem, we will simulate a kernel
112 * fault on the kernel stack and let the miss handler
113 * bring it in, and return from the trap handler. The
114 * processor will immediately take the original fault,
115 * which we should be able to handle with the now-valid
119 /* Switch to tlbstack */
120 addi %r30,%r1,-FRAMELEN
122 addi %r1,%r1,tlbstack@l
127 /* Take an explicit fault at (kernelstack,pid) */
128 lwz %r3, tlbstack+4(0)
130 bl _C_LABEL(pmap_tlbmiss)
132 * We can retry the old fault or switch stacks and
133 * take it now. It's easier to retry.
138 /* kernel stack not in the pmap? we should panic */
143 lwz %r3,FRAME_DEAR+8(1)
144 lwz %r4,FRAME_PID+8(1)
145 bl _C_LABEL(pmap_tlbmiss)
149 /* XXX DEBUG -- make sure we're not on tlbstack */
150 addi %r7,%r1,-tlbsave
151 twllei %r7,(tlbstacksize)
153 /* PTE not found, time to cause a fault */
158 ba . /* Protect against prefetch */