support.S (66486) | support.S (66633) |
---|---|
1/*- 2 * Copyright (c) 1998 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/ia64/ia64/support.S 66486 2000-09-30 17:48:44Z dfr $ | 26 * $FreeBSD: head/sys/ia64/ia64/support.S 66633 2000-10-04 17:53:03Z dfr $ |
27 */ 28/* 29 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 30 * All rights reserved. 31 * 32 * Author: Chris G. Demetriou 33 * 34 * Permission to use, copy, modify and distribute this software and --- 23 unchanged lines hidden (view full) --- 58 .text 59 60/**************************************************************************/ 61 62/* 63 * fu{byte,word} : fetch a byte (word) from user memory 64 */ 65 | 27 */ 28/* 29 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 30 * All rights reserved. 31 * 32 * Author: Chris G. Demetriou 33 * 34 * Permission to use, copy, modify and distribute this software and --- 23 unchanged lines hidden (view full) --- 58 .text 59 60/**************************************************************************/ 61 62/* 63 * fu{byte,word} : fetch a byte (word) from user memory 64 */ 65 |
66LEAF(suword, 1) 67#if 0 68 LDGP(pv) | 66ENTRY(suword, 2) |
69 | 67 |
70 ldiq t0, VM_MAXUSER_ADDRESS /* verify address validity */ 71 cmpult a0, t0, t1 72 beq t1, fusufault | 68 movl r14=VM_MAXUSER_ADDRESS;; // make sure address is ok 69 cmp.geu p6,p0=in0,r14 70(p6) br.dpnt.few fusufault |
73 | 71 |
74 lda t0, fusufault /* trap faults */ 75 ldq t2, curproc 76 ldq t2, P_ADDR(t2) 77 stq t0, U_PCB_ONFAULT(t2) | 72 movl r14=fusufault // set up fault handler. 73 add r15=GD_CURPROC,r13 // find curproc 74 ;; 75 ld8 r15=[r15] 76 ;; 77 add r15=P_ADDR,r15 // find pcb 78 ;; 79 ld8 r15=[r15] 80 ;; 81 add r15=U_PCB_ONFAULT,r15 82 ;; 83 st8 [r15]=r14 84 ;; 85 st8.rel [in0]=in1 // try the store 86 ;; 87 st8 [r15]=r0 // clean up |
78 | 88 |
79 stq a1, 0(a0) /* try the store */ | 89 mov ret0=r0 90 br.ret.sptk.few rp |
80 | 91 |
81 stq zero, U_PCB_ONFAULT(t2) /* clean up */ 82 83 mov zero, v0 84 RET 85#endif | |
86END(suword) 87 | 92END(suword) 93 |
88LEAF(subyte, 1) 89#if 0 90 LDGP(pv) | 94ENTRY(subyte, 2) |
91 | 95 |
92 ldiq t0, VM_MAXUSER_ADDRESS /* verify address validity */ 93 cmpult a0, t0, t1 94 beq t1, fusufault | 96 movl r14=VM_MAXUSER_ADDRESS;; // make sure address is ok 97 cmp.geu p6,p0=in0,r14 98(p6) br.dpnt.few fusufault |
95 | 99 |
96 lda t0, fusufault /* trap faults */ 97 ldq t2, curproc 98 ldq t2, P_ADDR(t2) 99 stq t0, U_PCB_ONFAULT(t2) | 100 movl r14=fusufault // set up fault handler. 101 add r15=GD_CURPROC,r13 // find curproc 102 ;; 103 ld8 r15=[r15] 104 ;; 105 add r15=P_ADDR,r15 // find pcb 106 ;; 107 ld8 r15=[r15] 108 ;; 109 add r15=U_PCB_ONFAULT,r15 110 ;; 111 st8 [r15]=r14 112 ;; 113 st1.rel [in0]=in1 // try the store 114 ;; 115 st8 [r15]=r0 // clean up |
100 | 116 |
101 zap a1, 0xfe, a1 /* mask off the byte to store */ 102 insbl a1, a0, a1 /* shift it to the right place */ 103 ldq_u t0, 0(a0) /* read the qword to store it in */ 104 mskbl t0, a0, t0 /* make a place for our byte */ 105 or a1, t0, a1 /* move it in */ 106 stq_u a1, 0(a0) /* and put the byte back */ | 117 mov ret0=r0 118 br.ret.sptk.few rp |
107 | 119 |
108 stq zero, U_PCB_ONFAULT(t2) /* clean up */ 109 110 mov zero, v0 111 RET 112#endif | |
113END(subyte) 114 | 120END(subyte) 121 |
115LEAF(fuword, 1) 116#if 0 117 LDGP(pv) | 122ENTRY(fuword, 1) |
118 | 123 |
119 ldiq t0, VM_MAXUSER_ADDRESS /* verify address validity */ 120 cmpult a0, t0, t1 121 beq t1, fusufault | 124 movl r14=VM_MAXUSER_ADDRESS;; // make sure address is ok 125 cmp.geu p6,p0=in0,r14 126(p6) br.dpnt.few fusufault |
122 | 127 |
123 lda t0, fusufault /* trap faults */ 124 ldq t2, curproc 125 ldq t2, P_ADDR(t2) 126 stq t0, U_PCB_ONFAULT(t2) | 128 movl r14=fusufault // set up fault handler. 129 add r15=GD_CURPROC,r13 // find curproc 130 ;; 131 ld8 r15=[r15] 132 ;; 133 add r15=P_ADDR,r15 // find pcb 134 ;; 135 ld8 r15=[r15] 136 ;; 137 add r15=U_PCB_ONFAULT,r15 138 ;; 139 st8 [r15]=r14 140 ;; 141 ld8.acq ret0=[in0] // try the fetch 142 ;; 143 st8 [r15]=r0 // clean up |
127 | 144 |
128 ldq v0, 0(a0) /* try the fetch */ | 145 br.ret.sptk.few rp |
129 | 146 |
130 stq zero, U_PCB_ONFAULT(t2) /* clean up */ 131 132 RET 133#endif | |
134END(fuword) 135 | 147END(fuword) 148 |
136LEAF(fubyte, 1) 137#if 0 138 LDGP(pv) | 149ENTRY(fubyte, 1) |
139 | 150 |
140 ldiq t0, VM_MAXUSER_ADDRESS /* verify address validity */ 141 cmpult a0, t0, t1 142 beq t1, fusufault | 151 movl r14=VM_MAXUSER_ADDRESS;; // make sure address is ok 152 cmp.geu p6,p0=in0,r14 153(p6) br.dpnt.few fusufault |
143 | 154 |
144 lda t0, fusufault /* trap faults */ 145 ldq t2, curproc 146 ldq t2, P_ADDR(t2) 147 stq t0, U_PCB_ONFAULT(t2) | 155 movl r14=fusufault // set up fault handler. 156 add r15=GD_CURPROC,r13 // find curproc 157 ;; 158 ld8 r15=[r15] 159 ;; 160 add r15=P_ADDR,r15 // find pcb 161 ;; 162 ld8 r15=[r15] 163 ;; 164 add r15=U_PCB_ONFAULT,r15 165 ;; 166 st8 [r15]=r14 167 ;; 168 ld1.acq ret0=[in0] // try the fetch 169 ;; 170 st8 [r15]=r0 // clean up |
148 | 171 |
149 ldq_u v0, 0(a0) /* get the word containing our byte */ 150 extbl v0, a0, v0 /* extract the byte */ | 172 br.ret.sptk.few rp |
151 | 173 |
152 stq zero, U_PCB_ONFAULT(t2) /* clean up */ 153 154 RET 155#endif | |
156END(fubyte) 157 | 174END(fubyte) 175 |
158LEAF(suibyte, 2) 159#if 0 160 ldiq v0, -1 161 RET 162#endif 163 END(suibyte) | 176ENTRY(suibyte, 2) 177 mov ret0=-1 178 br.ret.sptk.few rp 179END(suibyte) |
164 | 180 |
165 LEAF(fusufault, 0) 166#if 0 167 ldq t0, curproc 168 ldq t0, P_ADDR(t0) 169 stq zero, U_PCB_ONFAULT(t0) 170 ldiq v0, -1 171 RET 172#endif | 181ENTRY(fusufault, 0) 182 st8 [r15]=r0 ;; // r15 points at onfault 183 mov ret0=r0 184 br.ret.sptk.few rp |
173END(fusufault) 174 | 185END(fusufault) 186 |
175LEAF(fswintrberr, 0) 176XLEAF(fuswintr) /* XXX what is a 'word'? */ 177XLEAF(suswintr) /* XXX what is a 'word'? */ 178#if 0 179 LDGP(pv) 180 ldiq v0, -1 181 RET 182#endif | 187ENTRY(fswintrberr, 0) 188XENTRY(fuswintr) /* XXX what is a 'word'? */ 189XENTRY(suswintr) /* XXX what is a 'word'? */ 190 mov ret0=-1 191 br.ret.sptk.few rp |
183END(fswintrberr) 184 185/**************************************************************************/ 186 187/* 188 * Copy a null-terminated string within the kernel's address space. 189 * If lenp is not NULL, store the number of chars copied in *lenp 190 * 191 * int copystr(char *from, char *to, size_t len, size_t *lenp); 192 */ | 192END(fswintrberr) 193 194/**************************************************************************/ 195 196/* 197 * Copy a null-terminated string within the kernel's address space. 198 * If lenp is not NULL, store the number of chars copied in *lenp 199 * 200 * int copystr(char *from, char *to, size_t len, size_t *lenp); 201 */ |
193LEAF(copystr, 4) | 202ENTRY(copystr, 4) |
194 mov r14=in2 // r14 = i = len 195 cmp.eq p6,p0=r0,in2 196(p6) br.cond.spnt.few 2f // if (len == 0), bail out 197 1981: ld1 r15=[in0],1 // read one byte 199 ;; 200 st1 [in1]=r15,1 // write that byte 201 add in2=-1,in2 // len-- --- 16 unchanged lines hidden (view full) --- 218 mov ret0=ENAMETOOLONG // *from != '\0'; error. 219 br.ret.sptk.few rp 220 2214: mov ret0=0 // return 0. 222 br.ret.sptk.few rp 223 224END(copystr) 225 | 203 mov r14=in2 // r14 = i = len 204 cmp.eq p6,p0=r0,in2 205(p6) br.cond.spnt.few 2f // if (len == 0), bail out 206 2071: ld1 r15=[in0],1 // read one byte 208 ;; 209 st1 [in1]=r15,1 // write that byte 210 add in2=-1,in2 // len-- --- 16 unchanged lines hidden (view full) --- 227 mov ret0=ENAMETOOLONG // *from != '\0'; error. 228 br.ret.sptk.few rp 229 2304: mov ret0=0 // return 0. 231 br.ret.sptk.few rp 232 233END(copystr) 234 |
226NESTED(copyinstr, 4) | 235ENTRY(copyinstr, 4) |
227 alloc loc0=ar.pfs,4,3,4,0 228 mov loc1=rp 229 230 movl loc2=VM_MAXUSER_ADDRESS // make sure that src addr 231 ;; | 236 alloc loc0=ar.pfs,4,3,4,0 237 mov loc1=rp 238 239 movl loc2=VM_MAXUSER_ADDRESS // make sure that src addr 240 ;; |
232 cmp.ltu p6,p0=in0,loc2 // is in user space. | 241 cmp.geu p6,p0=in0,loc2 // is in user space. |
233 ;; 234(p6) br.cond.spnt.few copyerr // if it's not, error out. 235 movl r14=copyerr // set up fault handler. 236 add r15=GD_CURPROC,r13 // find curproc 237 ;; 238 ld8 r15=[r15] 239 ;; 240 add r15=P_ADDR,r15 // find pcb --- 11 unchanged lines hidden (view full) --- 252 ;; 253 br.call.sptk.few rp=copystr // do the copy. 254 st8 [loc2]=r0 // kill the fault handler. 255 mov rp=loc1 // restore ra. 256 br.ret.sptk.few rp // ret0 left over from copystr 257 258END(copyinstr) 259 | 242 ;; 243(p6) br.cond.spnt.few copyerr // if it's not, error out. 244 movl r14=copyerr // set up fault handler. 245 add r15=GD_CURPROC,r13 // find curproc 246 ;; 247 ld8 r15=[r15] 248 ;; 249 add r15=P_ADDR,r15 // find pcb --- 11 unchanged lines hidden (view full) --- 261 ;; 262 br.call.sptk.few rp=copystr // do the copy. 263 st8 [loc2]=r0 // kill the fault handler. 264 mov rp=loc1 // restore ra. 265 br.ret.sptk.few rp // ret0 left over from copystr 266 267END(copyinstr) 268 |
260NESTED(copyoutstr, 4) | 269ENTRY(copyoutstr, 4) |
261 alloc loc0=ar.pfs,4,3,4,0 262 mov loc1=rp 263 264 movl loc2=VM_MAXUSER_ADDRESS // make sure that dest addr 265 ;; | 270 alloc loc0=ar.pfs,4,3,4,0 271 mov loc1=rp 272 273 movl loc2=VM_MAXUSER_ADDRESS // make sure that dest addr 274 ;; |
266 cmp.ltu p6,p0=in1,loc2 // is in user space. | 275 cmp.geu p6,p0=in1,loc2 // is in user space. |
267 ;; 268(p6) br.cond.spnt.few copyerr // if it's not, error out. 269 movl r14=copyerr // set up fault handler. 270 add r15=GD_CURPROC,r13 // find curproc 271 ;; 272 ld8 r15=[r15] 273 ;; 274 add r15=P_ADDR,r15 // find pcb --- 14 unchanged lines hidden (view full) --- 289 mov rp=loc1 // restore ra. 290 br.ret.sptk.few rp // ret0 left over from copystr 291 292END(copyoutstr) 293 294/* 295 * Not the fastest bcopy in the world. 296 */ | 276 ;; 277(p6) br.cond.spnt.few copyerr // if it's not, error out. 278 movl r14=copyerr // set up fault handler. 279 add r15=GD_CURPROC,r13 // find curproc 280 ;; 281 ld8 r15=[r15] 282 ;; 283 add r15=P_ADDR,r15 // find pcb --- 14 unchanged lines hidden (view full) --- 298 mov rp=loc1 // restore ra. 299 br.ret.sptk.few rp // ret0 left over from copystr 300 301END(copyoutstr) 302 303/* 304 * Not the fastest bcopy in the world. 305 */ |
297LEAF(bcopy, 3) 298XLEAF(ovbcopy) | 306ENTRY(bcopy, 3) 307XENTRY(ovbcopy) |
299 300 mov ret0=r0 // return zero for copy{in,out} 301 ;; 302 cmp.le p6,p0=in2,r0 // bail if len <= 0 303(p6) br.ret.spnt.few rp 304 305 sub r14=in1,in0 ;; // check for overlap 306 cmp.ltu p6,p0=r14,in2 // dst-src < len --- 49 unchanged lines hidden (view full) --- 356 add in2=-1,in2 ;; 357 cmp.ne p6,p0=r0,in2 358(p6) br.cond.spnt.few 6b 359 360 br.ret.sptk.few rp 361 362END(bcopy) 363 | 308 309 mov ret0=r0 // return zero for copy{in,out} 310 ;; 311 cmp.le p6,p0=in2,r0 // bail if len <= 0 312(p6) br.ret.spnt.few rp 313 314 sub r14=in1,in0 ;; // check for overlap 315 cmp.ltu p6,p0=r14,in2 // dst-src < len --- 49 unchanged lines hidden (view full) --- 365 add in2=-1,in2 ;; 366 cmp.ne p6,p0=r0,in2 367(p6) br.cond.spnt.few 6b 368 369 br.ret.sptk.few rp 370 371END(bcopy) 372 |
364LEAF(memcpy,3) | 373ENTRY(memcpy,3) |
365 366 mov r14=in0 ;; 367 mov in0=in1 ;; 368 mov in1=r14 369 br.cond.sptk.few bcopy 370 371END(memcpy) 372 | 374 375 mov r14=in0 ;; 376 mov in0=in1 ;; 377 mov in1=r14 378 br.cond.sptk.few bcopy 379 380END(memcpy) 381 |
373NESTED(copyin, 3) | 382ENTRY(copyin, 3) |
374 375 alloc loc0=ar.pfs,3,3,3,0 376 mov loc1=rp 377 378 movl loc2=VM_MAXUSER_ADDRESS // make sure that src addr 379 ;; 380 cmp.ltu p6,p0=in0,loc2 // is in user space. 381 ;; --- 17 unchanged lines hidden (view full) --- 399 ;; 400 br.call.sptk.few rp=bcopy // do the copy. 401 st8 [loc2]=r0 // kill the fault handler. 402 mov rp=loc1 // restore ra. 403 br.ret.sptk.few rp // ret0 left over from bcopy 404 405END(copyin) 406 | 383 384 alloc loc0=ar.pfs,3,3,3,0 385 mov loc1=rp 386 387 movl loc2=VM_MAXUSER_ADDRESS // make sure that src addr 388 ;; 389 cmp.ltu p6,p0=in0,loc2 // is in user space. 390 ;; --- 17 unchanged lines hidden (view full) --- 408 ;; 409 br.call.sptk.few rp=bcopy // do the copy. 410 st8 [loc2]=r0 // kill the fault handler. 411 mov rp=loc1 // restore ra. 412 br.ret.sptk.few rp // ret0 left over from bcopy 413 414END(copyin) 415 |
407NESTED(copyout, 3) | 416ENTRY(copyout, 3) |
408 409 alloc loc0=ar.pfs,3,3,3,0 410 mov loc1=rp 411 412 movl loc2=VM_MAXUSER_ADDRESS // make sure that dest addr 413 ;; 414 cmp.ltu p6,p0=in1,loc2 // is in user space. 415 ;; --- 17 unchanged lines hidden (view full) --- 433 ;; 434 br.call.sptk.few rp=bcopy // do the copy. 435 st8 [loc2]=r0 // kill the fault handler. 436 mov rp=loc1 // restore ra. 437 br.ret.sptk.few rp // ret0 left over from bcopy 438 439END(copyout) 440 | 417 418 alloc loc0=ar.pfs,3,3,3,0 419 mov loc1=rp 420 421 movl loc2=VM_MAXUSER_ADDRESS // make sure that dest addr 422 ;; 423 cmp.ltu p6,p0=in1,loc2 // is in user space. 424 ;; --- 17 unchanged lines hidden (view full) --- 442 ;; 443 br.call.sptk.few rp=bcopy // do the copy. 444 st8 [loc2]=r0 // kill the fault handler. 445 mov rp=loc1 // restore ra. 446 br.ret.sptk.few rp // ret0 left over from bcopy 447 448END(copyout) 449 |
441LEAF(copyerr, 0) | 450ENTRY(copyerr, 0) |
442 443 add r14=GD_CURPROC,r13 ;; // find curproc 444 ld8 r14=[r14] ;; 445 add r14=P_ADDR,r14 ;; // curproc->p_addr 446 ld8 r14=[r14] ;; 447 add r14=U_PCB_ONFAULT,r14 ;; // &curproc->p_addr->u_pcb.pcb_onfault 448 st8 [r14]=r0 // reset fault handler 449 --- 9 unchanged lines hidden (view full) --- 459 * 460 * longjmp(label_t *a) 461 * will generate a "return (1)" from the last call to 462 * setjmp(label_t *a) 463 * by restoring registers from the stack, 464 */ 465 466 | 451 452 add r14=GD_CURPROC,r13 ;; // find curproc 453 ld8 r14=[r14] ;; 454 add r14=P_ADDR,r14 ;; // curproc->p_addr 455 ld8 r14=[r14] ;; 456 add r14=U_PCB_ONFAULT,r14 ;; // &curproc->p_addr->u_pcb.pcb_onfault 457 st8 [r14]=r0 // reset fault handler 458 --- 9 unchanged lines hidden (view full) --- 468 * 469 * longjmp(label_t *a) 470 * will generate a "return (1)" from the last call to 471 * setjmp(label_t *a) 472 * by restoring registers from the stack, 473 */ 474 475 |
467LEAF(setjmp, 1) | 476ENTRY(setjmp, 1) |
468#if 0 469 LDGP(pv) 470 471 stq ra, (0 * 8)(a0) /* return address */ 472 stq s0, (1 * 8)(a0) /* callee-saved registers */ 473 stq s1, (2 * 8)(a0) 474 stq s2, (3 * 8)(a0) 475 stq s3, (4 * 8)(a0) --- 5 unchanged lines hidden (view full) --- 481 ldiq t0, 0xbeeffedadeadbabe /* set magic number */ 482 stq t0, (9 * 8)(a0) 483 484 mov zero, v0 /* return zero */ 485 RET 486#endif 487END(setjmp) 488 | 477#if 0 478 LDGP(pv) 479 480 stq ra, (0 * 8)(a0) /* return address */ 481 stq s0, (1 * 8)(a0) /* callee-saved registers */ 482 stq s1, (2 * 8)(a0) 483 stq s2, (3 * 8)(a0) 484 stq s3, (4 * 8)(a0) --- 5 unchanged lines hidden (view full) --- 490 ldiq t0, 0xbeeffedadeadbabe /* set magic number */ 491 stq t0, (9 * 8)(a0) 492 493 mov zero, v0 /* return zero */ 494 RET 495#endif 496END(setjmp) 497 |
489LEAF(longjmp, 1) | 498ENTRY(longjmp, 1) |
490#if 0 491 LDGP(pv) 492 493 ldiq t0, 0xbeeffedadeadbabe /* check magic number */ 494 ldq t1, (9 * 8)(a0) 495 cmpeq t0, t1, t0 496 beq t0, longjmp_botch /* if bad, punt */ 497 --- 25 unchanged lines hidden --- | 499#if 0 500 LDGP(pv) 501 502 ldiq t0, 0xbeeffedadeadbabe /* check magic number */ 503 ldq t1, (9 * 8)(a0) 504 cmpeq t0, t1, t0 505 beq t0, longjmp_botch /* if bad, punt */ 506 --- 25 unchanged lines hidden --- |