OSDN Git Service

69d1bdca2c5b79453ce270d80e9f72a3de60909a
[uclinux-h8/linux.git] / arch / h8300 / include / asm / processor.h
1 /*
2  * include/asm-h8300/processor.h
3  *
4  * Copyright (C) 2002 Yoshinori Sato
5  *
6  * Based on: linux/asm-m68nommu/processor.h
7  *
8  * Copyright (C) 1995 Hamish Macdonald
9  */
10
11 #ifndef __ASM_H8300_PROCESSOR_H
12 #define __ASM_H8300_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 #include <linux/compiler.h>
21 #include <asm/segment.h>
22 #include <asm/ptrace.h>
23 #include <asm/current.h>
24
25 static inline unsigned long rdusp(void) {
26         extern unsigned int     _sw_usp;
27         return _sw_usp;
28 }
29
30 static inline void wrusp(unsigned long usp) {
31         extern unsigned int     _sw_usp;
32         _sw_usp = usp;
33 }
34
35 /*
36  * User space process size: 3.75GB. This is hardcoded into a few places,
37  * so don't change it unless you know what you are doing.
38  */
39 #define TASK_SIZE       (0xFFFFFFFFUL)
40
41 #ifdef __KERNEL__
42 #define STACK_TOP       TASK_SIZE
43 #define STACK_TOP_MAX   STACK_TOP
44 #endif
45
46 /*
47  * This decides where the kernel will search for a free chunk of vm
48  * space during mmap's. We won't be using it
49  */
50 #define TASK_UNMAPPED_BASE      0
51
52 struct thread_struct {
53         unsigned long  ksp;             /* kernel stack pointer */
54         unsigned long  usp;             /* user stack pointer */
55         unsigned long  ccr;             /* saved status register */
56         unsigned long  esp0;            /* points to SR of stack frame */
57         struct {
58                 unsigned short *addr;
59                 unsigned short inst;
60         } breakinfo;
61 };
62
63 #define INIT_THREAD  {                                          \
64         .ksp  = sizeof(init_stack) + (unsigned long)init_stack, \
65         .usp  = 0,                                              \
66         .ccr  = PS_S,                                           \
67         .esp0 = 0,                                              \
68         .breakinfo = {                                          \
69                 .addr = (unsigned short *)-1,                   \
70                 .inst = 0                                       \
71         }                                                       \
72 }
73
74 /*
75  * Do necessary setup to start up a newly executed thread.
76  *
77  * pass the data segment into user programs if it exists,
78  * it can't hurt anything as far as I can tell
79  */
80 #if defined(CONFIG_CPU_H8300H)
81 #define start_thread(_regs, _pc, _usp)                          \
82 do {                                                            \
83         (_regs)->pc = (_pc);                                    \
84         (_regs)->ccr = 0x00;       /* clear all flags */        \
85         (_regs)->er5 = current->mm->start_data; /* GOT base */  \
86         wrusp((unsigned long)(_usp) - sizeof(unsigned long)*3); \
87 } while(0)
88 #endif
89 #if defined(CONFIG_CPU_H8S)
90 #define start_thread(_regs, _pc, _usp)                          \
91 do {                                                            \
92         (_regs)->pc = (_pc);                                    \
93         (_regs)->ccr = 0x00;       /* clear kernel flag */      \
94         (_regs)->exr = 0x78;       /* enable all interrupts */  \
95         (_regs)->er5 = current->mm->start_data; /* GOT base */  \
96         /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \
97         wrusp(((unsigned long)(_usp)) - 14);                    \
98 } while(0)
99 #endif
100
101 /* Forward declaration, a strange C thing */
102 struct task_struct;
103
104 /* Free all resources held by a thread. */
105 static inline void release_thread(struct task_struct *dead_task)
106 {
107 }
108
109 /*
110  * Free current thread data structures etc..
111  */
112 static inline void exit_thread(void)
113 {
114 }
115
116 /*
117  * Return saved PC of a blocked thread.
118  */
119 unsigned long thread_saved_pc(struct task_struct *tsk);
120 unsigned long get_wchan(struct task_struct *p);
121
122 #define KSTK_EIP(tsk)   \
123     ({                  \
124         unsigned long eip = 0;   \
125         if ((tsk)->thread.esp0 > PAGE_SIZE && \
126             MAP_NR((tsk)->thread.esp0) < max_mapnr) \
127               eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
128         eip; })
129 #define KSTK_ESP(tsk)   ((tsk) == current ? rdusp() : (tsk)->thread.usp)
130
131 #define cpu_relax()    barrier()
132 #define cpu_relax_lowlatency()  cpu_relax()
133
134 #define HARD_RESET_NOW() ({             \
135         local_irq_disable();            \
136         asm("jmp @@0");                 \
137 })
138
139 #endif