?? os_cpu_c.c
字號:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
* (c) Copyright ARM Limited 1999. All rights reserved.
*
* ARM Specific code
*
*
* File : OS_CPU_C.C
*********************************************************************************************************
*/
#define OS_CPU_GLOBALS
#include "includes.h"
/*與CPU硬件及編譯器相關的代碼,在UCOS_II.H中聲明*/
SYS_Stk sys_stk_info;
SYS_Stk *Sys_sp;
/*任務堆棧初始化*/
void *OSTaskStkInit (void (*task)(void *pd), void *pdata, void *ptos, INT16U opt)
{
unsigned int *stk;
opt = opt; /* 'opt' is not used, prevent warning */
stk = (unsigned int *)ptos; /* Load stack pointer 當前的棧底 */
/* build a context for the new task */
*--stk = opt;
*--stk = (unsigned int) task; /* opt maybe need pc */
*--stk = (unsigned int) task; /* pc */
*--stk = 0x0000; /* Y */
*--stk = 0x0000; /* X */
*--stk = 0; /* A,B */
((INT8U *)stk)--;
*(INT8U *)stk=(INT8U)(0x00);/*CCR*/
//((INT8U *)stk)--;
//*(INT8U *)stk=*(INT8U *)pdata;/*PPAGE*//*在建立任務時 需要利用pdata這個參數將PPAGE信息傳入*/
return ((void *)stk);
}
/*優先級最高的就緒任務開始運行*/
void OSStartHighRdy(void){
OSRunning=1;
Sys_sp=&sys_stk_info;//指向SYS_Stk這個結構體
asm{
ldx Sys_sp
sts 0,x //save sp to Sys_sp
ldx OSTCBCur
lds 0,x
//pula /*出棧并賦值給A*/
//staa $30/*把A的值傳遞給 PPAGE(0x30)*/
//nop
rti/*出棧順序CCR,B,A,X,Y,PC*/
}
}
/*任務級任務切換函數*/
void OSCtxSw(void){
asm{
pshy
pshx
pshd
pshc //模擬中斷保存現場 PC在Call OSCtxSw()已經保存
//ldaa $30 //save PPAGE to A
//psha //save A to stack
ldx OSTCBCur
sts 0,x //save sp to OSTCBCur
}
OSTCBCur = OSTCBHighRdy;
OSPrioCur = OSPrioHighRdy;
asm{
ldx OSTCBCur //Get the new OSTCBCur to x
lds 0,x //load x to sp
//pula
//staa $30
rti
}
}
/*中斷級任務切換函數*/
void OSIntCtxSw(void){
//從系統堆棧切換回任務堆棧
asm{
ldx Sys_sp
ins
ins
ins
ins //調整堆棧深度OSIntExit 2byte OSIntCtxSw 2byte
sts 0,x //save sp to Sys_sp
}
//進入中斷時系統已經在被打斷任務的堆棧中保存了信息
OSTCBCur = OSTCBHighRdy;
OSPrioCur = OSPrioHighRdy;
asm{
ldx OSTCBCur //Get the new OSTCBCur to x
lds 0,x //load x to sp
//pula //PPAGE 在中斷調用時已經入棧
//staa $30
//nop
rti
}
}
/*$PAGE*/
#if OS_CPU_HOOKS_EN
/*
*********************************************************************************************************
* 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)
{
}
/*
*********************************************************************************************************
* 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)
{
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -