1 /* 2 * Process/processor support for the Hexagon architecture 3 * 4 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. 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 and 8 * only version 2 as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 * 02110-1301, USA. 19 */ 20 21 #ifndef _ASM_PROCESSOR_H 22 #define _ASM_PROCESSOR_H 23 24 #ifndef __ASSEMBLY__ 25 26 #include <asm/mem-layout.h> 27 #include <asm/registers.h> 28 #include <asm/hexagon_vm.h> 29 30 /* task_struct, defined elsewhere, is the "process descriptor" */ 31 struct task_struct; 32 33 extern void start_thread(struct pt_regs *, unsigned long, unsigned long); 34 35 /* 36 * thread_struct is supposed to be for context switch data. 37 * Specifically, to hold the state necessary to perform switch_to... 38 */ 39 struct thread_struct { 40 void *switch_sp; 41 }; 42 43 /* 44 * initializes thread_struct 45 * The only thing we have in there is switch_sp 46 * which doesn't really need to be initialized. 47 */ 48 49 #define INIT_THREAD { \ 50 } 51 52 #define cpu_relax() __vmyield() 53 54 /* 55 * Decides where the kernel will search for a free chunk of vm space during 56 * mmaps. 57 * See also arch_get_unmapped_area. 58 * Doesn't affect if you have MAX_FIXED in the page flags set though... 59 * 60 * Apparently the convention is that ld.so will ask for "unmapped" private 61 * memory to be allocated SOMEWHERE, but it also asks for memory explicitly 62 * via MAP_FIXED at the lower * addresses starting at VA=0x0. 63 * 64 * If the two requests collide, you get authentic segfaulting action, so 65 * you have to kick the "unmapped" base requests higher up. 66 */ 67 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE/3)) 68 69 70 #define task_pt_regs(task) \ 71 ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1) 72 73 #define KSTK_EIP(tsk) (pt_elr(task_pt_regs(tsk))) 74 #define KSTK_ESP(tsk) (pt_psp(task_pt_regs(tsk))) 75 76 /* Free all resources held by a thread; defined in process.c */ 77 extern void release_thread(struct task_struct *dead_task); 78 79 /* Get wait channel for task P. */ 80 extern unsigned long get_wchan(struct task_struct *p); 81 82 /* The following stuff is pretty HEXAGON specific. */ 83 84 /* This is really just here for __switch_to. 85 Offsets are pulled via asm-offsets.c */ 86 87 /* 88 * No real reason why VM and native switch stacks should be different. 89 * Ultimately this should merge. Note that Rev C. ABI called out only 90 * R24-27 as callee saved GPRs needing explicit attention (R29-31 being 91 * dealt with automagically by allocframe), but the current ABI has 92 * more, R16-R27. By saving more, the worst case is that we waste some 93 * cycles if building with the old compilers. 94 */ 95 96 struct hexagon_switch_stack { 97 union { 98 struct { 99 unsigned long r16; 100 unsigned long r17; 101 }; 102 unsigned long long r1716; 103 }; 104 union { 105 struct { 106 unsigned long r18; 107 unsigned long r19; 108 }; 109 unsigned long long r1918; 110 }; 111 union { 112 struct { 113 unsigned long r20; 114 unsigned long r21; 115 }; 116 unsigned long long r2120; 117 }; 118 union { 119 struct { 120 unsigned long r22; 121 unsigned long r23; 122 }; 123 unsigned long long r2322; 124 }; 125 union { 126 struct { 127 unsigned long r24; 128 unsigned long r25; 129 }; 130 unsigned long long r2524; 131 }; 132 union { 133 struct { 134 unsigned long r26; 135 unsigned long r27; 136 }; 137 unsigned long long r2726; 138 }; 139 140 unsigned long fp; 141 unsigned long lr; 142 }; 143 144 #endif /* !__ASSEMBLY__ */ 145 146 #endif 147