Merge HEAD from oss.sgi.com:/oss/git/linux-2.6.git
[powerpc.git] / include / asm-powerpc / ppc_asm.h
index f8ad5df..0dc798d 100644 (file)
@@ -6,8 +6,13 @@
 
 #include <linux/stringify.h>
 #include <linux/config.h>
+#include <asm/asm-compat.h>
 
-#ifdef __ASSEMBLY__
+#ifndef __ASSEMBLY__
+#error __FILE__ should only be used in assembler files
+#else
+
+#define SZL                    (BITS_PER_LONG/8)
 
 /*
  * Macros for storing registers into and loading registers from
@@ -89,6 +94,7 @@
 #define RFDI           .long 0x4c00004e        /* rfdi instruction */
 #define RFMCI          .long 0x4c00004c        /* rfmci instruction */
 
+#ifdef __KERNEL__
 #ifdef CONFIG_PPC64
 
 #define XGLUE(a,b) a##b
@@ -154,7 +160,7 @@ n:
  *   loads the address of 'name' into 'rn'
  *
  * LOADBASE( rn, name )
- *   loads the address (less the low 16 bits) of 'name' into 'rn'
+ *   loads the address (possibly without the low 16 bits) of 'name' into 'rn'
  *   suitable for base+disp addressing
  */
 #ifdef __powerpc64__
@@ -166,10 +172,7 @@ n:
        ori     rn,rn,name##@l
 
 #define LOADBASE(rn,name)              \
-       .section .toc,"aw";             \
-1:     .tc     name[TC],name;          \
-       .previous;                      \
-       ld      rn,1b@toc(r2)
+       ld      rn,name@got(r2)
 
 #define OFF(name)      0
 
@@ -187,10 +190,8 @@ n:
        oris    reg,reg,(label)@h;                      \
        ori     reg,reg,(label)@l;
 
-/* operations for longs and pointers */
-#define LDL    ld
-#define STL    std
-#define CMPI   cmpdi
+/* offsets for stack frame layout */
+#define LRSAVE 16
 
 #else /* 32-bit */
 #define LOADADDR(rn,name) \
@@ -202,10 +203,8 @@ n:
 
 #define OFF(name)      name@l
 
-/* operations for longs and pointers */
-#define LDL    lwz
-#define STL    stw
-#define CMPI   cmpwi
+/* offsets for stack frame layout */
+#define LRSAVE 4
 
 #endif
 
@@ -261,15 +260,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 #endif
 
 
-#ifdef CONFIG_IBM405_ERR77
-#define PPC405_ERR77(ra,rb)    dcbt    ra, rb;
-#define        PPC405_ERR77_SYNC       sync;
-#else
-#define PPC405_ERR77(ra,rb)
-#define PPC405_ERR77_SYNC
-#endif
-
-
 #ifdef CONFIG_IBM440EP_ERR42
 #define PPC440EP_ERR42 isync
 #else
@@ -278,6 +268,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 
 
 #if defined(CONFIG_BOOKE)
+#define toreal(rd)
+#define fromreal(rd)
+
 #define tophys(rd,rs)                          \
        addis   rd,rs,0
 
@@ -285,23 +278,24 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
        addis   rd,rs,0
 
 #elif defined(CONFIG_PPC64)
-/* PPPBBB - DRENG  If KERNELBASE is always 0xC0...,
- * Then we can easily do this with one asm insn. -Peter
- */
+#define toreal(rd)             /* we can access c000... in real mode */
+#define fromreal(rd)
+
 #define tophys(rd,rs)                           \
-        lis     rd,((KERNELBASE>>48)&0xFFFF);   \
-        rldicr  rd,rd,32,31;                    \
-        sub     rd,rs,rd
+       clrldi  rd,rs,2
 
 #define tovirt(rd,rs)                           \
-        lis     rd,((KERNELBASE>>48)&0xFFFF);   \
-        rldicr  rd,rd,32,31;                    \
-        add     rd,rs,rd
+       rotldi  rd,rs,16;                       \
+       ori     rd,rd,((KERNELBASE>>48)&0xFFFF);\
+       rotldi  rd,rd,48
 #else
 /*
  * On APUS (Amiga PowerPC cpu upgrade board), we don't know the
  * physical base address of RAM at compile time.
  */
+#define toreal(rd)     tophys(rd,rd)
+#define fromreal(rd)   tovirt(rd,rd)
+
 #define tophys(rd,rs)                          \
 0:     addis   rd,rs,-KERNELBASE@h;            \
        .section ".vtop_fixup","aw";            \
@@ -332,6 +326,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 #define CLR_TOP32(r)
 #endif
 
+#endif /* __KERNEL__ */
+
 /* The boring bits... */
 
 /* Condition Register Bit Fields */
@@ -493,10 +489,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 #define N_SLINE        68
 #define N_SO   100
 
-#define ASM_CONST(x) x
-#else
-  #define __ASM_CONST(x) x##UL
-  #define ASM_CONST(x) __ASM_CONST(x)
 #endif /*  __ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_PPC_ASM_H */