?? emos_core.h
字號(hào):
/****************************************************************************
*
* (c) Copyright 2001,2008, EMB system, All Rights Reserved.
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF EMB SYSTEM, INC.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
* Subsystem: EMOS
* File: emos_core.h
* Author: zenf zhao
* Description: embedded software operation system core include files
*
****************************************************************************/
#ifndef _EMOS_CORE_H_
#define _EMOS_CORE_H_
#include "emos_inc.h"
#include "emos_cfg.h"
#include "emos_cpu.h"
/**********************************************************************************************************
* MISCELLANEOUS
*********************************************************************************************************/
/* Version of EMS_os (Vx.yy multiplied by 100) */
#define EMOS_VERSION (100)
#define EMOS_VER_STRING "emos version 1.0 by zenf_zhao @ EMB system"
#define EMOS_Print printf
#define EMOS_AUTH_STRING "zenf_zhao"
#define EMOS_TRC_BOOT (0x01 << 0)
#define EMOS_TRC_TASK (0x01 << 1)
#define EMOS_TRC_MSGQ (0x01 << 2)
#define EMOS_TRC_SEM (0x01 << 3)
#define EMOS_TRC_MEM (0x01 << 4)
#define EMOS_TRC_EVENT (0x01 << 5)
#define EMOS_TRC_ALL (0xFFFFFFFF)
/*
#ifdef EMOS_DBG_EN
#define EMOS_Trace(a,b) if(a&gEmosDbgLevel) printf b
#else
#define EMOS_Trace(a,b) if(a) printf b
#endif
*/
#define EMOS_DEBUG_EN
#ifdef EMOS_DEBUG_EN
#define EMOS_DBGID_STR "EMOS DBG:"
#define EMOS_Trace(fmt,arg...) printf(EMOS_DBGID_STR fmt,##arg)
#else
#define EMOS_Trace(fmt,arg...)
#endif
#ifdef EMOS_DEBUG_EN
/*will be porting to another callback again*/
#define EMOS_Printf(fmt,arg...) printf(fmt,##arg)
#else
#define EMOS_Printf(fmt,arg...)
#endif
#ifdef EMOS_GLOBALS
#define EMOS_EXT
#else
#define EMOS_EXT extern
#endif
#define EMOS_WAIT_FOREVER (0xFFFF)
#define EMOS_PRIO_SELF (0xFF) /* Indicate SELF priority */
#if EMOS_TASK_STAT_EN
#define EMOS_N_SYS_TASKS (2) /* Number of system tasks */
#else
#define EMOS_N_SYS_TASKS (1)
#endif
#define EMOS_IDLE_PRIO (EMOS_LOWEST_PRIO) /* IDLE task priority lowest priority */
#define EMOS_STAT_PRIO (EMOS_LOWEST_PRIO - 1) /* Statistic task priority, higher than idle*/
#define EMOS_EVENT_TBL_SIZE ((EMOS_LOWEST_PRIO) / 8 + 1) /* Size of event table */
#define EMOS_RDY_TBL_SIZE ((EMOS_LOWEST_PRIO) / 8 + 1) /* Size of ready table */
#define EMOS_TASK_IDLE_ID (65535) /* I.D. numbers for Idle and Stat tasks */
#define EMOS_TASK_STAT_ID (65534)
/* TASK STATUS (Bit definition for EMS_osTCBStat) */
#define EMOS_STAT_RDY (0x00) /* Ready to run */
#define EMOS_STAT_SEM (0x01) /* Pending on semaphore*/
#define EMOS_STAT_MBOX (0x02) /* Pending on mailbox*/
#define EMOS_STAT_Q (0x04) /* Pending on queue*/
#define EMOS_STAT_SUSPEND (0x08) /* Task is suspended*/
#define EMOS_STAT_MSGQ (0x10) /* Pending on msgq*/
#define EMOS_EVENT_TYPE_MBOX (1)
#define EMOS_EVENT_TYPE_Q (2)
#define EMOS_EVENT_TYPE_SEM (3)
#define EMOS_EVENT_TYPE_MSGQ (4)
/* TASK OPTIONS (see EMS_osTaskCreateExt()) */
#define EMOS_TASK_OPT_STK_CHK (0x0001) /* Enable stack checking for the task */
#define EMOS_TASK_OPT_STK_CLR (0x0002) /* Clear the stack when the task is create */
#define EMOS_TASK_OPT_SAVE_FP (0x0004) /* Save the contents of any floating-point registers */
/**********************************************************************************************************
* ERROR CODES
**********************************************************************************************************/
#define EMOS_OK (0)
#define EMOS_FAIL (2)
#define EMOS_NO_ERR 0
#define EMOS_ERR_EVENT_TYPE 1
#define EMOS_ERR_PEND_ISR 2
#define EMOS_INVALID_INPARA 3
#define EMOS_TIMEOUT 10
#define EMOS_TASK_NOT_EXIST 11
#define EMOS_MBOX_FULL 20
#define EMOS_Q_FULL 30
#define EMOS_Q_EMPTY 31
#define EMOS_PRIO_EXIST 40
#define EMOS_PRIO_ERR 41
#define EMOS_PRIO_INVALID 42
#define EMOS_SEM_OVF 50
#define EMOS_TASK_DEL_ERR 60
#define EMOS_TASK_DEL_IDLE 61
#define EMOS_TASK_DEL_REQ 62
#define EMOS_TASK_DEL_ISR 63
#define EMOS_NO_MORE_TCB 70
#define EMOS_TIME_NOT_DLY 80
#define EMOS_TIME_INVALID_MINUTES 81
#define EMOS_TIME_INVALID_SECONDS 82
#define EMOS_TIME_INVALID_MILLI 83
#define EMOS_TIME_ZERO_DLY 84
#define EMOS_TASK_SUSPEND_PRIO 90
#define EMOS_TASK_SUSPEND_IDLE 91
#define EMOS_TASK_RESUME_PRIO 100
#define EMOS_TASK_NOT_SUSPENDED 101
#define EMOS_MEM_INVALID_PART 110
#define EMOS_MEM_INVALID_BLKS 111
#define EMOS_MEM_INVALID_SIZE 112
#define EMOS_MEM_NO_FREE_BLKS 113
#define EMOS_MEM_FULL 114
#define EMOS_TASK_OPT_ERR 130
/**********************************************************************************************************
* EVENT CONTROL BLOCK
**********************************************************************************************************/
#if (EMOS_MAX_EVENTS >= 2)
typedef struct EMOS_EVENT_t
{
/* Pointer to message or queue structure */
void* osEventPtr;
/* List of tasks waiting for event to occur*/
uint8 osEventTbl[EMOS_EVENT_TBL_SIZE];
/* EMOS_EVENT_TYPE_MBOX, EMOS_EVENT_TYPE_Q or EMOS_EVENT_TYPE_SEM */
uint8 osEventType;
/* Group corresponding to tasks waiting for event to occur */
uint8 osEventGrp;
/* Count of used when event is a semaphore */
uint16 osEventCnt;
} EMOS_EVENT_T;
#endif
/**********************************************************************************************************
* MESSAGE MAILBOX DATA
**********************************************************************************************************/
#if EMOS_MBOX_EN
typedef struct EMOS_MBOX_DATA_t
{
/* Pointer to message in mailbox */
void* osMsg;
/* List of tasks waiting for event to occur*/
uint8 osEventTbl[EMOS_EVENT_TBL_SIZE];
/* Group corresponding to tasks waiting for event to occur */
uint8 osEventGrp;
} EMOS_MBOX_DATA_T;
#endif
/**********************************************************************************************************
* MEMORY PARTITION DATA STRUCTURES
**********************************************************************************************************/
#if EMOS_MEM_EN && (EMOS_MAX_MEM_PART >= 2)
typedef struct EMOS_MEM_DATA_t
{
void* osAddr; /* Pointer to the beginning address of the memory partition */
void* osFreeList; /* Pointer to the beginning of the free list of memory blocks */
uint32 osBlkSize; /* Size (in bytes) of each memory block */
uint32 osNBlks; /* Total number of blocks in the partition */
uint32 osNFree; /* Number of memory blocks free */
uint32 osNUsed; /* Number of memory blocks used */
} EMOS_MEM_DATA_T;
typedef struct EMOS_MEM_t
{
/* MEMORY CONTROL BLOCK */
void* osMemAddr; /* Pointer to beginning of memory partition */
void* osMemFreeList; /* Pointer to list of free memory blocks */
uint32 osMemBlkSize; /* Size (in bytes) of each block of memory */
uint32 osMemNBlks; /* Total number of blocks in this partition */
uint32 osMemNFree; /* Number of memory blocks remaining in this partition */
} EMOS_MEM_T;
typedef EMOS_MEM_T EMOS_MEM_ID;
#endif
/********************************************************************************************************
* MESSAGE QUEUE DATA
**********************************************************************************************************/
#if EMOS_Q_EN
typedef struct EMOS_Q_DATA_t
{
void * osMsg; /* Pointer to next message to be extracted from queue */
uint16 osNMsgs; /* Number of messages in message queue */
uint16 osQSize; /* Size of message queue */
uint8 osEventTbl[EMOS_EVENT_TBL_SIZE]; /* List of tasks waiting for event to occur */
uint8 osEventGrp; /* Group corresponding to tasks waiting for event to occur */
} EMOS_Q_DATA_T;
#endif
/**********************************************************************************************************
* SEMAPHORE DATA
**********************************************************************************************************/
#if EMOS_SEM_EN
typedef struct EMOS_SEM_DATA_t
{
uint16 osCnt; /* Semaphore count */
/* List of tasks waiting for event to occur */
uint8 osEventTbl[EMOS_EVENT_TBL_SIZE];
/* Group corresponding to tasks waiting for event to occur */
uint8 osEventGrp;
} EMOS_SEM_DATA_T;
#endif
/**********************************************************************************************************
* TASK STACK DATA
**********************************************************************************************************/
#if EMOS_TASK_CREATE_EXT_EN
typedef struct EMOS_STK_DATA_t
{
uint32 osFree; /* Number of free bytes on the stack */
uint32 osUsed; /* Number of bytes used on the stack */
} EMOS_STK_DATA_T;
#endif
/**********************************************************************************************************
* TASK CONTROL BLOCK
**********************************************************************************************************/
typedef struct emos_tcb {
EMOS_STK* osTCBStkPtr; /* Pointer to current top of stack */
#if EMOS_TASK_CREATE_EXT_EN
void* osTCBExtPtr; /* Pointer to user definable data for TCB extension */
EMOS_STK* osTCBStkBottom; /* Pointer to bottom of stack */
uint32 osTCBStkSize; /* Size of task stack (in bytes) */
uint16 osTCBOpt; /* Task options as passed by osTaskCreateExt() */
uint16 osTCBId; /* Task ID (0..65535) */
#endif
struct emos_tcb* osTCBNext; /* Pointer to next TCB in the TCB list */
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -