📄 os_cpu_c.c
字号:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* AT89C/S5x Specific Code
* LARGE MEMORY MODEL
*
* Keil C/C++ V7.09
*
* 文件名 : OS_CPU_C.C
* 作者 : Jean J. Labrosse
; 改编 : 华歆 Huaxin@wxzte.com 中兴光电子 研发一部 2005.06
*********************************************************************************************************
*/
#define OS_CPU_GLOBALS
#include "includes.h"
/*
*********************************************************************************************************
* 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_CPU_HOOKS_EN > 0 && OS_VERSION > 203
void OSInitHookBegin (void) reentrant
{
}
#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_CPU_HOOKS_EN > 0 && OS_VERSION > 203
void OSInitHookEnd (void) reentrant
{
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* 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.
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskCreateHook (OS_TCB *ptcb) reentrant
{
ptcb = ptcb; /* Prevent compiler warning */
}
#endif
/*
*********************************************************************************************************
* 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.
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskDelHook (OS_TCB *ptcb) reentrant
{
ptcb = ptcb; /* Prevent compiler warning */
}
#endif
/*
*********************************************************************************************************
* 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_CPU_HOOKS_EN > 0 && OS_VERSION >= 251
void OSTaskIdleHook (void) reentrant
{
}
#endif
/*
*********************************************************************************************************
* 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
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskStatHook (void) reentrant
{
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* OSTaskStkInit
*
* Description: Init stack before task running.
*
* Arguments : task is a pointer to the task code
*
* pdata 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_???).
*
* Returns : Always returns the bottom of stack.
*
* Note(s) : 1) stack stored as following format
; CONTENT START POSITION IN OSTCBStk
; ---------- ----------------------
; AR7
; AR6
; AR5
; AR4
; AR3
; AR2
; AR1
; AR0
; PSW
; DPL
; DPH
; B
; ACC
; HARDWARE STACK CONTENT(NOT INCLUDE REGISTERS) 2+SmltStkSize
; HARDWARE STACK SIZE(INCLUDE REGISTERS) 1+SmltStkSize
; SIMULATED STACK CONTENT 1
; ?C_IBP 0
*********************************************************************************************************
*/
OS_STK *OSTaskStkInit (void (*task)(void *pd) reentrant, void *os_pdata, OS_STK *ptos, INT16U opt) reentrant
{
OS_STK *stk;
os_pdata = os_pdata;
opt = opt; //opt没被用到,保留此语句防止告警产生
stk = (OS_STK *)ptos; //用户堆栈最低有效地址
*stk++ = 2 + 13; /* tow bytes of return address and 13 byte registers */
*stk++ = (INT16U)task & 0xFF; /* low byte of return address */
*stk++ = (INT16U)task >> 8; /* high byte of return address */
*stk++ = 0x0A; /* ACC */
*stk++ = 0x0B; /* B */
*stk++ = 0xD1; /* DPH */
*stk++ = 0xD0; /* DPL */
*stk++ = 0x00; /* PSW */
*stk++ = 0x00; /* R0 */
*stk++ = 0x01; /* R1 */
*stk++ = 0x02; /* R2 */
*stk++ = 0x03; /* R3 */
*stk++ = 0x04; /* R4 */
*stk++ = 0x05; /* R5 */
*stk++ = 0x06; /* R6 */
*stk++ = 0x07; /* R7 */
return ((void *)ptos);
}
/*$PAGE*/
/*
*********************************************************************************************************
* 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).
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTaskSwHook (void) reentrant
{
}
#endif
/*
*********************************************************************************************************
* OSTCBInit() HOOK
*
* Description: This function is called by OS_TCBInit() 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_CPU_HOOKS_EN > 0 && OS_VERSION > 203
void OSTCBInitHook (OS_TCB *ptcb) reentrant
{
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.
*********************************************************************************************************
*/
#if OS_CPU_HOOKS_EN > 0
void OSTimeTickHook (void) reentrant
{
}
#endif
/*
*********************************************************************************************************
* 中断服务程序外挂
* NOTE : 注意:所有中断外挂都在临界区之外,用户可以自行控制进/退临界区
*********************************************************************************************************
*/
#if OS_ISR_T1_EN > 0
void OSISR_T1HOOK (void) reentrant
{
/* 请在这里输入中断服务程序 */
}
#endif
#if OS_ISR_INT0_EN > 0
void OSISR_INT0HOOK (void) reentrant
{
/* 请在这里输入中断服务程序 */
}
#endif
#if OS_ISR_INT1_EN > 0
void OSISR_INT1HOOK (void) reentrant
{
/* 请在这里输入中断服务程序 */
}
#endif
#if OS_ISR_S0_EN > 0
void OSISR_S0HOOK (void) reentrant
{
/* 请在这里输入中断服务程序 */
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -