/*
|
/*
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
CHiPES Embedded RTR Systems Copyright (c) Tim Oliver 2002-2004
|
CHiPES Embedded RTR Systems Copyright (c) Tim Oliver 2002-2004
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
File : os_cpu_c.c
|
File : os_cpu_c.c
|
Author : Tim Oliver
|
Author : Tim Oliver
|
Email : timtimoliver@yahoo.co.uk
|
Email : timtimoliver@yahoo.co.uk
|
---------------------------[Description]------------------------------
|
---------------------------[Description]------------------------------
|
|
|
uC/OS-II
|
uC/OS-II
|
The Real-Time Kernel
|
The Real-Time Kernel
|
|
|
(c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
|
(c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
|
All Rights Reserved
|
All Rights Reserved
|
|
|
OpenCores OpenRISC
|
OpenCores OpenRISC
|
|
|
Inline NOP ORP simulator functions :
|
Inline NOP ORP simulator functions :
|
void exit (int i) - simulator exit point
|
void exit (int i) - simulator exit point
|
void report(unsigned long value) - simulator report messaging
|
void report(unsigned long value) - simulator report messaging
|
|
|
Internal Routines :
|
Internal Routines :
|
void mtspr(unsigned long spr, unsigned long vakye) - Move To SPR
|
void mtspr(unsigned long spr, unsigned long vakye) - Move To SPR
|
unsigned long mfspr(unsigned long spr) - Move From SPR
|
unsigned long mfspr(unsigned long spr) - Move From SPR
|
OS_CPU_SR OSDisableInterrupts (void)
|
OS_CPU_SR OSDisableInterrupts (void)
|
void OSEnableInterrupts(OS_CPU_SR cpu_sr)
|
void OSEnableInterrupts(OS_CPU_SR cpu_sr)
|
void OSInitTick(void)
|
void OSInitTick(void)
|
void putc (char c) - standard output patch to UART
|
void putc (char c) - standard output patch to UART
|
int getc () - standard input patch to UART
|
int getc () - standard input patch to UART
|
int testc () - check for character received by UART
|
int testc () - check for character received by UART
|
int ctrlc () - check for control-C received by UART
|
int ctrlc () - check for control-C received by UART
|
For OS Routines see descriptions below
|
For OS Routines see descriptions below
|
|
|
*/
|
*/
|
|
|
/*
|
/*
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
(at your option) any later version.
|
(at your option) any later version.
|
|
|
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU General Public License for more details.
|
GNU General Public License for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
*/
|
*/
|
|
|
#define OS_CPU_GLOBALS
|
#define OS_CPU_GLOBALS
|
#include "includes.h"
|
#include "includes.h"
|
|
|
/* return value by making a syscall */
|
/* return value by making a syscall */
|
void exit (int i)
|
void exit (int i)
|
{
|
{
|
asm("l.add r3,r0,%0": : "r" (i));
|
asm("l.add r3,r0,%0": : "r" (i));
|
asm("l.nop %0": :"K" (NOP_EXIT));
|
asm("l.nop %0": :"K" (NOP_EXIT));
|
while (1);
|
while (1);
|
}
|
}
|
|
|
/* print long */
|
/* print long */
|
void report(unsigned long value)
|
void report(unsigned long value)
|
{
|
{
|
asm("l.addi\tr3,%0,0": :"r" (value));
|
asm("l.addi\tr3,%0,0": :"r" (value));
|
asm("l.nop %0": :"K" (NOP_REPORT));
|
asm("l.nop %0": :"K" (NOP_REPORT));
|
}
|
}
|
|
|
/* For writing into SPR. */
|
/* For writing into SPR. */
|
void mtspr(unsigned long spr, unsigned long value)
|
void mtspr(unsigned long spr, unsigned long value)
|
{
|
{
|
asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
|
asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
|
}
|
}
|
|
|
/* For reading SPR. */
|
/* For reading SPR. */
|
unsigned long mfspr(unsigned long spr)
|
unsigned long mfspr(unsigned long spr)
|
{
|
{
|
unsigned long value;
|
unsigned long value;
|
asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
|
asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
|
return value;
|
return value;
|
}
|
}
|
|
|
#if OS_CRITICAL_METHOD == 3
|
#if OS_CRITICAL_METHOD == 3
|
OS_CPU_SR OSDisableInterrupts (void)
|
OS_CPU_SR OSDisableInterrupts (void)
|
{
|
{
|
OS_CPU_SR cpu_sr;
|
OS_CPU_SR cpu_sr;
|
|
|
cpu_sr = mfspr(SPR_SR);
|
cpu_sr = mfspr(SPR_SR);
|
mtspr(SPR_SR, cpu_sr & ~(SPR_SR_IEE | SPR_SR_TEE));
|
mtspr(SPR_SR, cpu_sr & ~(SPR_SR_IEE | SPR_SR_TEE));
|
return cpu_sr;
|
return cpu_sr;
|
}
|
}
|
|
|
void OSEnableInterrupts(OS_CPU_SR cpu_sr)
|
void OSEnableInterrupts(OS_CPU_SR cpu_sr)
|
{
|
{
|
mtspr(SPR_SR, cpu_sr); /* | (SPR_SR_IEE | SPR_SR_TEE)*/
|
mtspr(SPR_SR, cpu_sr); /* | (SPR_SR_IEE | SPR_SR_TEE)*/
|
}
|
}
|
|
|
#endif
|
#endif
|
|
|
void OSInitTick(void)
|
void OSInitTick(void)
|
{
|
{
|
/* Enable tick interrupts in supervisor register */
|
/* Enable tick interrupts in supervisor register */
|
mtspr(SPR_SR, SPR_SR_TEE | mfspr(SPR_SR));
|
mtspr(SPR_SR, SPR_SR_TEE | mfspr(SPR_SR));
|
/* Set tick timer to restart on match, and set interrupt enable, and set period depending on clock
|
/* Set tick timer to restart on match, and set interrupt enable, and set period depending on clock
|
frequency and desired tick rate */
|
frequency and desired tick rate */
|
mtspr(SPR_TTMR, SPR_TTMR_IE | SPR_TTMR_RT | ((IN_CLK/TICKS_PER_SEC) & SPR_TTMR_PERIOD));
|
mtspr(SPR_TTMR, SPR_TTMR_IE | SPR_TTMR_RT | ((IN_CLK/TICKS_PER_SEC) & SPR_TTMR_PERIOD));
|
}
|
}
|
|
|
/* stdio patches */
|
/* stdio patches */
|
void putc (char c) {
|
void putc (char c) {
|
OS_CPU_SR cpu_sr;
|
OS_CPU_SR cpu_sr;
|
|
|
OS_ENTER_CRITICAL()
|
OS_ENTER_CRITICAL()
|
uart_putc (c);
|
uart_putc (c);
|
OS_EXIT_CRITICAL()
|
OS_EXIT_CRITICAL()
|
}
|
}
|
|
|
int getc () {
|
int getc () {
|
|
|
return uart_getc ();
|
return uart_getc ();
|
}
|
}
|
|
|
|
|
int testc () {
|
int testc () {
|
|
|
return uart_testc ();
|
return uart_testc ();
|
}
|
}
|
|
|
int ctrlc ()
|
int ctrlc ()
|
{
|
{
|
if (testc ()) {
|
if (testc ()) {
|
switch (getc ()) {
|
switch (getc ()) {
|
case 0x03: /* ^C - Control C */
|
case 0x03: /* ^C - Control C */
|
return 1;
|
return 1;
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* OS INITIALIZATION HOOK
|
* OS INITIALIZATION HOOK
|
* (BEGINNING)
|
* (BEGINNING)
|
*
|
*
|
* Description: This function is called by OSInit() at the beginning of OSInit().
|
* Description: This function is called by OSInit() at the beginning of OSInit().
|
*
|
*
|
* Arguments : none
|
* Arguments : none
|
*
|
*
|
* Note(s) : 1) Interrupts should be disabled during this call.
|
* Note(s) : 1) Interrupts should be disabled during this call.
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
|
void OSInitHookBegin (void)
|
void OSInitHookBegin (void)
|
{
|
{
|
|
|
uart_init();
|
uart_init();
|
|
|
#ifdef __TFP_PRINTF__
|
#ifdef __TFP_PRINTF__
|
init_printf(NULL,putc);
|
init_printf(NULL,putc);
|
#endif
|
#endif
|
|
|
return;
|
return;
|
|
|
}
|
}
|
#endif
|
#endif
|
|
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* OS INITIALIZATION HOOK
|
* OS INITIALIZATION HOOK
|
* (END)
|
* (END)
|
*
|
*
|
* Description: This function is called by OSInit() at the end of OSInit().
|
* Description: This function is called by OSInit() at the end of OSInit().
|
*
|
*
|
* Arguments : none
|
* Arguments : none
|
*
|
*
|
* Note(s) : 1) Interrupts should be disabled during this call.
|
* Note(s) : 1) Interrupts should be disabled during this call.
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
|
void OSInitHookEnd (void)
|
void OSInitHookEnd (void)
|
{
|
{
|
}
|
}
|
#endif
|
#endif
|
|
|
/*$PAGE*/
|
/*$PAGE*/
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* TASK CREATION HOOK
|
* TASK CREATION HOOK
|
*
|
*
|
* Description: This function is called when a task is created.
|
* 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.
|
* Arguments : ptcb is a pointer to the task control block of the task being created.
|
*
|
*
|
* Note(s) : 1) Interrupts are disabled during this call.
|
* Note(s) : 1) Interrupts are disabled during this call.
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0
|
#if OS_CPU_HOOKS_EN > 0
|
void OSTaskCreateHook (OS_TCB *ptcb)
|
void OSTaskCreateHook (OS_TCB *ptcb)
|
{
|
{
|
ptcb = ptcb; /* Prevent compiler warning */
|
ptcb = ptcb; /* Prevent compiler warning */
|
}
|
}
|
#endif
|
#endif
|
|
|
|
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* TASK DELETION HOOK
|
* TASK DELETION HOOK
|
*
|
*
|
* Description: This function is called when a task is deleted.
|
* 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.
|
* Arguments : ptcb is a pointer to the task control block of the task being deleted.
|
*
|
*
|
* Note(s) : 1) Interrupts are disabled during this call.
|
* Note(s) : 1) Interrupts are disabled during this call.
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0
|
#if OS_CPU_HOOKS_EN > 0
|
void OSTaskDelHook (OS_TCB *ptcb)
|
void OSTaskDelHook (OS_TCB *ptcb)
|
{
|
{
|
ptcb = ptcb; /* Prevent compiler warning */
|
ptcb = ptcb; /* Prevent compiler warning */
|
}
|
}
|
#endif
|
#endif
|
|
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* IDLE TASK HOOK
|
* IDLE TASK HOOK
|
*
|
*
|
* Description: This function is called by the idle task. This hook has been added to allow you to do
|
* 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.
|
* such things as STOP the CPU to conserve power.
|
*
|
*
|
* Arguments : none
|
* Arguments : none
|
*
|
*
|
* Note(s) : 1) Interrupts are enabled during this call.
|
* Note(s) : 1) Interrupts are enabled during this call.
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION >= 251
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION >= 251
|
void OSTaskIdleHook (void)
|
void OSTaskIdleHook (void)
|
{
|
{
|
/* printf("\nEntering idle task"); */
|
/* printf("\nEntering idle task"); */
|
}
|
}
|
#endif
|
#endif
|
|
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* STATISTIC TASK HOOK
|
* STATISTIC TASK HOOK
|
*
|
*
|
* Description: This function is called every second by uC/OS-II's statistics task. This allows your
|
* 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.
|
* application to add functionality to the statistics task.
|
*
|
*
|
* Arguments : none
|
* Arguments : none
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
|
|
#if OS_CPU_HOOKS_EN > 0
|
#if OS_CPU_HOOKS_EN > 0
|
void OSTaskStatHook (void)
|
void OSTaskStatHook (void)
|
{
|
{
|
}
|
}
|
#endif
|
#endif
|
|
|
/*$PAGE*/
|
/*$PAGE*/
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* INITIALIZE A TASK'S STACK
|
* INITIALIZE A TASK'S STACK
|
*
|
*
|
* Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
|
* Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
|
* stack frame of the task being created. This function is highly processor specific.
|
* stack frame of the task being created. This function is highly processor specific.
|
*
|
*
|
* Arguments : task is a pointer to the task code
|
* 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
|
* pdata is a pointer to a user supplied data area that will be passed to the task
|
* when the task first executes.
|
* when the task first executes.
|
*
|
*
|
* ptos is a pointer to the top of stack. It is assumed that 'ptos' points to
|
* 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
|
* 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
|
* '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
|
* OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
|
* of the stack.
|
* of the stack.
|
*
|
*
|
* opt specifies options that can be used to alter the behavior of OSTaskStkInit().
|
* opt specifies options that can be used to alter the behavior of OSTaskStkInit().
|
* (see uCOS_II.H for OS_TASK_OPT_???).
|
* (see uCOS_II.H for OS_TASK_OPT_???).
|
*
|
*
|
* Returns : Always returns the location of the new top-of-stack' once the processor registers have
|
* Returns : Always returns the location of the new top-of-stack' once the processor registers have
|
* been placed on the stack in the proper order.
|
* been placed on the stack in the proper order.
|
*
|
*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
|
|
OS_STK *OSTaskStkInit (void (*task)(void *pd), void *pdata, OS_STK *ptos,
|
OS_STK *OSTaskStkInit (void (*task)(void *pd), void *pdata, OS_STK *ptos,
|
INT16U opt)
|
INT16U opt)
|
{
|
{
|
OS_STK *stk;
|
OS_STK *stk;
|
OS_STK *fp;
|
OS_STK *fp;
|
|
INT32U sr;
|
|
|
#ifdef DEBUG
|
#ifdef DEBUG
|
printf("\nCreating Stack at %x for task %x", ptos, task);
|
printf("\nCreating Stack at %x for task %x", ptos, task);
|
#endif
|
#endif
|
|
|
|
sr = mfspr(SPR_SR);
|
opt = opt; /* 'opt' is not used, prevent warning */
|
opt = opt; /* 'opt' is not used, prevent warning */
|
stk = ptos; /* Load stack pointer */
|
stk = ptos; /* Load stack pointer */
|
stk -=32; /* Skip over red zone, 32 words */
|
stk -=32; /* Skip over red zone, 32 words */
|
stk--;
|
stk--;
|
|
|
*stk-- = (OS_STK)(pdata); /* fp+0 -> parameter 0 */
|
*stk-- = (OS_STK)(pdata); /* fp+0 -> parameter 0 */
|
fp = stk;
|
fp = stk;
|
*stk-- = (OS_STK)fp; /* sp+4 -> previous fp */
|
*stk-- = (OS_STK)fp; /* sp+4 -> previous fp */
|
*stk-- = (INT32U)0; /* sp+0 -> return address */
|
*stk-- = (INT32U)0; /* sp+0 -> return address */
|
|
|
*stk-- = (INT32U)31; /* r31 = 0 */
|
*stk-- = (INT32U)31; /* r31 = 0 */
|
*stk-- = (INT32U)30; /* r30 = 0 */
|
*stk-- = (INT32U)30; /* r30 = 0 */
|
*stk-- = (INT32U)29; /* r29 = 0 */
|
*stk-- = (INT32U)29; /* r29 = 0 */
|
*stk-- = (INT32U)28; /* r28 = 0 */
|
*stk-- = (INT32U)28; /* r28 = 0 */
|
*stk-- = (INT32U)27; /* r27 = 0 */
|
*stk-- = (INT32U)27; /* r27 = 0 */
|
*stk-- = (INT32U)26; /* r26 = 0 */
|
*stk-- = (INT32U)26; /* r26 = 0 */
|
*stk-- = (INT32U)25; /* r25 = 0 */
|
*stk-- = (INT32U)25; /* r25 = 0 */
|
*stk-- = (INT32U)24; /* r24 = 0 */
|
*stk-- = (INT32U)24; /* r24 = 0 */
|
*stk-- = (INT32U)23; /* r23 = 0 */
|
*stk-- = (INT32U)23; /* r23 = 0 */
|
*stk-- = (INT32U)22; /* r22 = 0 */
|
*stk-- = (INT32U)22; /* r22 = 0 */
|
*stk-- = (INT32U)21; /* r21 = 0 */
|
*stk-- = (INT32U)21; /* r21 = 0 */
|
*stk-- = (INT32U)20; /* r20 = 0 */
|
*stk-- = (INT32U)20; /* r20 = 0 */
|
*stk-- = (INT32U)19; /* r19 = 0 */
|
*stk-- = (INT32U)19; /* r19 = 0 */
|
*stk-- = (INT32U)18; /* r18 = 0 */
|
*stk-- = (INT32U)18; /* r18 = 0 */
|
*stk-- = (INT32U)17; /* r17 = 0 */
|
*stk-- = (INT32U)17; /* r17 = 0 */
|
*stk-- = (INT32U)16; /* r16 = 0 */
|
*stk-- = (INT32U)16; /* r16 = 0 */
|
*stk-- = (INT32U)15; /* r15 = 0 */
|
*stk-- = (INT32U)15; /* r15 = 0 */
|
*stk-- = (INT32U)14; /* r14 = 0 */
|
*stk-- = (INT32U)14; /* r14 = 0 */
|
*stk-- = (INT32U)13; /* r13 = 0 */
|
*stk-- = (INT32U)13; /* r13 = 0 */
|
*stk-- = (INT32U)12; /* r12 = 0 */
|
*stk-- = (INT32U)12; /* r12 = 0 */
|
*stk-- = (INT32U)11; /* r11 = 0 return value */
|
*stk-- = (INT32U)11; /* r11 = 0 return value */
|
*stk-- = (INT32U)10; /* r10 = 0 */
|
*stk-- = (INT32U)10; /* r10 = 0 */
|
*stk-- = (INT32U)9; /* r09 = 0 link register */
|
*stk-- = (INT32U)9; /* r09 = 0 link register */
|
*stk-- = (INT32U)8; /* r08 = 0 function paramters*/
|
*stk-- = (INT32U)8; /* r08 = 0 function paramters*/
|
*stk-- = (INT32U)7; /* r07 = 0 */
|
*stk-- = (INT32U)7; /* r07 = 0 */
|
*stk-- = (INT32U)6; /* r06 = 0 */
|
*stk-- = (INT32U)6; /* r06 = 0 */
|
*stk-- = (INT32U)5; /* r05 = 0 */
|
*stk-- = (INT32U)5; /* r05 = 0 */
|
*stk-- = (INT32U)4; /* r04 = 0 */
|
*stk-- = (INT32U)4; /* r04 = 0 */
|
*stk-- = (OS_STK)(pdata); /* r03 = arg0 */
|
*stk-- = (OS_STK)(pdata); /* r03 = arg0 */
|
*stk-- = (OS_STK)fp; /* r02 = frame pointer */
|
*stk-- = (OS_STK)fp; /* r02 = frame pointer */
|
*stk-- = (INT32U)(SPR_SR_IEE | SPR_SR_TEE | SPR_SR_SM); /* status word */
|
/* supervision register */
|
|
*stk-- = (INT32U)(SPR_SR_IEE | SPR_SR_TEE | SPR_SR_SM |
|
|
(sr & (SPR_SR_ICE | SPR_SR_DCE)));
|
*stk = (OS_STK)(task); /* program counter */
|
*stk = (OS_STK)(task); /* program counter */
|
|
|
return ((OS_STK *)stk); /* sp gets saved in TCB */
|
return ((OS_STK *)stk); /* sp gets saved in TCB */
|
}
|
}
|
|
|
|
|
/*$PAGE*/
|
/*$PAGE*/
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* TASK SWITCH HOOK
|
* TASK SWITCH HOOK
|
*
|
*
|
* Description: This function is called when a task switch is performed. This allows you to perform other
|
* Description: This function is called when a task switch is performed. This allows you to perform other
|
* operations during a context switch.
|
* operations during a context switch.
|
*
|
*
|
* Arguments : none
|
* Arguments : none
|
*
|
*
|
* Note(s) : 1) Interrupts are disabled during this call.
|
* 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
|
* 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
|
* will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
|
* task being switched out (i.e. the preempted task).
|
* task being switched out (i.e. the preempted task).
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0
|
#if OS_CPU_HOOKS_EN > 0
|
void OSTaskSwHook (void)
|
void OSTaskSwHook (void)
|
{
|
{
|
/* printf("\nTask Switching\n"); */
|
/* printf("\nTask Switching\n"); */
|
}
|
}
|
#endif
|
#endif
|
|
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* OSTCBInit() HOOK
|
* OSTCBInit() HOOK
|
*
|
*
|
* Description: This function is called by OS_TCBInit() after setting up most of the TCB.
|
* 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.
|
* 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.
|
* Note(s) : 1) Interrupts may or may not be ENABLED during this call.
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
|
#if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
|
void OSTCBInitHook (OS_TCB *ptcb)
|
void OSTCBInitHook (OS_TCB *ptcb)
|
{
|
{
|
ptcb = ptcb; /* Prevent Compiler warning */
|
ptcb = ptcb; /* Prevent Compiler warning */
|
}
|
}
|
#endif
|
#endif
|
|
|
|
|
/*
|
/*
|
*********************************************************************************************************
|
*********************************************************************************************************
|
* TICK HOOK
|
* TICK HOOK
|
*
|
*
|
* Description: This function is called every tick.
|
* Description: This function is called every tick.
|
*
|
*
|
* Arguments : none
|
* Arguments : none
|
*
|
*
|
* Note(s) : 1) Interrupts may or may not be ENABLED during this call.
|
* Note(s) : 1) Interrupts may or may not be ENABLED during this call.
|
*********************************************************************************************************
|
*********************************************************************************************************
|
*/
|
*/
|
#if OS_CPU_HOOKS_EN > 0
|
#if OS_CPU_HOOKS_EN > 0
|
void OSTimeTickHook (void)
|
void OSTimeTickHook (void)
|
{
|
{
|
}
|
}
|
#endif
|
#endif
|
|
|
|
|
void OSTaskReturnHook (OS_TCB *ptcb)
|
void OSTaskReturnHook (OS_TCB *ptcb)
|
{
|
{
|
/* do nothing for now */
|
/* do nothing for now */
|
return;
|
return;
|
}
|
}
|
|
|