📄 cpu_status.h
字号:
/* *---------------------------------------------------------------------- * T-Kernel * * Copyright (C) 2004 by Ken Sakamura. All rights reserved. * T-Kernel is distributed under the T-License. *---------------------------------------------------------------------- * * Version: 1.01.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2004/6/28. * *---------------------------------------------------------------------- *//* * cpu_status.h (M32104) * M32R -Dependent Definition */#ifndef _CPU_STATUS_#define _CPU_STATUS_#include <tk/syslib.h>#include <tk/sysdef.h>#include "cpu_insn.h"/* * Start/End critical section */#define BEGIN_CRITICAL_SECTION { UINT _psw_ = disint();#define END_CRITICAL_SECTION if ( !isDI(_psw_) \ && ctxtsk != schedtsk \ && !isTaskIndependent() \ && !dispatch_disabled ) { \ dispatch(); \ } \ enaint(_psw_); }/* * Start/End interrupt disable section */#define BEGIN_DISABLE_INTERRUPT { UINT _psw_ = disint();#define END_DISABLE_INTERRUPT enaint(_psw_); }/* * Interrupt enable/disable */#define ENABLE_INTERRUPT { enaint(0); }#define DISABLE_INTERRUPT { disint(); }/* * Enable interrupt nesting * Enable the interrupt that has a higher priority than 'level.' */#define ENABLE_INTERRUPT_UPTO(level) { enaint(0); }/* * Move to/Restore task independent part * Note: Using assembler source, check whether there is a * problem in the area for referring to a stack in order to * switch the stack mode. */#define ENTER_TASK_INDEPENDENT { UINT _psw_; \ Asm("mvfc %0, psw": "=r"(_psw_)); \ Asm("mvtc %0, psw":: "r"(_psw_ & ~PSW_SM));#define LEAVE_TASK_INDEPENDENT Asm("mvtc %0, psw":: "r"(_psw_)); }/* ----------------------------------------------------------------------- *//* * Check system state *//* * When a system call is made from the task independent part, TRUE */#define in_indp() ( isTaskIndependent() || ctxtsk == NULL )/* * When a system call is made during a dispatch disable, TRUE * Also include the task independent part as during the dispatch disable. */#define in_ddsp() ( dispatch_disabled \ || in_indp() \ || isDI(~getPSW()) )/* * When a system call is called during a CPU lock (interrupt disable), TRUE * Also include the task independent part as during the CPU lock. */#define in_loc() ( isDI(~getPSW()) \ || in_indp() )/* * When a system call is made during executing the quasi task part, TRUE * Valid only when in_indp() == FALSE because it is not discriminated from * the task independent part. */#define in_qtsk() ( ctxtsk->sysmode > ctxtsk->isysmode )/* ----------------------------------------------------------------------- *//* * Task dispatcher startup routine *//* * Request for task dispatcher startup * Do nothing at this point because there is no delayed interrupt * function in M32R. * Perform dispatcher startup with END_CRITICAL_SECTION. */#define dispatch_request() /* *//* * Trash the current task context and forcibly dispatch to the task that * should be performed next. * Use at system startup and 'tk_ext_tsk, tk_exd_tsk.' */Inline void force_dispatch( void ){ Asm("bra dispatch_to_schedtsk");}/* * Start task dispatcher */Inline void dispatch( void ){ Asm("trap #%0":: "i"(TRAP_DISPATCH));}/* ----------------------------------------------------------------------- *//* * Task exception *//* * Task exception handler startup reservation */IMPORT void request_tex( TCB *tcb );/* ----------------------------------------------------------------------- *//* * Task context block */typedef struct { VP ssp; /* System stack pointer */ VP uatb; /* Task space page table */ INT lsid; /* Task space ID */} CTXB;/* * CPU information */IMPORT ATR available_cop; /* Available coprocessor (TA_COPn) */#endif /* _CPU_STATUS_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -