18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Process/processor support for the Hexagon architecture 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _ASM_PROCESSOR_H 98c2ecf20Sopenharmony_ci#define _ASM_PROCESSOR_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <asm/mem-layout.h> 148c2ecf20Sopenharmony_ci#include <asm/registers.h> 158c2ecf20Sopenharmony_ci#include <asm/hexagon_vm.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* task_struct, defined elsewhere, is the "process descriptor" */ 188c2ecf20Sopenharmony_cistruct task_struct; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciextern void start_thread(struct pt_regs *, unsigned long, unsigned long); 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * thread_struct is supposed to be for context switch data. 248c2ecf20Sopenharmony_ci * Specifically, to hold the state necessary to perform switch_to... 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_cistruct thread_struct { 278c2ecf20Sopenharmony_ci void *switch_sp; 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* 318c2ecf20Sopenharmony_ci * initializes thread_struct 328c2ecf20Sopenharmony_ci * The only thing we have in there is switch_sp 338c2ecf20Sopenharmony_ci * which doesn't really need to be initialized. 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define INIT_THREAD { \ 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define cpu_relax() __vmyield() 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* 428c2ecf20Sopenharmony_ci * Decides where the kernel will search for a free chunk of vm space during 438c2ecf20Sopenharmony_ci * mmaps. 448c2ecf20Sopenharmony_ci * See also arch_get_unmapped_area. 458c2ecf20Sopenharmony_ci * Doesn't affect if you have MAX_FIXED in the page flags set though... 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * Apparently the convention is that ld.so will ask for "unmapped" private 488c2ecf20Sopenharmony_ci * memory to be allocated SOMEWHERE, but it also asks for memory explicitly 498c2ecf20Sopenharmony_ci * via MAP_FIXED at the lower * addresses starting at VA=0x0. 508c2ecf20Sopenharmony_ci * 518c2ecf20Sopenharmony_ci * If the two requests collide, you get authentic segfaulting action, so 528c2ecf20Sopenharmony_ci * you have to kick the "unmapped" base requests higher up. 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_ci#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE/3)) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define task_pt_regs(task) \ 588c2ecf20Sopenharmony_ci ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define KSTK_EIP(tsk) (pt_elr(task_pt_regs(tsk))) 618c2ecf20Sopenharmony_ci#define KSTK_ESP(tsk) (pt_psp(task_pt_regs(tsk))) 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci/* Free all resources held by a thread; defined in process.c */ 648c2ecf20Sopenharmony_ciextern void release_thread(struct task_struct *dead_task); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* Get wait channel for task P. */ 678c2ecf20Sopenharmony_ciextern unsigned long get_wchan(struct task_struct *p); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* The following stuff is pretty HEXAGON specific. */ 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* This is really just here for __switch_to. 728c2ecf20Sopenharmony_ci Offsets are pulled via asm-offsets.c */ 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* 758c2ecf20Sopenharmony_ci * No real reason why VM and native switch stacks should be different. 768c2ecf20Sopenharmony_ci * Ultimately this should merge. Note that Rev C. ABI called out only 778c2ecf20Sopenharmony_ci * R24-27 as callee saved GPRs needing explicit attention (R29-31 being 788c2ecf20Sopenharmony_ci * dealt with automagically by allocframe), but the current ABI has 798c2ecf20Sopenharmony_ci * more, R16-R27. By saving more, the worst case is that we waste some 808c2ecf20Sopenharmony_ci * cycles if building with the old compilers. 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistruct hexagon_switch_stack { 848c2ecf20Sopenharmony_ci union { 858c2ecf20Sopenharmony_ci struct { 868c2ecf20Sopenharmony_ci unsigned long r16; 878c2ecf20Sopenharmony_ci unsigned long r17; 888c2ecf20Sopenharmony_ci }; 898c2ecf20Sopenharmony_ci unsigned long long r1716; 908c2ecf20Sopenharmony_ci }; 918c2ecf20Sopenharmony_ci union { 928c2ecf20Sopenharmony_ci struct { 938c2ecf20Sopenharmony_ci unsigned long r18; 948c2ecf20Sopenharmony_ci unsigned long r19; 958c2ecf20Sopenharmony_ci }; 968c2ecf20Sopenharmony_ci unsigned long long r1918; 978c2ecf20Sopenharmony_ci }; 988c2ecf20Sopenharmony_ci union { 998c2ecf20Sopenharmony_ci struct { 1008c2ecf20Sopenharmony_ci unsigned long r20; 1018c2ecf20Sopenharmony_ci unsigned long r21; 1028c2ecf20Sopenharmony_ci }; 1038c2ecf20Sopenharmony_ci unsigned long long r2120; 1048c2ecf20Sopenharmony_ci }; 1058c2ecf20Sopenharmony_ci union { 1068c2ecf20Sopenharmony_ci struct { 1078c2ecf20Sopenharmony_ci unsigned long r22; 1088c2ecf20Sopenharmony_ci unsigned long r23; 1098c2ecf20Sopenharmony_ci }; 1108c2ecf20Sopenharmony_ci unsigned long long r2322; 1118c2ecf20Sopenharmony_ci }; 1128c2ecf20Sopenharmony_ci union { 1138c2ecf20Sopenharmony_ci struct { 1148c2ecf20Sopenharmony_ci unsigned long r24; 1158c2ecf20Sopenharmony_ci unsigned long r25; 1168c2ecf20Sopenharmony_ci }; 1178c2ecf20Sopenharmony_ci unsigned long long r2524; 1188c2ecf20Sopenharmony_ci }; 1198c2ecf20Sopenharmony_ci union { 1208c2ecf20Sopenharmony_ci struct { 1218c2ecf20Sopenharmony_ci unsigned long r26; 1228c2ecf20Sopenharmony_ci unsigned long r27; 1238c2ecf20Sopenharmony_ci }; 1248c2ecf20Sopenharmony_ci unsigned long long r2726; 1258c2ecf20Sopenharmony_ci }; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci unsigned long fp; 1288c2ecf20Sopenharmony_ci unsigned long lr; 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#endif 134