exception_vector.S revision 1.8
11.8Such/* $NetBSD: exception_vector.S,v 1.8 2002/04/28 17:10:38 uch Exp $ */ 21.1Such 31.1Such/*- 41.1Such * Copyright (c) 2002 The NetBSD Foundation, Inc. 51.1Such * All rights reserved. 61.1Such * 71.1Such * Redistribution and use in source and binary forms, with or without 81.1Such * modification, are permitted provided that the following conditions 91.1Such * are met: 101.1Such * 1. Redistributions of source code must retain the above copyright 111.1Such * notice, this list of conditions and the following disclaimer. 121.1Such * 2. Redistributions in binary form must reproduce the above copyright 131.1Such * notice, this list of conditions and the following disclaimer in the 141.1Such * documentation and/or other materials provided with the distribution. 151.1Such * 3. All advertising materials mentioning features or use of this software 161.1Such * must display the following acknowledgement: 171.1Such * This product includes software developed by the NetBSD 181.1Such * Foundation, Inc. and its contributors. 191.1Such * 4. Neither the name of The NetBSD Foundation nor the names of its 201.1Such * contributors may be used to endorse or promote products derived 211.1Such * from this software without specific prior written permission. 221.1Such * 231.1Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 241.1Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 251.1Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 261.1Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 271.1Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 281.1Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 291.1Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 301.1Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 311.1Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 321.1Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 331.1Such * POSSIBILITY OF SUCH DAMAGE. 341.1Such */ 351.1Such 361.1Such#include "assym.h" 371.7Such#include "opt_cputype.h" 381.7Such 391.3Such#include <sh3/param.h> 401.1Such#include <sh3/asm.h> 411.1Such#include <sh3/locore.h> 421.8Such#include <sh3/exception.h> 431.2Such#include <sh3/ubcreg.h> 441.3Such#include <sh3/mmu_sh3.h> 451.3Such#include <sh3/mmu_sh4.h> 461.1Such 471.1Such/* 481.1Such * Exception vectors. following routines are copied to vector addreses. 491.8Such * sh_vector_generic: VBR + 0x100 501.8Such * sh_vector_tlbmiss: VBR + 0x400 511.1Such * sh_vector_interrupt: VBR + 0x600 521.8Such */ 531.8Such 541.1Such/* 551.8Such * void sh_vector_generic(void) __attribute__((__noreturn__)): 561.1Such * copied to VBR+0x100. This code should be relocatable and max 384 571.8Such * instructions. 581.1Such * 0x40 TLB miss (load) 591.1Such * 0x60 TLB miss (store) 601.1Such * 0xc0 TLB protection (store) 611.1Such * -> tlbmiss_exp() 621.1Such * 0xa0 TLB protection (load) 631.1Such * 0x80 Initial page write. 641.1Such * and other... 651.1Such * -> trap() 661.8Such */ 671.1Such .globl _C_LABEL(sh_vector_generic), _C_LABEL(sh_vector_generic_end) 681.8Such .text 691.1Such .align 2 701.1Such_C_LABEL(sh_vector_generic): 711.5Such __EXCEPTION_ENTRY 721.1Such /* Identify exception cause */ 731.1Such MOV (EXPEVT, r0) 741.1Such mov.l @r0, r0 751.1Such /* 761.1Such * TLB exception. 771.1Such */ 781.1Such cmp/eq #0x40, r0 /* T_TLBINVALIDR */ 791.1Such bf 1f 801.1Such3: 811.2Such __INTR_MASK(r0, r1) 821.2Such __EXCEPTION_UNBLOCK(r0, r1) 831.1Such mov.l _L.tlb_handler, r0 841.1Such jsr @r0 851.3Such mov r14, r6 861.1Such bra 4f 871.1Such nop 881.1Such1: 891.1Such cmp/eq #0x60, r0 /* T_TLBINVALIDW */ 901.1Such bt 3b 911.1Such 921.1Such mov.l _L.TLBPROTWR, r1 /* T_TLBPRIVW */ 931.1Such cmp/eq r0, r1 941.1Such bt 3b 951.8Such 961.1Such /* 971.1Such * General exception. 981.8Such */ 991.1Such#ifdef DDB 1001.1Such mov #0, r2 1011.1Such MOV (BBRA, r1) 1021.1Such mov.w r2, @r1 /* disable UBC */ 1031.3Such mov.l r2, @(TF_UBC, r14) /* clear trapframe->tf_ubc */ 1041.1Such#endif /* DDB */ 1051.3Such 1061.3Such mov.l r0, @(TF_TRAPNO, r14) /* trapframe->tf_trapno = EXPEVT */ 1071.2Such __INTR_UNMASK(r0, r1) 1081.2Such __EXCEPTION_UNBLOCK(r0, r1) 1091.1Such mov.l _L.trap, r0 1101.1Such jsr @r0 1111.3Such mov r14, r6 1121.1Such 1131.1Such /* Check for ASTs on exit to user mode. */ 1141.1Such mov.l _L.ast, r0 1151.1Such jsr @r0 1161.3Such mov r14, r4 1171.1Such 1181.8Such#ifdef DDB /* BBRA = trapframe->tf_ubc */ 1191.2Such __EXCEPTION_BLOCK(r0, r1) 1201.3Such mov.l @(TF_UBC, r14), r0 1211.1Such MOV (BBRA, r1) 1221.1Such mov.w r0, @r1 1231.1Such#endif /* DDB */ 1241.8Such4: 1251.5Such __EXCEPTION_RETURN 1261.1Such /* NOTREACHED */ 1271.1Such .align 2 1281.1SuchREG_SYMBOL(EXPEVT) 1291.1SuchREG_SYMBOL(BBRA) 1301.1Such_L.TLBPROTWR: .long 0x000000c0 1311.1Such_L.trap: .long _C_LABEL(trap) 1321.1Such_L.ast: .long _C_LABEL(ast) 1331.1Such_L.tlb_handler: .long _C_LABEL(tlb_handler) 1341.3Such_C_LABEL(sh_vector_generic_end): .long 0 1351.8Such 1361.3Such#ifdef SH3 1371.8Such/* 1381.8Such * void sh3_vector_tlbmiss(void) __attribute__((__noreturn__)): 1391.1Such * copied to VBR+0x400. This code should be relocatable and max 256 1401.1Such * instructions. 1411.1Such */ 1421.3Such .globl _C_LABEL(sh3_vector_tlbmiss), _C_LABEL(sh3_vector_tlbmiss_end) 1431.8Such .text 1441.3Such .align 2 1451.3Such_C_LABEL(sh3_vector_tlbmiss): 1461.8Such __EXCEPTION_ENTRY 1471.2Such __INTR_MASK(r0, r1) 1481.2Such __EXCEPTION_UNBLOCK(r0, r1) 1491.3Such#if !defined(P1_STACK) 1501.4Such /* Load kernel stack */ 1511.3Such mov.l _L.TEA, r1 1521.3Such mov.l @r1, r0 /* r0 = va */ 1531.3Such mov.l _L.VPN_MASK, r1 1541.3Such and r1, r0 /* va = trunc_page(va) */ 1551.3Such mov.l _L.CURUPTE, r1 1561.3Such mov #UPAGES,r3 1571.3Such mov #1, r2 1581.3Such4: mov.l @r1+, r6 1591.8Such cmp/eq r6, r0 /* md_upte.addr: u-area VPN */ 1601.3Such bt 5f 1611.3Such add #4, r1 /* skip md_upte.data */ 1621.3Such cmp/eq r2, r3 1631.3Such bf/s 4b 1641.8Such add #1, r2 1651.3Such bra 6f 1661.3Such nop 1671.3Such5: mov.l @r1, r2 /* md_upte.data: u-area PTE */ 1681.3Such mov.l _L.PTEL, r1 1691.3Such mov.l r2, @r1 1701.3Such ldtlb 1711.3Such bra 3f 1721.3Such nop 1731.3Such#endif /* !P1_STACK */ 1741.3Such6: mov r0, r2 1751.3Such mov #-22, r1 1761.3Such shld r1, r2 /* r2 = va >> 22 */ 1771.3Such shll2 r2 /* r2 *= sizeof(pt_entry_t) */ 1781.3Such mov.l _L.TTB, r1 1791.3Such mov.l @r1, r1 1801.3Such add r1, r2 /* r2 = page directory entry address */ 1811.3Such mov #1 r1 1821.3Such swap.b r1, r1 /* 0x100 (PG_V) */ 1831.3Such mov.l @r2, r2 /* r2 = pde */ 1841.3Such and r2, r1 1851.3Such tst r1, r1 1861.3Such bt 2f /* (pde & PG_V) == 0 -> tlb_handler */ 1871.3Such mov.l _L.VPN_MASK, r1 1881.3Such and r1, r2 /* zero attribute bits */ 1891.3Such mov.l _L.PT_MASK, r1 1901.3Such mov r0, r3 1911.3Such and r1, r3 /* r3 = va & 0x003ff000 */ 1921.3Such mov #-12 r1 1931.3Such shld r1, r3 /* r3 = (va & 0x003ff000) >> 12 */ 1941.3Such shll2 r3 /* r3 *= sizeof(pt_entry_t) */ 1951.3Such add r2, r3 /* r3 = page table entry address */ 1961.3Such mov.l @r3, r3 /* r3 = page table entry */ 1971.3Such mov #1, r1 1981.3Such swap.b r1, r1 /* r1 = PG_V */ 1991.3Such and r3, r1 2001.3Such tst r1, r1 2011.3Such bt 2f /* (pte & PG_V) == 0 -> tlb_handler */ 2021.8Such mov.l _L.PTE_HW_BITS, r2 2031.8Such and r2, r3 2041.3Such mov.l _L.PTEL, r1 2051.3Such mov.l r3, @r1 /* PTEL = (pte & PG_HW_BITS) */ 2061.3Such ldtlb 2071.3Such bra 3f 2081.3Such nop 2091.3Such2: 2101.1Such mov.l 1f, r0 2111.1Such jsr @r0 2121.3Such mov r14, r6 2131.8Such3: 2141.5Such __EXCEPTION_RETURN 2151.3Such .align 2 2161.8Such1: .long _C_LABEL(tlb_handler) 2171.3Such_L.TEA: .long SH3_TEA 2181.3Such_L.TTB: .long SH3_TTB 2191.3Such_L.PTEL: .long SH3_PTEL 2201.3Such_L.PTE_HW_BITS: .long 0x1ffff17e 2211.8Such_L.PT_MASK: .long 0x003ff000 2221.3Such_L.VPN_MASK: .long 0xfffff000 2231.3Such_L.CURUPTE: .long _C_LABEL(curupte) 2241.3Such .align 2 2251.3Such_C_LABEL(sh3_vector_tlbmiss_end): .long 0 2261.3Such#endif /* SH3 */ 2271.3Such 2281.3Such#ifdef SH4 2291.8Such/* 2301.8Such * void sh4_vector_tlbmiss(void) __attribute__((__noreturn__)): 2311.3Such * copied to VBR+0x400. This code should be relocatable and max 256 2321.3Such * instructions. 2331.3Such */ 2341.3Such .globl _C_LABEL(sh4_vector_tlbmiss), _C_LABEL(sh4_vector_tlbmiss_end) 2351.8Such .text 2361.3Such .align 2 2371.3Such_C_LABEL(sh4_vector_tlbmiss): 2381.8Such __EXCEPTION_ENTRY 2391.3Such __INTR_MASK(r0, r1) 2401.3Such __EXCEPTION_UNBLOCK(r0, r1) 2411.3Such mov #0x20, r7 2421.3Such swap.b r7, r7 2431.3Such swap.w r7, r7 /* r7 = 0x20000000 */ 2441.3Such mov.l __L.TEA, r1 2451.3Such mov.l @r1, r0 /* r0 = va */ 2461.3Such mov r0, r2 2471.3Such mov #-22, r1 2481.3Such shld r1, r2 /* r2 = va >> 22 */ 2491.3Such shll2 r2 /* r2 *= sizeof(pt_entry_t) */ 2501.3Such mov.l __L.TTB, r1 2511.3Such mov.l @r1, r1 2521.3Such or r7, r1 /* XXX P2 access */ 2531.3Such add r1, r2 /* r2 = page directory entry address */ 2541.3Such mov #1 r1 2551.3Such swap.b r1, r1 /* 0x100 (PG_V) */ 2561.3Such mov.l @r2, r2 /* r2 = pde */ 2571.3Such and r2, r1 2581.3Such tst r1, r1 2591.3Such bt 2f /* (pde & PG_V) == 0 -> tlb_handler */ 2601.3Such mov.l __L.VPN_MASK, r1 2611.3Such and r1, r2 /* zero attribute bits */ 2621.3Such mov.l __L.PT_MASK, r1 2631.3Such mov r0, r3 2641.3Such and r1, r3 /* r3 = va & 0x003ff000 */ 2651.3Such mov #-12 r1 2661.3Such shld r1, r3 /* r3 = (va & 0x003ff000) >> 12 */ 2671.3Such shll2 r3 /* r3 *= sizeof(pt_entry_t) */ 2681.3Such add r2, r3 /* r3 = page table entry address */ 2691.3Such or r7, r3 /* XXX P2 access */ 2701.3Such mov.l @r3, r3 /* r3 = page table entry */ 2711.3Such mov #1, r1 2721.3Such swap.b r1, r1 /* r1 = PG_V */ 2731.3Such and r3, r1 2741.3Such tst r1, r1 2751.3Such bt 2f /* (pte & PG_V) == 0 -> tlb_handler */ 2761.3Such mov #0xe, r1 2771.3Such swap.b r1, r1 /* r1 = _PG_PCMCIA (0x0e00) */ 2781.3Such and r3, r1 2791.3Such tst r1, r1 2801.3Such bt 4f 2811.3Such mov r3, r2 2821.3Such mov #-9 r1 2831.3Such shld r1, r2 2841.3Such mov #7, r1 2851.3Such and r1, r2 /* r2 = (pte >> 9) & 0x7 */ 2861.3Such mov.l __L.PTEA, r1 2871.3Such mov.l r2, @r1 2881.3Such mov.l __L.PTE_HW_BITS, r1 2891.3Such and r3, r1 2901.3Such mov #-9, r2 2911.3Such and r2, r3 /* pte &= ~PG_N XXX */ 2921.3Such mov.l __L.PTEL, r1 2931.3Such mov.l r3, @r1 2941.3Such bra 6f 2951.3Such nop 2961.3Such4: 2971.3Such mov.l __L.PTE_HW_BITS, r1 2981.3Such and r1, r3 2991.3Such mov.l __L.P3SEGBASE, r1 3001.3Such cmp/hs r1, r0 /* va >= 0xc0000000 ? T = 1 */ 3011.3Such bf 5f 3021.3Such mov #1, r1 3031.3Such or r1, r3 /* PG_WT P3 write-through XXX */ 3041.3Such5: 3051.3Such mov.l __L.PTEA, r1 3061.3Such xor r0, r0 3071.3Such mov.l r0, @r1 3081.3Such mov.l __L.PTEL, r1 3091.3Such mov.l r3, @r1 3101.3Such nop 3111.3Such6: ldtlb 3121.3Such bra 3f 3131.1Such nop 3141.3Such2: 3151.3Such mov.l 1f, r0 3161.3Such jsr @r0 3171.3Such mov r14, r6 3181.8Such3: 3191.5Such __EXCEPTION_RETURN 3201.1Such .align 2 3211.8Such1: .long _C_LABEL(tlb_handler) 3221.3Such__L.TEA: .long SH4_TEA 3231.3Such__L.TTB: .long SH4_TTB 3241.3Such__L.PTEL: .long SH4_PTEL 3251.3Such__L.PTEA: .long SH4_PTEA 3261.3Such__L.P3SEGBASE: .long 0xc0000000 3271.3Such__L.PTE_HW_BITS:.long 0x1ffff17e 3281.8Such__L.PT_MASK: .long 0x003ff000 3291.3Such__L.VPN_MASK: .long 0xfffff000 3301.3Such_C_LABEL(sh4_vector_tlbmiss_end): .long 0 3311.3Such#endif /* SH4 */ 3321.1Such 3331.1Such/* 3341.8Such * void sh_vector_interrupt(void) __attribute__((__noreturn__)): 3351.1Such * copied to VBR+0x600. This code should be relocatable. 3361.8Such */ 3371.1Such .globl _C_LABEL(sh_vector_interrupt), _C_LABEL(sh_vector_interrupt_end) 3381.1Such .align 2 3391.3Such .text 3401.1Such_C_LABEL(sh_vector_interrupt): 3411.5Such __EXCEPTION_ENTRY 3421.8Such stc r0_bank,r6 /* ssp */ 3431.5Such /* Enable exception for P3 access */ 3441.5Such __INTR_MASK(r0, r1) 3451.5Such __EXCEPTION_UNBLOCK(r0, r1) 3461.6Such /* uvmexp.intrs++ */ 3471.6Such mov.l __L.uvmexp.intrs, r0 3481.6Such mov.l @r0, r1 3491.6Such add #1 r1 3501.6Such mov.l r1, @r0 3511.5Such /* Dispatch interrupt handler */ 3521.6Such mov.l __L.intc_intr, r0 3531.5Such jsr @r0 /* intc_intr(ssr, spc, ssp) */ 3541.1Such nop 3551.5Such /* Check for ASTs on exit to user mode. */ 3561.6Such mov.l __L.ast, r0 3571.5Such jsr @r0 3581.5Such mov r14, r4 3591.5Such __EXCEPTION_RETURN 3601.1Such .align 2 3611.8Such__L.intc_intr: .long _C_LABEL(intc_intr) 3621.8Such__L.ast: .long _C_LABEL(ast) 3631.6Such__L.uvmexp.intrs: .long _C_LABEL(uvmexp) + UVMEXP_INTRS 3641.3Such_C_LABEL(sh_vector_interrupt_end): .long 0 365