?? os_cpu_c.c
字號:
/*
*********************************************************************************************************
* 文件: OS_CPU_C.C.
* 描述: uC/OS-II在 S3C2410 上的移植代碼 C 語言部分,包括任務堆棧初始化代碼和鉤子函數等.
* 編寫: 深思 (001-12345@sohu.com).
*********************************************************************************************************
*/
#define OS_CPU_GLOBALS
#include "uC_OS.h"
/*
********************************************************************************************************
* 函數: OSIntCtxSw.
* 描述: 中斷級任務切換,此處并不真正進行任務切換,具體切換在 IRQ 服務程序的匯編返回中.
********************************************************************************************************
*/
void OSIntCtxSw(void)
{
;
}
/*
********************************************************************************************************
* 函數: OSTaskStkInit.
* 描述: 任務堆棧初始化代碼.
* 輸入: task : 任務開始執行的地址.
* ptos :任務的堆棧開始位置.
* opt :附加參數,當前版本對于本函數無用,具體意義參見OSTaskCreateExt()的opt參數.
* 輸出: 棧頂指針位置.
********************************************************************************************************
*/
OS_STK *OSTaskStkInit (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt)
{
OS_STK *stk;
opt = opt; /* 'opt' 沒有使用. 作用是避免編譯器警告 */
stk = ptos; /* 獲取堆棧指針 */
*--stk = (OS_STK) task; /* PC */
*--stk = (OS_STK) task; /* R14 (LR) */
*--stk = 0x12; /* R12 */
*--stk = 0x11; /* R11 */
*--stk = 0x10; /* R10 */
*--stk = 0x09; /* R9 */
*--stk = 0x08; /* R8 */
*--stk = 0x07; /* R7 */
*--stk = 0x06; /* R6 */
*--stk = 0x05; /* R5 */
*--stk = 0x04; /* R4 */
*--stk = 0x03; /* R3 */
*--stk = 0x02; /* R2 */
*--stk = 0x01; /* R1 */
*--stk = (INT32U) pdata; /* R0 第一個參數使用R0傳遞. */
*--stk = 0x001f; /* CPSR system mode,允許 IRQ.FIQ 中斷.*/
*--stk = 0; /* 關中斷計數器OsEnterSum. */
return (stk);
}
#if OS_CPU_HOOKS_EN
/*
*********************************************************************************************************
* OS INITIALIZATION HOOK
* (BEGINNING)
*
* Description: This function is called by OSInit() at the beginning of OSInit().
*
* Arguments : none
*
* Note(s) : 1) Interrupts should be disabled during this call.
*********************************************************************************************************
*/
#if OS_VERSION > 203
void OSInitHookBegin (void)
{
}
#endif
/*
*********************************************************************************************************
* OS INITIALIZATION HOOK
* (END)
*
* Description: This function is called by OSInit() at the end of OSInit().
*
* Arguments : none
*
* Note(s) : 1) Interrupts should be disabled during this call.
*********************************************************************************************************
*/
#if OS_VERSION > 203
void OSInitHookEnd (void)
{
}
#endif
/*
*********************************************************************************************************
* TASK CREATION HOOK
*
* Description: This function is called when a task is created.
*
* Arguments : ptcb is a pointer to the task control block of the task being created.
*
* Note(s) : 1) Interrupts are disabled during this call.
*********************************************************************************************************
*/
void OSTaskCreateHook (OS_TCB *ptcb)
{
ptcb = ptcb; /* Prevent compiler warning */
}
/*
*********************************************************************************************************
* TASK DELETION HOOK
*
* Description: This function is called when a task is deleted.
*
* Arguments : ptcb is a pointer to the task control block of the task being deleted.
*
* Note(s) : 1) Interrupts are disabled during this call.
*********************************************************************************************************
*/
void OSTaskDelHook (OS_TCB *ptcb)
{
ptcb = ptcb; /* Prevent compiler warning */
}
/*
*********************************************************************************************************
* TASK SWITCH HOOK
*
* Description: This function is called when a task switch is performed. This allows you to perform other
* operations during a context switch.
*
* Arguments : none
*
* Note(s) : 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).
*********************************************************************************************************
*/
void OSTaskSwHook (void)
{
}
/*
*********************************************************************************************************
* STATISTIC TASK HOOK
*
* Description: This function is called every second by uC/OS-II's statistics task. This allows your
* application to add functionality to the statistics task.
*
* Arguments : none
*********************************************************************************************************
*/
void OSTaskStatHook (void)
{
}
/*
*********************************************************************************************************
* OSTCBInit() HOOK
*
* Description: This function is called by OSTCBInit() after setting up most of the TCB.
*
* Arguments : ptcb is a pointer to the TCB of the task being created.
*
* Note(s) : 1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/
#if OS_VERSION > 203
void OSTCBInitHook (OS_TCB *ptcb)
{
ptcb = ptcb; /* Prevent Compiler warning */
}
#endif
/*
*********************************************************************************************************
* TICK HOOK
*
* Description: This function is called every tick.
*
* Arguments : none
*
* Note(s) : 1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/
void OSTimeTickHook (void)
{
}
/*
*********************************************************************************************************
* IDLE TASK HOOK
*
* Description: 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.
*
* Arguments : none
*
* Note(s) : 1) Interrupts are enabled during this call.
*********************************************************************************************************
*/
#if OS_VERSION >= 251
void OSTaskIdleHook (void)
{
}
#endif
#endif
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -