xref: /openbmc/linux/arch/x86/boot/copy.S (revision 22246614)
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 * Memory copy routines
13 */
14
15	.code16gcc
16	.text
17
18	.globl	memcpy
19	.type	memcpy, @function
20memcpy:
21	pushw	%si
22	pushw	%di
23	movw	%ax, %di
24	movw	%dx, %si
25	pushw	%cx
26	shrw	$2, %cx
27	rep; movsl
28	popw	%cx
29	andw	$3, %cx
30	rep; movsb
31	popw	%di
32	popw	%si
33	ret
34	.size	memcpy, .-memcpy
35
36	.globl	memset
37	.type	memset, @function
38memset:
39	pushw	%di
40	movw	%ax, %di
41	movzbl	%dl, %eax
42	imull	$0x01010101,%eax
43	pushw	%cx
44	shrw	$2, %cx
45	rep; stosl
46	popw	%cx
47	andw	$3, %cx
48	rep; stosb
49	popw	%di
50	ret
51	.size	memset, .-memset
52
53	.globl	copy_from_fs
54	.type	copy_from_fs, @function
55copy_from_fs:
56	pushw	%ds
57	pushw	%fs
58	popw	%ds
59	call	memcpy
60	popw	%ds
61	ret
62	.size	copy_from_fs, .-copy_from_fs
63
64	.globl	copy_to_fs
65	.type	copy_to_fs, @function
66copy_to_fs:
67	pushw	%es
68	pushw	%fs
69	popw	%es
70	call	memcpy
71	popw	%es
72	ret
73	.size	copy_to_fs, .-copy_to_fs
74
75#if 0 /* Not currently used, but can be enabled as needed */
76
77	.globl	copy_from_gs
78	.type	copy_from_gs, @function
79copy_from_gs:
80	pushw	%ds
81	pushw	%gs
82	popw	%ds
83	call	memcpy
84	popw	%ds
85	ret
86	.size	copy_from_gs, .-copy_from_gs
87	.globl	copy_to_gs
88
89	.type	copy_to_gs, @function
90copy_to_gs:
91	pushw	%es
92	pushw	%gs
93	popw	%es
94	call	memcpy
95	popw	%es
96	ret
97	.size	copy_to_gs, .-copy_to_gs
98
99#endif
100