summaryrefslogtreecommitdiffstats
path: root/bsps/powerpc/qoriq/mpci/lock.S
blob: 4b33b4baf1a3b6910b9022d44fd9acdf5dc76e1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * @file
 *
 * @ingroup RTEMSBSPsPowerPCQorIQInterCom
 *
 * @brief qoriq_spin_lock() and qoriq_spin_unlock() implementation.
 */

/*
 * Copyright (c) 2011 embedded brains GmbH.  All rights reserved.
 *
 *  embedded brains GmbH
 *  Obere Lagerstr. 30
 *  82178 Puchheim
 *  Germany
 *  <rtems@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <libcpu/powerpc-utility.h>

	.global qoriq_spin_lock
	.global qoriq_spin_unlock

qoriq_spin_lock:
	li	r0, 1
	mfmsr	r4
	GET_INTERRUPT_MASK r5
	andc	r5, r4, r5
	b	2f
1:
	mtmsr	r4
2:
	lwarx	r6, r0, r3
	cmpwi	r6, 0
	bne	2b
	mtmsr	r5
	stwcx.	r0, r0, r3
	bne	1b
	isync
	mr	r3, r4
	blr

qoriq_spin_unlock:
	msync
	li	r0, 0
	stw	r0, 0(r3)
	mtmsr	r4
	blr