Blackfin arch: push bf561 PERIPHERAL_MAP oddity into bf561-specific code
[linux-2.6.git] / arch / blackfin / mach-bf561 / include / mach / mem_map.h
index f1d4c0637bd2f7fb762ae981b08e2577243fd5fd..419dffdc96ebd4ad6c6bbf80b0228786f692c054 100644 (file)
 #define L1_SCRATCH_START       COREA_L1_SCRATCH_START
 #define L1_SCRATCH_LENGTH      0x1000
 
+#ifdef __ASSEMBLY__
+
+/*
+ * The following macros both return the address of the PDA for the
+ * current core.
+ *
+ * In its first safe (and hairy) form, the macro neither clobbers any
+ * register aside of the output Preg, nor uses the stack, since it
+ * could be called with an invalid stack pointer, or the current stack
+ * space being uncovered by any CPLB (e.g. early exception handling).
+ *
+ * The constraints on the second form are a bit relaxed, and the code
+ * is allowed to use the specified Dreg for determining the PDA
+ * address to be returned into Preg.
+ */
+#ifdef CONFIG_SMP
+#define GET_PDA_SAFE(preg)             \
+       preg.l = lo(DSPID);             \
+       preg.h = hi(DSPID);             \
+       preg = [preg];                  \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       preg = preg << 2;               \
+       if cc jump 2f;                  \
+       cc = preg == 0x0;               \
+       preg.l = _cpu_pda;              \
+       preg.h = _cpu_pda;              \
+       if !cc jump 3f;                 \
+1:                                     \
+       /* preg = 0x0; */               \
+       cc = !cc; /* restore cc to 0 */ \
+       jump 4f;                        \
+2:                                     \
+       cc = preg == 0x0;               \
+       preg.l = _cpu_pda;              \
+       preg.h = _cpu_pda;              \
+       if cc jump 4f;                  \
+       /* preg = 0x1000000; */         \
+       cc = !cc; /* restore cc to 1 */ \
+3:                                     \
+       preg = [preg];                  \
+4:
+
+#define GET_PDA(preg, dreg)            \
+       preg.l = lo(DSPID);             \
+       preg.h = hi(DSPID);             \
+       dreg = [preg];                  \
+       preg.l = _cpu_pda;              \
+       preg.h = _cpu_pda;              \
+       cc = bittst(dreg, 0);           \
+       if !cc jump 1f;                 \
+       preg = [preg];                  \
+1:                                     \
+
+#define GET_CPUID(preg, dreg)          \
+       preg.l = lo(DSPID);             \
+       preg.h = hi(DSPID);             \
+       dreg = [preg];                  \
+       dreg = ROT dreg BY -1;          \
+       dreg = CC;
+
+#else
+#define GET_PDA_SAFE(preg)             \
+       preg.l = _cpu_pda;              \
+       preg.h = _cpu_pda;
+
+#define GET_PDA(preg, dreg)    GET_PDA_SAFE(preg)
+#endif /* CONFIG_SMP */
+
+#endif /* __ASSEMBLY__ */
+
 #endif                         /* _MEM_MAP_533_H_ */