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.
58 /* XXX Probably not appropriate for non-Hydra SMPs */
60 bl _C_LABEL(cpu_number)
62 ldr r2, [r2, r0, lsl #2]
63 ldr r2, [r2, #CI_CURPCB]
75 adr r4, .Lcasuwordfault
76 str r4, [r3, #PCB_ONFAULT]
84 str r1, [r3, #PCB_ONFAULT]
88 * Handle faults from casuword. Clean up and return -1.
93 str r0, [r3, #PCB_ONFAULT]
98 * fuword(caddr_t uaddr);
99 * Fetch an int from the user's address space.
104 #ifdef MULTIPROCESSOR
105 /* XXX Probably not appropriate for non-Hydra SMPs */
107 bl _C_LABEL(cpu_number)
109 ldr r2, [r2, r0, lsl #2]
110 ldr r2, [r2, #CI_CURPCB]
123 str r1, [r2, #PCB_ONFAULT]
128 str r1, [r2, #PCB_ONFAULT]
133 * fusword(caddr_t uaddr);
134 * Fetch a short from the user's address space.
138 #ifdef MULTIPROCESSOR
139 /* XXX Probably not appropriate for non-Hydra SMPs */
141 bl _C_LABEL(cpu_number)
143 ldr r2, [r2, r0, lsl #2]
144 ldr r2, [r2, #CI_CURPCB]
157 str r1, [r2, #PCB_ONFAULT]
162 orr r0, ip, r3, asl #8
164 orr r0, r3, ip, asl #8
167 str r1, [r2, #PCB_ONFAULT]
171 * fuswintr(caddr_t uaddr);
172 * Fetch a short from the user's address space. Can be called during an
177 ldr r2, Lblock_userspace_access
180 mvnne r0, #0x00000000
183 #ifdef MULTIPROCESSOR
184 /* XXX Probably not appropriate for non-Hydra SMPs */
186 bl _C_LABEL(cpu_number)
188 ldr r2, [r2, r0, lsl #2]
189 ldr r2, [r2, #CI_CURPCB]
201 adr r1, _C_LABEL(fusubailout)
202 str r1, [r2, #PCB_ONFAULT]
207 orr r0, ip, r3, asl #8
209 orr r0, r3, ip, asl #8
213 str r1, [r2, #PCB_ONFAULT]
216 Lblock_userspace_access:
217 .word _C_LABEL(block_userspace_access)
221 .global _C_LABEL(block_userspace_access)
222 _C_LABEL(block_userspace_access):
227 * fubyte(caddr_t uaddr);
228 * Fetch a byte from the user's address space.
232 #ifdef MULTIPROCESSOR
233 /* XXX Probably not appropriate for non-Hydra SMPs */
235 bl _C_LABEL(cpu_number)
237 ldr r2, [r2, r0, lsl #2]
238 ldr r2, [r2, #CI_CURPCB]
251 str r1, [r2, #PCB_ONFAULT]
256 str r1, [r2, #PCB_ONFAULT]
261 * Handle faults from [fs]u*(). Clean up and return -1.
266 str r0, [r2, #PCB_ONFAULT]
271 * Handle faults from [fs]u*(). Clean up and return -1. This differs from
272 * fusufault() in that trap() will recognise it and return immediately rather
273 * than trying to page fault.
276 /* label must be global as fault.c references it */
277 .global _C_LABEL(fusubailout)
278 _C_LABEL(fusubailout):
280 str r0, [r2, #PCB_ONFAULT]
286 * Handle earlier faults from [fs]u*(), due to no pcb
291 adr r0, fusupcbfaulttext
295 .asciz "Yikes - no valid PCB during fusuxxx() addr=%08x\n"
300 * suword(caddr_t uaddr, int x);
301 * Store an int in the user's address space.
306 #ifdef MULTIPROCESSOR
307 /* XXX Probably not appropriate for non-Hydra SMPs */
308 stmfd sp!, {r0, r1, r14}
309 bl _C_LABEL(cpu_number)
311 ldr r2, [r2, r0, lsl #2]
312 ldr r2, [r2, #CI_CURPCB]
313 ldmfd sp!, {r0, r1, r14}
325 str r3, [r2, #PCB_ONFAULT]
330 str r0, [r2, #PCB_ONFAULT]
334 * suswintr(caddr_t uaddr, short x);
335 * Store a short in the user's address space. Can be called during an
340 ldr r2, Lblock_userspace_access
343 mvnne r0, #0x00000000
346 #ifdef MULTIPROCESSOR
347 stmfd sp!, {r0, r1, r14}
348 bl _C_LABEL(cpu_number)
350 ldr r2, [r2, r0, lsl #2]
351 ldr r2, [r2, #CI_CURPCB]
352 ldmfd sp!, {r0, r1, r14}
363 adr r3, _C_LABEL(fusubailout)
364 str r3, [r2, #PCB_ONFAULT]
376 str r0, [r2, #PCB_ONFAULT]
380 * susword(caddr_t uaddr, short x);
381 * Store a short in the user's address space.
385 #ifdef MULTIPROCESSOR
386 stmfd sp!, {r0, r1, r14}
387 bl _C_LABEL(cpu_number)
389 ldr r2, [r2, r0, lsl #2]
390 ldr r2, [r2, #CI_CURPCB]
391 ldmfd sp!, {r0, r1, r14}
403 str r3, [r2, #PCB_ONFAULT]
415 str r0, [r2, #PCB_ONFAULT]
419 * subyte(caddr_t uaddr, char x);
420 * Store a byte in the user's address space.
424 #ifdef MULTIPROCESSOR
425 stmfd sp!, {r0, r1, r14}
426 bl _C_LABEL(cpu_number)
428 ldr r2, [r2, r0, lsl #2]
429 ldr r2, [r2, #CI_CURPCB]
430 ldmfd sp!, {r0, r1, r14}
443 str r3, [r2, #PCB_ONFAULT]
447 str r0, [r2, #PCB_ONFAULT]