SAMPScheduler.h
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:3k
- #include "Config.h" // Global Configuration - do not remove!
- #include "playcoresampsamp_gen.h"
- #ifndef SAMPSCHEDULER_H_
- #define SAMPSCHEDULER_H_
- #define MESSAGE_LENGTH 12
- #define MAX_NUM_OF_MESSAGE 6
- #define SAMP_API_PARAM (gns.sacd.samp_api_param)
- // *****************************************************************************
- // * Types definition
- // *****************************************************************************
- //general
- //#define OPTIMIZE_PARAMETER_SIZE
- #ifdef OPTIMIZE_PARAMETER_SIZE
- typedef UINT16 IDENT;
- typedef UINT16 TIMEOUT;
- typedef PRI PRIORITY;
- typedef UINT16 CAPACITY;
- typedef UINT16 UNITS;
- #define OS_FOREVER 0xffffu
- #else
- typedef UINT32 IDENT;
- typedef UINT32 TIMEOUT;
- typedef UINT32 PRIORITY;
- typedef UINT32 CAPACITY;
- typedef UINT32 UNITS;
- #define OS_FOREVER 0xfffffffful
- #endif
- //task status states
- typedef enum
- {
- TASK_NOT_STARTED = 0,
- TASK_STATUS_READY,
- TASK_STATUS_WAITING_FOR_MESSAGE,
- TASK_STATUS_WAITING_FOR_SEMAPHORE
- } SAMP_TASK_STATUS;
- //task control block
- typedef struct
- {
- UINT16 Status;
- UINT16 SemaphoreID;
- UINT16 MailboxID;
- void* MessagePtr;
- UINT16 StackOff;
- UINT32 SDRAMStackAddr;
- }
- TCB;
- //task context
- typedef struct
- {
- UH bp;
- UH di;
- UH si;
- FP task; /* procedure */
- } TASK_CONTEXT;
- //semaphore
- typedef UINT16 SEMAPHORE;
- //mailbox
- typedef struct
- {
- UINT8 Message[MESSAGE_LENGTH];
- }
- MESSAGE;
- typedef struct
- {
- UINT16 Capacity;
- UINT16 MessageCount;
- UINT16 WritePointer;
- UINT16 ReadPointer;
- MESSAGE *MessageQueue;
- }
- MAILBOX;
- SAMP(ErrCode) SAMP(OS_TaskCreate) (PRIORITY Priority, size_t Stacksize, void(*Entry)(void),IDENT *Id);
- SAMP(ErrCode) SAMP(OS_TaskDelete) (IDENT Id);
- SAMP(ErrCode) SAMP(OS_SemCreate) (UNITS Units,IDENT *Id);
- SAMP(ErrCode) SAMP(OS_SemDelete) (IDENT Id);
- SAMP(ErrCode) SAMP(OS_SemP) (IDENT Id,TIMEOUT Timeout);
- SAMP(ErrCode) SAMP(OS_SemV) (IDENT Id);
- SAMP(ErrCode) SAMP(OS_MboxCreate) (CAPACITY Capacity,IDENT *Id);
- SAMP(ErrCode) SAMP(OS_MboxDelete) (IDENT Id);
- SAMP(ErrCode) SAMP(OS_SendMsg) (IDENT Id,void *Ptr,size_t Size);
- SAMP(ErrCode) SAMP(OS_ISendMsg) (IDENT Id,void *Ptr,size_t Size);
- SAMP(ErrCode) SAMP(OS_RecvMsg) (IDENT Id,TIMEOUT Timeout,void *Ptr,size_t Size,size_t *Msgsize);
- SAMP(ErrCode) SAMP(OS_GetTime)(UINT32 *Ticks);
- SAMP(ErrCode) SAMP(OS_TimerEvery)(UINT32 Ticks, void (*Callback)(void), IDENT *Id);
- SAMP(ErrCode) SAMP(OS_TimerCancel)(IDENT Id);
- int SAMP_SchedulerInstall(void);
- void SAMP_SchedulerRemove (void);
- #endif