pvcopy.S revision 1.1 1 /* $NetBSD: pvcopy.S,v 1.1 2003/04/16 13:24:10 dsl Exp $ */
2
3 /*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by David Laight.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <machine/asm.h>
40
41 /*
42 * Routines to copy to/from absolute virtual addresses.
43 * Needed because the boot code runs with %ds having a 64k offset
44 * whereas Unix runs with a zero offset.
45 *
46 * These routines are optimised for code space, not execution speed.
47 */
48
49 /*
50 * pbzero(void *dst, int cnt)
51 * zero absolute virtual memory
52 */
53 ENTRY(pbzero)
54 .code32
55 push %edi
56 push %es
57 mov 12(%esp),%edi
58 mov 16(%esp),%ecx
59
60 mov $flatdataseg, %ax /* selector with offset == 0 */
61 mov %ax, %es
62 xor %eax,%eax
63
64 cld
65 rep
66 stosb
67
68 pop %es
69 pop %edi
70 ret
71
72 /*
73 * vpbcopy(const void *src, void *dst, int cnt)
74 * Copy to absolute virtual address
75 */
76 ENTRY(vpbcopy)
77 .code32
78 push %esi
79 push %edi
80 push %es
81 mov 16(%esp),%esi
82 mov 20(%esp),%edi
83 mov 24(%esp),%ecx
84
85 mov $flatdataseg, %ax /* selector with offset == 0 */
86 mov %ax, %es
87 xor %eax,%eax
88
89 cld
90 rep
91 movsb
92
93 popl %es
94 popl %edi
95 popl %esi
96 ret
97
98 /*
99 * pvbcopy(const void *src, void *dst, int cnt)
100 * Copy from absolute virtual address
101 */
102 ENTRY(pvbcopy)
103 .code32
104 push %esi
105 push %edi
106 push %ds
107 mov 16(%esp),%esi
108 mov 20(%esp),%edi
109 mov 24(%esp),%ecx
110
111 mov $flatdataseg, %ax /* selector with offset == 0 */
112 mov %ax, %ds
113 xor %eax,%eax
114
115 cld
116 rep
117 movsb
118
119 popl %ds
120 popl %edi
121 popl %esi
122 ret
123