| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: locore.s,v 1.138 2021/07/07 02:44:04 thorpej Exp $ */ | | 1 | /* $NetBSD: locore.s,v 1.139 2021/07/07 03:30:35 thorpej Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1999, 2000, 2019 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center. | | 9 | * NASA Ames Research Center. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -57,27 +57,27 @@ | | | @@ -57,27 +57,27 @@ |
57 | * rights to redistribute these changes. | | 57 | * rights to redistribute these changes. |
58 | */ | | 58 | */ |
59 | | | 59 | |
60 | .stabs __FILE__,100,0,0,kernel_text | | 60 | .stabs __FILE__,100,0,0,kernel_text |
61 | | | 61 | |
62 | #include "opt_ddb.h" | | 62 | #include "opt_ddb.h" |
63 | #include "opt_kgdb.h" | | 63 | #include "opt_kgdb.h" |
64 | #include "opt_multiprocessor.h" | | 64 | #include "opt_multiprocessor.h" |
65 | #include "opt_lockdebug.h" | | 65 | #include "opt_lockdebug.h" |
66 | #include "opt_compat_netbsd.h" | | 66 | #include "opt_compat_netbsd.h" |
67 | | | 67 | |
68 | #include <machine/asm.h> | | 68 | #include <machine/asm.h> |
69 | | | 69 | |
70 | __KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.138 2021/07/07 02:44:04 thorpej Exp $"); | | 70 | __KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.139 2021/07/07 03:30:35 thorpej Exp $"); |
71 | | | 71 | |
72 | #include "assym.h" | | 72 | #include "assym.h" |
73 | | | 73 | |
74 | .stabs __FILE__,132,0,0,kernel_text | | 74 | .stabs __FILE__,132,0,0,kernel_text |
75 | | | 75 | |
76 | /* don't reorder instructions; paranoia. */ | | 76 | /* don't reorder instructions; paranoia. */ |
77 | .set noreorder | | 77 | .set noreorder |
78 | .text | | 78 | .text |
79 | | | 79 | |
80 | .macro bfalse reg, dst | | 80 | .macro bfalse reg, dst |
81 | beq \reg, \dst | | 81 | beq \reg, \dst |
82 | .endm | | 82 | .endm |
83 | | | 83 | |
| @@ -892,26 +892,64 @@ LEAF_NOPROFILE(lwp_trampoline, 0) | | | @@ -892,26 +892,64 @@ LEAF_NOPROFILE(lwp_trampoline, 0) |
892 | mov s3, a1 /* a1 = new_lwp (that's us!) */ | | 892 | mov s3, a1 /* a1 = new_lwp (that's us!) */ |
893 | CALL(lwp_startup) /* lwp_startup(prev_lwp, new_lwp); */ | | 893 | CALL(lwp_startup) /* lwp_startup(prev_lwp, new_lwp); */ |
894 | mov s0, pv /* pv = func */ | | 894 | mov s0, pv /* pv = func */ |
895 | mov s1, ra /* ra = (probably exception_return()) */ | | 895 | mov s1, ra /* ra = (probably exception_return()) */ |
896 | mov s2, a0 /* a0 = arg */ | | 896 | mov s2, a0 /* a0 = arg */ |
897 | jmp zero, (pv) /* func(arg) */ | | 897 | jmp zero, (pv) /* func(arg) */ |
898 | END(lwp_trampoline) | | 898 | END(lwp_trampoline) |
899 | | | 899 | |
900 | /**************************************************************************/ | | 900 | /**************************************************************************/ |
901 | | | 901 | |
902 | /* | | 902 | /* |
903 | * alpha_copystr(const void *from, void *to, size_t len, size_t *donep) | | 903 | * alpha_copystr(const void *from, void *to, size_t len, size_t *donep) |
904 | */ | | 904 | */ |
| | | 905 | .arch ev56 |
| | | 906 | LEAF(alpha_copystr_bwx, 4) |
| | | 907 | LDGP(pv) |
| | | 908 | |
| | | 909 | mov a2, t0 /* t0 = i = len */ |
| | | 910 | beq a2, 5f /* if (len == 0), bail */ |
| | | 911 | |
| | | 912 | 1: ldbu t1, 0(a0) /* t1 = *from */ |
| | | 913 | subl a2, 1, a2 /* len-- */ |
| | | 914 | addq a0, 1, a0 /* from++ */ |
| | | 915 | stb t1, 0(a1) /* *to = t1 */ |
| | | 916 | beq t1, 2f /* if (t1 == '\0'), bail out */ |
| | | 917 | addq a1, 1, a1 /* to++ */ |
| | | 918 | bne a2, 1b /* if (len != 0), copy more */ |
| | | 919 | |
| | | 920 | 2: beq a3, 3f /* if (lenp != NULL) */ |
| | | 921 | subl t0, a2, t0 /* *lenp = (i - len) */ |
| | | 922 | stq t0, 0(a3) |
| | | 923 | 3: bne t1, 4f /* *from != '\0'; leave in a huff */ |
| | | 924 | |
| | | 925 | mov zero, v0 /* return 0. */ |
| | | 926 | RET |
| | | 927 | |
| | | 928 | 4: ldiq v0, ENAMETOOLONG |
| | | 929 | RET |
| | | 930 | |
| | | 931 | 5: ldiq t1, 1 /* fool the test above... */ |
| | | 932 | br zero, 2b |
| | | 933 | |
| | | 934 | nop /* pad to same length as... */ |
| | | 935 | nop /* non-BWX version. */ |
| | | 936 | nop |
| | | 937 | nop |
| | | 938 | nop |
| | | 939 | EXPORT(alpha_copystr_bwx_end) |
| | | 940 | END(alpha_copystr_bwx) |
| | | 941 | .arch ev4 |
| | | 942 | |
905 | LEAF(alpha_copystr, 4) | | 943 | LEAF(alpha_copystr, 4) |
906 | LDGP(pv) | | 944 | LDGP(pv) |
907 | | | 945 | |
908 | mov a2, t0 /* t0 = i = len */ | | 946 | mov a2, t0 /* t0 = i = len */ |
909 | beq a2, 5f /* if (len == 0), bail */ | | 947 | beq a2, 5f /* if (len == 0), bail */ |
910 | | | 948 | |
911 | 1: ldq_u t1, 0(a0) /* t1 = *from */ | | 949 | 1: ldq_u t1, 0(a0) /* t1 = *from */ |
912 | extbl t1, a0, t1 | | 950 | extbl t1, a0, t1 |
913 | ldq_u t3, 0(a1) /* set up t2 with quad around *to */ | | 951 | ldq_u t3, 0(a1) /* set up t2 with quad around *to */ |
914 | insbl t1, a1, t2 | | 952 | insbl t1, a1, t2 |
915 | mskbl t3, a1, t3 | | 953 | mskbl t3, a1, t3 |
916 | or t3, t2, t3 /* add *from to quad around *to */ | | 954 | or t3, t2, t3 /* add *from to quad around *to */ |
917 | stq_u t3, 0(a1) /* write out that quad */ | | 955 | stq_u t3, 0(a1) /* write out that quad */ |
| @@ -925,26 +963,27 @@ LEAF(alpha_copystr, 4) | | | @@ -925,26 +963,27 @@ LEAF(alpha_copystr, 4) |
925 | 2: beq a3, 3f /* if (lenp != NULL) */ | | 963 | 2: beq a3, 3f /* if (lenp != NULL) */ |
926 | subl t0, a2, t0 /* *lenp = (i - len) */ | | 964 | subl t0, a2, t0 /* *lenp = (i - len) */ |
927 | stq t0, 0(a3) | | 965 | stq t0, 0(a3) |
928 | 3: bne t1, 4f /* *from != '\0'; leave in a huff */ | | 966 | 3: bne t1, 4f /* *from != '\0'; leave in a huff */ |
929 | | | 967 | |
930 | mov zero, v0 /* return 0. */ | | 968 | mov zero, v0 /* return 0. */ |
931 | RET | | 969 | RET |
932 | | | 970 | |
933 | 4: ldiq v0, ENAMETOOLONG | | 971 | 4: ldiq v0, ENAMETOOLONG |
934 | RET | | 972 | RET |
935 | | | 973 | |
936 | 5: ldiq t1, 1 /* fool the test above... */ | | 974 | 5: ldiq t1, 1 /* fool the test above... */ |
937 | br zero, 2b | | 975 | br zero, 2b |
| | | 976 | EXPORT(alpha_copystr_end) |
938 | END(alpha_copystr) | | 977 | END(alpha_copystr) |
939 | | | 978 | |
940 | NESTED(copyinstr, 4, 16, ra, IM_RA|IM_S0, 0) | | 979 | NESTED(copyinstr, 4, 16, ra, IM_RA|IM_S0, 0) |
941 | LDGP(pv) | | 980 | LDGP(pv) |
942 | lda sp, -16(sp) /* set up stack frame */ | | 981 | lda sp, -16(sp) /* set up stack frame */ |
943 | stq ra, (16-8)(sp) /* save ra */ | | 982 | stq ra, (16-8)(sp) /* save ra */ |
944 | stq s0, (16-16)(sp) /* save s0 */ | | 983 | stq s0, (16-16)(sp) /* save s0 */ |
945 | ldiq t0, VM_MAX_ADDRESS /* make sure that src addr */ | | 984 | ldiq t0, VM_MAX_ADDRESS /* make sure that src addr */ |
946 | cmpult a0, t0, t1 /* is in user space. */ | | 985 | cmpult a0, t0, t1 /* is in user space. */ |
947 | beq t1, copyerr_efault /* if it's not, error out. */ | | 986 | beq t1, copyerr_efault /* if it's not, error out. */ |
948 | /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ | | 987 | /* Note: GET_CURLWP clobbers v0, t0, t8...t11. */ |
949 | GET_CURLWP | | 988 | GET_CURLWP |
950 | ldq s0, L_PCB(v0) /* s0 = pcb */ | | 989 | ldq s0, L_PCB(v0) /* s0 = pcb */ |