root/include/asm-alpha/system.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. xchg_u32
  2. xchg_u64
  3. __xchg

   1 #ifndef __ALPHA_SYSTEM_H
   2 #define __ALPHA_SYSTEM_H
   3 
   4 #include <asm/pal.h>    /* for backwards compatibility... */
   5 
   6 /*
   7  * System defines.. Note that this is included both from .c and .S
   8  * files, so it does only defines, not any C code.
   9  */
  10 
  11 /*
  12  * We leave one page for the initial stack page, and one page for
  13  * the initial process structure. Also, the console eats 3 MB for
  14  * the initial bootloader (one of which we can reclaim later).
  15  * With a few other pages for various reasons, we'll use an initial
  16  * load address of 0xfffffc0000310000UL
  17  */
  18 #define BOOT_PCB        0x20000000
  19 #define BOOT_ADDR       0x20000000
  20 #define BOOT_SIZE       (16*1024)
  21 
  22 #define KERNEL_START    0xfffffc0000300000
  23 #define SWAPPER_PGD     0xfffffc0000300000
  24 #define INIT_STACK      0xfffffc0000302000
  25 #define EMPTY_PGT       0xfffffc0000304000
  26 #define EMPTY_PGE       0xfffffc0000308000
  27 #define ZERO_PGE        0xfffffc000030A000
  28 
  29 #define START_ADDR      0xfffffc0000310000
  30 #define START_SIZE      (2*1024*1024)
  31 
  32 #ifndef __ASSEMBLY__
  33 
  34 /*
  35  * This is the logout header that should be common to all platforms
  36  * (assuming they are running OSF/1 PALcode, I guess).
  37  */
  38 struct el_common {
  39         unsigned int    size;           /* size in bytes of logout area */
  40         int             sbz1    : 31;   /* should be zero */
  41         char            retry   :  1;   /* retry flag */
  42         unsigned int    proc_offset;    /* processor-specific offset */
  43         unsigned int    sys_offset;     /* system-specific offset */
  44 };
  45 
  46 extern void wrent(void *, unsigned long);
  47 extern void wrkgp(unsigned long);
  48 extern void wrusp(unsigned long);
  49 extern unsigned long rdusp(void);
  50 extern unsigned long rdmces (void);
  51 extern void wrmces (unsigned long);
  52 
  53 #define halt() __asm__ __volatile__(".long 0");
  54 
  55 extern void alpha_switch_to(unsigned long pctxp);
  56 
  57 #define switch_to(p) do { \
  58         current = p; \
  59         alpha_switch_to((unsigned long) &(p)->tss - 0xfffffc0000000000); \
  60 } while (0)
  61 
  62 #define mb() \
  63 __asm__ __volatile__("mb": : :"memory")
  64 
  65 #define draina() \
  66 __asm__ __volatile__ ("call_pal %0" : : "i" (PAL_draina) : "memory")
  67 
  68 #define getipl() \
  69 ({ unsigned long __old_ipl; \
  70 __asm__ __volatile__( \
  71         "call_pal 54\n\t" \
  72         "bis $0,$0,%0" \
  73         : "=r" (__old_ipl) \
  74         : : "$0", "$1", "$16", "$22", "$23", "$24", "$25"); \
  75 __old_ipl; })
  76 
  77 #define setipl(__new_ipl) \
  78 __asm__ __volatile__( \
  79         "bis %0,%0,$16\n\t" \
  80         "call_pal 53" \
  81         : : "r" (__new_ipl) \
  82         : "$0", "$1", "$16", "$22", "$23", "$24", "$25")
  83 
  84 #define swpipl(__new_ipl) \
  85 ({ unsigned long __old_ipl; \
  86 __asm__ __volatile__( \
  87         "bis %1,%1,$16\n\t" \
  88         "call_pal 53\n\t" \
  89         "bis $0,$0,%0" \
  90         : "=r" (__old_ipl) \
  91         : "r" (__new_ipl) \
  92         : "$0", "$1", "$16", "$22", "$23", "$24", "$25"); \
  93 __old_ipl; })
  94 
  95 #define cli()                   setipl(7)
  96 #define sti()                   setipl(0)
  97 #define save_flags(flags)       do { flags = getipl(); } while (0)
  98 #define restore_flags(flags)    setipl(flags)
  99 
 100 extern inline unsigned long xchg_u32(volatile int * m, unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
 101 {
 102         unsigned long dummy, dummy2;
 103 
 104         __asm__ __volatile__(
 105                 "\n1:\t"
 106                 "ldl_l %0,%1\n\t"
 107                 "bis %2,%2,%3\n\t"
 108                 "stl_c %3,%1\n\t"
 109                 "beq %3,1b\n"
 110                 : "=r" (val), "=m" (*m), "=r" (dummy), "=r" (dummy2)
 111                 : "1" (*m), "2" (val));
 112         return val;
 113 }
 114 
 115 extern inline unsigned long xchg_u64(volatile long * m, unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
 116 {
 117         unsigned long dummy, dummy2;
 118 
 119         __asm__ __volatile__(
 120                 "\n1:\t"
 121                 "ldq_l %0,%1\n\t"
 122                 "bis %2,%2,%3\n\t"
 123                 "stq_c %3,%1\n\t"
 124                 "beq %3,1b\n"
 125                 : "=r" (val), "=m" (*m), "=r" (dummy), "=r" (dummy2)
 126                 : "1" (*m), "2" (val));
 127         return val;
 128 }
 129 
 130 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
 131 #define tas(ptr) (xchg((ptr),1))
 132 
 133 /*
 134  * This function doesn't exist, so you'll get a linker error
 135  * if something tries to do an invalid xchg().
 136  *
 137  * This only works if the compiler isn't horribly bad at optimizing.
 138  * gcc-2.5.8 reportedly can't handle this, but as that doesn't work
 139  * too well on the alpha anyway..
 140  */
 141 extern void __xchg_called_with_bad_pointer(void);
 142 
 143 static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
 144 {
 145         switch (size) {
 146                 case 4:
 147                         return xchg_u32(ptr, x);
 148                 case 8:
 149                         return xchg_u64(ptr, x);
 150         }
 151         __xchg_called_with_bad_pointer();
 152         return x;
 153 }
 154 
 155 #endif /* __ASSEMBLY__ */
 156 
 157 #endif

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