18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (C) 2013 Altera Corporation 38c2ecf20Sopenharmony_ci * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch> 48c2ecf20Sopenharmony_ci * Copyright (C) 2004 Microtronix Datacom Ltd 58c2ecf20Sopenharmony_ci * Copyright (C) 2001 Ken Hill (khill@microtronix.com) 68c2ecf20Sopenharmony_ci * Vic Phillips (vic@microtronix.com) 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * based on SPARC asm/processor_32.h which is: 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Copyright (C) 1994 David S. Miller 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 138c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 148c2ecf20Sopenharmony_ci * for more details. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifndef _ASM_NIOS2_PROCESSOR_H 188c2ecf20Sopenharmony_ci#define _ASM_NIOS2_PROCESSOR_H 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 218c2ecf20Sopenharmony_ci#include <asm/registers.h> 228c2ecf20Sopenharmony_ci#include <asm/page.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define NIOS2_FLAG_KTHREAD 0x00000001 /* task is a kernel thread */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define NIOS2_OP_NOP 0x1883a 278c2ecf20Sopenharmony_ci#define NIOS2_OP_BREAK 0x3da03a 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define STACK_TOP TASK_SIZE 328c2ecf20Sopenharmony_ci#define STACK_TOP_MAX STACK_TOP 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* Kuser helpers is mapped to this user space address */ 378c2ecf20Sopenharmony_ci#define KUSER_BASE 0x1000 388c2ecf20Sopenharmony_ci#define KUSER_SIZE (PAGE_SIZE) 398c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci# define TASK_SIZE 0x7FFF0000UL 428c2ecf20Sopenharmony_ci# define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* The Nios processor specific thread struct. */ 458c2ecf20Sopenharmony_cistruct thread_struct { 468c2ecf20Sopenharmony_ci struct pt_regs *kregs; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci /* Context switch saved kernel state. */ 498c2ecf20Sopenharmony_ci unsigned long ksp; 508c2ecf20Sopenharmony_ci unsigned long kpsr; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define INIT_MMAP \ 548c2ecf20Sopenharmony_ci { &init_mm, (0), (0), __pgprot(0x0), VM_READ | VM_WRITE | VM_EXEC } 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci# define INIT_THREAD { \ 578c2ecf20Sopenharmony_ci .kregs = NULL, \ 588c2ecf20Sopenharmony_ci .ksp = 0, \ 598c2ecf20Sopenharmony_ci .kpsr = 0, \ 608c2ecf20Sopenharmony_ci} 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciextern void start_thread(struct pt_regs *regs, unsigned long pc, 638c2ecf20Sopenharmony_ci unsigned long sp); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct task_struct; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* Free all resources held by a thread. */ 688c2ecf20Sopenharmony_cistatic inline void release_thread(struct task_struct *dead_task) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci} 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciextern unsigned long get_wchan(struct task_struct *p); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define task_pt_regs(p) \ 758c2ecf20Sopenharmony_ci ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* Used by procfs */ 788c2ecf20Sopenharmony_ci#define KSTK_EIP(tsk) ((tsk)->thread.kregs->ea) 798c2ecf20Sopenharmony_ci#define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define cpu_relax() barrier() 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#endif /* _ASM_NIOS2_PROCESSOR_H */ 86