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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [proc-trio/] [semaphore.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/semaphore.h
3
 */
4
#ifndef __ASM_PROC_SEMAPHORE_H
5
#define __ASM_PROC_SEMAPHORE_H
6
 
7
/*
8
 * This is ugly, but we want the default case to fall through.
9
 * "__down" is the actual routine that waits...
10
 */
11
extern inline void down(struct semaphore * sem)
12
{
13
        __asm__ __volatile__ ("
14
        @ atomic down operation
15
        mrs     r0, cpsr
16
        orr     r1, r0, #128            @ disable IRQs
17
        bic     r0, r0, #0x80000000     @ clear N
18
        msr     cpsr, r1
19
        ldr     r1, [%0]
20
        subs    r1, r1, #1
21
        str     r1, [%0]
22
        orrmi   r0, r0, #0x80000000     @ set N
23
        msr     cpsr, r0
24
        movmi   r0, %0
25
        blmi    " SYMBOL_NAME_STR(__down)
26
                : : "r" (sem) : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
27
}
28
 
29
/*
30
 * This is ugly, but we want the default case to fall through.
31
 * "__down_interruptible" is the actual routine that waits...
32
 */
33
extern inline int down_interruptible (struct semaphore * sem)
34
{
35
        int result;
36
        __asm__ __volatile__ ("
37
        @ atomic down operation
38
        mrs     r0, cpsr
39
        orr     r1, r0, #128            @ disable IRQs
40
        bic     r0, r0, #0x80000000     @ clear N
41
        msr     cpsr, r1
42
        ldr     r1, [%1]
43
        subs    r1, r1, #1
44
        str     r1, [%1]
45
        orrmi   r0, r0, #0x80000000     @ set N
46
        msr     cpsr, r0
47
        movmi   r0, %1
48
        movpl   r0, #0
49
        blmi    " SYMBOL_NAME_STR(__down_interruptible) "
50
        mov     %0, r0"
51
                : "=r" (result)
52
                : "r" (sem)
53
                : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
54
        return result;
55
}
56
 
57
/*
58
 * Note! This is subtle. We jump to wake people up only if
59
 * the semaphore was negative (== somebody was waiting on it).
60
 * The default case (no contention) will result in NO
61
 * jumps for both down() and up().
62
 */
63
extern inline void up(struct semaphore * sem)
64
{
65
        __asm__ __volatile__ ("
66
        @ atomic up operation
67
        mrs     r0, cpsr
68
        orr     r1, r0, #128            @ disable IRQs
69
        bic     r0, r0, #0x80000000     @ clear N
70
        msr     cpsr, r1
71
        ldr     r1, [%0]
72
        adds    r1, r1, #1
73
        str     r1, [%0]
74
        orrls   r0, r0, #0x80000000     @ set N
75
        msr     cpsr, r0
76
        movmi   r0, %0
77
        blmi    " SYMBOL_NAME_STR(__up)
78
                : : "r" (sem) : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
79
}
80
 
81
#endif

powered by: WebSVN 2.1.0

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