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

📄 ucos.h

📁 各种硬件平台上的us OS移植实例(arm6)
💻 H
字号:
/* * u C / O S . h * * Modified by *		Geary Chopoff * for	VLSI * * Version October 18, 1994 *	Added IRQMboxPost() to post a message from an IRQ * * Version July 15, 1994 *	Moved MACRO for OS_ENTER_CRITICAL and OS_EXIT_CRITICAL to SWIS.H * * Version July 14, 1994 *	finished making prototypes * Version July 13, 1994 *	Added OSTaskIdle() to prototypes * Version July 11, 1994 *	This file is based on the source from uC/OS book as documented below. My *	changes are to identify the difference between that source and VLSI's. If *	a comment is started with VLSI then that line is different from the *	original source. * * File:	ucos.h * * uC/OS Real-time multitasking kernel for the ARM processor. * * Copyright (C) 1992 Jean J. Labrosse. All rights reserved. * Copyright (C) 1993 VLSI Technology Inc. All rights reserved. * * VLSI Technology Inc. does not assume any liability arising out of * this program or use thereof. * *//* general compiler pragma directives */#pragma no_check_stack#pragma no_optimise_crossjump#pragma no_optimise_cse#pragma no_optimise_multiple_loadstypedef unsigned int uint;			/* VLSI Unsigned integer */typedef volatile unsigned int ureg;	/* VLSI Register type */typedef unsigned char byte;			/* VLSI Unsigned characters */typedef int (*PFI)(void);			/* VLSI Pointer to function with no arguments returning int */typedef void (*PFV)(void);			/* VLSI Pointer to function with no arguments returning void */typedef void (*PTV)(void *);		/* VLSI Pointer to function with a pointer argument returning void *//* definition of switches */#define FALSE	0			/* we hold these to be self-evident */#define TRUE	!FALSE#define	FOREVER	TRUE#define	NULL	0/* * uC/OS configuration */#define	uCOS			0x80	/* Interrupt vector assigned to uCOS */#define	OS_MAX_TASKS	20		/* max number of tasks in an application */#define	OS_MAX_EVENTS	20		/* max number of events */#define	OS_MAX_QS		 5		/* max number of queues */#define	OS_IDLE_TASK_STK_SIZE	1024	/* Idle task stack size (BYTES) *//* * Error codes */#define	OS_NO_ERR			 0#define	OS_TIMEOUT			10#define	OS_MBOX_FULL		20#define	OS_Q_FULL			30#define	OS_PRIO_EXIST		40#define	OS_PRIO_ERR			41#define	OS_SEM_ERR			50#define	OS_SEM_OVF			51#define	OS_TASK_DEL_ERR		60#define	OS_TASK_DEL_IDLE	61#define	OS_NO_MORE_TCB		70#define OS_LO_PRIO      	63	/* VLSI lowest priority */#define	MAXbits				8	/* GIC 94Jul11 if we want we can change this to 32, ONLY IF OSMapTbl, OSUnMapTbl, */								/* and OSRdyTbl are properly doctored (and maybe some other bit related things *//* * Event control block. */typedef struct os_event {	uint	 OSEventGrp;		/* VLSI (instead of UBYTE) Group corresponding to tasks waiting for event to occur */	uint	 OSEventTbl[8];		/* VLSI (instead of UBYTE) List of tasks waiting for event to occur */	int		 OSEventCnt;		/* VLSI (instead of WORD)  Count of used when event is a semaphore */	void	*OSEventPtr;		/* Pointer to message or queue structure */} OS_EVENT;/* * Task control block. */typedef struct os_tcb {	void			*OSTCBStkPtr;		/* Pointer to current top of stack */	uint			OSTCBStat;			/* VLSI (instead of UBYTE) Task status */	uint			OSTCBPrio;			/* VLSI (instead of UBYTE) Task priority (0 == highest, OS_LO_PRIO == lowest) */	uint			OSTCBDly;			/* VLSI (instead of UWORD) Number of ticks to delay or, timeout waiting for event */	uint			OSTCBX;				/* VLSI (instead of UBYTE) Bit position in group corresponding to task priority (0..7) */	uint			OSTCBY;				/* VLSI (instead of UBYTE) Index into ready table corresponding to task priority */	uint			OSTCBBitX;			/* VLSI (instead of UBYTE) Bit mask to access bit position in ready table */	uint			OSTCBBitY;			/* VLSI (instead of UBYTE) Bit mask to access bit position in ready group */	OS_EVENT		*OSTCBEventPtr;		/* Pointer to event control block */	struct os_tcb	*OSTCBNext;			/* Pointer to next TCB in TCB list */	struct os_tcb	*OSTCBPrev;			/* Pointer to previous TCB in TCB list */} OS_TCB;/* * Queue control block. */typedef struct os_q {	struct os_q	 *OSQPtr;		/* Link to next queue control block in list of free blocks */	void		**OSQStart;		/* Pointer to start of queue data */	void		**OSQEnd;		/* Pointer to end of queue data */	void		**OSQIn;		/* Pointer to where next message will be inserted in the queue */	void		**OSQOut;		/* Pointer to where next message will be extracted from the queue */	uint		  OSQSize;		/* VLSI (instead of UBYTE) Size of queue (maximum number of entries) */	uint		  OSQEntries;	/* VLSI (instead of UBYTE) Current number of entries in the queue */} OS_Q;/* * uC/OS GLOBAL VARIABLES * * see: OSDEFS.H for global variables */#ifndef	uC_OS/* * Function prototypes in uCOS.c */extern void		 OSInit(void);							/* initialize uC/OS */extern void		 OSTaskIdle(void *data);				/* idle task */extern void		 OSStart(void);							/* start multitasking */extern void		 OSSched(void);							/* scheduler */extern void		 OSSchedLock(void);						/* prevent rescheduling */extern void		 OSSchedUnlock(void);					/* allow rescheduling */extern int		 OSTCBInit(uint	prio, void *pstk);		/* initialize Task Control Block */extern void		 OSIntEnter(void);						/* interrupt entered */extern int		 OSIntExit(void);						/* interrupt exited */extern int		 OSTaskChangePrio(uint oldp, uint newp); /* change priority of task */extern int		 OSTaskDel(uint p);						/* delete a task */extern void		 OSTimeDly(uint ticks);					/* delay a task */extern void		 OSTimeTick(void);						/* process a system tick */extern void		 OSTimeSet(uint ticks);					/* set system time */extern uint		 OSTimeGet(void);						/* get system time */extern OS_EVENT	*OSSemCreate(int cnt);					/* create a semaphore */extern void		 OSSemPend(OS_EVENT *pevent, uint timeout, uint *err);	/* wait semaphore */extern uint		 OSSemPost(OS_EVENT *pevent);			/* signal semaphore */extern OS_EVENT *OSMboxCreate(void *msg);				/* create mailbox */extern void		*OSMboxPend(OS_EVENT *pevent, uint timeout, uint *err);	/* pend for message */extern uint		 OSMboxPost(OS_EVENT *pevent, void *msg); /* post message */extern OS_EVENT	*OSQCreate(void **start, uint size);	/* create a queue */extern void		*OSQPend(OS_EVENT *pevent, uint timeout, uint *err);	/* pend for message */extern uint		 OSQPost(OS_EVENT *pevent, void *msg);	/* post a message */extern void		 OSEventTaskResume(OS_EVENT *pevent);extern int		 OSTaskCreate(PTV task, void *pdata, void *ptsk, uint prio);extern uint		 IRQMboxPost(OS_EVENT *pevent, void *msg); /* post message */#endif/* * Function prototypes in PID.C */extern  PFV 	IRQInstall(int, PFV);/* * Function prototypes in KERN600.S */extern void 	OSStartHighRdy(void);extern void		SaveCtx( void );extern void		RestoreCtx(void);

⌨️ 快捷键说明

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