18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * vineetg: March 2009
68c2ecf20Sopenharmony_ci *  -Implemented task_pt_regs( )
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Amit Bhor, Sameer Dhavale, Ashwin Chaugule: Codito Technologies 2004
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef __ASM_ARC_PROCESSOR_H
128c2ecf20Sopenharmony_ci#define __ASM_ARC_PROCESSOR_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
178c2ecf20Sopenharmony_ci#include <asm/dsp.h>
188c2ecf20Sopenharmony_ci#include <asm/fpu.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* Arch specific stuff which needs to be saved per task.
218c2ecf20Sopenharmony_ci * However these items are not so important so as to earn a place in
228c2ecf20Sopenharmony_ci * struct thread_info
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_cistruct thread_struct {
258c2ecf20Sopenharmony_ci	unsigned long ksp;	/* kernel mode stack pointer */
268c2ecf20Sopenharmony_ci	unsigned long callee_reg;	/* pointer to callee regs */
278c2ecf20Sopenharmony_ci	unsigned long fault_address;	/* dbls as brkpt holder as well */
288c2ecf20Sopenharmony_ci#ifdef CONFIG_ARC_DSP_SAVE_RESTORE_REGS
298c2ecf20Sopenharmony_ci	struct dsp_callee_regs dsp;
308c2ecf20Sopenharmony_ci#endif
318c2ecf20Sopenharmony_ci#ifdef CONFIG_ARC_FPU_SAVE_RESTORE
328c2ecf20Sopenharmony_ci	struct arc_fpu fpu;
338c2ecf20Sopenharmony_ci#endif
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define INIT_THREAD  {                          \
378c2ecf20Sopenharmony_ci	.ksp = sizeof(init_stack) + (unsigned long) init_stack, \
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* Forward declaration, a strange C thing */
418c2ecf20Sopenharmony_cistruct task_struct;
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define task_pt_regs(p) \
448c2ecf20Sopenharmony_ci	((struct pt_regs *)(THREAD_SIZE + (void *)task_stack_page(p)) - 1)
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* Free all resources held by a thread */
478c2ecf20Sopenharmony_ci#define release_thread(thread) do { } while (0)
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/*
508c2ecf20Sopenharmony_ci * A lot of busy-wait loops in SMP are based off of non-volatile data otherwise
518c2ecf20Sopenharmony_ci * get optimised away by gcc
528c2ecf20Sopenharmony_ci */
538c2ecf20Sopenharmony_ci#define cpu_relax()		barrier()
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define KSTK_EIP(tsk)   (task_pt_regs(tsk)->ret)
568c2ecf20Sopenharmony_ci#define KSTK_ESP(tsk)   (task_pt_regs(tsk)->sp)
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/*
598c2ecf20Sopenharmony_ci * Where about of Task's sp, fp, blink when it was last seen in kernel mode.
608c2ecf20Sopenharmony_ci * Look in process.c for details of kernel stack layout
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci#define TSK_K_ESP(tsk)		(tsk->thread.ksp)
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#define TSK_K_REG(tsk, off)	(*((unsigned long *)(TSK_K_ESP(tsk) + \
658c2ecf20Sopenharmony_ci					sizeof(struct callee_regs) + off)))
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define TSK_K_BLINK(tsk)	TSK_K_REG(tsk, 4)
688c2ecf20Sopenharmony_ci#define TSK_K_FP(tsk)		TSK_K_REG(tsk, 0)
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ciextern void start_thread(struct pt_regs * regs, unsigned long pc,
718c2ecf20Sopenharmony_ci			 unsigned long usp);
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ciextern unsigned int get_wchan(struct task_struct *p);
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/*
788c2ecf20Sopenharmony_ci * Default System Memory Map on ARC
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci * ---------------------------- (lower 2G, Translated) -------------------------
818c2ecf20Sopenharmony_ci * 0x0000_0000		0x5FFF_FFFF	(user vaddr: TASK_SIZE)
828c2ecf20Sopenharmony_ci * 0x6000_0000		0x6FFF_FFFF	(reserved gutter between U/K)
838c2ecf20Sopenharmony_ci * 0x7000_0000		0x7FFF_FFFF	(kvaddr: vmalloc/modules/pkmap..)
848c2ecf20Sopenharmony_ci *
858c2ecf20Sopenharmony_ci * PAGE_OFFSET ---------------- (Upper 2G, Untranslated) -----------------------
868c2ecf20Sopenharmony_ci * 0x8000_0000		0xBFFF_FFFF	(kernel direct mapped)
878c2ecf20Sopenharmony_ci * 0xC000_0000		0xFFFF_FFFF	(peripheral uncached space)
888c2ecf20Sopenharmony_ci * -----------------------------------------------------------------------------
898c2ecf20Sopenharmony_ci */
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define TASK_SIZE	0x60000000
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define VMALLOC_START	(PAGE_OFFSET - (CONFIG_ARC_KVADDR_SIZE << 20))
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci/* 1 PGDIR_SIZE each for fixmap/pkmap, 2 PGDIR_SIZE gutter (see asm/highmem.h) */
968c2ecf20Sopenharmony_ci#define VMALLOC_SIZE	((CONFIG_ARC_KVADDR_SIZE << 20) - PGDIR_SIZE * 4)
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define VMALLOC_END	(VMALLOC_START + VMALLOC_SIZE)
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define USER_KERNEL_GUTTER    (VMALLOC_START - TASK_SIZE)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define STACK_TOP       TASK_SIZE
1038c2ecf20Sopenharmony_ci#define STACK_TOP_MAX   STACK_TOP
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/* This decides where the kernel will search for a free chunk of vm
1068c2ecf20Sopenharmony_ci * space during mmap's.
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_ci#define TASK_UNMAPPED_BASE      (TASK_SIZE / 3)
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#endif /* __ASM_ARC_PROCESSOR_H */
111