xref: /openbmc/linux/arch/x86/lib/cmpxchg8b_emu.S (revision 82e6fdd6)
1/*
2 *	This program is free software; you can redistribute it and/or
3 *	modify it under the terms of the GNU General Public License
4 *	as published by the Free Software Foundation; version 2
5 *	of the License.
6 *
7 */
8
9#include <linux/linkage.h>
10#include <asm/export.h>
11
12.text
13
14/*
15 * Inputs:
16 * %esi : memory location to compare
17 * %eax : low 32 bits of old value
18 * %edx : high 32 bits of old value
19 * %ebx : low 32 bits of new value
20 * %ecx : high 32 bits of new value
21 */
22ENTRY(cmpxchg8b_emu)
23
24#
25# Emulate 'cmpxchg8b (%esi)' on UP except we don't
26# set the whole ZF thing (caller will just compare
27# eax:edx with the expected value)
28#
29	pushfl
30	cli
31
32	cmpl  (%esi), %eax
33	jne .Lnot_same
34	cmpl 4(%esi), %edx
35	jne .Lhalf_same
36
37	movl %ebx,  (%esi)
38	movl %ecx, 4(%esi)
39
40	popfl
41	ret
42
43.Lnot_same:
44	movl  (%esi), %eax
45.Lhalf_same:
46	movl 4(%esi), %edx
47
48	popfl
49	ret
50
51ENDPROC(cmpxchg8b_emu)
52EXPORT_SYMBOL(cmpxchg8b_emu)
53