18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* include/asm/processor.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu) 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __ASM_SPARC_PROCESSOR_H 88c2ecf20Sopenharmony_ci#define __ASM_SPARC_PROCESSOR_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <asm/psr.h> 118c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 128c2ecf20Sopenharmony_ci#include <asm/head.h> 138c2ecf20Sopenharmony_ci#include <asm/signal.h> 148c2ecf20Sopenharmony_ci#include <asm/page.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too... 178c2ecf20Sopenharmony_ci * That one page is used to protect kernel from intruders, so that 188c2ecf20Sopenharmony_ci * we can make our access_ok test faster 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci#define TASK_SIZE PAGE_OFFSET 218c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 228c2ecf20Sopenharmony_ci#define STACK_TOP (PAGE_OFFSET - PAGE_SIZE) 238c2ecf20Sopenharmony_ci#define STACK_TOP_MAX STACK_TOP 248c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct task_struct; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 298c2ecf20Sopenharmony_cistruct fpq { 308c2ecf20Sopenharmony_ci unsigned long *insn_addr; 318c2ecf20Sopenharmony_ci unsigned long insn; 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci#endif 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_citypedef struct { 368c2ecf20Sopenharmony_ci int seg; 378c2ecf20Sopenharmony_ci} mm_segment_t; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* The Sparc processor specific thread struct. */ 408c2ecf20Sopenharmony_cistruct thread_struct { 418c2ecf20Sopenharmony_ci struct pt_regs *kregs; 428c2ecf20Sopenharmony_ci unsigned int _pad1; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci /* Special child fork kpsr/kwim values. */ 458c2ecf20Sopenharmony_ci unsigned long fork_kpsr __attribute__ ((aligned (8))); 468c2ecf20Sopenharmony_ci unsigned long fork_kwim; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci /* Floating point regs */ 498c2ecf20Sopenharmony_ci unsigned long float_regs[32] __attribute__ ((aligned (8))); 508c2ecf20Sopenharmony_ci unsigned long fsr; 518c2ecf20Sopenharmony_ci unsigned long fpqdepth; 528c2ecf20Sopenharmony_ci struct fpq fpqueue[16]; 538c2ecf20Sopenharmony_ci unsigned long flags; 548c2ecf20Sopenharmony_ci mm_segment_t current_ds; 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */ 588c2ecf20Sopenharmony_ci#define SPARC_FLAG_UNALIGNED 0x2 /* is allowed to do unaligned accesses */ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define INIT_THREAD { \ 618c2ecf20Sopenharmony_ci .flags = SPARC_FLAG_KTHREAD, \ 628c2ecf20Sopenharmony_ci .current_ds = KERNEL_DS, \ 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Do necessary setup to start up a newly executed thread. */ 668c2ecf20Sopenharmony_cistatic inline void start_thread(struct pt_regs * regs, unsigned long pc, 678c2ecf20Sopenharmony_ci unsigned long sp) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci register unsigned long zero asm("g1"); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci regs->psr = (regs->psr & (PSR_CWP)) | PSR_S; 728c2ecf20Sopenharmony_ci regs->pc = ((pc & (~3)) - 4); 738c2ecf20Sopenharmony_ci regs->npc = regs->pc + 4; 748c2ecf20Sopenharmony_ci regs->y = 0; 758c2ecf20Sopenharmony_ci zero = 0; 768c2ecf20Sopenharmony_ci __asm__ __volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t" 778c2ecf20Sopenharmony_ci "std\t%%g0, [%0 + %3 + 0x08]\n\t" 788c2ecf20Sopenharmony_ci "std\t%%g0, [%0 + %3 + 0x10]\n\t" 798c2ecf20Sopenharmony_ci "std\t%%g0, [%0 + %3 + 0x18]\n\t" 808c2ecf20Sopenharmony_ci "std\t%%g0, [%0 + %3 + 0x20]\n\t" 818c2ecf20Sopenharmony_ci "std\t%%g0, [%0 + %3 + 0x28]\n\t" 828c2ecf20Sopenharmony_ci "std\t%%g0, [%0 + %3 + 0x30]\n\t" 838c2ecf20Sopenharmony_ci "st\t%1, [%0 + %3 + 0x38]\n\t" 848c2ecf20Sopenharmony_ci "st\t%%g0, [%0 + %3 + 0x3c]" 858c2ecf20Sopenharmony_ci : /* no outputs */ 868c2ecf20Sopenharmony_ci : "r" (regs), 878c2ecf20Sopenharmony_ci "r" (sp - sizeof(struct reg_window32)), 888c2ecf20Sopenharmony_ci "r" (zero), 898c2ecf20Sopenharmony_ci "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0])) 908c2ecf20Sopenharmony_ci : "memory"); 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* Free all resources held by a thread. */ 948c2ecf20Sopenharmony_ci#define release_thread(tsk) do { } while(0) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciunsigned long get_wchan(struct task_struct *); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define task_pt_regs(tsk) ((tsk)->thread.kregs) 998c2ecf20Sopenharmony_ci#define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc) 1008c2ecf20Sopenharmony_ci#define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP]) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ciextern struct task_struct *last_task_used_math; 1058c2ecf20Sopenharmony_ciint do_mathemu(struct pt_regs *regs, struct task_struct *fpt); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define cpu_relax() barrier() 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ciextern void (*sparc_idle)(void); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#endif 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#endif /* __ASM_SPARC_PROCESSOR_H */ 114