root/include/asm-sparc/system.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. setipl
  2. getipl
  3. swpipl
  4. xchg_u32
  5. __xchg

   1 /* $Id: system.h,v 1.19 1995/11/25 02:32:59 davem Exp $ */
   2 #ifndef __SPARC_SYSTEM_H
   3 #define __SPARC_SYSTEM_H
   4 
   5 #include <asm/segment.h>
   6 
   7 #include <asm/page.h>
   8 #include <asm/openprom.h>
   9 #include <asm/psr.h>
  10 
  11 #define EMPTY_PGT       (&empty_bad_page)
  12 #define EMPTY_PGE       (&empty_bad_page_table)
  13 #define ZERO_PGE        (&empty_zero_page)
  14 
  15 #ifndef __ASSEMBLY__
  16 
  17 /*
  18  * Sparc (general) CPU types
  19  */
  20 enum sparc_cpu {
  21   sun4        = 0x00,
  22   sun4c       = 0x01,
  23   sun4m       = 0x02,
  24   sun4d       = 0x03,
  25   sun4e       = 0x04,
  26   sun4u       = 0x05, /* V8 ploos ploos */
  27   sun_unknown = 0x06,
  28 };
  29 
  30 extern enum sparc_cpu sparc_cpu_model;
  31 
  32 extern unsigned long empty_bad_page;
  33 extern unsigned long empty_bad_page_table;
  34 extern unsigned long empty_zero_page;
  35 
  36 extern struct linux_romvec *romvec;
  37 #define halt() romvec->pv_halt()
  38 
  39 /* When a context switch happens we must flush all user windows so that
  40  * the windows of the current process are flushed onto it's stack. This
  41  * way the windows are all clean for the next process and the stack
  42  * frames are up to date.
  43  */
  44 extern void flush_user_windows(void);
  45 extern void sparc_switch_to(void *new_task);
  46 #define switch_to(p) do { \
  47                           flush_user_windows(); \
  48                           switch_to_context(p); \
  49                           sparc_switch_to(p); \
  50                      } while(0)
  51 
  52 /* Changing the IRQ level on the Sparc. */
  53 extern inline void setipl(int __new_ipl)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55         __asm__ __volatile__("rd %%psr, %%g1\n\t"
  56                              "andn %%g1, %1, %%g1\n\t"
  57                              "sll %0, 8, %%g2\n\t"
  58                              "and %%g2, %1, %%g2\n\t"
  59                              "or %%g1, %%g2, %%g1\n\t"
  60                              "wr %%g1, 0x0, %%psr\n\t"
  61                              "nop; nop; nop\n\t" : :
  62                              "r" (__new_ipl), "i" (PSR_PIL) :
  63                              "g1", "g2");
  64 }
  65 
  66 extern inline int getipl(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  67 {
  68         int retval;
  69 
  70         __asm__ __volatile__("rd %%psr, %0\n\t"
  71                              "and %0, %1, %0\n\t"
  72                              "srl %0, 8, %0\n\t" :
  73                              "=r" (retval) :
  74                              "i" (PSR_PIL));
  75         return retval;
  76 }
  77 
  78 extern inline int swpipl(int __new_ipl)
     /* [previous][next][first][last][top][bottom][index][help] */
  79 {
  80         int retval;
  81 
  82         __asm__ __volatile__("rd %%psr, %%g1\n\t"
  83                              "srl %%g1, 8, %0\n\t"
  84                              "and %0, 15, %0\n\t"
  85                              "andn %%g1, %2, %%g1\n\t"
  86                              "and %1, 15, %%g2\n\t"
  87                              "sll %%g2, 8, %%g2\n\t"
  88                              "or %%g1, %%g2, %%g1\n\t"
  89                              "wr %%g1, 0x0, %%psr\n\t"
  90                              "nop; nop; nop\n\t" :
  91                              "=r" (retval) :
  92                              "r" (__new_ipl), "i" (PSR_PIL) :
  93                              "g1", "g2");
  94         return retval;
  95 }
  96 
  97 #define cli()                   setipl(15)  /* 15 = no int's except nmi's */
  98 #define sti()                   setipl(0)   /* I'm scared */
  99 #define save_flags(flags)       do { flags = getipl(); } while (0)
 100 #define restore_flags(flags)    setipl(flags)
 101 #define nop() __asm__ __volatile__ ("nop");
 102 
 103 extern inline unsigned long xchg_u32(volatile unsigned long *m, unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
 104 {
 105         unsigned long flags, retval;
 106 
 107         save_flags(flags); cli();
 108         retval = *m;
 109         *m = val;
 110         restore_flags(flags);
 111         return retval;
 112 }
 113 
 114 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
 115 #define tas(ptr) (xchg((ptr),1))
 116 
 117 extern void __xchg_called_with_bad_pointer(void);
 118 
 119 static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
 120 {
 121         switch (size) {
 122         case 4:
 123                 return xchg_u32(ptr, x);
 124         };
 125         __xchg_called_with_bad_pointer();
 126         return x;
 127 }
 128 
 129 #endif /* __ASSEMBLY__ */
 130 
 131 #endif /* !(__SPARC_SYSTEM_H) */

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