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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [libl4/] [src/] [arch/] [arm/] [v7/] [mutex.S.ARM] - Diff between revs 2 and 6

Show entire file | Details | Blame | View Log

Rev 2 Rev 6
?rev1line?
?rev2line?
 
/*
 
 * Copyright (C) 2009 Bahadir Balban
 
 */
 
 
 
#include 
 
#include 
 
 
 
/*
 
 * @r0 = address of mutex word
 
 */
 
BEGIN_PROC(__l4_mutex_lock)
 
1:
 
        ldrex   r1, [r0]                        @ Load value
 
        add     r1, r1, #1                      @ Add 1
 
        strex   r3, r1, [r0]                    @ Store prospective lock state
 
        cmp     r3, #0                          @ If not successful
 
        bne     1b                              @ Retry and decide again on the prospective lock state. No WFE as this would be a problem on single cpu
 
        dsb
 
 
 
        cmp     r1, #L4_MUTEX_LOCKED            @ We succeeded in store, but are we a locker or a contender?
 
        movne   r2, #L4_MUTEX_CONTENDED
 
        moveq   r2, #L4_MUTEX_SUCCESS
 
        mov     r0, r2
 
        mov     pc, lr
 
END_PROC(__l4_mutex_lock)
 
 
 
/*
 
 * @r0 = address of mutex word
 
 */
 
BEGIN_PROC(__l4_mutex_unlock)
 
        dsb
 
        mov     r3, #L4_MUTEX_UNLOCKED
 
1:
 
        ldrex   r1, [r0]
 
        strex   r2, r3, [r0]
 
        cmp     r2, #0
 
        bne     1b
 
        mov     r0, r1
 
        mov     pc, lr
 
END_PROC(__l4_mutex_unlock)
 
 

powered by: WebSVN 2.1.0

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