[PATCH] powerpc: Add/remove/update properties in firmware device tree
[powerpc.git] / include / asm-powerpc / system.h
index e926e43..9b822af 100644 (file)
@@ -4,11 +4,9 @@
 #ifndef _ASM_POWERPC_SYSTEM_H
 #define _ASM_POWERPC_SYSTEM_H
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 
 #include <asm/hw_irq.h>
-#include <asm/ppc_asm.h>
 #include <asm/atomic.h>
 
 /*
@@ -43,6 +41,7 @@
 #define set_mb(var, value)     do { var = value; mb(); } while (0)
 #define set_wmb(var, value)    do { var = value; wmb(); } while (0)
 
+#ifdef __KERNEL__
 #ifdef CONFIG_SMP
 #define smp_mb()       mb()
 #define smp_rmb()      rmb()
@@ -55,7 +54,6 @@
 #define smp_read_barrier_depends()     do { } while(0)
 #endif /* CONFIG_SMP */
 
-#ifdef __KERNEL__
 struct task_struct;
 struct pt_regs;
 
@@ -135,6 +133,14 @@ extern int fix_alignment(struct pt_regs *);
 extern void cvt_fd(float *from, double *to, struct thread_struct *thread);
 extern void cvt_df(double *from, float *to, struct thread_struct *thread);
 
+#ifndef CONFIG_SMP
+extern void discard_lazy_cpu_state(void);
+#else
+static inline void discard_lazy_cpu_state(void)
+{
+}
+#endif
+
 #ifdef CONFIG_ALTIVEC
 extern void flush_altivec_to_thread(struct task_struct *);
 #else
@@ -177,8 +183,20 @@ struct thread_struct;
 extern struct task_struct *_switch(struct thread_struct *prev,
                                   struct thread_struct *next);
 
+/*
+ * On SMP systems, when the scheduler does migration-cost autodetection,
+ * it needs a way to flush as much of the CPU's caches as possible.
+ *
+ * TODO: fill this in!
+ */
+static inline void sched_cacheflush(void)
+{
+}
+
 extern unsigned int rtas_data;
 extern int mem_init_done;      /* set on boot once kmalloc can be called */
+extern unsigned long memory_limit;
+extern unsigned long klimit;
 
 extern int powersave_nap;      /* set if nap mode can be used in idle loop */
 
@@ -288,7 +306,7 @@ __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new)
 
 #ifdef CONFIG_PPC64
 static __inline__ unsigned long
-__cmpxchg_u64(volatile long *p, unsigned long old, unsigned long new)
+__cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new)
 {
        unsigned long prev;
 
@@ -358,5 +376,53 @@ extern void reloc_got2(unsigned long);
 
 #define PTRRELOC(x)    ((typeof(x)) add_reloc_offset((unsigned long)(x)))
 
+static inline void create_instruction(unsigned long addr, unsigned int instr)
+{
+       unsigned int *p;
+       p  = (unsigned int *)addr;
+       *p = instr;
+       asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (p));
+}
+
+/* Flags for create_branch:
+ * "b"   == create_branch(addr, target, 0);
+ * "ba"  == create_branch(addr, target, BRANCH_ABSOLUTE);
+ * "bl"  == create_branch(addr, target, BRANCH_SET_LINK);
+ * "bla" == create_branch(addr, target, BRANCH_ABSOLUTE | BRANCH_SET_LINK);
+ */
+#define BRANCH_SET_LINK        0x1
+#define BRANCH_ABSOLUTE        0x2
+
+static inline void create_branch(unsigned long addr,
+               unsigned long target, int flags)
+{
+       unsigned int instruction;
+
+       if (! (flags & BRANCH_ABSOLUTE))
+               target = target - addr;
+
+       /* Mask out the flags and target, so they don't step on each other. */
+       instruction = 0x48000000 | (flags & 0x3) | (target & 0x03FFFFFC);
+
+       create_instruction(addr, instruction);
+}
+
+static inline void create_function_call(unsigned long addr, void * func)
+{
+       unsigned long func_addr;
+
+#ifdef CONFIG_PPC64
+       /*
+        * On PPC64 the function pointer actually points to the function's
+        * descriptor. The first entry in the descriptor is the address
+        * of the function text.
+        */
+       func_addr = *(unsigned long *)func;
+#else
+       func_addr = (unsigned long)func;
+#endif
+       create_branch(addr, func_addr, BRANCH_SET_LINK);
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_SYSTEM_H */