blob: 0ee158e09abb3f259f7fb9f6572893748850ac62 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/asm-m68k/processor.h
3 *
4 * Copyright (C) 1995 Hamish Macdonald
5 */
6
7#ifndef __ASM_M68K_PROCESSOR_H
8#define __ASM_M68K_PROCESSOR_H
9
10/*
11 * Default implementation of macro that returns current
12 * instruction pointer ("program counter").
13 */
14#define current_text_addr() ({ __label__ _l; _l: &&_l;})
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/threads.h>
17#include <asm/types.h>
18#include <asm/segment.h>
19#include <asm/fpu.h>
20#include <asm/ptrace.h>
21#include <asm/current.h>
22
Greg Ungererc514b8b2005-11-02 14:42:03 +100023static inline unsigned long rdusp(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
25#ifdef CONFIG_COLDFIRE
26 extern unsigned int sw_usp;
27 return(sw_usp);
28#else
29 unsigned long usp;
30 __asm__ __volatile__("move %/usp,%0" : "=a" (usp));
31 return usp;
32#endif
33}
34
Greg Ungererc514b8b2005-11-02 14:42:03 +100035static inline void wrusp(unsigned long usp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
37#ifdef CONFIG_COLDFIRE
38 extern unsigned int sw_usp;
39 sw_usp = usp;
40#else
41 __asm__ __volatile__("move %0,%/usp" : : "a" (usp));
42#endif
43}
44
45/*
46 * User space process size: 3.75GB. This is hardcoded into a few places,
47 * so don't change it unless you know what you are doing.
48 */
49#define TASK_SIZE (0xF0000000UL)
50
51/*
52 * This decides where the kernel will search for a free chunk of vm
53 * space during mmap's. We won't be using it
54 */
55#define TASK_UNMAPPED_BASE 0
56
57/*
58 * if you change this structure, you must change the code and offsets
59 * in m68k/machasm.S
60 */
61
62struct thread_struct {
63 unsigned long ksp; /* kernel stack pointer */
64 unsigned long usp; /* user stack pointer */
65 unsigned short sr; /* saved status register */
66 unsigned short fs; /* saved fs (sfc, dfc) */
67 unsigned long crp[2]; /* cpu root pointer */
68 unsigned long esp0; /* points to SR of stack frame */
69 unsigned long fp[8*3];
70 unsigned long fpcntl[3]; /* fp control regs */
71 unsigned char fpstate[FPSTATESIZE]; /* floating point state */
72};
73
74#define INIT_THREAD { \
75 sizeof(init_stack) + (unsigned long) init_stack, 0, \
76 PS_S, __KERNEL_DS, \
77 {0, 0}, 0, {0,}, {0, 0, 0}, {0,}, \
78}
79
80/*
Greg Ungerer7bf9a372006-06-26 11:01:32 +100081 * Coldfire stacks need to be re-aligned on trap exit, conventional
82 * 68k can handle this case cleanly.
83 */
84#if defined(CONFIG_COLDFIRE)
85#define reformat(_regs) do { (_regs)->format = 0x4; } while(0)
86#else
87#define reformat(_regs) do { } while (0)
88#endif
89
90/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 * Do necessary setup to start up a newly executed thread.
92 *
93 * pass the data segment into user programs if it exists,
94 * it can't hurt anything as far as I can tell
95 */
Greg Ungerer7bf9a372006-06-26 11:01:32 +100096#define start_thread(_regs, _pc, _usp) \
97do { \
98 set_fs(USER_DS); /* reads from user space */ \
99 (_regs)->pc = (_pc); \
100 ((struct switch_stack *)(_regs))[-1].a6 = 0; \
101 reformat(_regs); \
102 if (current->mm) \
103 (_regs)->d5 = current->mm->start_data; \
104 (_regs)->sr &= ~0x2000; \
105 wrusp(_usp); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106} while(0)
107
108/* Forward declaration, a strange C thing */
109struct task_struct;
110
111/* Free all resources held by a thread. */
112static inline void release_thread(struct task_struct *dead_task)
113{
114}
115
116/* Prepare to copy thread state - unlazy all lazy status */
117#define prepare_to_copy(tsk) do { } while (0)
118
119extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
120
121/*
122 * Free current thread data structures etc..
123 */
124static inline void exit_thread(void)
125{
126}
127
128unsigned long thread_saved_pc(struct task_struct *tsk);
129unsigned long get_wchan(struct task_struct *p);
130
131#define KSTK_EIP(tsk) \
132 ({ \
133 unsigned long eip = 0; \
134 if ((tsk)->thread.esp0 > PAGE_SIZE && \
135 (virt_addr_valid((tsk)->thread.esp0))) \
136 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
137 eip; })
138#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
139
140#define cpu_relax() do { } while (0)
141
142#endif