Ignore:
File:
1 edited

Legend:

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

    r7a0359b rc00589d  
    3636#define KERN_amd64_ATOMIC_H_
    3737
    38 #include <typedefs.h>
     38#include <arch/types.h>
    3939#include <arch/barrier.h>
    4040#include <preemption.h>
    41 #include <trace.h>
    4241
    43 NO_TRACE static inline void atomic_inc(atomic_t *val)
    44 {
     42static inline void atomic_inc(atomic_t *val) {
    4543#ifdef CONFIG_SMP
    4644        asm volatile (
     
    5654}
    5755
    58 NO_TRACE static inline void atomic_dec(atomic_t *val)
    59 {
     56static inline void atomic_dec(atomic_t *val) {
    6057#ifdef CONFIG_SMP
    6158        asm volatile (
     
    7168}
    7269
    73 NO_TRACE static inline atomic_count_t atomic_postinc(atomic_t *val)
     70static inline long atomic_postinc(atomic_t *val)
    7471{
    75         atomic_count_t r = 1;
     72        long r = 1;
    7673       
    7774        asm volatile (
    7875                "lock xaddq %[r], %[count]\n"
    79                 : [count] "+m" (val->count),
    80                   [r] "+r" (r)
     76                : [count] "+m" (val->count), [r] "+r" (r)
    8177        );
    8278       
     
    8480}
    8581
    86 NO_TRACE static inline atomic_count_t atomic_postdec(atomic_t *val)
     82static inline long atomic_postdec(atomic_t *val)
    8783{
    88         atomic_count_t r = -1;
     84        long r = -1;
    8985       
    9086        asm volatile (
    9187                "lock xaddq %[r], %[count]\n"
    92                 : [count] "+m" (val->count),
    93                   [r] "+r" (r)
     88                : [count] "+m" (val->count), [r] "+r" (r)
    9489        );
    9590       
     
    10095#define atomic_predec(val)  (atomic_postdec(val) - 1)
    10196
    102 NO_TRACE static inline atomic_count_t test_and_set(atomic_t *val)
    103 {
    104         atomic_count_t v = 1;
     97static inline uint64_t test_and_set(atomic_t *val) {
     98        uint64_t v;
    10599       
    106100        asm volatile (
     101                "movq $1, %[v]\n"
    107102                "xchgq %[v], %[count]\n"
    108                 : [v] "+r" (v),
    109                   [count] "+m" (val->count)
     103                : [v] "=r" (v), [count] "+m" (val->count)
    110104        );
    111105       
     
    113107}
    114108
     109
    115110/** amd64 specific fast spinlock */
    116 NO_TRACE static inline void atomic_lock_arch(atomic_t *val)
     111static inline void atomic_lock_arch(atomic_t *val)
    117112{
    118         atomic_count_t tmp;
     113        uint64_t tmp;
    119114       
    120115        preemption_disable();
    121116        asm volatile (
    122117                "0:\n"
    123                 "       pause\n"
    124                 "       mov %[count], %[tmp]\n"
    125                 "       testq %[tmp], %[tmp]\n"
    126                 "       jnz 0b\n"       /* lightweight looping on locked spinlock */
     118                "pause\n"
     119                "mov %[count], %[tmp]\n"
     120                "testq %[tmp], %[tmp]\n"
     121                "jnz 0b\n"       /* lightweight looping on locked spinlock */
    127122               
    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)
     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)
    134128        );
    135        
    136129        /*
    137130         * Prevent critical section code from bleeding out this way up.
Note: See TracChangeset for help on using the changeset viewer.