18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Port on Texas Instruments TMS320C6x architecture 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated 68c2ecf20Sopenharmony_ci * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com) 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Updated for 2.6.34: Mark Salter <msalter@redhat.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci#ifndef _ASM_C6X_PROCESSOR_H 118c2ecf20Sopenharmony_ci#define _ASM_C6X_PROCESSOR_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 148c2ecf20Sopenharmony_ci#include <asm/page.h> 158c2ecf20Sopenharmony_ci#include <asm/current.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* 188c2ecf20Sopenharmony_ci * User space process size. This is mostly meaningless for NOMMU 198c2ecf20Sopenharmony_ci * but some C6X processors may have RAM addresses up to 0xFFFFFFFF. 208c2ecf20Sopenharmony_ci * Since calls like mmap() can return an address or an error, we 218c2ecf20Sopenharmony_ci * have to allow room for error returns when code does something 228c2ecf20Sopenharmony_ci * like: 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * addr = do_mmap(...) 258c2ecf20Sopenharmony_ci * if ((unsigned long)addr >= TASK_SIZE) 268c2ecf20Sopenharmony_ci * ... its an error code, not an address ... 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * Here, we allow for 4096 error codes which means we really can't 298c2ecf20Sopenharmony_ci * use the last 4K page on systems with RAM extending all the way 308c2ecf20Sopenharmony_ci * to the end of the 32-bit address space. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_ci#define TASK_SIZE 0xFFFFF000 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * This decides where the kernel will search for a free chunk of vm 368c2ecf20Sopenharmony_ci * space during mmap's. We won't be using it 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci#define TASK_UNMAPPED_BASE 0 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct thread_struct { 418c2ecf20Sopenharmony_ci unsigned long long b15_14; 428c2ecf20Sopenharmony_ci unsigned long long a15_14; 438c2ecf20Sopenharmony_ci unsigned long long b13_12; 448c2ecf20Sopenharmony_ci unsigned long long a13_12; 458c2ecf20Sopenharmony_ci unsigned long long b11_10; 468c2ecf20Sopenharmony_ci unsigned long long a11_10; 478c2ecf20Sopenharmony_ci unsigned long long ricl_icl; 488c2ecf20Sopenharmony_ci unsigned long usp; /* user stack pointer */ 498c2ecf20Sopenharmony_ci unsigned long pc; /* kernel pc */ 508c2ecf20Sopenharmony_ci unsigned long wchan; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define INIT_THREAD \ 548c2ecf20Sopenharmony_ci{ \ 558c2ecf20Sopenharmony_ci .usp = 0, \ 568c2ecf20Sopenharmony_ci .wchan = 0, \ 578c2ecf20Sopenharmony_ci} 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define INIT_MMAP { \ 608c2ecf20Sopenharmony_ci &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, \ 618c2ecf20Sopenharmony_ci NULL, NULL } 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define task_pt_regs(task) \ 648c2ecf20Sopenharmony_ci ((struct pt_regs *)(THREAD_START_SP + task_stack_page(task)) - 1) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define alloc_kernel_stack() __get_free_page(GFP_KERNEL) 678c2ecf20Sopenharmony_ci#define free_kernel_stack(page) free_page((page)) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* Forward declaration, a strange C thing */ 718c2ecf20Sopenharmony_cistruct task_struct; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciextern void start_thread(struct pt_regs *regs, unsigned int pc, 748c2ecf20Sopenharmony_ci unsigned long usp); 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Free all resources held by a thread. */ 778c2ecf20Sopenharmony_cistatic inline void release_thread(struct task_struct *dead_task) 788c2ecf20Sopenharmony_ci{ 798c2ecf20Sopenharmony_ci} 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* 828c2ecf20Sopenharmony_ci * saved kernel SP and DP of a blocked thread. 838c2ecf20Sopenharmony_ci */ 848c2ecf20Sopenharmony_ci#ifdef _BIG_ENDIAN 858c2ecf20Sopenharmony_ci#define thread_saved_ksp(tsk) \ 868c2ecf20Sopenharmony_ci (*(unsigned long *)&(tsk)->thread.b15_14) 878c2ecf20Sopenharmony_ci#define thread_saved_dp(tsk) \ 888c2ecf20Sopenharmony_ci (*(((unsigned long *)&(tsk)->thread.b15_14) + 1)) 898c2ecf20Sopenharmony_ci#else 908c2ecf20Sopenharmony_ci#define thread_saved_ksp(tsk) \ 918c2ecf20Sopenharmony_ci (*(((unsigned long *)&(tsk)->thread.b15_14) + 1)) 928c2ecf20Sopenharmony_ci#define thread_saved_dp(tsk) \ 938c2ecf20Sopenharmony_ci (*(unsigned long *)&(tsk)->thread.b15_14) 948c2ecf20Sopenharmony_ci#endif 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciextern unsigned long get_wchan(struct task_struct *p); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define KSTK_EIP(task) (task_pt_regs(task)->pc) 998c2ecf20Sopenharmony_ci#define KSTK_ESP(task) (task_pt_regs(task)->sp) 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#define cpu_relax() do { } while (0) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ciextern const struct seq_operations cpuinfo_op; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* Reset the board */ 1068c2ecf20Sopenharmony_ci#define HARD_RESET_NOW() 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ciextern unsigned int c6x_core_freq; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ciextern void (*c6x_restart)(void); 1128c2ecf20Sopenharmony_ciextern void (*c6x_halt)(void); 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#endif /* ASM_C6X_PROCESSOR_H */ 115