Skip to content

Commit

Permalink
Disintegrate asm/system.h for SH
Browse files Browse the repository at this point in the history
Disintegrate asm/system.h for SH.

Signed-off-by: David Howells <[email protected]>
cc: [email protected]
  • Loading branch information
dhowells committed Mar 28, 2012
1 parent 4eb14db commit e839ca5
Show file tree
Hide file tree
Showing 56 changed files with 503 additions and 396 deletions.
1 change: 0 additions & 1 deletion arch/sh/boards/mach-microdev/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <asm/system.h>
#include <asm/io.h>
#include <mach/microdev.h>

Expand Down
2 changes: 2 additions & 0 deletions arch/sh/include/asm/atomic-irq.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef __ASM_SH_ATOMIC_IRQ_H
#define __ASM_SH_ATOMIC_IRQ_H

#include <linux/irqflags.h>

/*
* To get proper branch prediction for the main line, we must branch
* forward to code at the end of this object's .text section, then
Expand Down
2 changes: 1 addition & 1 deletion arch/sh/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/system.h>
#include <asm/cmpxchg.h>

#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )

Expand Down
2 changes: 2 additions & 0 deletions arch/sh/include/asm/auxvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
#define AT_L1D_CACHESHAPE 35
#define AT_L2_CACHESHAPE 36

#define AT_VECTOR_SIZE_ARCH 5 /* entries in ARCH_DLINFO */

#endif /* __ASM_SH_AUXVEC_H */
54 changes: 54 additions & 0 deletions arch/sh/include/asm/barrier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
* Copyright (C) 2002 Paul Mundt
*/
#ifndef __ASM_SH_BARRIER_H
#define __ASM_SH_BARRIER_H

#if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5)
#include <asm/cache_insns.h>
#endif

/*
* A brief note on ctrl_barrier(), the control register write barrier.
*
* Legacy SH cores typically require a sequence of 8 nops after
* modification of a control register in order for the changes to take
* effect. On newer cores (like the sh4a and sh5) this is accomplished
* with icbi.
*
* Also note that on sh4a in the icbi case we can forego a synco for the
* write barrier, as it's not necessary for control registers.
*
* Historically we have only done this type of barrier for the MMUCR, but
* it's also necessary for the CCR, so we make it generic here instead.
*/
#if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5)
#define mb() __asm__ __volatile__ ("synco": : :"memory")
#define rmb() mb()
#define wmb() __asm__ __volatile__ ("synco": : :"memory")
#define ctrl_barrier() __icbi(PAGE_OFFSET)
#define read_barrier_depends() do { } while(0)
#else
#define mb() __asm__ __volatile__ ("": : :"memory")
#define rmb() mb()
#define wmb() __asm__ __volatile__ ("": : :"memory")
#define ctrl_barrier() __asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop")
#define read_barrier_depends() do { } while(0)
#endif

#ifdef CONFIG_SMP
#define smp_mb() mb()
#define smp_rmb() rmb()
#define smp_wmb() wmb()
#define smp_read_barrier_depends() read_barrier_depends()
#else
#define smp_mb() barrier()
#define smp_rmb() barrier()
#define smp_wmb() barrier()
#define smp_read_barrier_depends() do { } while(0)
#endif

#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)

#endif /* __ASM_SH_BARRIER_H */
1 change: 0 additions & 1 deletion arch/sh/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#error only <linux/bitops.h> can be included directly
#endif

#include <asm/system.h>
/* For __swab32 */
#include <asm/byteorder.h>

Expand Down
10 changes: 10 additions & 0 deletions arch/sh/include/asm/bl_bit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __ASM_SH_BL_BIT_H
#define __ASM_SH_BL_BIT_H

#ifdef CONFIG_SUPERH32
# include "bl_bit_32.h"
#else
# include "bl_bit_64.h"
#endif

#endif /* __ASM_SH_BL_BIT_H */
33 changes: 33 additions & 0 deletions arch/sh/include/asm/bl_bit_32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef __ASM_SH_BL_BIT_32_H
#define __ASM_SH_BL_BIT_32_H

static inline void set_bl_bit(void)
{
unsigned long __dummy0, __dummy1;

__asm__ __volatile__ (
"stc sr, %0\n\t"
"or %2, %0\n\t"
"and %3, %0\n\t"
"ldc %0, sr\n\t"
: "=&r" (__dummy0), "=r" (__dummy1)
: "r" (0x10000000), "r" (0xffffff0f)
: "memory"
);
}

static inline void clear_bl_bit(void)
{
unsigned long __dummy0, __dummy1;

__asm__ __volatile__ (
"stc sr, %0\n\t"
"and %2, %0\n\t"
"ldc %0, sr\n\t"
: "=&r" (__dummy0), "=r" (__dummy1)
: "1" (~0x10000000)
: "memory"
);
}

#endif /* __ASM_SH_BL_BIT_32_H */
40 changes: 40 additions & 0 deletions arch/sh/include/asm/bl_bit_64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2000, 2001 Paolo Alberelli
* Copyright (C) 2003 Paul Mundt
* Copyright (C) 2004 Richard Curnow
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#ifndef __ASM_SH_BL_BIT_64_H
#define __ASM_SH_BL_BIT_64_H

#include <asm/processor.h>

#define SR_BL_LL 0x0000000010000000LL

static inline void set_bl_bit(void)
{
unsigned long long __dummy0, __dummy1 = SR_BL_LL;

__asm__ __volatile__("getcon " __SR ", %0\n\t"
"or %0, %1, %0\n\t"
"putcon %0, " __SR "\n\t"
: "=&r" (__dummy0)
: "r" (__dummy1));

}

static inline void clear_bl_bit(void)
{
unsigned long long __dummy0, __dummy1 = ~SR_BL_LL;

__asm__ __volatile__("getcon " __SR ", %0\n\t"
"and %0, %1, %0\n\t"
"putcon %0, " __SR "\n\t"
: "=&r" (__dummy0)
: "r" (__dummy1));
}

#endif /* __ASM_SH_BL_BIT_64_H */
5 changes: 5 additions & 0 deletions arch/sh/include/asm/bug.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef __ASM_SH_BUG_H
#define __ASM_SH_BUG_H

#include <linux/linkage.h>

#define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */
#define BUGFLAG_UNWINDER (1 << 1)

Expand Down Expand Up @@ -107,4 +109,7 @@ do { \

#include <asm-generic/bug.h>

struct pt_regs;
extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn));

#endif /* __ASM_SH_BUG_H */
11 changes: 11 additions & 0 deletions arch/sh/include/asm/cache_insns.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __ASM_SH_CACHE_INSNS_H
#define __ASM_SH_CACHE_INSNS_H


#ifdef CONFIG_SUPERH32
# include "cache_insns_32.h"
#else
# include "cache_insns_64.h"
#endif

#endif /* __ASM_SH_CACHE_INSNS_H */
21 changes: 21 additions & 0 deletions arch/sh/include/asm/cache_insns_32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef __ASM_SH_CACHE_INSNS_32_H
#define __ASM_SH_CACHE_INSNS_32_H

#include <linux/types.h>

#if defined(CONFIG_CPU_SH4A)
#define __icbi(addr) __asm__ __volatile__ ( "icbi @%0\n\t" : : "r" (addr))
#else
#define __icbi(addr) mb()
#endif

#define __ocbp(addr) __asm__ __volatile__ ( "ocbp @%0\n\t" : : "r" (addr))
#define __ocbi(addr) __asm__ __volatile__ ( "ocbi @%0\n\t" : : "r" (addr))
#define __ocbwb(addr) __asm__ __volatile__ ( "ocbwb @%0\n\t" : : "r" (addr))

static inline reg_size_t register_align(void *val)
{
return (unsigned long)(signed long)val;
}

#endif /* __ASM_SH_CACHE_INSNS_32_H */
23 changes: 23 additions & 0 deletions arch/sh/include/asm/cache_insns_64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2000, 2001 Paolo Alberelli
* Copyright (C) 2003 Paul Mundt
* Copyright (C) 2004 Richard Curnow
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#ifndef __ASM_SH_CACHE_INSNS_64_H
#define __ASM_SH_CACHE_INSNS_64_H

#define __icbi(addr) __asm__ __volatile__ ( "icbi %0, 0\n\t" : : "r" (addr))
#define __ocbp(addr) __asm__ __volatile__ ( "ocbp %0, 0\n\t" : : "r" (addr))
#define __ocbi(addr) __asm__ __volatile__ ( "ocbi %0, 0\n\t" : : "r" (addr))
#define __ocbwb(addr) __asm__ __volatile__ ( "ocbwb %0, 0\n\t" : : "r" (addr))

static inline reg_size_t register_align(void *val)
{
return (unsigned long long)(signed long long)(signed long)val;
}

#endif /* __ASM_SH_CACHE_INSNS_64_H */
2 changes: 2 additions & 0 deletions arch/sh/include/asm/cmpxchg-irq.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef __ASM_SH_CMPXCHG_IRQ_H
#define __ASM_SH_CMPXCHG_IRQ_H

#include <linux/irqflags.h>

static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
{
unsigned long flags, retval;
Expand Down
70 changes: 70 additions & 0 deletions arch/sh/include/asm/cmpxchg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#ifndef __ASM_SH_CMPXCHG_H
#define __ASM_SH_CMPXCHG_H

/*
* Atomic operations that C can't guarantee us. Useful for
* resource counting etc..
*/

#include <linux/compiler.h>
#include <linux/types.h>

#if defined(CONFIG_GUSA_RB)
#include <asm/cmpxchg-grb.h>
#elif defined(CONFIG_CPU_SH4A)
#include <asm/cmpxchg-llsc.h>
#else
#include <asm/cmpxchg-irq.h>
#endif

extern void __xchg_called_with_bad_pointer(void);

#define __xchg(ptr, x, size) \
({ \
unsigned long __xchg__res; \
volatile void *__xchg_ptr = (ptr); \
switch (size) { \
case 4: \
__xchg__res = xchg_u32(__xchg_ptr, x); \
break; \
case 1: \
__xchg__res = xchg_u8(__xchg_ptr, x); \
break; \
default: \
__xchg_called_with_bad_pointer(); \
__xchg__res = x; \
break; \
} \
\
__xchg__res; \
})

#define xchg(ptr,x) \
((__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr))))

/* 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);

#define __HAVE_ARCH_CMPXCHG 1

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);
}
__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))); \
})

#endif /* __ASM_SH_CMPXCHG_H */
10 changes: 10 additions & 0 deletions arch/sh/include/asm/exec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
* Copyright (C) 2002 Paul Mundt
*/
#ifndef __ASM_SH_EXEC_H
#define __ASM_SH_EXEC_H

#define arch_align_stack(x) (x)

#endif /* __ASM_SH_EXEC_H */
1 change: 0 additions & 1 deletion arch/sh/include/asm/futex-irq.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef __ASM_SH_FUTEX_IRQ_H
#define __ASM_SH_FUTEX_IRQ_H

#include <asm/system.h>

static inline int atomic_futex_op_xchg_set(int oparg, u32 __user *uaddr,
int *oldval)
Expand Down
1 change: 0 additions & 1 deletion arch/sh/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
#include <linux/errno.h>
#include <asm/cache.h>
#include <asm/system.h>
#include <asm/addrspace.h>
#include <asm/machvec.h>
#include <asm/pgtable.h>
Expand Down
15 changes: 15 additions & 0 deletions arch/sh/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ extern struct sh_cpuinfo cpu_data[];
#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory")
#define cpu_relax() barrier()

void default_idle(void);
void cpu_idle_wait(void);
void stop_this_cpu(void *);

/* Forward decl */
struct seq_operations;
struct task_struct;
Expand Down Expand Up @@ -161,6 +165,17 @@ int vsyscall_init(void);
#define vsyscall_init() do { } while (0)
#endif

/*
* SH-2A has both 16 and 32-bit opcodes, do lame encoding checks.
*/
#ifdef CONFIG_CPU_SH2A
extern unsigned int instruction_size(unsigned int insn);
#elif defined(CONFIG_SUPERH32)
#define instruction_size(insn) (2)
#else
#define instruction_size(insn) (4)
#endif

#endif /* __ASSEMBLY__ */

#ifdef CONFIG_SUPERH32
Expand Down
Loading

0 comments on commit e839ca5

Please sign in to comment.