| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #ifndef __ASM_SH_SYSTEM_H
 | 
					
						
							|  |  |  | #define __ASM_SH_SYSTEM_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (C) 1999, 2000  Niibe Yutaka  &  Kaz Kojima | 
					
						
							|  |  |  |  * Copyright (C) 2002 Paul Mundt | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-04 18:17:28 +09:00
										 |  |  | #include <linux/irqflags.h>
 | 
					
						
							| 
									
										
										
										
											2007-03-28 17:26:19 +09:00
										 |  |  | #include <linux/compiler.h>
 | 
					
						
							| 
									
										
										
										
											2007-05-14 12:52:56 +09:00
										 |  |  | #include <linux/linkage.h>
 | 
					
						
							| 
									
										
										
										
											2006-09-27 11:28:20 +09:00
										 |  |  | #include <asm/types.h>
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-10 16:21:57 +09:00
										 |  |  | #define AT_VECTOR_SIZE_ARCH 5 /* entries in ARCH_DLINFO */
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-27 14:57:44 +09:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * 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. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2007-11-10 19:46:31 +09:00
										 |  |  | #if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5)
 | 
					
						
							| 
									
										
										
										
											2006-09-27 14:57:44 +09:00
										 |  |  | #define mb()		__asm__ __volatile__ ("synco": : :"memory")
 | 
					
						
							|  |  |  | #define rmb()		mb()
 | 
					
						
							|  |  |  | #define wmb()		__asm__ __volatile__ ("synco": : :"memory")
 | 
					
						
							| 
									
										
										
										
											2010-01-13 12:59:24 +09:00
										 |  |  | #define ctrl_barrier()	__icbi(PAGE_OFFSET)
 | 
					
						
							| 
									
										
										
										
											2006-09-27 14:05:52 +09:00
										 |  |  | #define read_barrier_depends()	do { } while(0)
 | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2006-09-27 14:57:44 +09:00
										 |  |  | #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")
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #define read_barrier_depends()	do { } while(0)
 | 
					
						
							| 
									
										
										
										
											2006-09-27 14:05:52 +09:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-11 15:32:07 +09:00
										 |  |  | #define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-30 16:12:36 +09:00
										 |  |  | #ifdef CONFIG_GUSA_RB
 | 
					
						
							|  |  |  | #include <asm/cmpxchg-grb.h>
 | 
					
						
							| 
									
										
										
										
											2008-08-07 18:01:43 +09:00
										 |  |  | #elif defined(CONFIG_CPU_SH4A)
 | 
					
						
							|  |  |  | #include <asm/cmpxchg-llsc.h>
 | 
					
						
							| 
									
										
										
										
											2007-11-30 16:12:36 +09:00
										 |  |  | #else
 | 
					
						
							|  |  |  | #include <asm/cmpxchg-irq.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-27 16:05:56 +09:00
										 |  |  | 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)))) | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-27 11:28:20 +09:00
										 |  |  | /* 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))); \ | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-12 15:40:00 +09:00
										 |  |  | struct pt_regs; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-01 16:33:10 +09:00
										 |  |  | extern void die(const char *str, struct pt_regs *regs, long err) __attribute__ ((noreturn)); | 
					
						
							| 
									
										
										
										
											2008-09-04 18:53:58 +09:00
										 |  |  | void free_initmem(void); | 
					
						
							|  |  |  | void free_initrd_mem(unsigned long start, unsigned long end); | 
					
						
							| 
									
										
										
										
											2007-05-01 16:33:10 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-19 16:20:25 +09:00
										 |  |  | extern void *set_exception_table_vec(unsigned int vec, void *handler); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void *set_exception_table_evt(unsigned int evt, void *handler) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return set_exception_table_vec(evt >> 5, handler); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-08 14:50:59 +09:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * 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); | 
					
						
							| 
									
										
										
										
											2007-11-08 19:08:28 +09:00
										 |  |  | #elif defined(CONFIG_SUPERH32)
 | 
					
						
							| 
									
										
										
										
											2007-05-08 14:50:59 +09:00
										 |  |  | #define instruction_size(insn)	(2)
 | 
					
						
							| 
									
										
										
										
											2007-11-08 19:08:28 +09:00
										 |  |  | #else
 | 
					
						
							|  |  |  | #define instruction_size(insn)	(4)
 | 
					
						
							| 
									
										
										
										
											2007-05-08 14:50:59 +09:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-30 17:06:36 +09:00
										 |  |  | extern unsigned long cached_to_uncached; | 
					
						
							| 
									
										
										
										
											2010-01-21 15:54:31 +09:00
										 |  |  | extern unsigned long uncached_size; | 
					
						
							| 
									
										
										
										
											2007-11-30 17:06:36 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-07 17:19:58 +09:00
										 |  |  | extern struct dentry *sh_debugfs_root; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-21 18:32:32 +09:00
										 |  |  | void per_cpu_trap_init(void); | 
					
						
							| 
									
										
										
										
											2009-04-02 13:08:31 +09:00
										 |  |  | void default_idle(void); | 
					
						
							| 
									
										
										
										
											2009-06-19 14:40:51 +09:00
										 |  |  | void cpu_idle_wait(void); | 
					
						
							| 
									
										
										
										
											2010-01-20 16:42:52 +09:00
										 |  |  | void stop_this_cpu(void *); | 
					
						
							| 
									
										
										
										
											2007-05-14 12:52:56 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-20 18:08:06 +09:00
										 |  |  | #ifdef CONFIG_SUPERH32
 | 
					
						
							|  |  |  | #define BUILD_TRAP_HANDLER(name)					\
 | 
					
						
							|  |  |  | asmlinkage void name##_trap_handler(unsigned long r4, unsigned long r5,	\ | 
					
						
							|  |  |  | 				    unsigned long r6, unsigned long r7,	\ | 
					
						
							|  |  |  | 				    struct pt_regs __regs) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define TRAP_HANDLER_DECL				\
 | 
					
						
							|  |  |  | 	struct pt_regs *regs = RELOC_HIDE(&__regs, 0);	\ | 
					
						
							| 
									
										
										
										
											2007-11-23 14:02:20 +09:00
										 |  |  | 	unsigned int vec = regs->tra;			\ | 
					
						
							|  |  |  | 	(void)vec; | 
					
						
							| 
									
										
										
										
											2007-11-20 18:08:06 +09:00
										 |  |  | #else
 | 
					
						
							|  |  |  | #define BUILD_TRAP_HANDLER(name)	\
 | 
					
						
							|  |  |  | asmlinkage void name##_trap_handler(unsigned int vec, struct pt_regs *regs) | 
					
						
							|  |  |  | #define TRAP_HANDLER_DECL
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BUILD_TRAP_HANDLER(address_error); | 
					
						
							|  |  |  | BUILD_TRAP_HANDLER(debug); | 
					
						
							|  |  |  | BUILD_TRAP_HANDLER(bug); | 
					
						
							| 
									
										
										
										
											2008-12-11 18:46:46 +09:00
										 |  |  | BUILD_TRAP_HANDLER(breakpoint); | 
					
						
							|  |  |  | BUILD_TRAP_HANDLER(singlestep); | 
					
						
							| 
									
										
										
										
											2007-11-26 20:38:36 +09:00
										 |  |  | BUILD_TRAP_HANDLER(fpu_error); | 
					
						
							|  |  |  | BUILD_TRAP_HANDLER(fpu_state_restore); | 
					
						
							| 
									
										
										
										
											2009-09-01 17:38:32 +09:00
										 |  |  | BUILD_TRAP_HANDLER(nmi); | 
					
						
							| 
									
										
										
										
											2009-08-16 21:54:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #define arch_align_stack(x) (x)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-07 20:18:21 +09:00
										 |  |  | struct mem_access { | 
					
						
							| 
									
										
										
										
											2008-09-04 18:53:58 +09:00
										 |  |  | 	unsigned long (*from)(void *dst, const void __user *src, unsigned long cnt); | 
					
						
							|  |  |  | 	unsigned long (*to)(void __user *dst, const void *src, unsigned long cnt); | 
					
						
							| 
									
										
										
										
											2008-02-07 20:18:21 +09:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-10 19:46:31 +09:00
										 |  |  | #ifdef CONFIG_SUPERH32
 | 
					
						
							|  |  |  | # include "system_32.h"
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | # include "system_64.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | #endif
 |