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