1/* Copyright 2013-2014 IBM Corp. 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 * implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <asm-utils.h> 18#include <asm-offsets.h> 19#include <processor.h> 20 21 .section ".text","ax" 22 .balign 0x10 23 24 /* bool try_lock(struct lock *lock) */ 25.global __try_lock 26__try_lock: 27 ld %r0,0(%r3) 28 andi. %r10,%r0,1 29 bne 2f 30 lwz %r9,CPUTHREAD_PIR(%r13) 311: ldarx %r0,0,%r3 32 andi. %r10,%r0,1 33 bne- 2f 34 ori %r0,%r0,1 35 rldimi %r0,%r9,32,0 36 stdcx. %r0,0,%r3 37 bne 1b 38 sync 39 li %r3,-1 40 blr 412: li %r3,0 42 blr 43 44