blob: 4a9845997a75b861dce954441f57c1c8dbc09e7c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/asm-arm/processor.h
3 *
4 * Copyright (C) 1995-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARM_PROCESSOR_H
12#define __ASM_ARM_PROCESSOR_H
13
14/*
15 * Default implementation of macro that returns current
16 * instruction pointer ("program counter").
17 */
18#define current_text_addr() ({ __label__ _l; _l: &&_l;})
19
20#ifdef __KERNEL__
21
22#include <asm/ptrace.h>
23#include <asm/procinfo.h>
24#include <asm/types.h>
25
26#define KERNEL_STACK_SIZE PAGE_SIZE
27
28union debug_insn {
29 u32 arm;
30 u16 thumb;
31};
32
33struct debug_entry {
34 u32 address;
35 union debug_insn insn;
36};
37
38struct debug_info {
39 int nsaved;
40 struct debug_entry bp[2];
41};
42
43struct thread_struct {
44 /* fault info */
45 unsigned long address;
46 unsigned long trap_no;
47 unsigned long error_code;
48 /* debugging */
49 struct debug_info debug;
50};
51
52#define INIT_THREAD { }
53
54#define start_thread(regs,pc,sp) \
55({ \
56 unsigned long *stack = (unsigned long *)sp; \
57 set_fs(USER_DS); \
58 memzero(regs->uregs, sizeof(regs->uregs)); \
59 if (current->personality & ADDR_LIMIT_32BIT) \
60 regs->ARM_cpsr = USR_MODE; \
61 else \
62 regs->ARM_cpsr = USR26_MODE; \
63 if (elf_hwcap & HWCAP_THUMB && pc & 1) \
64 regs->ARM_cpsr |= PSR_T_BIT; \
65 regs->ARM_pc = pc & ~1; /* pc */ \
66 regs->ARM_sp = sp; /* sp */ \
67 regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
68 regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
69 regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
70})
71
72/* Forward declaration, a strange C thing */
73struct task_struct;
74
75/* Free all resources held by a thread. */
76extern void release_thread(struct task_struct *);
77
78/* Prepare to copy thread state - unlazy all lazy status */
79#define prepare_to_copy(tsk) do { } while (0)
80
81unsigned long get_wchan(struct task_struct *p);
82
83#define cpu_relax() barrier()
84
85/*
86 * Create a new kernel thread
87 */
88extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
89
90#define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1019])
91#define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1017])
92
93/*
94 * Prefetching support - only ARMv5.
95 */
96#if __LINUX_ARM_ARCH__ >= 5
97
98#define ARCH_HAS_PREFETCH
99#define prefetch(ptr) \
100 ({ \
101 __asm__ __volatile__( \
102 "pld\t%0" \
103 : \
104 : "o" (*(char *)(ptr)) \
105 : "cc"); \
106 })
107
108#define ARCH_HAS_PREFETCHW
109#define prefetchw(ptr) prefetch(ptr)
110
111#define ARCH_HAS_SPINLOCK_PREFETCH
112#define spin_lock_prefetch(x) do { } while (0)
113
114#endif
115
116#endif
117
118#endif /* __ASM_ARM_PROCESSOR_H */