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

📄 rtos.h

📁 一个完整的rtos源代码.运行在嵌入80186 cpu上.提供4个任务,信号灯,定时器,schedule等.
💻 H
📖 第 1 页 / 共 2 页
字号:

/****************************************************************************************
 *  Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
 *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
 *
 *  File: $Workfile: rtos.h $             
 *
 * Description: 
 * ============
 * 
 * 
 * Log:
 * ====
 * $Revision: 13 $
 * Last Modified by $Author: Stephaneh $ at $Modtime: 1/30/04 11:52a $ 
 ****************************************************************************************
 * Updates:
 ****************************************************************************************
 * $Log: /SourceCode/I64_Common/I64_Reference/Kernel/uITRON/rtos.h $
 * 
 * 13    1/30/04 11:52a Stephaneh
 * Integrated CDG Feature
 * 
 * 12    8/27/03 10:57a Leonh
 * add the debug function for get the satus if the semaphore is set
 * 
 * 11    03-07-29 20:02 Fwang
 * Add SEM_ADP
 * Enable USED_GET_TID
 * 
 * 10    03-06-17 18:27 Admin
 * Merge for ExinoII project
 * 
 * 9     03-04-17 11:53 Jerryc
 * share reflasher burner APIS with capture_logo and store_ps_in_flash
 * features.
 * 
 * 10    24/05/02 16:53 Nirm
 * - Enabled Event-Flags.
 * 
 * 9     23/04/02 9:27 Nirm
 * - Added dependency in "Config.h".
 * 
 * 8     31/03/02 9:31 Nirm
 * Increased number of Tasks and Mailboxes.
 * 
 * 7     27/03/02 8:32 Nirm
 * - Corrected typo in the name of InterruptEnable().
 * 
 * 6     26/03/02 23:18 Nirm
 * - Changed the value of RTOS_TICK_MS.
 * 
 * 5     26/02/02 21:18 Nirm
 * Enabled use of Lock/Unlock CPU.
 * 
 * 3     1/15/02 2:18p Tomasp
 * - code cleanup
 * - removed compilation warnings
 * - functions _disable and _enable replaced by InterruptDisable and
 * InterruptEnable to prevent name colisions with function in embedded.h
 * 
 * 2     9/01/02 18:31 Nirm
 * Corrected Include-Paths.
 ****************************************************************************************/

#include "Config.h"		// Global Configuration - do not remove!
#include "Include\Sysdefs.h"

#ifndef _RTOS_H_
#define _RTOS_H_


/*****************************************************************************
; Copyright (c) 1999,2000 by Hiroshi Iwabuchi, Japan
; All Rights Reserved.
;
; Pragram Name : IW-RTOS
;
;*****************************************************************************/
/* ////////////////////////////////////////////////////////////////////////////
; DEFINE
//////////////////////////////////////////////////////////////////////////// */
#define _TIME_SLICE_
#define INIT_SR_VALUE	0xF200	/* Enable all interrupt */
#define RTOS_TICK_MS	2

/* Important Definion for OS */
// #define DEBUG_OS			/* Debug mode for OS */
/* #define NO_ERCHK */			/* Disable Error Check */
#ifdef _DEBUG
#define RDYQMAX	3		/* Number of ready queue (same priority) */
#define TSKMAX		4		/* Number of task */
#else
#define RDYQMAX	3		/* Number of ready queue (same priority) */
#define TSKMAX		3		/* Number of task */
#endif

#if 0
#ifdef EXINO_FP
#ifdef SUPPORT_CAPTURE_LOGO
#define SEMMAX		6		/* Number of sempore */
#else
#define SEMMAX		4		/* Number of sempore */
#endif
#else // EXINO_FP
#ifdef SUPPORT_CAPTURE_LOGO
#define SEMMAX		5		/* Number of sempore */
#else
#define SEMMAX		3		/* Number of sempore */
#endif
#endif // EXINO_FP
#endif
#define SEMMAX   (SEM_MAX-1)

#define FLGMAX		1		/* Number of event flag */
#define MAILMAX 	3		/* Number of kind of mail box */
#define MSGQUEMAX	20		/* Number of message queue */

#define MEM_BLOCK_MAX  40
#define MEM_BLOCK_SIZE 8

#define NO_SUSCNT			/* Please define */

/* Parameter for debug */
#ifdef DEBUG_OS
#define TRACEMAXCNT	32		/* Number of trace buffer */
#endif

#define MAX_WUPCNT	125		/* Maximum number of queuing to wake-up */
#ifndef NO_SUSCNT
#define MAX_SUSCNT	125		/* Maximum nesting number of SUSPEND */
#endif

/* Used service routine */
//#define USED_DIS_DSP
//#define USED_ENA_DSP
#define USED_STA_TSK
#define USED_EXT_TSK
// #define USED_TER_TSK
#define USED_CHG_PRI
// #define USED_ROT_RDQ
#define USED_REL_WAI
#define USED_GET_TID
// #define USED_SLP_TSK
// #define USED_WUP_TSK
// #define USED_CAN_WUP
// #define USED_SUS_TSK
// #define USED_RSM_TSK
#define USED_SIG_SEM
#define USED_WAI_SEM
// #define USED_PREQ_SEM
#if defined(_DEBUG) ||  defined(D_CD_GRAPHIC_ENABLED)	// Stephane.Hollande.012903:Added for CDG
#define USED_CHECK_SEM//LeonH_0827_2003_a
#endif
#define USED_SET_FLG
#define USED_CLR_FLG
#define USED_WAI_FLG
// #define USED_POL_FLG
#define USED_SND_MSG
#define USED_RCV_MSG
#define USED_PRCV_MSG
#define USED_REF_MBX
#define USED_LOC_CPU
#define USED_UNL_CPU
#define USED_REL_BLF
//#define USED_GET_BLF
#define USED_PGET_BLF
#define USED_REL_BLK
#define USED_GET_BLK
#define USED_PGET_BLK
// #define USED_SET_TIM
// #define USED_GET_TIM
#define USED_DLY_TSK
// #define USED_GET_VER

/* Basic definition */
#ifndef NADR
#define NADR		(-1)	/* invalid address or pointer value */
#endif

#ifndef TRUE
#define TRUE		1		/* true */
#endif

#ifndef FALSE
#define FALSE		0		/* false */
#endif

#ifndef NULL
#define NULL		0		/* none */
#endif

/* Parameter of function call */
#define TSK_SELF	  0		/* task specifies itself */
#define TPRI_INI	  0		/* specifies the initial priority on task startup
							   (chg_pri) */
#define TPRI_RUN	  0		/* specifies the highest priority during execution
							   (rot_rdq) */

/* task status */
#define TTS_RUN		0x01	/* RUN */
#define TTS_RDY		0x02	/* READY */
#define TTS_WAI		0x04	/* WAIT */
#define TTS_SUS		0x08	/* SUSPEND */
#define TTS_WAS		0x0c	/* WAIT-SUSPEND */
#define TTS_DMT		0x10	/* DORMANT */

/* task wait */
#define TTW_SLP		0x0001	/* wait due to slp_tsk or tslp_tsk */
#define TTW_DLY		0x0002	/* wait due to dly_tsk */
#define TTW_FLG		0x0010	/* wait due to wai_flg or twai_flg */
#define TTW_SEM		0x0020	/* wait due to wai_sem or twai_sem */
#define TTW_MBX		0x0040	/* wait due to rcv_msg or trcv_msg */
#define TTW_MPL		0x1000	/* wait due to get_blk or tget_blk */
#define TTW_MPF		0x2000	/* wait due to get_blf or tget_blf */

/* Error Codes */
#define E_OK	   0		/* Normal completion */
#define E_SYS	   (-5)	/* System error */
#define E_NOMEM	(-10)	/* Insufficient memory */
#define E_NOSPT	(-17)	/* Feature not supported */
#define E_INOSPT  (-18)	/* Feature not supported by ITRON/FILE specification */
#define E_RSFN	   (-20)	/* Reserved function code number */
#define E_RSATR	(-24)	/* Reserved attribute */
#define E_PAR	   (-33)	/* Parameter error */
#define E_ID	   (-35)	/* Invalid ID number */
#define E_NOEXS	(-52)	/* Object does not exist */
#define E_OBJ	   (-63)	/* Invalid object state */
#define E_MACV	   (-65)	/* Memory access disabled or memory access violation */
#define E_OACV	   (-66)	/* Object access violation */
#define E_CTX	   (-69)	/* Context error */
#define E_QOVR	   (-73)	/* Queuing or nesting overflow */
#define E_DLT	   (-81)	/* Object being waited for was deleted */
#define E_TMOUT	(-85)	/* Polling failure or timeout exceeded */
#define E_RLWAI	(-86)	/* WAIT state was forcibly released */
#define EN_NOND	(-113)	/* Target node does not exist or cannot be accessed */
#define EN_OBJNO  (-114)	/* Specifies an object number which could not be
							   accessed on the target node*/
#define EN_PROTO  (-115)	/* Protocol not supported on target node */
#define EN_RSFN	(-116)	/* System call or function not supported on target node */
#define EN_COMM	(-117)	/* No response from target node */
#define EN_RLWAI  (-118)	/* Connection function response wait state was forcibly
							   released */
#define EN_PAR	   (-119)	/* A value outside the range supported by the target
							   node and/or transmission packet format was specified
							   as a parameter */
#define EN_RPAR	(-120)	/* A value outside the range supported by the issuing
							   node and/or transmission packet format was returned
							   as a return parameter */
#define EN_CTXID  (-121)	/* An object on another node was specified to a system
							   call issued from a task in dispatch disabled state
							   or from a task-independent portion */
#define EN_EXEC	(-122)	/* System call could not be executed due to
							   insufficient resources on the target node */
#define EN_NOSPT  (-123)	/* Connection function not supported */

/* system status */
#define TSS_TSK	0x00	/* normal state in which dispatching is enabled during
							   task portion execution */
#define TSS_DDSP	0x01	/* state after dis_dsp has been executed during task
							   portion execution (dispatch disabled) */
#define TSS_DINT	0x02	/* disable interrupt */
#define TSS_LOC	0x03	/* state after loc_cpu has been executed during task
							   portion execution (interrupt and dispatch disabled)
							*/
#define TSS_INDP	0x04	/* state during execution of task-independent portions
							   (interrupt and timer handlers) */

/* event flag control parameter */
#define TWF_ANDW  0x00		/* AND wait */
#define TWF_ORW	0x02		/* OR wait */
#define TWF_CLR	0x01		/* clear specification */

/* ////////////////////////////////////////////////////////////////////////////
; TYPEDEF
//////////////////////////////////////////////////////////////////////////// */
/* General-Purpose Data Types */
typedef signed char		   B;	/* signed 8-bit integer */
typedef signed int		   H;	/* signed 16-bit integer */
typedef signed long		   W;	/* signed 32-bit integer */

typedef unsigned char	   UB;	/* unsigned 8-bit integer */
typedef unsigned int	   	UH;	/* unsigned 16-bit integer */
typedef unsigned long	   UW;	/* unsigned 32-bit integer */

typedef unsigned char	   VB;	/* unpredictable data type (8-bit size) */
typedef unsigned int	   	VH;	/* unpredictable data type (16-bit size) */
typedef unsigned long      VW;	/* unpredictable data type (32-bit size) */

typedef void			   *VP; 		/* pointer to an unpredictable data type */
typedef void 				(*FP)();	/* program start address */

/* Data Types Dependent */
typedef int		ID;	/* Object ID number (???id)
				   Value range depends on the system.  Usually a signed integer.
				   Certain ID values may represent objects on other nodes when the
				   connection function is supported. */
typedef int		ER;	/* Error code.  A signed integer. */

#ifndef __OPSYS_API_H
#ifndef  __CONVENTION_H
#ifndef __TYPEDEF_H__
typedef int				   INT;	/* Signed integer (bit width of processor) */
#endif

typedef unsigned int	   UINT;	/* Unsigned integer (bit width of processor) */
#endif
#endif

#ifndef __TYPEDEF_H__
typedef int				   BOOL;	/* Boolean value.  TRUE (1) or FALSE (0). */
#endif

typedef int				   FN;	/* Function code.  Signed integer.  Maximum 2 bytes. */
typedef int				   BOOL_ID;	/* Boolean value or ID number */
typedef int				   HNO;	/* Handler number */
typedef int				   RNO;	/* Rendezvous number */
typedef int				   NODE;	/* Node Number.  Usually a signed integer. */
typedef unsigned int	   ATR;	/* Object or handler attribute.  An unsigned integer. */
typedef int				   PRI;	/* Task priority.  A signed integer. */
typedef long			   TMO;	/* Timeout value.  A signed integer. */
typedef VP					T_MSG;	/* Message packet data structure used for mailboxes */

typedef UW				   SYSTIME;	/* Data types used for specifying times. */
typedef INT				   DLYTIME;	/* Data types used for specifying times. */

⌨️ 快捷键说明

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