root/include/asm-sparc/system.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. xchg_u32
  2. xchg_ptr

   1 #ifndef __SPARC_SYSTEM_H
   2 #define __SPARC_SYSTEM_H
   3 
   4 /*
   5  * System defines.. Note that this is included both from .c and .S
   6  * files, so it does only defines, not any C code.
   7  */
   8 
   9 /*
  10  * I wish the boot time image was as beautiful as the Alpha's
  11  * but no such luck. The icky PROM loads us at 0x0, and jumps
  12  * to magic address 0x4000 to start thing going. This means that
  13  * I can stick the pcb and user/kernel stacks in the area from
  14  * 0x0-0x4000 and be reasonably sure that this is sane.
  15  *
  16  * Sorry, I can't impress people with cool looking 64-bit values
  17  * yet. ;-)
  18  */
  19 
  20 #include <asm/openprom.h>
  21 
  22 #define INIT_PCB        0x00011fe0
  23 #define INIT_STACK      0x00013fe0
  24 #define START_ADDR      0x00004000
  25 #define START_SIZE      (32*1024)
  26 
  27 #ifndef __ASSEMBLY__
  28 
  29 extern void wrent(void *, unsigned long);
  30 extern void wrkgp(unsigned long);
  31 extern struct linux_romvec *romvec;
  32 
  33 #define halt() { romvec->pv_halt(); }
  34 #define move_to_user_mode() halt()
  35 #define switch_to(x) halt()
  36 
  37 #ifndef stbar  /* store barrier Sparc insn to synchronize stores in PSO */
  38 #define stbar() __asm__ __volatile__("stbar": : :"memory")
  39 #endif
  40 
  41 /* Changing the PIL on the sparc is a bit hairy. I figure out some
  42  * more optimized way of doing this soon.
  43  */
  44 
  45 #define swpipl(__new_ipl) \
  46 ({ unsigned long __old_ipl, psr; \
  47 __asm__ __volatile__( \
  48         "and %1, 15, %1\n\t" \
  49         "sll %1, 8, %1\n\t" \
  50         "rd %%psr, %2\n\t" \
  51         "or %%g0, %2, %0\n\t" \
  52         "or %2, %1, %2\n\t" \
  53         "wr %2, 0x0, %%psr\n\t" \
  54         "srl %0, 8, %0\n\t" \
  55         "and %0, 15, %0\n\t" \
  56         : "=r" (__old_ipl) \
  57         : "r" (__new_ipl), "r" (psr=0)); \
  58 __old_ipl; })
  59 
  60 #define cli()                   swpipl(15)  /* 15 = no int's except nmi's */
  61 #define sti()                   swpipl(0)   /* same as alpha */
  62 #define save_flags(flags)       do { flags = swpipl(15); } while (0)
  63 #define restore_flags(flags)    swpipl(flags)
  64 
  65 #define iret() __asm__ __volatile__ ("jmp %%l1\n\t" \
  66                                      "rett %l2\n\t": : :"memory")
  67 
  68 #define _set_gate(gate_addr,type,dpl,addr) \
  69 __asm__ __volatile__ ("nop\n\t")
  70 
  71 #define set_intr_gate(n,addr) \
  72         _set_gate(&idt[n],14,0,addr)
  73 
  74 #define set_trap_gate(n,addr) \
  75         _set_gate(&idt[n],15,0,addr)
  76 
  77 #define set_system_gate(n,addr) \
  78         _set_gate(&idt[n],15,3,addr)
  79 
  80 #define set_call_gate(a,addr) \
  81         _set_gate(a,12,3,addr)
  82 
  83 
  84 /* Must this be atomic? */
  85 
  86 extern inline void *xchg_u32(int * m, unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
  87 {
  88         unsigned long dummy;
  89 
  90         __asm__ __volatile__(
  91                 "ld [%1],%2\n\t"
  92                 "st %0, [%1]\n\t"
  93                 "or %%g0, %2, %0"
  94                 : "=r" (val), "=r" (m), "=r" (dummy)
  95                 : "0" (val));
  96         return (void *)val;
  97 }
  98 
  99 
 100 /* pointers are 32 bits on the sparc (at least the v8, and they'll work
 101  * on the V9 none the less). I don't need the xchg_u64 routine for now.
 102  */
 103 
 104 extern inline void *xchg_ptr(void *m, void *val)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106         return (void *) xchg_u32((int *) m, (unsigned long) val);
 107 }
 108 
 109 
 110 
 111 #endif /* __ASSEMBLY__ */
 112 
 113 #endif

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