Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
at v5.18 126 lines 3.1 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * include/asm-h8300/processor.h 4 * 5 * Copyright (C) 2002 Yoshinori Sato 6 * 7 * Based on: linux/asm-m68nommu/processor.h 8 * 9 * Copyright (C) 1995 Hamish Macdonald 10 */ 11 12#ifndef __ASM_H8300_PROCESSOR_H 13#define __ASM_H8300_PROCESSOR_H 14 15#include <linux/compiler.h> 16#include <asm/ptrace.h> 17#include <asm/current.h> 18 19static inline unsigned long rdusp(void) 20{ 21 extern unsigned int _sw_usp; 22 23 return _sw_usp; 24} 25 26static inline void wrusp(unsigned long usp) 27{ 28 extern unsigned int _sw_usp; 29 30 _sw_usp = usp; 31} 32 33/* 34 * User space process size: 3.75GB. This is hardcoded into a few places, 35 * so don't change it unless you know what you are doing. 36 */ 37#define TASK_SIZE (0xFFFFFFFFUL) 38 39#ifdef __KERNEL__ 40#define STACK_TOP TASK_SIZE 41#define STACK_TOP_MAX STACK_TOP 42#endif 43 44/* 45 * This decides where the kernel will search for a free chunk of vm 46 * space during mmap's. We won't be using it 47 */ 48#define TASK_UNMAPPED_BASE 0 49 50struct thread_struct { 51 unsigned long ksp; /* kernel stack pointer */ 52 unsigned long usp; /* user stack pointer */ 53 unsigned long ccr; /* saved status register */ 54 unsigned long esp0; /* points to SR of stack frame */ 55 struct { 56 unsigned short *addr; 57 unsigned short inst; 58 } breakinfo; 59}; 60 61#define INIT_THREAD { \ 62 .ksp = sizeof(init_stack) + (unsigned long)init_stack, \ 63 .usp = 0, \ 64 .ccr = PS_S, \ 65 .esp0 = 0, \ 66 .breakinfo = { \ 67 .addr = (unsigned short *)-1, \ 68 .inst = 0 \ 69 } \ 70} 71 72/* 73 * Do necessary setup to start up a newly executed thread. 74 * 75 * pass the data segment into user programs if it exists, 76 * it can't hurt anything as far as I can tell 77 */ 78#if defined(CONFIG_CPU_H8300H) 79#define start_thread(_regs, _pc, _usp) \ 80do { \ 81 (_regs)->pc = (_pc); \ 82 (_regs)->ccr = 0x00; /* clear all flags */ \ 83 (_regs)->er5 = current->mm->start_data; /* GOT base */ \ 84 (_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \ 85} while (0) 86#endif 87#if defined(CONFIG_CPU_H8S) 88#define start_thread(_regs, _pc, _usp) \ 89do { \ 90 (_regs)->pc = (_pc); \ 91 (_regs)->ccr = 0x00; /* clear kernel flag */ \ 92 (_regs)->exr = 0x78; /* enable all interrupts */ \ 93 (_regs)->er5 = current->mm->start_data; /* GOT base */ \ 94 /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \ 95 (_regs)->sp = ((unsigned long)(_usp)) - 14; \ 96} while (0) 97#endif 98 99/* Forward declaration, a strange C thing */ 100struct task_struct; 101 102/* Free all resources held by a thread. */ 103static inline void release_thread(struct task_struct *dead_task) 104{ 105} 106 107unsigned long __get_wchan(struct task_struct *p); 108 109#define KSTK_EIP(tsk) \ 110 ({ \ 111 unsigned long eip = 0; \ 112 if ((tsk)->thread.esp0 > PAGE_SIZE && \ 113 MAP_NR((tsk)->thread.esp0) < max_mapnr) \ 114 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \ 115 eip; }) 116 117#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) 118 119#define cpu_relax() barrier() 120 121#define HARD_RESET_NOW() ({ \ 122 local_irq_disable(); \ 123 asm("jmp @@0"); \ 124}) 125 126#endif