?? os_cpu_c.c
字號:
/*
/*******************************************************************************
uS/OS-II v2.8
文 件 名 : os_cpu_c.c
作 者 : czn
版 本 : v1.0
********************************************************************************
*/
#define OS_CPU_GLOBALS
#include "includes.h"
/*
*******************************************************************************
OSTaskStkInit()
功能描述: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
stack frame of the task being created. This function is highly processor specific.
參 數: task is a pointer to the task code
p_arg is a pointer to a user supplied data area that will be passed to the task
when the task first executes.
ptos is a pointer to the top of stack. It is assumed that 'ptos' points to
a 'free' entry on the task stack. If OS_STK_GROWTH is set to 1 then
'ptos' will contain the HIGHEST valid address of the stack. Similarly, if
OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
of the stack.
opt specifies options that can be used to alter the behavior of OSTaskStkInit().
(see uCOS_II.H for OS_TASK_OPT_???).
說 明: Interrupts are enabled when your task starts executing.
*******************************************************************************
*/
OS_STK *OSTaskStkInit(void (*task)(void *p_arg),void *p_arg, OS_STK *ptos, INT16U opt) reentrant
{
OS_STK *stk;
p_arg = p_arg;
opt = opt;
stk = (OS_STK *)ptos;
*stk++ = 15; /*用戶堆棧長度 */
*stk++ = (INT16U)task & 0xFF; /*任務地址低8位 */
*stk++ = (INT16U)task >> 8; /*任務地址高8位 */
*stk++ = 0x00; /*PSW */
*stk++ = 0x0A; /*ACC */
*stk++ = 0x0B; /*B */
*stk++ = 0x00; /*DPL */
*stk++ = 0x00; /*DPH */
*stk++ = 0x00; /*R0 */
/*R3、R2、R1用于傳遞任務參數ppdata,其中R3代表存儲器類型,R2為高字節偏移,R1為低字節位移。*/
/*通過分析KEIL匯編,了解到任務的void *ppdata參數恰好是用R3、R2、R1傳遞,不是通過虛擬堆棧。*/
*stk++ = (INT16U)p_arg & 0xFF; /*R1 */
*stk++ = (INT16U)p_arg >> 8; /*R2 */
*stk++ = 0x01; /*R3 XDATA,存儲器類型為1 */
*stk++ = 0x04; /*R4 */
*stk++ = 0x05; /*R5 */
*stk++ = 0x06; /*R6 */
*stk++ = 0x07; /*R7 */
/*不用保存SP,任務切換時根據用戶堆棧長度計算得出。*/
*stk++ = (INT16U) (ptos+MaxStkSize) >> 8; /*?C_XBP 仿真堆棧指針高8位 */
*stk++ = (INT16U) (ptos+MaxStkSize) & 0xFF; /*?C_XBP 仿真堆棧指針低8位 */
return ((void *)ptos);
}
/*
*******************************************************************************
OSTaskCreateHook()
功能描述: This function is called when a task is created.
參 數: ptcb is a pointer to the task control block of the task being created.
說 明: 1) Interrupts are disabled during this call.
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskCreateHook(OS_TCB *ptcb) reentrant
{
ptcb = ptcb; /* Prevent compiler warning */
}
#endif
/*
*******************************************************************************
OSTaskDelHook()
功能描述: This function is called when a task is deleted.
參 數: ptcb is a pointer to the task control block of the task being deleted.
說 明: 1) Interrupts are disabled during this call.
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskDelHook(OS_TCB *ptcb) reentrant
{
ptcb = ptcb; /* Prevent compiler warning */
}
#endif
/*
*******************************************************************************
OSTaskSwHook()
功能描述: This function is called when a task switch is performed. This allows you to perform other
operations during a context switch.
參 數: none
說 明: 1) Interrupts are disabled during this call.
2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
task being switched out (i.e. the preempted task).
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskSwHook(void) reentrant
{
}
#endif
/*
*******************************************************************************
OSTaskIdleHook()
功能描述: This function is called by the idle task. This hook has been added to allow you to do
such things as STOP the CPU to conserve power.
參 數: none
說 明: 1) Interrupts are enabled during this call.
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION >= 251
void OSTaskIdleHook (void)reentrant
{
}
#endif
/*
*******************************************************************************
OSTaskStatHook()
功能描述: This function is called every second by uC/OS-II's statistics task. This allows your
application to add functionality to the statistics task.
參 數: none
說 明:
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskStatHook(void) reentrant
{
}
#endif
/*
*******************************************************************************
OSTimeTickHook()
功能描述: This function is called every tick.
參 數: none
說 明: 1) Interrupts may or may not be ENABLED during this call.
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTimeTickHook (void) reentrant
{
}
#endif
/*
*******************************************************************************
OSInitHookBegin()
功能描述: This function is called by OSInit() at the beginning of OSInit().
參 數: none
說 明: 1) Interrupts should be disabled during this call.
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
void OSInitHookBegin (void) reentrant
{
}
#endif
/*
*******************************************************************************
OSInitHookEnd()
功能描述: This function is called by OSInit() at the beginning of OSInit().
參 數: none
說 明: 1) Interrupts should be disabled during this call.
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
void OSInitHookEnd (void) reentrant
{
}
#endif
/*
*******************************************************************************
OSTCBInitHook()
功能描述: This function is called by OS_TCBInit() after setting up most of the TCB.
參 數: ptcb is a pointer to the TCB of the task being created.
說 明: 1) Interrupts may or may not be ENABLED during this call.
*******************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
void OSTCBInitHook (OS_TCB *ptcb) reentrant
{
ptcb = ptcb; /* Prevent Compiler warning */
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -