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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-or32/] [system.h] - Rev 1774

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

/*
 * Based on:
 * include/asm-ppc/system.h
 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
 */
#ifndef __OR32_SYSTEM_H
#define __OR32_SYSTEM_H
 
#include <linux/config.h>
#include <linux/kdev_t.h>
 
#include <asm/processor.h>
 
/* Memory bariers */
#define mb()  __asm__ __volatile__ ("" : : : "memory")
#define rmb()  __asm__ __volatile__ ("" : : : "memory")
#define wmb()  __asm__ __volatile__ ("" : : : "memory")
 
#define set_mb(var, value)	do { var = value; mb(); } while (0)
#define set_wmb(var, value)	do { var = value; wmb(); } while (0)
 
#define smp_mb()	__asm__ __volatile__("": : :"memory")
#define smp_rmb()	__asm__ __volatile__("": : :"memory")
#define smp_wmb()	__asm__ __volatile__("": : :"memory")
 
#define nop() __asm__ __volatile__ ("l.nop"::)
 
#ifdef __KERNEL__
 
struct task_struct;
struct thread_struct;
extern unsigned int rtas_data;
struct pt_regs;
 
int printk(const char *, ...);
extern void show_regs(struct pt_regs * regs);
 
extern void __save_flags(unsigned long *flags);
extern void __restore_flags(unsigned long flags);
extern void __save_and_cli(unsigned long *flags);
extern void __sti(void);
extern void __cli(void);
extern void __mtspr(unsigned long add, unsigned long val);
extern unsigned long __mfspr(unsigned long add);
 
#define cli()	__cli()
#define sti()	__sti()
#define save_flags(flags)	__save_flags(&(flags))
#define restore_flags(flags)	__restore_flags(flags)
#define save_and_cli(flags)	__save_and_cli(&(flags))
#define mfspr(x) __mfspr(x)
#define mtspr(x,y) __mtspr(x,y)
 
#define local_irq_disable()		__cli()
#define local_irq_enable()		__sti()
#define local_irq_save(flags)		__save_and_cli(&(flags))
#define local_irq_restore(flags)	__restore_flags(flags)
 
#define prepare_to_switch()	do { } while(0)
#define switch_to(prev,next,last) _switch_to((prev),(next),&(last))
 
extern void _switch_to(struct task_struct *, struct task_struct *,
		       struct task_struct **);
 
struct thread_struct;
extern struct task_struct *_switch(struct thread_struct *prev,
				   struct thread_struct *next);
 
struct __xchg_dummy { unsigned long a[100]; };
#define __xg(x) ((volatile struct __xchg_dummy *)(x))
#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
#define tas(ptr) (xchg((ptr),1))
 
static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
{
  unsigned long tmp, flags;
 
  save_and_cli(flags);
 
  switch (size) {
  case 1:
    __asm__ __volatile__
    ("l.lbz %0,%2\n\t"
     "l.sb %2,%1"
    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
    break;
  case 2:
    __asm__ __volatile__
    ("l.lhz %0,%2\n\t"
     "l.sh %2,%1"
    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
    break;
  case 4:
    __asm__ __volatile__
    ("l.lwz %0,%2\n\t"
     "l.sw %2,%1"
    : "=&r" (tmp) : "r" (x), "m" (*__xg(ptr)) : "memory");
    break;
  }
 
  restore_flags(flags);
  return tmp;
}
 
extern inline void * xchg_ptr(void * m, void * val)
{
	return (void *) __xchg((unsigned long)m, val, sizeof(unsigned long));
}
 
/*
 * debugging aid
 */
extern void __print(const char *fmt, ...);
 
#endif /* __KERNEL__ */
#endif /* __OR32_SYSTEM_H */
 

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

powered by: WebSVN 2.1.0

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