📄 os_cpu.h
字号:
/*******************************************************************************
* 礐OS-II Blackfin port test example
* Blackfin Applications Team, Analog Devices Inc.,
* Norwood, MA, US
*
* File: os_cpu.h
* Author: Deep Bodapati
* Last Modified: 10-10-2006
* Project: 礐OS-II Blackfin port
* Platform: Any (EZKit, custom boards etc.)
* Tools: VisualDSP++ 4.5 (Updated September 2006)
* 礐OS-II Version: v2.83
*
* This file is part of the 礐OS-II port to the Blackfin processor.
******************************************************************************/
/*
Copyright...
This code is placed in the public domain, and can be distributed freely with no restrictions provided that the heading
of each source module file is not modified to remove the credit to the original author.
Disclaimer...
This program code is provided "as is". There is no warranty, either expressed or implied as to its fitness for use in
any application. It is provided only as an example of porting the MicroC/OS operating system to the Blackfin processor.
Its use is strictly at the risk of the user. The author will not be liable for any damages direct or consequential related
to the use of this software including, but not limited to loss of profit.
*/
#ifndef OS_CPU_H
#define OS_CPU_H
#if (!defined (FALSE))
#define FALSE false // for legacy
#endif
#if (!defined (TRUE))
#define TRUE true // for legacy
#endif
//------------------------------------------------------------------
// 礐OS-II support for reentrant (nested) and
// non-reentrant (non-nested) ISRs
//------------------------------------------------------------------
#define OS_ADI_Reentrant_ISR 0xad
#define OS_ADI_NonReentrant_ISR 0xda
//------------------------------------------------------------------
// IVG6 (Core Timer) ISR Type can be either reentrant or
// non-reentrant, independent of other ISR Types
//------------------------------------------------------------------
#define OS_ADI_IVGTMR_ISR_Type OS_ADI_Reentrant_ISR
#if !((OS_ADI_IVGTMR_ISR_Type == OS_ADI_Reentrant_ISR) || (OS_ADI_IVGTMR_ISR_Type == OS_ADI_NonReentrant_ISR))
#error OS_ADI_IVGTMR_ISR_Type must be defined as either OS_ADI_Reentrant_ISR or OS_ADI_NonReentrant_ISR
#endif
//------------------------------------------------------------------
// ADI System Services/Device Drivers Libraries
// (DD/SSL) Support Macros
//------------------------------------------------------------------
#if (!defined(ADI_SSL_UCOS))
#define ADI_SSL_UCOS // Inform System Services Library that this project uses ucos-II kernel
#endif
#if (!defined(ADI_DEV_UCOS))
#define ADI_DEV_UCOS // Inform Device Drivers Library that this project uses ucos-II kernel
#endif
/*
*********************************************************************************************************
* Blackfin Assembly Language Specific code
*********************************************************************************************************
*/
#if defined(_LANGUAGE_ASM)
//------------------------------------------------------------------
// P-Register Immediate Load/Address Load macros
//------------------------------------------------------------------
#define UPPER_( x ) (((x) >> 16) & 0x0000FFFF)
#define LOWER_( x ) ((x) & 0x0000FFFF)
#define LOAD(x, y) x##.h = UPPER_(y); x##.l = LOWER_(y)
#define LOADA(x, y) x##.h = y; x##.l = y
//------------------------------------------------------------------
// Blackfin C Run-Time stack/frame macros
//------------------------------------------------------------------
#define INIT_C_RUNTIME_STACK(frame_size)\
LINK frame_size; \
SP += -12 ;/* make space for outgoing arguments when calling C-functions */
#define DEL_C_RUNTIME_STACK() \
UNLINK ;
//------------------------------------------------------------------
// 礐OS-II ISR Prolog and Epilog macros
//------------------------------------------------------------------
//------------REENTRANT-----------------------
#define UCOS_II_REENTRANT_ISR_PROLOG(frame_size)\
[ -- SP ] = R0 ; \
[ -- SP ] = P1 ; \
[ -- SP ] = RETS ; \
CALL.X __uCOS_II_reentrant_interrupt_entry ;\
/* Workaround for anomaly 05-00-0283 */ \
CC = R0 == R0 ; /* always true */ \
P0.L = 0x14 ; /* MMR space - CHIPID */ \
P0.H = 0xffc0 ; \
IF CC JUMP 4 ; \
R0 = [ P0 ] ; /* bogus MMR read that is speculatively read and killed - never executed */\
INIT_C_RUNTIME_STACK(frame_size)
#define UCOS_II_REENTRANT_ISR_EPILOG() \
CALL.X _OSIntExit; \
DEL_C_RUNTIME_STACK() \
JUMP.X __uCOS_II_reentrant_interrupt_exit ;
//------------NON_REENTRANT-----------------------
#define UCOS_II_NON_REENTRANT_ISR_PROLOG(frame_size)\
[ -- SP ] = R0 ; \
[ -- SP ] = P1 ; \
[ -- SP ] = RETS ; \
CALL.X __uCOS_II_non_reentrant_interrupt_entry ;\
/* Workaround for anomaly 05-00-0283 */ \
CC = R0 == R0 ; /* always true */ \
P0.L = 0x14 ; /* MMR space - CHIPID */ \
P0.H = 0xffc0 ; \
IF CC JUMP 4 ; \
R0 = [ P0 ] ; /* bogus MMR read that is speculatively read and killed - never executed */\
INIT_C_RUNTIME_STACK(frame_size)
#define UCOS_II_NON_REENTRANT_ISR_EPILOG() \
CALL.X _OSIntExit; \
DEL_C_RUNTIME_STACK() \
JUMP.X __uCOS_II_non_reentrant_interrupt_exit ;
//------------------------------------------------------------------
// External Globals
//------------------------------------------------------------------
.extern _OSTaskSwHook;
.extern _OSIntEnter;
.extern _OSIntExit;
.extern _OSTimeTick;
.extern _OSTimeTickHook;
.extern _OSIntNesting;
.extern _OSPrioCur;
.extern _OSPrioHighRdy;
.extern _OSRunning;
.extern _OSTCBCur;
.extern _OSTCBHighRdy;
.extern __uCOS_II_reentrant_interrupt_entry;
.extern __uCOS_II_reentrant_interrupt_exit;
.extern __uCOS_II_non_reentrant_interrupt_entry;
.extern __uCOS_II_non_reentrant_interrupt_exit;
.extern _OS_ADI_RTS_from_Task;
/*
*********************************************************************************************************
* Blackfin C Language Specific code
*********************************************************************************************************
*/
#else /* _LANGUAGE_C */
//#include <ccblkfn.h>
//#include <signal.h>
//------------------------------------------------------------------
// 礐OS-II Stack Growth
//------------------------------------------------------------------
#define OS_STK_GROWTH 1 /* Stack grows from HIGH to LOW memory on Blackfin */
//------------------------------------------------------------------
// 礐OS-II Context Switch Trap
//------------------------------------------------------------------
#define OS_TASK_SW() asm("raise 14;"); /* Raise Interrupt 14 (trap) */
//------------------------------------------------------------------
// 礐OS-II Critical Sections (Method #3)
//------------------------------------------------------------------
#define OS_CRITICAL_METHOD 3
#if OS_CRITICAL_METHOD == 3
extern unsigned long cli(void);
extern void sti(unsigned long);
#define OS_ENTER_CRITICAL() (cpu_sr = cli()) /* Disable interrupts */
#define OS_EXIT_CRITICAL() (sti(cpu_sr)) /* Enable interrupts */
#endif
//------------------------------------------------------------------
// Data Types (Compiler Specific)
//------------------------------------------------------------------
#ifndef _OS_TYPES
typedef int BOOLEAN; /* Signed 32 bit quantity - bool is typdef'ed as int */
typedef unsigned char INT8U; /* Unsigned 8 bit quantity */
typedef signed char INT8S; /* Signed 8 bit quantity */
typedef unsigned short INT16U; /* Unsigned 16 bit quantity */
typedef signed short INT16S; /* Signed 16 bit quantity */
typedef unsigned int INT32U; /* Unsigned 32 bit quantity */
typedef signed int INT32S; /* Signed 32 bit quantity */
typedef float FP32; /* Single precision floating point */
typedef double FP64; /* Double precision floating point */
#define _OS_TYPES
#endif
typedef INT32U OS_STK; /* Each stack entry is 16-bit wide */
typedef INT32U OS_CPU_SR; /* Define size of CPU status register (PSW = 16 bits) */
//------------------------------------------------------------------
// Global variables
//------------------------------------------------------------------
//------------------------------------------------------------------
// Function Prototypes
//------------------------------------------------------------------
extern void OSStartHighRdy(void);
extern void OSCtxSw(void);
extern void OSIntCtxSw(void);
extern void CoreTimerInit(INT32U, INT32U);
// NO task should return with RTS - however, the following is
// a safety catch-all for tasks that return with an RTS
extern void OS_ADI_Invalid_RTS_from_Task (void);
#endif // _LANGUAGE_C
#endif /* OS_CPU_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -