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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-or32/] [system.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
2
 * Based on:
3
 * include/asm-ppc/system.h
4
 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
5
 */
6
#ifndef __OR32_SYSTEM_H
7
#define __OR32_SYSTEM_H
8
 
9
#include <linux/config.h>
10
#include <linux/kdev_t.h>
11
 
12
#include <asm/processor.h>
13
 
14
/* Memory bariers */
15
#define mb()  __asm__ __volatile__ ("" : : : "memory")
16
#define rmb()  __asm__ __volatile__ ("" : : : "memory")
17
#define wmb()  __asm__ __volatile__ ("" : : : "memory")
18
 
19
#define set_mb(var, value)      do { var = value; mb(); } while (0)
20
#define set_wmb(var, value)     do { var = value; wmb(); } while (0)
21
 
22
#define smp_mb()        __asm__ __volatile__("": : :"memory")
23
#define smp_rmb()       __asm__ __volatile__("": : :"memory")
24
#define smp_wmb()       __asm__ __volatile__("": : :"memory")
25
 
26
#define nop() __asm__ __volatile__ ("l.nop"::)
27
 
28
#ifdef __KERNEL__
29
 
30
struct task_struct;
31
struct thread_struct;
32
extern unsigned int rtas_data;
33
struct pt_regs;
34
 
35
int printk(const char *, ...);
36
extern void show_regs(struct pt_regs * regs);
37
 
38
extern void __save_flags(unsigned long *flags);
39
extern void __restore_flags(unsigned long flags);
40
extern void __save_and_cli(unsigned long *flags);
41
extern void __sti(void);
42
extern void __cli(void);
43
extern void __mtspr(unsigned long add, unsigned long val);
44
extern unsigned long __mfspr(unsigned long add);
45
 
46
#define cli()   __cli()
47
#define sti()   __sti()
48
#define save_flags(flags)       __save_flags(&(flags))
49
#define restore_flags(flags)    __restore_flags(flags)
50
#define save_and_cli(flags)     __save_and_cli(&(flags))
51
#define mfspr(x) __mfspr(x)
52
#define mtspr(x,y) __mtspr(x,y)
53
 
54
#define local_irq_disable()             __cli()
55
#define local_irq_enable()              __sti()
56
#define local_irq_save(flags)           __save_and_cli(&(flags))
57
#define local_irq_restore(flags)        __restore_flags(flags)
58
 
59
#define prepare_to_switch()     do { } while(0)
60
#define switch_to(prev,next,last) _switch_to((prev),(next),&(last))
61
 
62
extern void _switch_to(struct task_struct *, struct task_struct *,
63
                       struct task_struct **);
64
 
65
struct thread_struct;
66
extern struct task_struct *_switch(struct thread_struct *prev,
67
                                   struct thread_struct *next);
68
 
69
struct __xchg_dummy { unsigned long a[100]; };
70
#define __xg(x) ((volatile struct __xchg_dummy *)(x))
71
#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
72
#define tas(ptr) (xchg((ptr),1))
73
 
74
static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
75
{
76
  unsigned long tmp, flags;
77
 
78
  save_and_cli(flags);
79
 
80
  switch (size) {
81
  case 1:
82
    __asm__ __volatile__
83
    ("l.lbz %0,%2\n\t"
84
     "l.sb %2,%1"
85
    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
86
    break;
87
  case 2:
88
    __asm__ __volatile__
89
    ("l.lhz %0,%2\n\t"
90
     "l.sh %2,%1"
91
    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
92
    break;
93
  case 4:
94
    __asm__ __volatile__
95
    ("l.lwz %0,%2\n\t"
96
     "l.sw %2,%1"
97
    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
98
    break;
99
  }
100
 
101
  restore_flags(flags);
102
  return tmp;
103
}
104
 
105
extern inline void * xchg_ptr(void * m, void * val)
106
{
107
        return (void *) __xchg((unsigned long)m, val, sizeof(unsigned long));
108
}
109
 
110
/*
111
 * debugging aid
112
 */
113
extern void __print(const char *fmt, ...);
114
 
115
#endif /* __KERNEL__ */
116
#endif /* __OR32_SYSTEM_H */

powered by: WebSVN 2.1.0

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