processor.h 3.0 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 *  arch/arm/include/asm/processor.h
L
Linus Torvalds 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 *  Copyright (C) 1995-1999 Russell King
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef __ASM_ARM_PROCESSOR_H
#define __ASM_ARM_PROCESSOR_H

/*
 * Default implementation of macro that returns current
 * instruction pointer ("program counter").
 */
#define current_text_addr() ({ __label__ _l; _l: &&_l;})

#ifdef __KERNEL__

22
#include <asm/hw_breakpoint.h>
L
Linus Torvalds 已提交
23 24
#include <asm/ptrace.h>
#include <asm/types.h>
25
#include <asm/unified.h>
L
Linus Torvalds 已提交
26

27
#ifdef __KERNEL__
28
#define STACK_TOP	((current->personality & ADDR_LIMIT_32BIT) ? \
29 30 31 32
			 TASK_SIZE : TASK_SIZE_26)
#define STACK_TOP_MAX	TASK_SIZE
#endif

L
Linus Torvalds 已提交
33
struct debug_info {
34 35 36
#ifdef CONFIG_HAVE_HW_BREAKPOINT
	struct perf_event	*hbp[ARM_MAX_HBP_SLOTS];
#endif
L
Linus Torvalds 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49
};

struct thread_struct {
							/* fault info	  */
	unsigned long		address;
	unsigned long		trap_no;
	unsigned long		error_code;
							/* debugging	  */
	struct debug_info	debug;
};

#define INIT_THREAD  {	}

50 51 52 53 54 55
#ifdef CONFIG_MMU
#define nommu_start_thread(regs) do { } while (0)
#else
#define nommu_start_thread(regs) regs->ARM_r10 = current->mm->start_data
#endif

L
Linus Torvalds 已提交
56 57
#define start_thread(regs,pc,sp)					\
({									\
R
Russell King 已提交
58
	memset(regs->uregs, 0, sizeof(regs->uregs));			\
L
Linus Torvalds 已提交
59 60 61 62 63 64
	if (current->personality & ADDR_LIMIT_32BIT)			\
		regs->ARM_cpsr = USR_MODE;				\
	else								\
		regs->ARM_cpsr = USR26_MODE;				\
	if (elf_hwcap & HWCAP_THUMB && pc & 1)				\
		regs->ARM_cpsr |= PSR_T_BIT;				\
65
	regs->ARM_cpsr |= PSR_ENDSTATE;					\
L
Linus Torvalds 已提交
66 67
	regs->ARM_pc = pc & ~1;		/* pc */			\
	regs->ARM_sp = sp;		/* sp */			\
68
	nommu_start_thread(regs);					\
L
Linus Torvalds 已提交
69 70 71 72 73 74 75 76 77 78
})

/* Forward declaration, a strange C thing */
struct task_struct;

/* Free all resources held by a thread. */
extern void release_thread(struct task_struct *);

unsigned long get_wchan(struct task_struct *p);

79
#if __LINUX_ARM_ARCH__ == 6 || defined(CONFIG_ARM_ERRATA_754327)
80 81
#define cpu_relax()			smp_mb()
#else
L
Linus Torvalds 已提交
82
#define cpu_relax()			barrier()
83
#endif
L
Linus Torvalds 已提交
84

85
#define cpu_relax_yield()  	              cpu_relax()
86

A
Al Viro 已提交
87
#define task_pt_regs(p) \
A
Al Viro 已提交
88
	((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
A
Al Viro 已提交
89 90 91

#define KSTK_EIP(tsk)	task_pt_regs(tsk)->ARM_pc
#define KSTK_ESP(tsk)	task_pt_regs(tsk)->ARM_sp
L
Linus Torvalds 已提交
92

93 94 95 96 97 98 99 100 101 102 103
#ifdef CONFIG_SMP
#define __ALT_SMP_ASM(smp, up)						\
	"9998:	" smp "\n"						\
	"	.pushsection \".alt.smp.init\", \"a\"\n"		\
	"	.long	9998b\n"					\
	"	" up "\n"						\
	"	.popsection\n"
#else
#define __ALT_SMP_ASM(smp, up)	up
#endif

L
Linus Torvalds 已提交
104 105 106 107 108 109
/*
 * Prefetching support - only ARMv5.
 */
#if __LINUX_ARM_ARCH__ >= 5

#define ARCH_HAS_PREFETCH
110 111 112
static inline void prefetch(const void *ptr)
{
	__asm__ __volatile__(
113
		"pld\t%a0"
114
		:: "p" (ptr));
115
}
L
Linus Torvalds 已提交
116

117
#if __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
L
Linus Torvalds 已提交
118
#define ARCH_HAS_PREFETCHW
119 120 121 122 123 124 125 126 127 128 129
static inline void prefetchw(const void *ptr)
{
	__asm__ __volatile__(
		".arch_extension	mp\n"
		__ALT_SMP_ASM(
			WASM(pldw)		"\t%a0",
			WASM(pld)		"\t%a0"
		)
		:: "p" (ptr));
}
#endif
L
Linus Torvalds 已提交
130 131
#endif

R
Rob Herring 已提交
132 133
#define HAVE_ARCH_PICK_MMAP_LAYOUT

L
Linus Torvalds 已提交
134 135 136
#endif

#endif /* __ASM_ARM_PROCESSOR_H */