1 /* $NetBSD: fusu.S,v 1.10 2003/12/01 13:34:44 rearnsha Exp $ */
4 * Copyright (c) 1996-1998 Mark Brinicombe.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Mark Brinicombe
18 * 4. The name of the company nor the name of the author may be used to
19 * endorse or promote products derived from this software without specific
20 * prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <machine/asm.h>
37 #include <machine/asmacros.h>
38 #include <machine/armreg.h>
40 __FBSDID("$FreeBSD$");
44 .word _C_LABEL(cpu_info)
47 .word _C_LABEL(__pcpu) + PC_CURPCB
51 * fuword(caddr_t uaddr);
52 * Fetch an int from the user's address space.
57 /* XXX Probably not appropriate for non-Hydra SMPs */
59 bl _C_LABEL(cpu_number)
61 ldr r2, [r2, r0, lsl #2]
62 ldr r2, [r2, #CI_CURPCB]
74 adr r4, .Lcasuptrfault
75 str r4, [r3, #PCB_ONFAULT]
83 str r1, [r3, #PCB_ONFAULT]
87 * Handle faults from casuptr. Clean up and return -1.
92 str r0, [r3, #PCB_ONFAULT]
97 * fuword(caddr_t uaddr);
98 * Fetch an int from the user's address space.
103 #ifdef MULTIPROCESSOR
104 /* XXX Probably not appropriate for non-Hydra SMPs */
106 bl _C_LABEL(cpu_number)
108 ldr r2, [r2, r0, lsl #2]
109 ldr r2, [r2, #CI_CURPCB]
122 str r1, [r2, #PCB_ONFAULT]
127 str r1, [r2, #PCB_ONFAULT]
132 * fusword(caddr_t uaddr);
133 * Fetch a short from the user's address space.
137 #ifdef MULTIPROCESSOR
138 /* XXX Probably not appropriate for non-Hydra SMPs */
140 bl _C_LABEL(cpu_number)
142 ldr r2, [r2, r0, lsl #2]
143 ldr r2, [r2, #CI_CURPCB]
156 str r1, [r2, #PCB_ONFAULT]
161 orr r0, ip, r3, asl #8
163 orr r0, r3, ip, asl #8
166 str r1, [r2, #PCB_ONFAULT]
170 * fuswintr(caddr_t uaddr);
171 * Fetch a short from the user's address space. Can be called during an
176 ldr r2, Lblock_userspace_access
179 mvnne r0, #0x00000000
182 #ifdef MULTIPROCESSOR
183 /* XXX Probably not appropriate for non-Hydra SMPs */
185 bl _C_LABEL(cpu_number)
187 ldr r2, [r2, r0, lsl #2]
188 ldr r2, [r2, #CI_CURPCB]
200 adr r1, _C_LABEL(fusubailout)
201 str r1, [r2, #PCB_ONFAULT]
206 orr r0, ip, r3, asl #8
208 orr r0, r3, ip, asl #8
212 str r1, [r2, #PCB_ONFAULT]
215 Lblock_userspace_access:
216 .word _C_LABEL(block_userspace_access)
220 .global _C_LABEL(block_userspace_access)
221 _C_LABEL(block_userspace_access):
226 * fubyte(caddr_t uaddr);
227 * Fetch a byte from the user's address space.
231 #ifdef MULTIPROCESSOR
232 /* XXX Probably not appropriate for non-Hydra SMPs */
234 bl _C_LABEL(cpu_number)
236 ldr r2, [r2, r0, lsl #2]
237 ldr r2, [r2, #CI_CURPCB]
250 str r1, [r2, #PCB_ONFAULT]
255 str r1, [r2, #PCB_ONFAULT]
260 * Handle faults from [fs]u*(). Clean up and return -1.
265 str r0, [r2, #PCB_ONFAULT]
270 * Handle faults from [fs]u*(). Clean up and return -1. This differs from
271 * fusufault() in that trap() will recognise it and return immediately rather
272 * than trying to page fault.
275 /* label must be global as fault.c references it */
276 .global _C_LABEL(fusubailout)
277 _C_LABEL(fusubailout):
279 str r0, [r2, #PCB_ONFAULT]
285 * Handle earlier faults from [fs]u*(), due to no pcb
290 adr r0, fusupcbfaulttext
294 .asciz "Yikes - no valid PCB during fusuxxx() addr=%08x\n"
299 * suword(caddr_t uaddr, int x);
300 * Store an int in the user's address space.
305 #ifdef MULTIPROCESSOR
306 /* XXX Probably not appropriate for non-Hydra SMPs */
307 stmfd sp!, {r0, r1, r14}
308 bl _C_LABEL(cpu_number)
310 ldr r2, [r2, r0, lsl #2]
311 ldr r2, [r2, #CI_CURPCB]
312 ldmfd sp!, {r0, r1, r14}
324 str r3, [r2, #PCB_ONFAULT]
329 str r0, [r2, #PCB_ONFAULT]
333 * suswintr(caddr_t uaddr, short x);
334 * Store a short in the user's address space. Can be called during an
339 ldr r2, Lblock_userspace_access
342 mvnne r0, #0x00000000
345 #ifdef MULTIPROCESSOR
346 stmfd sp!, {r0, r1, r14}
347 bl _C_LABEL(cpu_number)
349 ldr r2, [r2, r0, lsl #2]
350 ldr r2, [r2, #CI_CURPCB]
351 ldmfd sp!, {r0, r1, r14}
362 adr r3, _C_LABEL(fusubailout)
363 str r3, [r2, #PCB_ONFAULT]
375 str r0, [r2, #PCB_ONFAULT]
379 * susword(caddr_t uaddr, short x);
380 * Store a short in the user's address space.
384 #ifdef MULTIPROCESSOR
385 stmfd sp!, {r0, r1, r14}
386 bl _C_LABEL(cpu_number)
388 ldr r2, [r2, r0, lsl #2]
389 ldr r2, [r2, #CI_CURPCB]
390 ldmfd sp!, {r0, r1, r14}
402 str r3, [r2, #PCB_ONFAULT]
414 str r0, [r2, #PCB_ONFAULT]
418 * subyte(caddr_t uaddr, char x);
419 * Store a byte in the user's address space.
423 #ifdef MULTIPROCESSOR
424 stmfd sp!, {r0, r1, r14}
425 bl _C_LABEL(cpu_number)
427 ldr r2, [r2, r0, lsl #2]
428 ldr r2, [r2, #CI_CURPCB]
429 ldmfd sp!, {r0, r1, r14}
442 str r3, [r2, #PCB_ONFAULT]
446 str r0, [r2, #PCB_ONFAULT]