OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [libl4/] [src/] [arch/] [or1k/] [v7/] [mutex.S.ARM] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Copyright (C) 2009 Bahadir Balban
3
 */
4
 
5
#include 
6
#include 
7
 
8
/*
9
 * @r0 = address of mutex word
10
 */
11
BEGIN_PROC(__l4_mutex_lock)
12
1:
13
        ldrex   r1, [r0]                        @ Load value
14
        add     r1, r1, #1                      @ Add 1
15
        strex   r3, r1, [r0]                    @ Store prospective lock state
16
        cmp     r3, #0                          @ If not successful
17
        bne     1b                              @ Retry and decide again on the prospective lock state. No WFE as this would be a problem on single cpu
18
        dsb
19
 
20
        cmp     r1, #L4_MUTEX_LOCKED            @ We succeeded in store, but are we a locker or a contender?
21
        movne   r2, #L4_MUTEX_CONTENDED
22
        moveq   r2, #L4_MUTEX_SUCCESS
23
        mov     r0, r2
24
        mov     pc, lr
25
END_PROC(__l4_mutex_lock)
26
 
27
/*
28
 * @r0 = address of mutex word
29
 */
30
BEGIN_PROC(__l4_mutex_unlock)
31
        dsb
32
        mov     r3, #L4_MUTEX_UNLOCKED
33
1:
34
        ldrex   r1, [r0]
35
        strex   r2, r3, [r0]
36
        cmp     r2, #0
37
        bne     1b
38
        mov     r0, r1
39
        mov     pc, lr
40
END_PROC(__l4_mutex_unlock)
41
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.