blob: 1eb7d298b47d5466d39e1f0ae8804dc4ebe172bb [file] [log] [blame]
H. Peter Anvin5be86562007-07-11 12:18:41 -07001/* ----------------------------------------------------------------------- *
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
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030011#include <linux/linkage.h>
12
H. Peter Anvin5be86562007-07-11 12:18:41 -070013/*
H. Peter Anvin5be86562007-07-11 12:18:41 -070014 * Memory copy routines
15 */
16
David Woodhousee24df922014-01-03 22:30:42 +000017 .code16
H. Peter Anvin5be86562007-07-11 12:18:41 -070018 .text
19
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030020GLOBAL(memcpy)
H. Peter Anvin5be86562007-07-11 12:18:41 -070021 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
David Woodhousee24df922014-01-03 22:30:42 +000033 retl
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030034ENDPROC(memcpy)
H. Peter Anvin5be86562007-07-11 12:18:41 -070035
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030036GLOBAL(memset)
H. Peter Anvin5be86562007-07-11 12:18:41 -070037 pushw %di
38 movw %ax, %di
39 movzbl %dl, %eax
40 imull $0x01010101,%eax
41 pushw %cx
42 shrw $2, %cx
43 rep; stosl
44 popw %cx
45 andw $3, %cx
46 rep; stosb
47 popw %di
David Woodhousee24df922014-01-03 22:30:42 +000048 retl
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030049ENDPROC(memset)
H. Peter Anvin5be86562007-07-11 12:18:41 -070050
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030051GLOBAL(copy_from_fs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070052 pushw %ds
53 pushw %fs
54 popw %ds
David Woodhousee24df922014-01-03 22:30:42 +000055 calll memcpy
H. Peter Anvin5be86562007-07-11 12:18:41 -070056 popw %ds
David Woodhousee24df922014-01-03 22:30:42 +000057 retl
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030058ENDPROC(copy_from_fs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070059
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030060GLOBAL(copy_to_fs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070061 pushw %es
62 pushw %fs
63 popw %es
David Woodhousee24df922014-01-03 22:30:42 +000064 calll memcpy
H. Peter Anvin5be86562007-07-11 12:18:41 -070065 popw %es
David Woodhousee24df922014-01-03 22:30:42 +000066 retl
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030067ENDPROC(copy_to_fs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070068
69#if 0 /* Not currently used, but can be enabled as needed */
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030070GLOBAL(copy_from_gs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070071 pushw %ds
72 pushw %gs
73 popw %ds
David Woodhousee24df922014-01-03 22:30:42 +000074 calll memcpy
H. Peter Anvin5be86562007-07-11 12:18:41 -070075 popw %ds
David Woodhousee24df922014-01-03 22:30:42 +000076 retl
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030077ENDPROC(copy_from_gs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070078
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030079GLOBAL(copy_to_gs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070080 pushw %es
81 pushw %gs
82 popw %es
David Woodhousee24df922014-01-03 22:30:42 +000083 calll memcpy
H. Peter Anvin5be86562007-07-11 12:18:41 -070084 popw %es
David Woodhousee24df922014-01-03 22:30:42 +000085 retl
Cyrill Gorcunov2f795552009-02-14 00:50:20 +030086ENDPROC(copy_to_gs)
H. Peter Anvin5be86562007-07-11 12:18:41 -070087#endif