162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 462306a36Sopenharmony_ci * Copyright (C) 2008-2009 PetaLogix 562306a36Sopenharmony_ci * Copyright (C) 2006 Atmark Techno, Inc. 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _ASM_MICROBLAZE_PROCESSOR_H 962306a36Sopenharmony_ci#define _ASM_MICROBLAZE_PROCESSOR_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <asm/ptrace.h> 1262306a36Sopenharmony_ci#include <asm/setup.h> 1362306a36Sopenharmony_ci#include <asm/registers.h> 1462306a36Sopenharmony_ci#include <asm/entry.h> 1562306a36Sopenharmony_ci#include <asm/current.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci# ifndef __ASSEMBLY__ 1862306a36Sopenharmony_ci/* from kernel/cpu/mb.c */ 1962306a36Sopenharmony_ciextern const struct seq_operations cpuinfo_op; 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci# define cpu_relax() barrier() 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define task_pt_regs(tsk) \ 2462306a36Sopenharmony_ci (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1) 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* Do necessary setup to start up a newly executed thread. */ 2762306a36Sopenharmony_civoid start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp); 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciextern void ret_from_fork(void); 3062306a36Sopenharmony_ciextern void ret_from_kernel_thread(void); 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci# endif /* __ASSEMBLY__ */ 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* 3562306a36Sopenharmony_ci * This is used to define STACK_TOP, and with MMU it must be below 3662306a36Sopenharmony_ci * kernel base to select the correct PGD when handling MMU exceptions. 3762306a36Sopenharmony_ci */ 3862306a36Sopenharmony_ci# define TASK_SIZE (CONFIG_KERNEL_START) 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* 4162306a36Sopenharmony_ci * This decides where the kernel will search for a free chunk of vm 4262306a36Sopenharmony_ci * space during mmap's. 4362306a36Sopenharmony_ci */ 4462306a36Sopenharmony_ci# define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci# define THREAD_KSP 0 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci# ifndef __ASSEMBLY__ 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci/* If you change this, you must change the associated assembly-languages 5162306a36Sopenharmony_ci * constants defined below, THREAD_*. 5262306a36Sopenharmony_ci */ 5362306a36Sopenharmony_cistruct thread_struct { 5462306a36Sopenharmony_ci /* kernel stack pointer (must be first field in structure) */ 5562306a36Sopenharmony_ci unsigned long ksp; 5662306a36Sopenharmony_ci unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ 5762306a36Sopenharmony_ci void *pgdir; /* root of page-table tree */ 5862306a36Sopenharmony_ci struct pt_regs *regs; /* Pointer to saved register state */ 5962306a36Sopenharmony_ci}; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci# define INIT_THREAD { \ 6262306a36Sopenharmony_ci .ksp = sizeof init_stack + (unsigned long)init_stack, \ 6362306a36Sopenharmony_ci .pgdir = swapper_pg_dir, \ 6462306a36Sopenharmony_ci} 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ciunsigned long __get_wchan(struct task_struct *p); 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci/* The size allocated for kernel stacks. This _must_ be a power of two! */ 6962306a36Sopenharmony_ci# define KERNEL_STACK_SIZE 0x2000 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci/* Return some info about the user process TASK. */ 7262306a36Sopenharmony_ci# define task_tos(task) ((unsigned long)(task) + KERNEL_STACK_SIZE) 7362306a36Sopenharmony_ci# define task_regs(task) ((struct pt_regs *)task_tos(task) - 1) 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci# define task_pt_regs_plus_args(tsk) \ 7662306a36Sopenharmony_ci ((void *)task_pt_regs(tsk)) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci# define task_sp(task) (task_regs(task)->r1) 7962306a36Sopenharmony_ci# define task_pc(task) (task_regs(task)->pc) 8062306a36Sopenharmony_ci/* Grotty old names for some. */ 8162306a36Sopenharmony_ci# define KSTK_EIP(task) (task_pc(task)) 8262306a36Sopenharmony_ci# define KSTK_ESP(task) (task_sp(task)) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci# define STACK_TOP TASK_SIZE 8562306a36Sopenharmony_ci# define STACK_TOP_MAX STACK_TOP 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 8862306a36Sopenharmony_ciextern struct dentry *of_debugfs_root; 8962306a36Sopenharmony_ci#endif 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci# endif /* __ASSEMBLY__ */ 9262306a36Sopenharmony_ci#endif /* _ASM_MICROBLAZE_PROCESSOR_H */ 93