Changeset 86b31ba9 in mainline


Ignore:
Timestamp:
2006-09-26T16:12:38Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a9ac978
Parents:
26678e5
Message:

Implement spinlock and test_and_set for sparc64.

Location:
kernel/arch/sparc64/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/include/atomic.h

    r26678e5 r86b31ba9  
    3636#define KERN_sparc64_ATOMIC_H_
    3737
     38#include <arch/barrier.h>
    3839#include <arch/types.h>
    3940#include <typedefs.h>
     
    9394}
    9495
     96static inline long test_and_set(atomic_t *val)
     97{
     98        uint64_t v = 1;
     99
     100        __asm__ volatile ("casx %0, %2, %1\n" : "+m" (*val), "+r" (v) : "r" (0));
     101
     102        return v;
     103}
     104
     105static inline void atomic_lock_arch(atomic_t *val)
     106{
     107        uint64_t tmp1 = 1;
     108        uint64_t tmp2;
     109
     110        __asm__ volatile (
     111        "0:\n"
     112                "casx %0, %3, %1\n"
     113                "brz %1, 2f\n"
     114                "nop\n"
     115        "1:\n"
     116                "ldx %0, %2\n"
     117                "brz %2, 0b\n"
     118                "nop\n"
     119                "ba 1b\n"
     120                "nop\n"
     121        "2:\n"
     122                : "+m" (*val), "+r" (tmp1), "+r" (tmp2) : "r" (0)
     123        );
     124       
     125        /*
     126         * Prevent critical section code from bleeding out this way up.
     127         */
     128        CS_ENTER_BARRIER();
     129}
     130
    95131#endif
    96132
  • kernel/arch/sparc64/include/barrier.h

    r26678e5 r86b31ba9  
    3737
    3838/*
    39  * TODO: Implement true SPARC V9 memory barriers for macros below.
     39 * We assume TSO memory model in which only reads can pass earlier stores
     40 * (but not earlier reads). Therefore, CS_ENTER_BARRIER() and CS_LEAVE_BARRIER()
     41 * can be empty.
    4042 */
    4143#define CS_ENTER_BARRIER()      __asm__ volatile ("" ::: "memory")
Note: See TracChangeset for help on using the changeset viewer.