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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-sparc/] [smp_lock.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/* 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
#include <asm/smp.h>
10
#include <asm/bitops.h>
11
#include <asm/atops.h>
12
#include <asm/pgtable.h>
13
 
14
#ifdef __SMP__
15
 
16
/*
17
 *      Locking the kernel
18
 */
19
 
20
/* Knock knock... */
21
extern __inline void lock_kernel(void)
22
{
23
        unsigned long flags;
24
        int proc = smp_processor_id();
25
 
26
        save_flags(flags); cli(); /* need this on sparc? */
27
        while(ldstub(&kernel_flag)) {
28
                if(proc == active_kernel_processor)
29
                        break;
30
                do {
31
#ifdef __SMP_PROF__             
32
                        smp_spins[smp_processor_id()]++;
33
#endif                  
34
                        barrier();
35
                } while(kernel_flag); /* Don't lock the bus more than we have to. */
36
        }
37
        active_kernel_processor = proc;
38
        kernel_counter++;
39
        restore_flags(flags);
40
}
41
 
42
/* I want out... */
43
extern __inline void unlock_kernel(void)
44
{
45
        unsigned long flags;
46
 
47
        save_flags(flags); cli(); /* need this on sparc? */
48
        if(kernel_counter == 0)
49
                panic("Bogus kernel counter.\n");
50
 
51
        if(!--kernel_counter) {
52
                active_kernel_processor = NO_PROC_ID;
53
                kernel_flag = KLOCK_CLEAR;
54
        }
55
        restore_flags(flags);
56
}
57
 
58
#endif /* !(__SPARC_SMPLOCK_H) */
59
 
60
#endif /* (__SMP__) */

powered by: WebSVN 2.1.0

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