?? zl5011xos.h
字號(hào):
/******************************************************************************
*
* File name: zl5011xVxWorksOs.h
*
* Version: 37
*
* Author: MRC
*
* Date created: 29/04/2002
*
* Copyright 2002, 2003, 2004, 2005, Zarlink Semiconductor Limited.
* All rights reserved.
*
* Module Description:
*
* The zl5011x API relies on various functions that need to be provided by
* the 'host' operating system. In order to make porting the API to a different
* 'host' easier to achieve we have defined some generic macros that the API uses.
*
* This module contains these generic macros that are used in the zl5011x API.
*
* Note: Currently this header file is only concerned with mapping macros
* to VxWorks.
* For more info on each of the function calls please see
* VxWorks 5.4 Reference Manual. Windriver Part Number DOC-12910-ND-00
*
*
* Revision History:
*
* Rev: Date: Author: Comments:
* 1 08/02/2002 MRC Creation
* 2 03/04/2002 MRC Updated
* 3 20/06/2002 MRC Added interrupt funcs
* 4 12/09/2002 MRC Tidied up mutex definitions
* 5 13/09/2002 MRC Corrected OS_MUTEX_ID define
* 6 17/09/2002 ARW Added include files: m8260Fcc.h & m8260Sio.h
* 7 18/09/2002 ARW Added macros for other RTOS specific memory
* allocations
* 8 19/09/2002 ARW Update
* 9 03/10/2002 ARW Added a Macro for determining the current size
* of a message queue
* 10 04/10/2002 ARW Added a Macro for verifing if a task exists
* 11 15/10/2002 ARW Added macros OS_TICK_DELAY & OS_IMMR_GET
* 12 31/10/2002 MRC Added variants + minor fixes
* 13 18/11/2002 ARW Added an include to inet.h (for NTP protocol)
* 14 10/01/2003 MRC Added message queue defines
* 15 14/01/2003 ARW Removed micro specific prototypes and include
* files
* 16 31/01/2003 MRC Added DMA include files and micro specific
* prototypes
* 17 03/02/2003 MRC Added OS_TASK_ID typedef
* 18 14/02/2003 MRC Added socket header files
* 19 03/04/2003 MRC Added OS enable / disable fns
* 20 15/04/2003 ARW Added MACRO for getting processor ticks
* 21 18/07/2003 APL Added OS_LOG_INIT macro
* 22 22/09/2003 PJE Added ZLS5011X_BUILDING_PC_MGMT_STA macro
* 23 24/09/2003 PJE Update
* 24 18/11/2003 APL Fixed file header version
* 25 05/05/2004 MRC Added AUX timer functions
* 26 23/06/2004 MRC Added definition of OS_SEM_EMPTY
* 27 23/07/2004 MRC Added prototype + information for OS calls
* 28 29/07/2004 MRC Fixed some compiler warnings
* 29 25/08/2004 MRC Added OS tick define
* 30 03/09/2004 APL Added parentheses around macro arguments to
* protect against inadvertent side effects
* 31 08/09/2004 MRC Added define to abstract the 64 bit integer type
* 32 09/12/2004 MRC Added information on VxWorks defines
* 33 13/12/2004 MRC Added FUNCPTR defines
* 34 15/12/2004 APL Added information on more VxWorks definitions
* 35 11/02/2005 MRC Added macros for DMA endian conversion
* 36 01/04/2005 APL Updated comments for OS_TASK_SPAWN
* 37 05/05/2005 APL Removed '//' comment characters
*
******************************************************************************/
#ifndef _ZL5011X_OS_H_
#define _ZL5011X_OS_H_
#ifdef __cplusplus
extern "C" {
#endif
/***************** INCLUDE FILES ******************************************/
/* Required VxWorks include files as specified in the VxWorks reference manual */
#ifndef ZLS5011X_BUILDING_PC_MGMT_STA
#include <vxWorks.h>
#include "vme.h"
#include "memLib.h"
#include "cacheLib.h"
#include <stdio.h>
#include <semLib.h>
#include <selectLib.h>
#include <msgQLib.h>
#include <wdLib.h>
#include <sockLib.h>
#include <socket.h>
#include <ioLib.h>
#include <in.h>
#include <taskLib.h>
#include <taskHookLib.h>
#include <tickLib.h>
#include <sysLib.h>
#include <errnoLib.h>
#include <intLib.h>
#include <iv.h>
#include <hostLib.h>
#include <usrLib.h>
#include <fcntl.h>
#include <ctype.h>
#include <timers.h>
#include <logLib.h>
#if 0
#include <net/inet.h>/*shf add 2005.9.5 FM 15:07*/
#endif
#include <netinet\tcp.h>
#include <netinet\in.h>
#include <drv\end\m8260Fcc.h>
#include <drv\sio\m8260Sio.h>
#include <le1veLib.h>
/******** Micro specfic function calls provided by RTOS (VxWorks) ***********/
/* the following functions provide a simple mechanism for allocating the
DPRAM (dual port RAM) to the CPM. The allocation system is very simple
and is only performed during initialisation */
void *sys82xxDpramAlignedMalloc (size_t length, size_t alignment);
/* Returns pointer to DPRAM memory allocated from memory pool.
Alignment is number of bytes i.e. 1, 2, 4, 8 etc.*/
void sys82xxDpramFree (void *address);
/* Free memory allocated from DPRAM main pool */
#define OS_DPRAM_FREE(address) sys82xxDpramFree(address)
#else /* ifndef ZLS5011X_BUILDING_PC_MGMT_STA */
/***************** # DEFINES **********************************************/
#define InLine inline
typedef struct wdog *WDOG_ID; /* watchdog id */
#endif /* ZLS5011X_BUILDING_PC_MGMT_STA */
/***************** General Constants **************************************/
#define OS_STATUS STATUS
/*
typedef int STATUS;
*/
#ifndef OS_OK
#define OS_OK OK
/*
#define OK 0
*/
#define OS_ERROR ERROR
/*
#define ERROR (-1)
*/
#endif /* ifndef OS_OK */
#define OS_WAIT_FOREVER WAIT_FOREVER
/*
#define WAIT_FOREVER (-1)
*/
#define OS_NO_WAIT NO_WAIT
/*
#define NO_WAIT 0
*/
/* define minimum -> maximum range for the data types */
#define OS_UINT32T_MAX ULONG_MAX
/* Maximum unsigned 32-bit quantity. Minimum is 0.
#define ULONG_MAX 4294967295uL
*/
#define OS_UINT16T_MAX USHRT_MAX
/* Maximum unsigned 16-bit quantity. Minimum is 0.
#define USHRT_MAX 65535u
*/
#define OS_UINT8T_MAX UCHAR_MAX
/* Maximum unsigned 8-bit quantity. Minimum is 0.
#define UCHAR_MAX 255u
*/
#define OS_SINT32T_MAX LONG_MAX
/* Maximum signed 32-bit quantity.
#define LONG_MAX 2147483647L
*/
#define OS_SINT32T_MIN LONG_MIN
/* Minimum signed 32-bit quantity.
#define LONG_MIN (-LONG_MAX-1)
*/
#define OS_SINT16T_MAX SHRT_MAX
/* Maximum signed 16-bit quantity.
#define SHRT_MAX 32767
*/
#define OS_SINT16T_MIN SHRT_MIN
/* Minimum signed 16-bit quantity.
#define SHRT_MIN (-32768)
*/
#define OS_SINT8T_MAX CHAR_MAX
/* Maximum signed 8-bit quantity.
#define CHAR_MAX 127
*/
#define OS_SINT8T_MIN CHAR_MIN
/* Minimum signed 8-bit quantity.
#define CHAR_MIN (-128)
*/
#define OS_RAND_MAX RAND_MAX
/* The maximum value that may be returned by rand.
The minimum is zero.
#define RAND_MAX 0x7FFF
*/
#define OS_INT64 long long
#ifndef __INCvxTypesOldh
typedef int (*FUNCPTR)(); /* ptr to function returning int */
typedef void (*VOIDFUNCPTR)(); /* ptr to function returning void */
#endif /* ifndef __INCvxTypesOldh */
/***************** Mutex / Sema4 related constants ************************/
#ifdef ZLS5011X_BUILDING_PC_MGMT_STA
typedef struct semaphore *SEM_ID;
#endif /* ZLS5011X_BUILDING_PC_MGMT_STA */
/* The following definitions are for binary semaphores/mutexes.
OS_MUTEX_ID is an OS specific type returned by OS_MUTEX_CREATE
which uniquely identifies a particular mutex.
See OS_MUTEX_CREATE for description of SEM_EMPTY and SEM_FULL.
*/
#define OS_MUTEX_ID SEM_ID
#define OS_SEM_EMPTY SEM_EMPTY
#define OS_SEM_FULL SEM_FULL
/* The following definition is for counting semaphores.
OS_SEM_ID is an OS specific type returned by OS_SEMA4_CREATE
which uniquely identify a particular semaphore
Note that om VxWorks both mutexes and semaphores have the same definition.
*/
#define OS_SEM_ID SEM_ID
#define OS_SEM_INVALID NULL
/* See OS_MUTEX_CREATE or OS_SEMA4_CREATE for description of SEM_Q_PRIORITY */
#define OS_SEM_Q_PRIORITY SEM_Q_PRIORITY
/***************** Message queue related constants ************************/
#ifdef ZLS5011X_BUILDING_PC_MGMT_STA
typedef struct msg_q *MSG_Q_ID; /* message queue ID */
typedef MSG_Q_ID OS_MsgQT;
#endif /* ZLS5011X_BUILDING_PC_MGMT_STA */
#define OS_MSG_Q_INVALID NULL
#define OS_MSG_Q_ID MSG_Q_ID
/* MSG_Q_ID is an OS specific type returned by OS_MSG_Q_CREATE which
uniquely identifies a particular message queue */
#define OS_MSG_Q_PRIORITY MSG_Q_PRIORITY
#define OS_MSG_Q_FIFO MSG_Q_FIFO
/* See OS_MSG_Q_CREATE for details of MSG_Q_PRIORITY and MSG_Q_FIFO */
/***************** Task Control related constants *************************/
#define OS_VX_NO_STACK_FILL VX_NO_STACK_FILL
/* See OS_TASK_SPAWN for details of VX_NO_STACK_FILL */
typedef Uint32T OS_TASK_ID; /* VxWorks task identifiers are arbitrary 32-bit integers */
/***************** Task Control *******************************************/
/* Create and activate a new task */
#define OS_TASK_SPAWN taskSpawn
/*
int taskSpawn
(
char * name, - name of new task (stored at pStackBase)
int priority, - priority of new task 0 = highest, 255 = lowest
int options, - task option word (see below).
int stackSize, - size (bytes) of stack needed plus name
FUNCPTR entryPt, - entry point of new task
int arg1, - First of 10 req'd task args to pass to func
int arg2, - Arguments 2-10 are unused by the API
int arg3,
int arg4,
int arg5,
int arg6,
int arg7,
int arg8,
int arg9,
int arg10
)
Notes:
Returns task ID, or ERROR if task cannot be created.
The task option word is a set of bit-ORed option flags. The API uses only the value
OS_VX_NO_STACK_FILL (0x100) which indicates that the API does not require the
task stack to be filled with a known value.
If the OS_VX_NO_STACK_FILL bit is not set then the stack should be filled which can
be useful for debugging.
In practice this behaviour of filling the stack is not important to the API
and can be either be ignored or recreated in the application environment at
the application designer's discretion.
*/
/* Delete a task */
#define OS_TASK_DELETE taskDelete
/*
STATUS taskDelete (int tid);
*/
/* Verify a task exists */
#define OS_TASK_ID_VERIFY taskIdVerify
/*
STATUS taskIdVerify (int tid);
Notes:
Returns OK or task ID is invalid.
*/
/* Delay a task from executing */
/* Note: The delay period should be specified in milliseconds */
#define OS_TASK_DELAY(milliseconds) taskDelay(OS_TICKS(milliseconds)+1)
/*
STATUS taskDelay (int ticks);
*/
#define OS_TICK_DELAY(ticks) taskDelay(ticks)
/***************** Time ***************************************************/
/* Work out the number of system ticks for given number of millisecinds */
/* Note: This is a 'local' macro used in this file only */
#define OS_TICKS(milliseconds) ((sysClkRateGet() * (milliseconds))/1000)
/*
int sysClkRateGet (void);
Notes:
Returns OS scheduling tick rate.
*/
/* Get the value of the kernel's tick counter */
#define OS_TICK_GET tickGet
/*
ULONG tickGet (void);
*/
/* Get the OS tick rate */
#define OS_TICK_RATE_GET() sysClkRateGet()
/*
int sysClkRateGet (void)
*/
/* auxilliary timer functions */
#define OS_AUX_TIMER_CONNECT(func, arg) sysAuxClkConnect(func, arg)
/*
STATUS sysAuxClkConnect (
FUNCPTR routine, - routine called at each aux. clock interrupt
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -