opensolaris_atomic.S revision 170431
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 .ident "%Z%%M% %I% %E% SMI" 28 29 .file "%M%" 30 31#define _ASM 32#include <sys/asm_linkage.h> 33 34 ENTRY(atomic_add_64) 35 ALTENTRY(atomic_add_64_nv) 36 pushl %edi 37 pushl %ebx 38 movl 12(%esp), %edi // %edi = target address 39 movl (%edi), %eax 40 movl 4(%edi), %edx // %edx:%eax = old value 411: 42 movl 16(%esp), %ebx 43 movl 20(%esp), %ecx // %ecx:%ebx = delta 44 addl %eax, %ebx 45 adcl %edx, %ecx // %ecx:%ebx = new value 46 lock 47 cmpxchg8b (%edi) // try to stick it in 48 jne 1b 49 movl %ebx, %eax 50 movl %ecx, %edx // return new value 51 popl %ebx 52 popl %edi 53 ret 54 SET_SIZE(atomic_add_64_nv) 55 SET_SIZE(atomic_add_64) 56 57 ENTRY(atomic_or_8_nv) 58 movl 4(%esp), %edx // %edx = target address 59 movb (%edx), %al // %al = old value 601: 61 movl 8(%esp), %ecx // %ecx = delta 62 orb %al, %cl // %cl = new value 63 lock 64 cmpxchgb %cl, (%edx) // try to stick it in 65 jne 1b 66 movzbl %cl, %eax // return new value 67 ret 68 SET_SIZE(atomic_or_8_nv) 69 70 ENTRY(atomic_cas_ptr) 71 movl 4(%esp), %edx 72 movl 8(%esp), %eax 73 movl 12(%esp), %ecx 74 lock 75 cmpxchgl %ecx, (%edx) 76 ret 77 SET_SIZE(atomic_cas_ptr) 78 79 ENTRY(atomic_cas_64) 80 pushl %ebx 81 pushl %esi 82 movl 12(%esp), %esi 83 movl 16(%esp), %eax 84 movl 20(%esp), %edx 85 movl 24(%esp), %ebx 86 movl 28(%esp), %ecx 87 lock 88 cmpxchg8b (%esi) 89 popl %esi 90 popl %ebx 91 ret 92 SET_SIZE(atomic_cas_64) 93 94 ENTRY(membar_producer) 95 lock 96 xorl $0, (%esp) 97 ret 98 SET_SIZE(membar_producer) 99