root/include/asm-sparc/smp_lock.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ldstub
  2. lock_kernel
  3. unlock_kernel

   1 /* smp_lock.h: Locking and unlocking the kernel on the Sparc.
   2  *
   3  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
   4  */
   5 
   6 #ifndef __SPARC_SMPLOCK_H
   7 #define __SPARC_SMPLOCK_H
   8 
   9 #ifdef __SMP__
  10 
  11 extern _inline_ unsigned char ldstub(klock_t *lock)
     /* [previous][next][first][last][top][bottom][index][help] */
  12 {
  13         klock_t retval;
  14 
  15         __asm__ __volatile__("ldstub [%1], %0\n\t" :
  16                              "=r" (retval) :
  17                              "r" (lock));
  18         return retval;
  19 }
  20 
  21 /* Knock knock... */
  22 extern _inline_ void lock_kernel(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24         unsigned long flags;
  25         int proc = smp_processor_id();
  26 
  27         save_flags(flags); cli(); /* need this on sparc? */
  28         while(ldstub(&kernel_lock)) {
  29                 if(proc == active_kernel_processor)
  30                         break;
  31                 if(test_bit(proc, (unsigned long *)&smp_invalidate_needed))
  32                         if(clear_bit(proc, (unsigned long *)&smp_invalidate_needed))
  33                                 local_invalidate();
  34         }
  35         active_kernel_processor = proc;
  36         kernel_counter++;
  37         restore_flags(flags);
  38 }
  39 
  40 /* I want out... */
  41 extern _inline_ void unlock_kernel(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43         unsigned long flags;
  44 
  45         save_flags(flags); cli(); /* need this on sparc? */
  46         if(kernel_counter == 0)
  47                 panic("Bogus kernel counter.\n");
  48         if(!--kernel_counter) {
  49                 active_kernel_processor = NO_PROC_ID;
  50                 kernel_lock = KLOCK_CLEAR;
  51         }
  52         restore_flag(flags);
  53 }
  54 
  55 #endif /* !(__SPARC_SMPLOCK_H) */
  56 
  57 #endif /* (__SMP__) */

/* [previous][next][first][last][top][bottom][index][help] */