?? ucos_cc.c
字號:
#ifndef RCSID
#define RCSID "$Header: /DspxBoot/Src/ProTyp2/UCOSC31C.C 3 8/14/97 7:50a Fowleydg $"
#endif
/*2002/10/19 upgrad to for ucos-ii
by zl*/
/*
* Copyright (c) 1997 by General Electric Company
*
* $Logfile: /DspxBoot/Src/ProTyp2/UCOSC31C.C $
* $Revision: 3 $
*
* $Log: /DspxBoot/Src/ProTyp2/UCOSC31C.C $
//
// 3 8/14/97 7:50a Fowleydg
// Remove IOF from the set of registers that are saved / restored during a
// context (task) switch
*
* 2 2/21/97 2:58p Fowleydg
* Indented to suit my style
*
* 1 2/21/97 2:10p Fowleydg
* Source for machine dependent 'C' code of uC/OS, the real-time kernel
*
* Last Mod: June 4, 1997 9:46:25AM
*/
#include "ucos_iif.h"
int os_start_high_ready_mate(void)
{
OSTaskSwHook();
OSRunning=1;
return (int)(OSTCBHighRdy->OSTCBStkPtr);
}
int os_text_switch_mate(int sps)
{
OSTCBCur->OSTCBStkPtr=(OS_STK*)sps;
OSTaskSwHook();
OSTCBCur=OSTCBHighRdy;
OSPrioCur=OSPrioHighRdy;
return (int)(OSTCBHighRdy->OSTCBStkPtr);
}
int os_interrupt_switch_mate(int sps)
{
OSTCBCur->OSTCBStkPtr=(OS_STK*)sps;
OSTaskSwHook();
OSTCBCur=OSTCBHighRdy;
OSPrioCur=OSPrioHighRdy;
return (int)(OSTCBHighRdy->OSTCBStkPtr);
}
void *OSTaskStkInit(void(*task)(void*pd),void*pdata,void*ptos,INT16U opt)
{
INT32U *stk;
OS_ENTER_CRITICAL();
stk=(INT32U*)ptos;
*stk = (INT32U) pdata; /* arg 0 */
*++stk = (INT32U) task;/*OSTaskSuspendSelf; /* return address */
*++stk = (INT32U) task; /* Interrupt return address = start of task */
*++stk = (INT32U) 0x2000;/* ST = Int. En. */
*++stk = (INT32U) 0x0000;/* R0 = 0 */
*++stk = (INT32U) 0x0000;/* FR0 = 0 */
*++stk = (INT32U) 0x0000;/* R1 = 0 */
*++stk = (INT32U) 0x0000;/* FR1 = 0 */
*++stk = (INT32U) 0x0000;/* R2 = 0 */
*++stk = (INT32U) 0x0000;/* FR2 = 0 */
*++stk = (INT32U) 0x0000;/* R3 = 0 */
*++stk = (INT32U) 0x0000;/* FR3 = 0 */
*++stk = (INT32U) 0x0000;/* R4 = 0 */
*++stk = (INT32U) 0x0000;/* FR4 = 0 */
*++stk = (INT32U) 0x0000;/* R5 = 0 */
*++stk = (INT32U) 0x0000;/* FR5 = 0 */
*++stk = (INT32U) 0x0000;/* R6 = 0 */
*++stk = (INT32U) 0x0000;/* FR6 = 0 */
*++stk = (INT32U) 0x0000;/* R7 = 0 */
*++stk = (INT32U) 0x0000;/* FR7 = 0 */
*++stk = (INT32U) 0x0000;/* AR0 = 0 */
*++stk = (INT32U) 0x0000;/* AR1 = 0 */
*++stk = (INT32U) 0x0000;/* AR2 = 0 */
*++stk = (INT32U) 0x0000;/* AR3 = 0 */
*++stk = (INT32U) 0x0000;/* AR4 = 0 */
*++stk = (INT32U) 0x0000;/* AR5 = 0 */
*++stk = (INT32U) 0x0000;/* AR6 = 0 */
*++stk = (INT32U) 0x0000;/* AR7 = 0 */
#if 1 /* large memory model - some one should play
* with DP */
*++stk = (INT32U) 0x0000;/* DP = 0 */
#endif
*++stk = (INT32U) 0x0000;/* IR0 = 0 */
*++stk = (INT32U) 0x0000;/* IR1 = 0 */
*++stk = (INT32U) 0x0000;/* BK = 0 */
#if 0 /* Task context should not include IOF, IF and IE */
*++stk = (INT32U) 0x0000;/* IE = 0 */
*++stk = (INT32U) 0x0000;/* IF = 0 */
*++stk = (INT32U) 0x0000;/* IOF = 0 */
#endif /* Task context should not include IOF, IF and IE */
*++stk = (INT32U) 0x0000;/* RS = 0 */
*++stk = (INT32U) 0x0000;/* RE = 0 */
*++stk = (INT32U) 0x0000;/* RC = 0 */
*++stk = (INT32U) 0x18; /*iostrb*/
return (void*)stk;
}
/*$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)
{
static int id;
if(OSTCBHighRdy->OSTCBPrio==id)
id=-1;
}
/*
*********************************************************************************************************
* 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.
*********************************************************************************************************
*/
#include "net32tcp.h"
#include "net32drv.h"
void fifo_test(void);
extern int lwl_time_over_flag;
void OSTimeTickHook (void)
{
if(lwl_time_over_flag>=0)
lwl_time_over_flag--;
fifo_test();
mss_update();
/*net_test(&udps_p.device);
udps_send_rise(&udps_p);*/
}
#endif
#if 0
/*
* CREATE A TASK
*/
UBYTE OSTaskCreate(void (far * task) (void *pd), void *pdata,
void *pstk, UBYTE p) {
UWORD *stk;
UBYTE err;
OS_ENTER_CRITICAL();
/*
* Make sure task doesn't already exist at this priority
*/
if (OSTCBPrioTbl[p] == (OS_TCB *) 0) {
OS_EXIT_CRITICAL();
stk = (UWORD *) pstk; /* Load stack pointer */
*stk = (UWORD) pdata; /* arg 0 */
*++stk = (UWORD) OSTaskSuspendSelf; /* return address */
*++stk = (UWORD) task; /* Interrupt return address = start of task */
*++stk = (UWORD) 0x2000;/* ST = Int. En. */
*++stk = (UWORD) 0x0000;/* R0 = 0 */
*++stk = (UWORD) 0x0000;/* FR0 = 0 */
*++stk = (UWORD) 0x0000;/* R1 = 0 */
*++stk = (UWORD) 0x0000;/* FR1 = 0 */
*++stk = (UWORD) 0x0000;/* R2 = 0 */
*++stk = (UWORD) 0x0000;/* FR2 = 0 */
*++stk = (UWORD) 0x0000;/* R3 = 0 */
*++stk = (UWORD) 0x0000;/* FR3 = 0 */
*++stk = (UWORD) 0x0000;/* R4 = 0 */
*++stk = (UWORD) 0x0000;/* FR4 = 0 */
*++stk = (UWORD) 0x0000;/* R5 = 0 */
*++stk = (UWORD) 0x0000;/* FR5 = 0 */
*++stk = (UWORD) 0x0000;/* R6 = 0 */
*++stk = (UWORD) 0x0000;/* FR6 = 0 */
*++stk = (UWORD) 0x0000;/* R7 = 0 */
*++stk = (UWORD) 0x0000;/* FR7 = 0 */
*++stk = (UWORD) 0x0000;/* AR0 = 0 */
*++stk = (UWORD) 0x0000;/* AR1 = 0 */
*++stk = (UWORD) 0x0000;/* AR2 = 0 */
*++stk = (UWORD) 0x0000;/* AR3 = 0 */
*++stk = (UWORD) 0x0000;/* AR4 = 0 */
*++stk = (UWORD) 0x0000;/* AR5 = 0 */
*++stk = (UWORD) 0x0000;/* AR6 = 0 */
*++stk = (UWORD) 0x0000;/* AR7 = 0 */
#if 0 /* Small memory model - no one should play
* with DP */
*++stk = (UWORD) 0x0000;/* DP = 0 */
#endif /* Small memory model - no one should play
* with DP */
*++stk = (UWORD) 0x0000;/* IR0 = 0 */
*++stk = (UWORD) 0x0000;/* IR1 = 0 */
*++stk = (UWORD) 0x0000;/* BK = 0 */
#if 0
/* Task context should not include IOF, IF and IE */
*++stk = (UWORD) 0x0000;/* IE = 0 */
*++stk = (UWORD) 0x0000;/* IF = 0 */
*++stk = (UWORD) 0x0000;/* IOF = 0 */
#endif
/* Task context should not include IOF, IF and IE */
*++stk = (UWORD) 0x0000;/* RS = 0 */
*++stk = (UWORD) 0x0000;/* RE = 0 */
*++stk = (UWORD) 0x0000;/* RC = 0 */
/*
* Get and initialize a TCB
*/
if ((err = OSTCBInit(p, (void far *) stk)) == OS_NO_ERR) {
/*
* Find highest priority task if multitasking has started
*/
if (OSRunning)
OSSched();
}
return err;
}
OS_EXIT_CRITICAL();
return OS_PRIO_EXIST;
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -