xref: /openbmc/linux/arch/x86/boot/copy.S (revision 643d1f7f)
1/* ----------------------------------------------------------------------- *
2 *
3 *   Copyright (C) 1991, 1992 Linus Torvalds
4 *   Copyright 2007 rPath, Inc. - All Rights Reserved
5 *
6 *   This file is part of the Linux kernel, and is made available under
7 *   the terms of the GNU General Public License version 2.
8 *
9 * ----------------------------------------------------------------------- */
10
11/*
12 * arch/i386/boot/copy.S
13 *
14 * Memory copy routines
15 */
16
17	.code16gcc
18	.text
19
20	.globl	memcpy
21	.type	memcpy, @function
22memcpy:
23	pushw	%si
24	pushw	%di
25	movw	%ax, %di
26	movw	%dx, %si
27	pushw	%cx
28	shrw	$2, %cx
29	rep; movsl
30	popw	%cx
31	andw	$3, %cx
32	rep; movsb
33	popw	%di
34	popw	%si
35	ret
36	.size	memcpy, .-memcpy
37
38	.globl	memset
39	.type	memset, @function
40memset:
41	pushw	%di
42	movw	%ax, %di
43	movzbl	%dl, %eax
44	imull	$0x01010101,%eax
45	pushw	%cx
46	shrw	$2, %cx
47	rep; stosl
48	popw	%cx
49	andw	$3, %cx
50	rep; stosb
51	popw	%di
52	ret
53	.size	memset, .-memset
54
55	.globl	copy_from_fs
56	.type	copy_from_fs, @function
57copy_from_fs:
58	pushw	%ds
59	pushw	%fs
60	popw	%ds
61	call	memcpy
62	popw	%ds
63	ret
64	.size	copy_from_fs, .-copy_from_fs
65
66	.globl	copy_to_fs
67	.type	copy_to_fs, @function
68copy_to_fs:
69	pushw	%es
70	pushw	%fs
71	popw	%es
72	call	memcpy
73	popw	%es
74	ret
75	.size	copy_to_fs, .-copy_to_fs
76
77#if 0 /* Not currently used, but can be enabled as needed */
78
79	.globl	copy_from_gs
80	.type	copy_from_gs, @function
81copy_from_gs:
82	pushw	%ds
83	pushw	%gs
84	popw	%ds
85	call	memcpy
86	popw	%ds
87	ret
88	.size	copy_from_gs, .-copy_from_gs
89	.globl	copy_to_gs
90
91	.type	copy_to_gs, @function
92copy_to_gs:
93	pushw	%es
94	pushw	%gs
95	popw	%es
96	call	memcpy
97	popw	%es
98	ret
99	.size	copy_to_gs, .-copy_to_gs
100
101#endif
102