⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_cpu_c.c

📁 在三星的S3C44B0X上移植的uCOSII2.80的源程序
💻 C
字号:
/*
*********************************************************************************************************
* 文件: OS_CPU_C.C.
* 描述: uC/OS-II在 44B0X 上的移植代码 C 语言部分,包括任务堆栈初始化代码和钩子函数等.
* 编写: 深思 (001-12345@sohu.com).
*********************************************************************************************************
*/

#define  OS_CPU_GLOBALS
#include "includes.h"

/*
********************************************************************************************************
* 函数: OSIntCtxSw.
* 描述: 中断级任务切换,此处并不真正进行任务切换,具体切换在 IRQ 服务程序中.
********************************************************************************************************
*/
void OSIntCtxSw(void)
{
    ;
}

/*
********************************************************************************************************
* 函数: OSTaskStkInit.
* 描述: 任务堆栈初始化代码.
* 输入: task  : 任务开始执行的地址.
*       pdata :传递给任务的参数.
*       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 + -