1/* This is a generated file. DO NOT EDIT. */
2/*
3 * Generated from:
4 *
5 *	OpenBSD: bcopy.m4
6 */
7/*
8 * Copyright (c) 1999 Michael Shalayeff
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33
34
35#undef _LOCORE
36#define _LOCORE
37#include <machine/asm.h>
38#include <machine/frame.h>
39
40
41#ifdef _KERNEL
42#include <assym.h>
43
44/*
45 * int spcopy (pa_space_t ssp, const void *src, pa_space_t dsp, void *dst,
46 *              size_t size)
47 * do a space to space bcopy.
48 *
49 * assumes that spaces do not clash, otherwise we lose
50 */
51	.import	copy_on_fault, code
52
53LEAF_ENTRY(spcopy)
54	ldw	HPPA_FRAME_ARG(4)(sp), ret0
55	sub,<>	r0, ret0, r0
56	bv	r0(rp)
57	nop
58
59	ldo	64(sp), sp
60	stw	rp, HPPA_FRAME_CRP(sp)
61	/* setup fault handler */
62	mfctl	cr29, t1
63	ldw	CI_CURPROC(t1), t3
64	ldil	L%copy_on_fault, t2
65	ldw	P_ADDR(t3), r2
66	ldo	R%copy_on_fault(t2), t2
67	ldw	PCB_ONFAULT+U_PCB(r2), r1
68	stw	t2, PCB_ONFAULT+U_PCB(r2)
69
70	mtsp	arg0, sr1
71	mtsp	arg2, sr2
72
73
74	comib,>=,n 15, ret0, $spcopy.byte
75
76	extru	arg1, 31, 2, t3
77	extru	arg3, 31, 2, t4
78	add	ret0, t4, ret0
79	comb,<> t3, t4, $spcopy.unaligned
80	dep	r0, 31, 2, arg1
81
82	addi	-16, ret0, ret0
83$spcopy.loop16a
84	ldws,ma	4(sr1, arg1), t1
85	ldws,ma	4(sr1, arg1), t2
86	ldws,ma	4(sr1, arg1), t3
87	ldws,ma	4(sr1, arg1), t4
88	stbys,b,m t1, 4(sr2, arg3)
89	stws,ma	t2, 4(sr2, arg3)
90	stws,ma	t3, 4(sr2, arg3)
91	addib,>= -16, ret0, $spcopy.loop16a
92	stws,ma	t4, 4(sr2, arg3)
93
94	addib,<,n 12, ret0, $spcopy.cleanup
95$spcopy.word
96	ldws,ma	4(sr1, arg1), t1
97	addib,>= -4, ret0, $spcopy.word
98	stws,ma	t1, 4(sr2, arg3)
99
100$spcopy.cleanup
101	addib,=,n 4, ret0, $spcopy.done
102	ldws	0(sr1, arg1), t1
103	add	arg3, ret0, arg3
104	b	$spcopy.done
105	stbys,e	t1, 0(sr2, arg3)
106
107$spcopy.unaligned
108	sub,>=	t4, t3, t2
109	ldwm	4(sr1, arg1), ret1
110	zdep	t2, 28, 29, t1
111	mtsar	t1
112
113	addi	-16, ret0, ret0
114$spcopy.loop16u
115	ldws,ma	4(sr1, arg1), t1
116	ldws,ma	4(sr1, arg1), t2
117	ldws,ma	4(sr1, arg1), t3
118	ldws,ma	4(sr1, arg1), t4
119	vshd	ret1, t1, r31
120	stbys,b,m r31, 4(sr2, arg3)
121	vshd	t1, t2, r31
122	stws,ma	r31, 4(sr2, arg3)
123	vshd	t2, t3, r31
124	stws,ma	r31, 4(sr2, arg3)
125	vshd	t3, t4, r31
126	stws,ma	r31, 4(sr2, arg3)
127	addib,>= -16, ret0, $spcopy.loop16u
128	copy	t4, ret1
129
130	addib,<,n 12, ret0, $spcopy.cleanup_un
131$spcopy.word_un
132	ldws,ma	4(sr1, arg1), t1
133	vshd	ret1, t1, t2
134	addib,<	-4, ret0, $spcopy.cleanup1_un
135	stws,ma	t2, 4(sr2, arg3)
136	ldws,ma	4(sr1, arg1), ret1
137	vshd	t1, ret1, t2
138	addib,>= -4, ret0, $spcopy.word_un
139	stws,ma	t2, 4(sr2, arg3)
140
141$spcopy.cleanup_un
142	addib,<=,n 4, ret0, $spcopy.done
143	mfctl	sar, t4
144	add	arg3, ret0, arg3
145	extru	t4, 28, 2, t4
146	sub,<=	ret0, t4, r0
147	ldws,ma	4(sr1, arg1), t1
148	vshd	ret1, t1, t2
149	b	$spcopy.done
150	stbys,e	t2, 0(sr2, arg3)
151
152$spcopy.cleanup1_un
153	b	$spcopy.cleanup_un
154	copy	t1, ret1
155
156$spcopy.byte
157	comb,>=,n r0, ret0, $spcopy.done
158$spcopy.byte_loop
159	ldbs,ma	1(sr1, arg1), t1
160	addib,<> -1, ret0, $spcopy.byte_loop
161	stbs,ma	t1, 1(sr2, arg3)
162$spcopy.done
163
164
165	mtsp	r0, sr1
166	mtsp	r0, sr2
167	/* reset fault handler */
168	stw	r1, PCB_ONFAULT+U_PCB(r2)
169	ldw	HPPA_FRAME_CRP(sp), rp
170	ldo	-64(sp), sp
171	bv	0(rp)
172	copy	r0, ret0
173EXIT(spcopy)
174#endif
175
176	.end
177