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

Subversion Repositories or1k_old

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/proc-armo/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
        mov     r0, pc
16
        orr     r1, r0, #0x08000000
17
        and     r0, r0, #0x0c000003
18
        teqp    r1, #0
19
        ldr     r1, [%0]
20
        subs    r1, r1, #1
21
        str     r1, [%0]
22
        mov     r1, pc, lsr #28
23
        teqp    r0, r1, lsl #28
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
        mov     r0, pc
39
        orr     r1, r0, #0x08000000
40
        and     r0, r0, #0x0c000003
41
        teqp    r1, #0
42
        ldr     r1, [%1]
43
        subs    r1, r1, #1
44
        str     r1, [%1]
45
        mov     r1, pc, lsr #28
46
        orrmi   r0, r0, #0x80000000     @ set N
47
        teqp    r0, r1, lsl #28
48
        movmi   r0, %1
49
        movpl   r0, #0
50
        blmi    " SYMBOL_NAME_STR(__down_interruptible) "
51
        mov     %0, r0"
52
                : "=r" (result)
53
                : "r" (sem)
54
                : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
55
        return result;
56
}
57
 
58
/*
59
 * Note! This is subtle. We jump to wake people up only if
60
 * the semaphore was negative (== somebody was waiting on it).
61
 * The default case (no contention) will result in NO
62
 * jumps for both down() and up().
63
 */
64
extern inline void up(struct semaphore * sem)
65
{
66
        __asm__ __volatile__ ("
67
        @ atomic up operation
68
        mov     r0, pc
69
        orr     r1, r0, #0x08000000
70
        and     r0, r0, #0x0c000003
71
        teqp    r1, #0
72
        ldr     r1, [%0]
73
        adds    r1, r1, #1
74
        str     r1, [%0]
75
        mov     r1, pc, lsr #28
76
        orrls   r0, r0, #0x80000000     @ set N
77
        teqp    r0, r1, lsl #28
78
        movmi   r0, %0
79
        blmi    " SYMBOL_NAME_STR(__up)
80
                : : "r" (sem) : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
81
}
82
 
83
#endif

powered by: WebSVN 2.1.0

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