| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: trap.S,v 1.63 2012/02/26 08:28:57 skrll Exp $ */ | | 1 | /* $NetBSD: trap.S,v 1.64 2012/04/05 19:42:14 skrll Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2002 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2002 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Matthew Fredette. | | 8 | * by Matthew Fredette. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -503,27 +503,27 @@ syscall_return: | | | @@ -503,27 +503,27 @@ syscall_return: |
503 | | | 503 | |
504 | #if pbably_not_worth_it | | 504 | #if pbably_not_worth_it |
505 | ldw TF_CR12(%sr3, %t3), %t1 | | 505 | ldw TF_CR12(%sr3, %t3), %t1 |
506 | ldw TF_CR13(%sr3, %t3), %t2 | | 506 | ldw TF_CR13(%sr3, %t3), %t2 |
507 | mtctl %t1, %pidr3 | | 507 | mtctl %t1, %pidr3 |
508 | mtctl %t2, %pidr4 | | 508 | mtctl %t2, %pidr4 |
509 | #endif | | 509 | #endif |
510 | ldw TF_CR27(%sr3, %t3), %t1 | | 510 | ldw TF_CR27(%sr3, %t3), %t1 |
511 | ldw TF_CR30(%sr3, %t3), %t2 | | 511 | ldw TF_CR30(%sr3, %t3), %t2 |
512 | mtctl %t1, CR_TLS | | 512 | mtctl %t1, CR_TLS |
513 | mtctl %t2, CR_FPPADDR | | 513 | mtctl %t2, CR_FPPADDR |
514 | | | 514 | |
515 | ldw TF_CR0(%sr3, %t3), %t1 | | 515 | ldw TF_CR0(%sr3, %t3), %t1 |
516 | mtctl %t1, %rctr | | 516 | mtctl %t1, CR_RCTR |
517 | | | 517 | |
518 | GET_CURCPU_SPACE(%sr3, %t3) | | 518 | GET_CURCPU_SPACE(%sr3, %t3) |
519 | | | 519 | |
520 | /* | | 520 | /* |
521 | * Clear the system mask, this puts us back into physical mode. Reload | | 521 | * Clear the system mask, this puts us back into physical mode. Reload |
522 | * the trapframe pointer with the correspondent PA value. %sp will be | | 522 | * the trapframe pointer with the correspondent PA value. %sp will be |
523 | * left in virtual until restored from trapframe, since we don't use it | | 523 | * left in virtual until restored from trapframe, since we don't use it |
524 | * anyway. | | 524 | * anyway. |
525 | */ | | 525 | */ |
526 | ssm 0, %r0 | | 526 | ssm 0, %r0 |
527 | ldo CI_TRAPSAVE(%t3), %t3 | | 527 | ldo CI_TRAPSAVE(%t3), %t3 |
528 | nop ! nop ! nop ! nop ! nop ! nop | | 528 | nop ! nop ! nop ! nop ! nop ! nop |
529 | rsm RESET_PSW, %r0 | | 529 | rsm RESET_PSW, %r0 |
| @@ -929,27 +929,27 @@ LEAF_ENTRY_NOPROFILE(TLABEL(emu)) | | | @@ -929,27 +929,27 @@ LEAF_ENTRY_NOPROFILE(TLABEL(emu)) |
929 | /* | | 929 | /* |
930 | * As an optimization, hppa_fpu_bootstrap replaces this branch inst- | | 930 | * As an optimization, hppa_fpu_bootstrap replaces this branch inst- |
931 | * ruction with a nop if there is a hardware FPU. | | 931 | * ruction with a nop if there is a hardware FPU. |
932 | * | | 932 | * |
933 | * Otherwise, this is the branch to emulate an FPU coprocessor. | | 933 | * Otherwise, this is the branch to emulate an FPU coprocessor. |
934 | */ | | 934 | */ |
935 | ALTENTRY(hppa_fpu_nop0) | | 935 | ALTENTRY(hppa_fpu_nop0) |
936 | b,n L$emulate_fpu | | 936 | b,n L$emulate_fpu |
937 | | | 937 | |
938 | /* | | 938 | /* |
939 | * We have a hardware FPU. If it is enabled, branch to emulate the | | 939 | * We have a hardware FPU. If it is enabled, branch to emulate the |
940 | * instruction. | | 940 | * instruction. |
941 | */ | | 941 | */ |
942 | mfctl %ccr, %arg0 | | 942 | mfctl CR_CCR, %arg0 |
943 | extru,= %arg0, 25, 2, %r1 | | 943 | extru,= %arg0, 25, 2, %r1 |
944 | b,n L$emulate_fpu | | 944 | b,n L$emulate_fpu |
945 | | | 945 | |
946 | /* | | 946 | /* |
947 | * The hardware FPU is disabled, so we need to swap in the FPU state of | | 947 | * The hardware FPU is disabled, so we need to swap in the FPU state of |
948 | * the LWP whose uspace physical address in CR_UPADDR. We may also | | 948 | * the LWP whose uspace physical address in CR_UPADDR. We may also |
949 | * need to swap out the FPU state of any LWP whose uspace physical | | 949 | * need to swap out the FPU state of any LWP whose uspace physical |
950 | * address is in curcpu()->ci_fpu_state. | | 950 | * address is in curcpu()->ci_fpu_state. |
951 | */ | | 951 | */ |
952 | | | 952 | |
953 | /* | | 953 | /* |
954 | * So far, the CTRAP() macro has saved %r1 in %tr7, and the dispatching | | 954 | * So far, the CTRAP() macro has saved %r1 in %tr7, and the dispatching |
955 | * above has saved %arg0 in tr2. Save the other registers that we want | | 955 | * above has saved %arg0 in tr2. Save the other registers that we want |
| @@ -1045,30 +1045,30 @@ ALTENTRY(hppa_fpu_swap) | | | @@ -1045,30 +1045,30 @@ ALTENTRY(hppa_fpu_swap) |
1045 | /* | | 1045 | /* |
1046 | * Note that this function must work in physical mode as well as virtual | | 1046 | * Note that this function must work in physical mode as well as virtual |
1047 | * mode, because it can be called by a trap handler. This also further | | 1047 | * mode, because it can be called by a trap handler. This also further |
1048 | * restricts the registers we can use. We can only use %arg0, %arg1, | | 1048 | * restricts the registers we can use. We can only use %arg0, %arg1, |
1049 | * and %r1. | | 1049 | * and %r1. |
1050 | */ | | 1050 | */ |
1051 | | | 1051 | |
1052 | /* | | 1052 | /* |
1053 | * Assuming that out and in aren't both NULL, we will have to run co- | | 1053 | * Assuming that out and in aren't both NULL, we will have to run co- |
1054 | * processor instructions, so we'd better enable it. | | 1054 | * processor instructions, so we'd better enable it. |
1055 | * | | 1055 | * |
1056 | * Also, branch if there's no FPU state to swap out. | | 1056 | * Also, branch if there's no FPU state to swap out. |
1057 | */ | | 1057 | */ |
1058 | mfctl %ccr, %r1 | | 1058 | mfctl CR_CCR, %r1 |
1059 | depi 3, 25, 2, %r1 | | 1059 | depi 3, 25, 2, %r1 |
1060 | comb,= %r0, %arg0, L$fpu_swap_in | | 1060 | comb,= %r0, %arg0, L$fpu_swap_in |
1061 | mtctl %r1, %ccr | | 1061 | mtctl %r1,CR_CCR |
1062 | | | 1062 | |
1063 | /* | | 1063 | /* |
1064 | * Swap out the current FPU state. | | 1064 | * Swap out the current FPU state. |
1065 | */ | | 1065 | */ |
1066 | fstds,ma %fr0 , 8(%arg0) /* fr0 must be saved first */ | | 1066 | fstds,ma %fr0 , 8(%arg0) /* fr0 must be saved first */ |
1067 | fstds,ma %fr1 , 8(%arg0) | | 1067 | fstds,ma %fr1 , 8(%arg0) |
1068 | fstds,ma %fr2 , 8(%arg0) | | 1068 | fstds,ma %fr2 , 8(%arg0) |
1069 | fstds,ma %fr3 , 8(%arg0) | | 1069 | fstds,ma %fr3 , 8(%arg0) |
1070 | fstds,ma %fr4 , 8(%arg0) | | 1070 | fstds,ma %fr4 , 8(%arg0) |
1071 | fstds,ma %fr5 , 8(%arg0) | | 1071 | fstds,ma %fr5 , 8(%arg0) |
1072 | fstds,ma %fr6 , 8(%arg0) | | 1072 | fstds,ma %fr6 , 8(%arg0) |
1073 | fstds,ma %fr7 , 8(%arg0) | | 1073 | fstds,ma %fr7 , 8(%arg0) |
1074 | fstds,ma %fr8 , 8(%arg0) | | 1074 | fstds,ma %fr8 , 8(%arg0) |
| @@ -1176,30 +1176,30 @@ L$fpu_swap_in: | | | @@ -1176,30 +1176,30 @@ L$fpu_swap_in: |
1176 | | | 1176 | |
1177 | L$fpu_swap_done: | | 1177 | L$fpu_swap_done: |
1178 | | | 1178 | |
1179 | /* Increment the switch count and return. */ | | 1179 | /* Increment the switch count and return. */ |
1180 | ldil L%fpu_csw, %r1 | | 1180 | ldil L%fpu_csw, %r1 |
1181 | ldw R%fpu_csw(%r1), %arg0 | | 1181 | ldw R%fpu_csw(%r1), %arg0 |
1182 | ldo 1(%arg0), %arg0 | | 1182 | ldo 1(%arg0), %arg0 |
1183 | bv %r0(%rp) | | 1183 | bv %r0(%rp) |
1184 | stw %arg0, R%fpu_csw(%r1) | | 1184 | stw %arg0, R%fpu_csw(%r1) |
1185 | | | 1185 | |
1186 | L$fpu_no_swap_in: | | 1186 | L$fpu_no_swap_in: |
1187 | | | 1187 | |
1188 | /* We didn't swap any FPU state in, so disable the FPU. */ | | 1188 | /* We didn't swap any FPU state in, so disable the FPU. */ |
1189 | mfctl %ccr, %r1 | | 1189 | mfctl CR_CCR, %r1 |
1190 | depi 0, 25, 2, %r1 | | 1190 | depi 0, 25, 2, %r1 |
1191 | b L$fpu_swap_done | | 1191 | b L$fpu_swap_done |
1192 | mtctl %r1, %ccr | | 1192 | mtctl %r1, CR_CCR |
1193 | EXIT(hppa_fpu_swapout) | | 1193 | EXIT(hppa_fpu_swapout) |
1194 | | | 1194 | |
1195 | /* Construct the virtual address tag. */ | | 1195 | /* Construct the virtual address tag. */ |
1196 | /* NB: it is legal for off and t to be the same. */ | | 1196 | /* NB: it is legal for off and t to be the same. */ |
1197 | #define VTAG(sp,off,t) \ | | 1197 | #define VTAG(sp,off,t) \ |
1198 | shd %r0, off, 1, t /* t[1..15] = off[0..14] */ ! \ | | 1198 | shd %r0, off, 1, t /* t[1..15] = off[0..14] */ ! \ |
1199 | dep sp, 31, 16, t /* put in the space id */ ! \ | | 1199 | dep sp, 31, 16, t /* put in the space id */ ! \ |
1200 | depi 1, 0, 1, t /* and set the valid bit */ | | 1200 | depi 1, 0, 1, t /* and set the valid bit */ |
1201 | | | 1201 | |
1202 | #if 0 | | 1202 | #if 0 |
1203 | BSS(dtlb_c, 8) | | 1203 | BSS(dtlb_c, 8) |
1204 | BSS(tlbd_c, 8) | | 1204 | BSS(tlbd_c, 8) |
1205 | BSS(itlb_c, 8) | | 1205 | BSS(itlb_c, 8) |
| @@ -2043,47 +2043,47 @@ L$trap_have_stack: | | | @@ -2043,47 +2043,47 @@ L$trap_have_stack: |
2043 | mfctl %isr, %t1 | | 2043 | mfctl %isr, %t1 |
2044 | mfctl %ior, %t2 | | 2044 | mfctl %ior, %t2 |
2045 | stw %t1, CI_TRAPSAVE + TF_CR20(%t3) /* use ,bc */ | | 2045 | stw %t1, CI_TRAPSAVE + TF_CR20(%t3) /* use ,bc */ |
2046 | stw %t2, CI_TRAPSAVE + TF_CR21(%t3) | | 2046 | stw %t2, CI_TRAPSAVE + TF_CR21(%t3) |
2047 | | | 2047 | |
2048 | /* save the interruption instruction register */ | | 2048 | /* save the interruption instruction register */ |
2049 | mfctl %iir, %t2 | | 2049 | mfctl %iir, %t2 |
2050 | stw %t2, CI_TRAPSAVE + TF_CR19(%t3) | | 2050 | stw %t2, CI_TRAPSAVE + TF_CR19(%t3) |
2051 | | | 2051 | |
2052 | /* save the trap type and flags */ | | 2052 | /* save the trap type and flags */ |
2053 | stw %r1, CI_TRAPSAVE + TF_FLAGS(%t3) | | 2053 | stw %r1, CI_TRAPSAVE + TF_FLAGS(%t3) |
2054 | | | 2054 | |
2055 | /* gotta get it before R is up */ | | 2055 | /* gotta get it before R is up */ |
2056 | mfctl %rctr, %t1 | | 2056 | mfctl CR_RCTR, %t1 |
2057 | | | 2057 | |
2058 | copy %sp, %t3 | | 2058 | copy %sp, %t3 |
2059 | ldo HPPA_FRAME_SIZE+TRAPFRAME_SIZEOF(%sp), %sp | | 2059 | ldo HPPA_FRAME_SIZE+TRAPFRAME_SIZEOF(%sp), %sp |
2060 | | | 2060 | |
2061 | #if defined(DDB) || defined(KGDB) | | 2061 | #if defined(DDB) || defined(KGDB) |
2062 | /* | | 2062 | /* |
2063 | * Match the offset from %sp for the trapframe with syscall_entry | | 2063 | * Match the offset from %sp for the trapframe with syscall_entry |
2064 | */ | | 2064 | */ |
2065 | ldo HPPA_FRAME_MAXARGS+HPPA_FRAME_SIZE-1(%sp),%sp | | 2065 | ldo HPPA_FRAME_MAXARGS+HPPA_FRAME_SIZE-1(%sp),%sp |
2066 | depi 0, 31, 6, %sp | | 2066 | depi 0, 31, 6, %sp |
2067 | #endif | | 2067 | #endif |
2068 | rfir | | 2068 | rfir |
2069 | nop ! nop ! nop ! nop ! nop ! nop ! nop ! nop | | 2069 | nop ! nop ! nop ! nop ! nop ! nop ! nop ! nop |
2070 | trapnowvirt: | | 2070 | trapnowvirt: |
2071 | /* | | 2071 | /* |
2072 | * %t3 contains the virtual address of the trapframe | | 2072 | * %t3 contains the virtual address of the trapframe |
2073 | * %sp is loaded w/ the right VA (we did not need it being physical) | | 2073 | * %sp is loaded w/ the right VA (we did not need it being physical) |
2074 | */ | | 2074 | */ |
2075 | | | 2075 | |
2076 | mfctl %ccr, %t2 | | 2076 | mfctl CR_CCR, %t2 |
2077 | stw %t1, TF_CR0(%sr3, %t3) | | 2077 | stw %t1, TF_CR0(%sr3, %t3) |
2078 | stw %t2, TF_CR10(%sr3, %t3) | | 2078 | stw %t2, TF_CR10(%sr3, %t3) |
2079 | | | 2079 | |
2080 | mfsp %sr0, %t1 | | 2080 | mfsp %sr0, %t1 |
2081 | mfsp %sr1, %t2 | | 2081 | mfsp %sr1, %t2 |
2082 | stw %t1, TF_SR0(%sr3, %t3) | | 2082 | stw %t1, TF_SR0(%sr3, %t3) |
2083 | stw %t2, TF_SR1(%sr3, %t3) | | 2083 | stw %t2, TF_SR1(%sr3, %t3) |
2084 | | | 2084 | |
2085 | mfsp %sr2, %t1 | | 2085 | mfsp %sr2, %t1 |
2086 | mfsp %sr4, %t2 | | 2086 | mfsp %sr4, %t2 |
2087 | stw %t1, TF_SR2(%sr3, %t3) | | 2087 | stw %t1, TF_SR2(%sr3, %t3) |
2088 | stw %t2, TF_SR4(%sr3, %t3) | | 2088 | stw %t2, TF_SR4(%sr3, %t3) |
2089 | | | 2089 | |