Embedded 版 (精华区)

发信人: Zinux (Linux技工), 信区: Embedded_system
标  题: ucos源码(header file)
发信站: 哈工大紫丁香 (2001年10月26日18:13:49 星期五), 站内信件


(本文转载自水木清华站精华区)

/*
************************************************************************
****
******************************
*                                                 uC/OS
*                                          The Real-Time Kernel
*                                           SYSTEM DECLARATIONS
*
*                        (c) Copyright 1992-1995, Jean J. Labrosse, 
Plantati
on, FL
*                                           All Rights Reserved
*
*                                                  V1.08
*
* File : UCOS.H
* By   : Jean J. Labrosse
* By   : Jean J. Labrosse
************************************************************************
****
******************************
*/
/*
************************************************************************
****
******************************
*                                          uC/OS CONFIGURATION
************************************************************************
****
******************************
*/
#define OS_FAR                  far    /* Define OS_FAR for the 
processor (i
x86 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 ap
pliccation                  */
#define OS_MAX_EVENTS            20    /* Maximum number of event 
control bl
ockss in your application   */
#define OS_MAX_QS                 5    /* Maximum number of queue 
control bl
ockss in your application   */
#define OS_IDLE_TASK_STK_SIZE  1024    /* Idle task stack size (BYTEs)
#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() a
nd OOSTaskResume()          */
/*$PAGE*/
/*
************************************************************************
****
******************************
*                                            MISCELLANEOUS
************************************************************************
****
******************************
*/
#ifdef  OS_GLOBALS
#define OS_EXT
#else
#define OS_EXT  extern
#endif
#endif
#define OS_PRIO_SELF           0xFF    /* Indicate SELF priority
/*
************************************************************************
****
******************************
*                                           uC/OS ERROR CODES
************************************************************************
****
******************************
*/
#define OS_NO_ERR                 0
#define OS_TIMEOUT               10
#define OS_TASK_NOT_EXIST        11
#define OS_MBOX_FULL             20
#define OS_MBOX_MSG_NOT_AVAIL    21
#define OS_Q_FULL                30
#define OS_Q_MSG_NOT_AVAIL       31
#define OS_PRIO_EXIST            40
#define OS_PRIO_ERR              41
#define OS_PRIO_INVALID          42
#define OS_SEM_ERR               50
#define OS_SEM_OVF               51
#define OS_SEM_NOT_AVAIL         52
#define OS_TASK_DEL_ERR          60
#define OS_TASK_DEL_ERR          60
#define OS_TASK_DEL_IDLE         61
#define OS_TASK_DEL_REQ          62
#define OS_NO_MORE_TCB           70
#define OS_TIME_NOT_DLY          80
#define OS_TASK_SUSPEND_PRIO     90
#define OS_TASK_SUSPEND_IDLE     91
#define OS_TASK_RESUME_PRIO     100
#define OS_TASK_NOT_SUSPENDED   101
/*$PAGE*/
/*
************************************************************************
****
******************************
*                                          EVENT CONTROL BLOCK
************************************************************************
****
******************************
*/
typedef struct os_event {
    UBYTE  OSEventGrp;                 /* Group corresponding to tasks 
waiti
ng ffor event to occur      */
    UBYTE  OSEventTbl[8];              /* List of tasks waiting for 
event to
 occcur                     */
    UWORD  OSEventCnt;                 /* Count of used when event is 
a sema
    UWORD  OSEventCnt;                 /* Count of used when event is 
a sema
phorre                      */
    void  *OSEventPtr;                 /* Pointer to message or queue 
struct
ure                        */
} 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 ==
 lowwest)                   */
    UWORD          OSTCBDly;           /* Nbr ticks to delay task or, 
timeou
t waaiting for event        */
    BOOLEAN        OSTCBDelReq;        /* Indicates whether a task needs
 to
deleete itself              */
    UBYTE          OSTCBX;             /* Bit position in group  
correspondi
ng tto task priority (0..7) */
ng tto task priority (0..7) */
    UBYTE          OSTCBY;             /* Index into ready table 
correspondi
ng tto task priority        */
    UBYTE          OSTCBBitX;          /* Bit mask to access bit 
position in
 reaady table               */
    UBYTE          OSTCBBitY;          /* Bit mask to access bit 
position in
 reaady 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
 lisst                      */
    struct os_tcb *OSTCBPrev;          /* Pointer to previous TCB in the
 TCB
 lisst                      */
} OS_TCB;
/*
************************************************************************
****
******************************
*                                          QUEUE CONTROL BLOCK
************************************************************************
****
******************************
*/
typedef struct os_q {
typedef struct os_q {
    struct os_q   *OSQPtr;             /* Link to next queue control 
block i
n liist 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 e
ntriies)                    */
    UBYTE          OSQEntries;         /* Current number of entries in 
the q
ueuee                       */
} OS_Q;
/*$PAGE*/
/*
************************************************************************
****
******************************
*                                         uC/OS GLOBAL VARIABLES
************************************************************************
****
******************************
*/
                                       /* SYSTEM VARIABLES
                                       /* SYSTEM VARIABLES
OS_EXT  UWORD      OSCtxSwCtr;         /* Counter of number of context 
switc
hes                        */
OS_EXT  ULONG      OSIdleCtr;          /* Idle counter
OS_EXT  UBYTE      OSIntNesting;       /* Interrupt nesting level
OS_EXT  BOOLEAN    OSRunning;          /* Flag indicating that kernel is
 run
ningg                       */
OS_EXT  OS_TCB    *OSTCBCur;           /* Pointer to currently running 
TCB
OS_EXT  OS_TCB    *OSTCBHighRdy;       /* Pointer to highest priority 
TCB re
ady to run                 */
OS_EXT  OS_TCB    *OSTCBPrioTbl[64];   /* Table of pointers to all 
created T
CBs                        */
/*
************************************************************************
****
******************************
*                                       uC/OS FUNCTION PROTOTYPES
************************************************************************
****
******************************
*/
void        OSInit(void);
void        OSStart(void);
void        OSStartHighRdy(void);
void        OSSched(void);
void        OSSched(void);
void        OSSchedLock(void);
void        OSSchedUnlock(void);
UBYTE       OSTaskCreate(void (OS_FAR *task)(void *pd), void *pdata, 
void *p
stk,, UBYTE prio);
UBYTE       OSTaskDel(UBYTE prio);
UBYTE       OSTaskDelReq(UBYTE prio);
UBYTE       OSTaskChangePrio(UBYTE oldprio, UBYTE newprio);
UBYTE       OSTaskSuspend(UBYTE prio);
UBYTE       OSTaskResume(UBYTE prio);
UBYTE       OSTCBInit(UBYTE prio, void OS_FAR *stk);
void        OSIntEnter(void);
void        OSIntExit(void);
void        OSIntCtxSw(void);
void OS_FAR OSCtxSw(void);
void OS_FAR OSTickISR(void);
void        OSTimeDly(UWORD ticks);
UBYTE       OSTimeDlyResume(UBYTE prio);
void        OSTimeTick(void);
void        OSTimeSet(ULONG ticks);
ULONG       OSTimeGet(void);
OS_EVENT   *OSSemCreate(UWORD value);
UWORD       OSSemAccept(OS_EVENT *pevent);
void OS_FAR OSTickISR(void);
UBYTE       OSSemPost(OS_EVENT *pevent);
void        OSSemPend(OS_EVENT *pevent, UWORD timeout, UBYTE *err);
OS_EVENT   *OSMboxCreate(void *msg);
void       *OSMboxAccept(OS_EVENT *pevent);
UBYTE       OSMboxPost(OS_EVENT *pevent, void *msg);
void       *OSMboxPend(OS_EVENT *pevent, UWORD timeout, UBYTE *err);
OS_EVENT   *OSQCreate(void **start, UBYTE size);
void       *OSQAccept(OS_EVENT *pevent);
UBYTE       OSQPost(OS_EVENT *pevent, void *msg);
void       *OSQPend(OS_EVENT *pevent, UWORD timeout, UBYTE *err)

--

  puke! 
  技工而已

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.152]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:218.909毫秒