1 /* 2 * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 3 * Copyright (C) 2008-2009 PetaLogix 4 * Copyright (C) 2006 Atmark Techno, Inc. 5 * 6 * This file is subject to the terms and conditions of the GNU General Public 7 * License. See the file "COPYING" in the main directory of this archive 8 * for more details. 9 */ 10 11 #ifndef _ASM_MICROBLAZE_PROCESSOR_H 12 #define _ASM_MICROBLAZE_PROCESSOR_H 13 14 #include <asm/ptrace.h> 15 #include <asm/setup.h> 16 #include <asm/registers.h> 17 #include <asm/entry.h> 18 #include <asm/current.h> 19 20 # ifndef __ASSEMBLY__ 21 /* from kernel/cpu/mb.c */ 22 extern const struct seq_operations cpuinfo_op; 23 24 # define cpu_relax() barrier() 25 # define cpu_sleep() do {} while (0) 26 # define prepare_to_copy(tsk) do {} while (0) 27 28 #define task_pt_regs(tsk) \ 29 (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1) 30 31 /* Do necessary setup to start up a newly executed thread. */ 32 void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp); 33 34 extern void ret_from_fork(void); 35 36 # endif /* __ASSEMBLY__ */ 37 38 # ifndef CONFIG_MMU 39 /* 40 * User space process size: memory size 41 * 42 * TASK_SIZE on MMU cpu is usually 1GB. However, on no-MMU arch, both 43 * user processes and the kernel is on the same memory region. They 44 * both share the memory space and that is limited by the amount of 45 * physical memory. thus, we set TASK_SIZE == amount of total memory. 46 */ 47 # define TASK_SIZE (0x81000000 - 0x80000000) 48 49 /* 50 * Default implementation of macro that returns current 51 * instruction pointer ("program counter"). 52 */ 53 # define current_text_addr() ({ __label__ _l; _l: &&_l; }) 54 55 /* 56 * This decides where the kernel will search for a free chunk of vm 57 * space during mmap's. We won't be using it 58 */ 59 # define TASK_UNMAPPED_BASE 0 60 61 /* definition in include/linux/sched.h */ 62 struct task_struct; 63 64 /* thread_struct is gone. use thread_info instead. */ 65 struct thread_struct { }; 66 # define INIT_THREAD { } 67 68 /* Free all resources held by a thread. */ 69 static inline void release_thread(struct task_struct *dead_task) 70 { 71 } 72 73 /* Free all resources held by a thread. */ 74 static inline void exit_thread(void) 75 { 76 } 77 78 extern unsigned long thread_saved_pc(struct task_struct *t); 79 80 extern unsigned long get_wchan(struct task_struct *p); 81 82 /* 83 * create a kernel thread without removing it from tasklists 84 */ 85 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 86 87 # define KSTK_EIP(tsk) (0) 88 # define KSTK_ESP(tsk) (0) 89 90 # else /* CONFIG_MMU */ 91 92 /* 93 * This is used to define STACK_TOP, and with MMU it must be below 94 * kernel base to select the correct PGD when handling MMU exceptions. 95 */ 96 # define TASK_SIZE (CONFIG_KERNEL_START) 97 98 /* 99 * This decides where the kernel will search for a free chunk of vm 100 * space during mmap's. 101 */ 102 # define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) 103 104 # define THREAD_KSP 0 105 106 # ifndef __ASSEMBLY__ 107 108 /* 109 * Default implementation of macro that returns current 110 * instruction pointer ("program counter"). 111 */ 112 # define current_text_addr() ({ __label__ _l; _l: &&_l; }) 113 114 /* If you change this, you must change the associated assembly-languages 115 * constants defined below, THREAD_*. 116 */ 117 struct thread_struct { 118 /* kernel stack pointer (must be first field in structure) */ 119 unsigned long ksp; 120 unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ 121 void *pgdir; /* root of page-table tree */ 122 struct pt_regs *regs; /* Pointer to saved register state */ 123 }; 124 125 # define INIT_THREAD { \ 126 .ksp = sizeof init_stack + (unsigned long)init_stack, \ 127 .pgdir = swapper_pg_dir, \ 128 } 129 130 /* Free all resources held by a thread. */ 131 extern inline void release_thread(struct task_struct *dead_task) 132 { 133 } 134 135 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 136 137 /* Free current thread data structures etc. */ 138 static inline void exit_thread(void) 139 { 140 } 141 142 /* Return saved (kernel) PC of a blocked thread. */ 143 # define thread_saved_pc(tsk) \ 144 ((tsk)->thread.regs ? (tsk)->thread.regs->r15 : 0) 145 146 unsigned long get_wchan(struct task_struct *p); 147 148 /* The size allocated for kernel stacks. This _must_ be a power of two! */ 149 # define KERNEL_STACK_SIZE 0x2000 150 151 /* Return some info about the user process TASK. */ 152 # define task_tos(task) ((unsigned long)(task) + KERNEL_STACK_SIZE) 153 # define task_regs(task) ((struct pt_regs *)task_tos(task) - 1) 154 155 # define task_pt_regs_plus_args(tsk) \ 156 ((void *)task_pt_regs(tsk)) 157 158 # define task_sp(task) (task_regs(task)->r1) 159 # define task_pc(task) (task_regs(task)->pc) 160 /* Grotty old names for some. */ 161 # define KSTK_EIP(task) (task_pc(task)) 162 # define KSTK_ESP(task) (task_sp(task)) 163 164 /* FIXME */ 165 # define deactivate_mm(tsk, mm) do { } while (0) 166 167 # define STACK_TOP TASK_SIZE 168 # define STACK_TOP_MAX STACK_TOP 169 170 void disable_hlt(void); 171 void enable_hlt(void); 172 void default_idle(void); 173 174 #ifdef CONFIG_DEBUG_FS 175 extern struct dentry *of_debugfs_root; 176 #endif 177 178 # endif /* __ASSEMBLY__ */ 179 # endif /* CONFIG_MMU */ 180 #endif /* _ASM_MICROBLAZE_PROCESSOR_H */ 181