mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
Disintegrate asm/system.h for Sparc
Disintegrate asm/system.h for Sparc. Signed-off-by: David Howells <dhowells@redhat.com> cc: sparclinux@vger.kernel.org
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <asm/cmpxchg.h>
|
||||
#include <asm-generic/atomic64.h>
|
||||
|
||||
#include <asm/system.h>
|
||||
|
||||
#define ATOMIC_INIT(i) { (i) }
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define __ARCH_SPARC64_ATOMIC__
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <asm/system.h>
|
||||
#include <asm/cmpxchg.h>
|
||||
|
||||
#define ATOMIC_INIT(i) { (i) }
|
||||
#define ATOMIC64_INIT(i) { (i) }
|
||||
@@ -85,7 +85,6 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
#define atomic64_cmpxchg(v, o, n) \
|
||||
((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
|
||||
#define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef _SPARC_AUXIO_H
|
||||
#define _SPARC_AUXIO_H
|
||||
|
||||
#include <asm/system.h>
|
||||
#include <asm/vaddrs.h>
|
||||
|
||||
/* This register is an unsigned char in IO space. It does two things.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef ___ASM_SPARC_BARRIER_H
|
||||
#define ___ASM_SPARC_BARRIER_H
|
||||
#if defined(__sparc__) && defined(__arch64__)
|
||||
#include <asm/barrier_64.h>
|
||||
#else
|
||||
#include <asm/barrier_32.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef __SPARC_BARRIER_H
|
||||
#define __SPARC_BARRIER_H
|
||||
|
||||
/* XXX Change this if we ever use a PSO mode kernel. */
|
||||
#define mb() __asm__ __volatile__ ("" : : : "memory")
|
||||
#define rmb() mb()
|
||||
#define wmb() mb()
|
||||
#define read_barrier_depends() do { } while(0)
|
||||
#define set_mb(__var, __value) do { __var = __value; mb(); } while(0)
|
||||
#define smp_mb() __asm__ __volatile__("":::"memory")
|
||||
#define smp_rmb() __asm__ __volatile__("":::"memory")
|
||||
#define smp_wmb() __asm__ __volatile__("":::"memory")
|
||||
#define smp_read_barrier_depends() do { } while(0)
|
||||
|
||||
#endif /* !(__SPARC_BARRIER_H) */
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef __SPARC64_BARRIER_H
|
||||
#define __SPARC64_BARRIER_H
|
||||
|
||||
/* These are here in an effort to more fully work around Spitfire Errata
|
||||
* #51. Essentially, if a memory barrier occurs soon after a mispredicted
|
||||
* branch, the chip can stop executing instructions until a trap occurs.
|
||||
* Therefore, if interrupts are disabled, the chip can hang forever.
|
||||
*
|
||||
* It used to be believed that the memory barrier had to be right in the
|
||||
* delay slot, but a case has been traced recently wherein the memory barrier
|
||||
* was one instruction after the branch delay slot and the chip still hung.
|
||||
* The offending sequence was the following in sym_wakeup_done() of the
|
||||
* sym53c8xx_2 driver:
|
||||
*
|
||||
* call sym_ccb_from_dsa, 0
|
||||
* movge %icc, 0, %l0
|
||||
* brz,pn %o0, .LL1303
|
||||
* mov %o0, %l2
|
||||
* membar #LoadLoad
|
||||
*
|
||||
* The branch has to be mispredicted for the bug to occur. Therefore, we put
|
||||
* the memory barrier explicitly into a "branch always, predicted taken"
|
||||
* delay slot to avoid the problem case.
|
||||
*/
|
||||
#define membar_safe(type) \
|
||||
do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \
|
||||
" membar " type "\n" \
|
||||
"1:\n" \
|
||||
: : : "memory"); \
|
||||
} while (0)
|
||||
|
||||
/* The kernel always executes in TSO memory model these days,
|
||||
* and furthermore most sparc64 chips implement more stringent
|
||||
* memory ordering than required by the specifications.
|
||||
*/
|
||||
#define mb() membar_safe("#StoreLoad")
|
||||
#define rmb() __asm__ __volatile__("":::"memory")
|
||||
#define wmb() __asm__ __volatile__("":::"memory")
|
||||
|
||||
#define read_barrier_depends() do { } while(0)
|
||||
#define set_mb(__var, __value) \
|
||||
do { __var = __value; membar_safe("#StoreLoad"); } while(0)
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
#define smp_mb() mb()
|
||||
#define smp_rmb() rmb()
|
||||
#define smp_wmb() wmb()
|
||||
#else
|
||||
#define smp_mb() __asm__ __volatile__("":::"memory")
|
||||
#define smp_rmb() __asm__ __volatile__("":::"memory")
|
||||
#define smp_wmb() __asm__ __volatile__("":::"memory")
|
||||
#endif
|
||||
|
||||
#define smp_read_barrier_depends() do { } while(0)
|
||||
|
||||
#endif /* !(__SPARC64_BARRIER_H) */
|
||||
@@ -19,4 +19,7 @@ extern void do_BUG(const char *file, int line);
|
||||
|
||||
#include <asm-generic/bug.h>
|
||||
|
||||
struct pt_regs;
|
||||
extern void die_if_kernel(char *str, struct pt_regs *regs) __attribute__ ((noreturn));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -83,4 +83,13 @@ extern void sparc_flush_page_to_ram(struct page *page);
|
||||
#define flush_cache_vmap(start, end) flush_cache_all()
|
||||
#define flush_cache_vunmap(start, end) flush_cache_all()
|
||||
|
||||
/* When a context switch happens we must flush all user windows so that
|
||||
* the windows of the current process are flushed onto its stack. This
|
||||
* way the windows are all clean for the next process and the stack
|
||||
* frames are up to date.
|
||||
*/
|
||||
extern void flush_user_windows(void);
|
||||
extern void kill_user_windows(void);
|
||||
extern void flushw_all(void);
|
||||
|
||||
#endif /* _SPARC_CACHEFLUSH_H */
|
||||
|
||||
@@ -9,6 +9,16 @@
|
||||
|
||||
/* Cache flush operations. */
|
||||
|
||||
|
||||
#define flushi(addr) __asm__ __volatile__ ("flush %0" : : "r" (addr) : "memory")
|
||||
#define flushw_all() __asm__ __volatile__("flushw")
|
||||
|
||||
extern void __flushw_user(void);
|
||||
#define flushw_user() __flushw_user()
|
||||
|
||||
#define flush_user_windows flushw_user
|
||||
#define flush_register_windows flushw_all
|
||||
|
||||
/* These are the same regardless of whether this is an SMP kernel or not. */
|
||||
#define flush_cache_mm(__mm) \
|
||||
do { if ((__mm) == current->mm) flushw_user(); } while(0)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef ___ASM_SPARC_CMPXCHG_H
|
||||
#define ___ASM_SPARC_CMPXCHG_H
|
||||
#if defined(__sparc__) && defined(__arch64__)
|
||||
#include <asm/cmpxchg_64.h>
|
||||
#else
|
||||
#include <asm/cmpxchg_32.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
/* 32-bit atomic xchg() and cmpxchg() definitions.
|
||||
*
|
||||
* Copyright (C) 1996 David S. Miller (davem@davemloft.net)
|
||||
* Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com.au)
|
||||
* Copyright (C) 2007 Kyle McMartin (kyle@parisc-linux.org)
|
||||
*
|
||||
* Additions by Keith M Wesolowski (wesolows@foobazco.org) based
|
||||
* on asm-parisc/atomic.h Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>.
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_SPARC_CMPXCHG__
|
||||
#define __ARCH_SPARC_CMPXCHG__
|
||||
|
||||
#include <asm/btfixup.h>
|
||||
|
||||
/* This has special calling conventions */
|
||||
#ifndef CONFIG_SMP
|
||||
BTFIXUPDEF_CALL(void, ___xchg32, void)
|
||||
#endif
|
||||
|
||||
static inline unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned long val)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
__asm__ __volatile__("swap [%2], %0"
|
||||
: "=&r" (val)
|
||||
: "0" (val), "r" (m)
|
||||
: "memory");
|
||||
return val;
|
||||
#else
|
||||
register unsigned long *ptr asm("g1");
|
||||
register unsigned long ret asm("g2");
|
||||
|
||||
ptr = (unsigned long *) m;
|
||||
ret = val;
|
||||
|
||||
/* Note: this is magic and the nop there is
|
||||
really needed. */
|
||||
__asm__ __volatile__(
|
||||
"mov %%o7, %%g4\n\t"
|
||||
"call ___f____xchg32\n\t"
|
||||
" nop\n\t"
|
||||
: "=&r" (ret)
|
||||
: "0" (ret), "r" (ptr)
|
||||
: "g3", "g4", "g7", "memory", "cc");
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void __xchg_called_with_bad_pointer(void);
|
||||
|
||||
static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size)
|
||||
{
|
||||
switch (size) {
|
||||
case 4:
|
||||
return xchg_u32(ptr, x);
|
||||
}
|
||||
__xchg_called_with_bad_pointer();
|
||||
return x;
|
||||
}
|
||||
|
||||
#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
|
||||
|
||||
/* Emulate cmpxchg() the same way we emulate atomics,
|
||||
* by hashing the object address and indexing into an array
|
||||
* of spinlocks to get a bit of performance...
|
||||
*
|
||||
* See arch/sparc/lib/atomic32.c for implementation.
|
||||
*
|
||||
* Cribbed from <asm-parisc/atomic.h>
|
||||
*/
|
||||
#define __HAVE_ARCH_CMPXCHG 1
|
||||
|
||||
/* bug catcher for when unsupported size is used - won't link */
|
||||
extern void __cmpxchg_called_with_bad_pointer(void);
|
||||
/* we only need to support cmpxchg of a u32 on sparc */
|
||||
extern unsigned long __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
|
||||
|
||||
/* don't worry...optimizer will get rid of most of this */
|
||||
static inline unsigned long
|
||||
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
|
||||
{
|
||||
switch (size) {
|
||||
case 4:
|
||||
return __cmpxchg_u32((u32 *)ptr, (u32)old, (u32)new_);
|
||||
default:
|
||||
__cmpxchg_called_with_bad_pointer();
|
||||
break;
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
||||
#define cmpxchg(ptr, o, n) \
|
||||
({ \
|
||||
__typeof__(*(ptr)) _o_ = (o); \
|
||||
__typeof__(*(ptr)) _n_ = (n); \
|
||||
(__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
|
||||
(unsigned long)_n_, sizeof(*(ptr))); \
|
||||
})
|
||||
|
||||
#include <asm-generic/cmpxchg-local.h>
|
||||
|
||||
/*
|
||||
* cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
|
||||
* them available.
|
||||
*/
|
||||
#define cmpxchg_local(ptr, o, n) \
|
||||
((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
|
||||
(unsigned long)(n), sizeof(*(ptr))))
|
||||
#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
|
||||
|
||||
#endif /* __ARCH_SPARC_CMPXCHG__ */
|
||||
@@ -0,0 +1,145 @@
|
||||
/* 64-bit atomic xchg() and cmpxchg() definitions.
|
||||
*
|
||||
* Copyright (C) 1996, 1997, 2000 David S. Miller (davem@redhat.com)
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_SPARC64_CMPXCHG__
|
||||
#define __ARCH_SPARC64_CMPXCHG__
|
||||
|
||||
static inline unsigned long xchg32(__volatile__ unsigned int *m, unsigned int val)
|
||||
{
|
||||
unsigned long tmp1, tmp2;
|
||||
|
||||
__asm__ __volatile__(
|
||||
" mov %0, %1\n"
|
||||
"1: lduw [%4], %2\n"
|
||||
" cas [%4], %2, %0\n"
|
||||
" cmp %2, %0\n"
|
||||
" bne,a,pn %%icc, 1b\n"
|
||||
" mov %1, %0\n"
|
||||
: "=&r" (val), "=&r" (tmp1), "=&r" (tmp2)
|
||||
: "0" (val), "r" (m)
|
||||
: "cc", "memory");
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline unsigned long xchg64(__volatile__ unsigned long *m, unsigned long val)
|
||||
{
|
||||
unsigned long tmp1, tmp2;
|
||||
|
||||
__asm__ __volatile__(
|
||||
" mov %0, %1\n"
|
||||
"1: ldx [%4], %2\n"
|
||||
" casx [%4], %2, %0\n"
|
||||
" cmp %2, %0\n"
|
||||
" bne,a,pn %%xcc, 1b\n"
|
||||
" mov %1, %0\n"
|
||||
: "=&r" (val), "=&r" (tmp1), "=&r" (tmp2)
|
||||
: "0" (val), "r" (m)
|
||||
: "cc", "memory");
|
||||
return val;
|
||||
}
|
||||
|
||||
#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
|
||||
|
||||
extern void __xchg_called_with_bad_pointer(void);
|
||||
|
||||
static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr,
|
||||
int size)
|
||||
{
|
||||
switch (size) {
|
||||
case 4:
|
||||
return xchg32(ptr, x);
|
||||
case 8:
|
||||
return xchg64(ptr, x);
|
||||
}
|
||||
__xchg_called_with_bad_pointer();
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Atomic compare and exchange. Compare OLD with MEM, if identical,
|
||||
* store NEW in MEM. Return the initial value in MEM. Success is
|
||||
* indicated by comparing RETURN with OLD.
|
||||
*/
|
||||
|
||||
#include <asm-generic/cmpxchg-local.h>
|
||||
|
||||
#define __HAVE_ARCH_CMPXCHG 1
|
||||
|
||||
static inline unsigned long
|
||||
__cmpxchg_u32(volatile int *m, int old, int new)
|
||||
{
|
||||
__asm__ __volatile__("cas [%2], %3, %0"
|
||||
: "=&r" (new)
|
||||
: "0" (new), "r" (m), "r" (old)
|
||||
: "memory");
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
|
||||
{
|
||||
__asm__ __volatile__("casx [%2], %3, %0"
|
||||
: "=&r" (new)
|
||||
: "0" (new), "r" (m), "r" (old)
|
||||
: "memory");
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/* This function doesn't exist, so you'll get a linker error
|
||||
if something tries to do an invalid cmpxchg(). */
|
||||
extern void __cmpxchg_called_with_bad_pointer(void);
|
||||
|
||||
static inline unsigned long
|
||||
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
|
||||
{
|
||||
switch (size) {
|
||||
case 4:
|
||||
return __cmpxchg_u32(ptr, old, new);
|
||||
case 8:
|
||||
return __cmpxchg_u64(ptr, old, new);
|
||||
}
|
||||
__cmpxchg_called_with_bad_pointer();
|
||||
return old;
|
||||
}
|
||||
|
||||
#define cmpxchg(ptr,o,n) \
|
||||
({ \
|
||||
__typeof__(*(ptr)) _o_ = (o); \
|
||||
__typeof__(*(ptr)) _n_ = (n); \
|
||||
(__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
|
||||
(unsigned long)_n_, sizeof(*(ptr))); \
|
||||
})
|
||||
|
||||
/*
|
||||
* cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
|
||||
* them available.
|
||||
*/
|
||||
|
||||
static inline unsigned long __cmpxchg_local(volatile void *ptr,
|
||||
unsigned long old,
|
||||
unsigned long new, int size)
|
||||
{
|
||||
switch (size) {
|
||||
case 4:
|
||||
case 8: return __cmpxchg(ptr, old, new, size);
|
||||
default:
|
||||
return __cmpxchg_local_generic(ptr, old, new, size);
|
||||
}
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
#define cmpxchg_local(ptr, o, n) \
|
||||
((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
|
||||
(unsigned long)(n), sizeof(*(ptr))))
|
||||
#define cmpxchg64_local(ptr, o, n) \
|
||||
({ \
|
||||
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
|
||||
cmpxchg_local((ptr), (o), (n)); \
|
||||
})
|
||||
|
||||
#endif /* __ARCH_SPARC64_CMPXCHG__ */
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef __ASM_CPU_TYPE_H
|
||||
#define __ASM_CPU_TYPE_H
|
||||
|
||||
/*
|
||||
* Sparc (general) CPU types
|
||||
*/
|
||||
enum sparc_cpu {
|
||||
sun4 = 0x00,
|
||||
sun4c = 0x01,
|
||||
sun4m = 0x02,
|
||||
sun4d = 0x03,
|
||||
sun4e = 0x04,
|
||||
sun4u = 0x05, /* V8 ploos ploos */
|
||||
sun_unknown = 0x06,
|
||||
ap1000 = 0x07, /* almost a sun4m */
|
||||
sparc_leon = 0x08, /* Leon SoC */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SPARC32
|
||||
extern enum sparc_cpu sparc_cpu_model;
|
||||
|
||||
#define ARCH_SUN4C (sparc_cpu_model==sun4c)
|
||||
|
||||
#define SUN4M_NCPUS 4 /* Architectural limit of sun4m. */
|
||||
|
||||
#else
|
||||
|
||||
#define sparc_cpu_model sun4u
|
||||
|
||||
/* This cannot ever be a sun4c :) That's just history. */
|
||||
#define ARCH_SUN4C 0
|
||||
#endif
|
||||
|
||||
#endif /* __ASM_CPU_TYPE_H */
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __SPARC_EXEC_H
|
||||
#define __SPARC_EXEC_H
|
||||
|
||||
#define arch_align_stack(x) (x)
|
||||
|
||||
#endif /* __SPARC_EXEC_H */
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <asm/page.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/system.h>
|
||||
#include <asm/idprom.h>
|
||||
#include <asm/machines.h>
|
||||
#include <asm/oplib.h>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <linux/futex.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <asm/errno.h>
|
||||
#include <asm/system.h>
|
||||
|
||||
#define __futex_cas_op(insn, ret, oldval, uaddr, oparg) \
|
||||
__asm__ __volatile__( \
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <linux/ioport.h> /* struct resource */
|
||||
|
||||
#include <asm/page.h> /* IO address mapping routines need this */
|
||||
#include <asm/system.h>
|
||||
#include <asm-generic/pci_iomap.h>
|
||||
|
||||
#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <asm/page.h> /* IO address mapping routines need this */
|
||||
#include <asm/system.h>
|
||||
#include <asm/asi.h>
|
||||
#include <asm-generic/pci_iomap.h>
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <asm/psr.h>
|
||||
|
||||
extern void arch_local_irq_restore(unsigned long);
|
||||
extern unsigned long arch_local_irq_save(void);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <linux/spinlock.h>
|
||||
#include <asm/system.h>
|
||||
#include <asm/spitfire.h>
|
||||
#include <asm-generic/mm_hooks.h>
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user