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

📄 bseppcc.c

📁 ppc860的ucos part
💻 C
字号:
/*
 * file: bseppcc.c
 *
 * Barnett Systems Engineering 
 * PowerPC Specific C Language Functions
 * for UCOS-II
 * Has only been checked with MPC8xx chips
 * but should work with any 32-bit non-floating point PowerPC
 *
 * Functions:
 * DEC_Hdlr ()
 * OSTaskStkInit ()
 *
 * Author: Harry E. Barnett	11/11/99
 * harryb@hbbse.com http://www.hbbse.com
 *
 * Version V1.00
 *
 */

#include "includes.h"

#define INITIAL_SR       0x9002
#define STACK_BUFFER_SIZE	0xA0
extern unsigned long _SDA_BASE_;
extern unsigned long _SDA2_BASE_;
unsigned long xjunk = 0;  /* Not used; creates an .sdata section for linking*/ 

/***********************************************************
*                    INITIALIZE A TASK STACK
************************************************************/
OS_STK *OSTaskStkInit (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt)
{
    OS_STK *	stkp;

	/* 8-byte align task's stack pointer (EABI) */
     stkp = (OS_STK *)((INT32U) ptos & (INT32U) 0xFFFFFFF8);  

	/* Leave buffer area for locals "above the stack" */ 
	/* in case the compiler prolog puts variables above the stack */ 
	 stkp -= STACK_BUFFER_SIZE;

	/*
	 * Ensure any changes to the order of these initializations
	 * are congruent with the Stack Frame definitions in bseppca.s
	 */ 
	*--stkp = (INT32U)INITIAL_SR;	/* MSR */  	
	*--stkp = 0L;					/* r31 */
	*--stkp = 0L;					/* r30 */
	*--stkp = 0L;					/* r29 */
	*--stkp = 0L;					/* r28 */
	*--stkp = 0L;					/* r27 */
	*--stkp = 0L;					/* r26 */
	*--stkp = 0L;					/* r25 */
	*--stkp = 0L;					/* r24 */
	*--stkp = 0L;					/* r23 */
	*--stkp = 0L;					/* r22 */
	*--stkp = 0L;					/* r21 */
	*--stkp = 0L;					/* r20 */
	*--stkp = 0L;					/* r19 */
	*--stkp = 0L;					/* r18 */
	*--stkp = 0L;					/* r17 */
	*--stkp = 0L;					/* r16 */
	*--stkp = 0L;					/* r15 */
	*--stkp = 0L;					/* r14 */
	*--stkp = (INT32U)&_SDA_BASE_;	/* r13 */ 
	*--stkp = 0L;					/* r12 */
	*--stkp = 0L;					/* r11 */
	*--stkp = 0L;					/* r10 */
	*--stkp = 0L;					/* r09 */
	*--stkp = 0L;					/* r08 */
	*--stkp = 0L;					/* r07 */
	*--stkp = 0L;					/* r06 */
	*--stkp = 0L;					/* r05 */
	*--stkp = 0L;					/* r04 */
	*--stkp = (INT32U)pdata;		/* r03 */
	*--stkp = (INT32U)&_SDA2_BASE_;	/* r02 */ 
	*--stkp = (INT32U)task;			/* LR */
	--stkp;							/* CR */
	--stkp;							/* XER */
	--stkp;							/* CTR */
	*--stkp = (INT32U)INITIAL_SR;	/* SRR1 */  	
	*--stkp = (INT32U)task;			/* SRR0 */
	--stkp;							/* R0 */
	--stkp; 						/* BLANK for 0xA0 size */
	*--stkp = (INT32U)ptos;			/* Stack Ptr */

	return ((void *) stkp);
}

void DEC_Hdlr (void)
{
	asm ("	mtspr	EID,r0");
	SMAC_set_decrementer (); 
	OSIntNesting++; /* Moved from OSIntEnter to eliminate function call */ 
	/* Note: the increment of OSIntNesting MUST be atomic */ 
	asm ("	mtspr	EIE,r0");
	OSTimeTick ();
	OSIntExit ();
}

/*$PAGE*/
/* Code from here to bottom of file is taken directly from 
 * Jean J. Labrosse's example file IX86L/OS_CPU_C.C
 */ 

/*
*********************************************************************************************************
*                                               uC/OS-II
*                                         The Real-Time Kernel
*
*                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
*                                          All Rights Reserved
*
* File : OS_CPU_C.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/
#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)
{
}


/*
*********************************************************************************************************
*                                           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)
{
}

/*
*********************************************************************************************************
*                                           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)
{
}
#endif

⌨️ 快捷键说明

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