#ifndef ARCH_PPC_H
-#define ARCH_PPH_H
+#define ARCH_PPC_H
#include <unistd.h>
#include <stdlib.h>
#define write_barrier() __asm__ __volatile__ ("sync" : : : "memory")
+#ifdef __powerpc64__
+#define PPC_CNTLZL "cntlzd"
+#else
+#define PPC_CNTLZL "cntlzw"
+#endif
+
static inline int __ilog2(unsigned long bitmask)
{
int lz;
- asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask));
- return 31 - lz;
+ asm (PPC_CNTLZL " %0,%1" : "=r" (lz) : "r" (bitmask));
+ return BITS_PER_LONG - 1 - lz;
}
static inline int arch_ffz(unsigned long bitmask)
{
if ((bitmask = ~bitmask) == 0)
- return 32;
+ return BITS_PER_LONG;
return __ilog2(bitmask & -bitmask);
}
tbl = mfspr(SPRN_ATBL);
tbu1 = mfspr(SPRN_ATBU);
} else {
- __asm__ __volatile__("mftbu %0" : "=r"(tbu0));
- __asm__ __volatile__("mftb %0" : "=r"(tbl) );
- __asm__ __volatile__("mftbu %0" : "=r"(tbu1));
+ tbu0 = mfspr(SPRN_TBRU);
+ tbl = mfspr(SPRN_TBRL);
+ tbu1 = mfspr(SPRN_TBRU);
}
} while (tbu0 != tbu1);
return ret;
}
+#if 0
static void atb_child(void)
{
arch_flags |= ARCH_FLAG_1;
pid = fork();
if (!pid)
atb_child();
- else {
+ else if (pid != -1) {
int status;
- wait(&status);
- if (!WIFEXITED(status))
+ pid = wait(&status);
+ if (pid == -1 || !WIFEXITED(status))
arch_flags &= ~ARCH_FLAG_1;
else
arch_flags |= ARCH_FLAG_1;
}
}
+#endif
#define ARCH_HAVE_INIT
extern int tsc_reliable;
static inline int arch_init(char *envp[])
{
+#if 0
tsc_reliable = 1;
atb_clocktest();
+#endif
return 0;
}
#define ARCH_HAVE_FFZ
-#define ARCH_HAVE_CPU_CLOCK
+
+/*
+ * We don't have it on all platforms, lets comment this out until we
+ * can handle it more intelligently.
+ *
+ * #define ARCH_HAVE_CPU_CLOCK
+ */
#endif