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

📄 os_cpu_c.c

📁 uCOS-II ports on Tensilica HiFi330 core.
💻 C
字号:
/******************************************************************************************************** *                                               uC/OS-II *                                         The Real-Time Kernel * *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL *                                          All Rights Reserved * * *                                           Xtensa T1040 * * File : OS_CPU_C.C * By   : Paul Subramanian *********************************************************************************************************/#define  OS_CPU_GLOBALS#include <xtensa/config/specreg.h>#include <xtensa/config/core.h>#include <xtensa/simcall.h>#include "os_cpu.h"#include "os_cfg.h"#include "ucos_ii.h"#include "includes.h"#include "timer.h"#include "interrupts.h"extern OS_STK *newUserStackPtr;extern OS_STK *userStackPtr; /********************************************************************************************************* *                                PERFORM A CONTEXT SWITCH (From interrupt level) *                                           void OSIntCtxSw(void) * **********************************************************************************************************/void OSIntCtxSw(void){  /* done as part of the user exception vector handler */   OSTCBCur->OSTCBStkPtr = userStackPtr;	OSTaskSwHook();	OSTCBCur = OSTCBHighRdy;	OSPrioCur = OSPrioHighRdy;	newUserStackPtr = OSTCBHighRdy->OSTCBStkPtr;	}/*********************************************************************************************************/void OSCtxSwIntsEnable(void){	set_ccompare0( read_ccount() + TIMER0_INTERVAL ); //Level 1 timer interrupt	enable_ints(SOFTWARE0_INT_MASK|TIMER0_INT_MASK);}/********************************************************************************************************* *                            Initialize Stack for the Task * **********************************************************************************************************/OS_STK *OSTaskStkInit(void (*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt){/* This function performs these functions * 1. Computation of the Initial Stack * 2. Initialization of the Stack */ 	OS_STK *sp1;	INT32U i;		opt = opt;		sp1 = (OS_STK *)((INT32U)ptos & 0xfffffff0);	sp1 = sp1 - FRAME_SIZE / 4;		for( i = 0 ; i < FRAME_SIZE / 4; i++ )		sp1[i] = 0 ;		sp1[ FRAME_PC/4 ] = (INT32U)task;	sp1[ FRAME_PS/4 ] = XCHAL_PS_WOE_MASK | XCHAL_PS_UM_MASK | XCHAL_PS_EXCM_MASK | 	(1 << XCHAL_PS_CALLINC_SHIFT);	sp1[ FRAME_AR(6)/4 ] = (INT32U)pdata;	sp1[ FRAME_AR(1)/4 ] = (INT32U)(sp1 + FRAME_SIZE / 4);	return(sp1);	 }/*********************************************************************************************************/#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){}/*********************************************************************************************************//********************************************************************************************************* *                                               OS Task Idle HOOK * * Description: This function is called by OS. * * Arguments  : none * * Note(s)    : 1) Interrupts may or may not be ENABLED during this call. *********************************************************************************************************/void OSTaskIdleHook (void){	/* WAITI instruction saves power by setting the current interrupt	 * level, powering down the processor's logic and waiting for an	 * interrupt	 */	asm("waiti 0");}/*********************************************************************************************************/#endif // #if OS_CPU_HOOKS_EN

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -