標(biāo)題: ucos(head file) [打印本頁(yè)] 作者: 諸葛孔明 時(shí)間: 2009-8-28 10:38 標(biāo)題: ucos(head file) /*
************************************ uC/OS
* The Real-Time Kernel
* SYSTEM DECLARATIONS
*
* (c) Copyright 1992-1995, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
* V1.08
*
* File : UCOS.H
* By : Jean J. Labrosse
************************************************************
*/
/*
************************************************************
* uC/OS CONFIGURATION
************************************************************
*/
#define OS_FAR far /* Define OS_FAR for the processor (ix86 CPUs) */
#define OS_STK_TYPE UBYTE /* Data type used for stack */
#define uCOS 0x80 /* Interrupt vector assigned to uC/OS */
#define OS_MAX_TASKS 63 /* Maximum number of tasks in your application */
#define OS_MAX_EVENTS 20 /* Maximum number of event control blocks in your application */
#define OS_MAX_QS 5 /* Maximum number of queue control blocks in your application */
#define OS_IDLE_TASK_STK_SIZE 1024 /* Idle task stack size (BYTEs) */
#define OS_IDLE_TASK_STK_TOP 1024 /* Index into idle task top of stack */
#define OS_TASK_CHANGE_PRIO_EN 1 /* Include code for OSTaskChangePrio() */
#define OS_TASK_DEL_EN 1 /* Include code for OSTaskDel() */
#define OS_SEM_EN 1 /* Include code for SEMAPHORES */
#define OS_MBOX_EN 1 /* Include code for MAILBOXES */
#define OS_Q_EN 1 /* Include code for QUEUES */
#define OS_TASK_SUSPEND_EN 1 /* Include code for OSTaskSuspend() and OSTaskResume() */
/*$PAGE*/
/*
************************************************************
* MISCELLANEOUS
************************************************************
*/
typedef struct os_event {
UBYTE OSEventGrp; /* Group corresponding to tasks waiting for event to occur */
UBYTE OSEventTbl[8]; /* List of tasks waiting for event to occur */
UWORD OSEventCnt; /* Count of used when event is a semaphore */
void *OSEventPtr; /* Pointer to message or queue structure */
} OS_EVENT;
/*
************************************************************
* uC/OS TASK CONTROL BLOCK
************************************************************
*/
typedef struct os_tcb {
void OS_FAR *OSTCBStkPtr; /* Pointer to current top of stack */
UBYTE OSTCBStat; /* Task status */
UBYTE OSTCBPrio; /* Task priority (0 == highest, 63 == lowest) */
UWORD OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
BOOLEAN OSTCBDelReq; /* Indicates whether a task needs to delete itself */
UBYTE OSTCBX; /* Bit position in group corresponding to task priority (0..7) */
UBYTE OSTCBY; /* Index into ready table corresponding to task priority */
UBYTE OSTCBBitX; /* Bit mask to access bit position in ready table */
UBYTE OSTCBBitY; /* Bit mask to access bit position in ready group */
OS_EVENT *OSTCBEventPtr; /* Pointer to event control block */
void *OSTCBMsg; /* Message received from OSMboxPost() or OSQPost() */
struct os_tcb *OSTCBNext; /* Pointer to next TCB in the TCB list */
struct os_tcb *OSTCBPrev; /* Pointer to previous TCB in the 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 Q */
void **OSQOut; /* Pointer to where next message will be extracted from the Q */
UBYTE OSQSize; /* Size of queue (maximum number of entries) */
UBYTE OSQEntries; /* Current number of entries in the queue */
} OS_Q;
/*$PAGE*/
/*
************************************************************
* uC/OS GLOBAL VARIABLES
************************************************************
*/
/* SYSTEM VARIABLES */
OS_EXT UWORD OSCtxSwCtr; /* Counter of number of context switches */
OS_EXT ULONG OSIdleCtr; /* Idle counter */
OS_EXT UBYTE OSIntNesting; /* Interrupt nesting level */
OS_EXT BOOLEAN OSRunning; /* Flag indicating that kernel is running */
OS_EXT OS_TCB *OSTCBCur; /* Pointer to currently running TCB */
OS_EXT OS_TCB *OSTCBHighRdy; /* Pointer to highest priority TCB ready to run */
OS_EXT OS_TCB *OSTCBPrioTbl[64]; /* Table of pointers to all created TCBs */
/*
*********************************************************************************************************
* uC/OS FUNCTION PROTOTYPES
*********************************************************************************************************
*/