Ignore:
File:
1 edited

Legend:

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

    rc00589d r7a0359b  
    3636#define KERN_amd64_ATOMIC_H_
    3737
    38 #include <arch/types.h>
     38#include <typedefs.h>
    3939#include <arch/barrier.h>
    4040#include <preemption.h>
     41#include <trace.h>
    4142
    42 static inline void atomic_inc(atomic_t *val) {
     43NO_TRACE static inline void atomic_inc(atomic_t *val)
     44{
    4345#ifdef CONFIG_SMP
    4446        asm volatile (
     
    5456}
    5557
    56 static inline void atomic_dec(atomic_t *val) {
     58NO_TRACE static inline void atomic_dec(atomic_t *val)
     59{
    5760#ifdef CONFIG_SMP
    5861        asm volatile (
     
    6871}
    6972
    70 static inline long atomic_postinc(atomic_t *val)
     73NO_TRACE static inline atomic_count_t atomic_postinc(atomic_t *val)
    7174{
    72         long r = 1;
     75        atomic_count_t r = 1;
    7376       
    7477        asm volatile (
    7578                "lock xaddq %[r], %[count]\n"
    76                 : [count] "+m" (val->count), [r] "+r" (r)
     79                : [count] "+m" (val->count),
     80                  [r] "+r" (r)
    7781        );
    7882       
     
    8084}
    8185
    82 static inline long atomic_postdec(atomic_t *val)
     86NO_TRACE static inline atomic_count_t atomic_postdec(atomic_t *val)
    8387{
    84         long r = -1;
     88        atomic_count_t r = -1;
    8589       
    8690        asm volatile (
    8791                "lock xaddq %[r], %[count]\n"
    88                 : [count] "+m" (val->count), [r] "+r" (r)
     92                : [count] "+m" (val->count),
     93                  [r] "+r" (r)
    8994        );
    9095       
     
    95100#define atomic_predec(val)  (atomic_postdec(val) - 1)
    96101
    97 static inline uint64_t test_and_set(atomic_t *val) {
    98         uint64_t v;
     102NO_TRACE static inline atomic_count_t test_and_set(atomic_t *val)
     103{
     104        atomic_count_t v = 1;
    99105       
    100106        asm volatile (
    101                 "movq $1, %[v]\n"
    102107                "xchgq %[v], %[count]\n"
    103                 : [v] "=r" (v), [count] "+m" (val->count)
     108                : [v] "+r" (v),
     109                  [count] "+m" (val->count)
    104110        );
    105111       
     
    107113}
    108114
    109 
    110115/** amd64 specific fast spinlock */
    111 static inline void atomic_lock_arch(atomic_t *val)
     116NO_TRACE static inline void atomic_lock_arch(atomic_t *val)
    112117{
    113         uint64_t tmp;
     118        atomic_count_t tmp;
    114119       
    115120        preemption_disable();
    116121        asm volatile (
    117122                "0:\n"
    118                 "pause\n"
    119                 "mov %[count], %[tmp]\n"
    120                 "testq %[tmp], %[tmp]\n"
    121                 "jnz 0b\n"       /* lightweight looping on locked spinlock */
     123                "       pause\n"
     124                "       mov %[count], %[tmp]\n"
     125                "       testq %[tmp], %[tmp]\n"
     126                "       jnz 0b\n"       /* lightweight looping on locked spinlock */
    122127               
    123                 "incq %[tmp]\n"  /* now use the atomic operation */
    124                 "xchgq %[count], %[tmp]\n"
    125                 "testq %[tmp], %[tmp]\n"
    126                 "jnz 0b\n"
    127                 : [count] "+m" (val->count), [tmp] "=&r" (tmp)
     128                "       incq %[tmp]\n"  /* now use the atomic operation */
     129                "       xchgq %[count], %[tmp]\n"
     130                "       testq %[tmp], %[tmp]\n"
     131                "       jnz 0b\n"
     132                : [count] "+m" (val->count),
     133                  [tmp] "=&r" (tmp)
    128134        );
     135       
    129136        /*
    130137         * Prevent critical section code from bleeding out this way up.
Note: See TracChangeset for help on using the changeset viewer.