📄 comdef.h
字号:
#ifndef COMDEF_H
#define COMDEF_H
/*===========================================================================
S T A N D A R D D E C L A R A T I O N S
DESCRIPTION
This header file contains general types and macros that are of use
to all modules. The values or definitions are dependent on the specified
target. T_WINNT specifies Windows NT based targets, otherwise the
default is for ARM targets.
T_WINNT Software is hosted on an NT platforn, triggers macro and
type definitions, unlike definition above which triggers
actual OS calls
DEFINED TYPES
Name Definition
------- --------------------------------------------------------
byte 8 bit unsigned value
word 16 bit unsigned value
dword 32 bit unsigned value
uint1 byte
uint2 word
uint4 dword
uint8 8 bit unsigned value
uint16 16 bit unsigned value
uint32 32 bit unsigned value
uint64 64 bit unsigned value
int8 8 bit signed value
int16 16 bit signed value
int32 32 bit signed value
int 64 64 bit signed value
sint31 32 bit signed value
sint15 16 bit signed value
sint7 8 bit signed value
int1 8 bit signed value
int2 16 bit signed value
int4 32 bit signed value
boolean 8 bit boolean value
DEFINED CONSTANTS
Name Definition
------- --------------------------------------------------------
TRUE Asserted boolean condition (Logical 1)
FALSE Deasserted boolean condition (Logical 0)
ON Asserted condition
OFF Deasserted condition
NULL Pointer to nothing
PACKED Used to indicate structures which should use packed
alignment
INLINE Used to inline functions for compilers which support this
Copyright (c) 1990,1992 by QUALCOMM, Incorporated. All Rights Reserved.
Copyright (c) 1993,1994 by QUALCOMM, Incorporated. All Rights Reserved.
Copyright (c) 1997,1998 by QUALCOMM, Incorporated. All Rights Reserved.
Copyright (c) 1999 by QUALCOMM, Incorporated. All Rights Reserved.
===========================================================================*/
/*===========================================================================
EDIT HISTORY FOR FILE
This section contains comments describing changes made to this file.
Notice that changes are listed in reverse chronological order.
$PVCSPath: O:/src/asw/COMMON/vcs/comdef.h_v 1.5 26 Sep 2001 16:04:10 rajeevg $
$Header: //depot/asic/msmshared/services/common/comdef.h#6 $ $DateTime: 2001/09/26 16:04:10 $ $Author: rajeevg $
when who what, where, why
-------- --- ----------------------------------------------------------
06/11/01 gr Added MOD_BY_POWER_OF_TWO macro.
04/12/01 sq Added inpdw and outpdw macros
vas Added solaris support
04/06/01 gr Removed the definitions of abs and labs.
01/25/01 day Merged from MSM5105_COMMON.00.00.05.
Added include for stdlib.h within WINNT ifdef
Added support for ARM_ASM
Added support SWIG preprocessor.
09/09/99 tac Merged in a bunch of panther changes.
08/11/99 jct Corrected conditional compilation around labs to check for
labs instead of abs
06/30/99 jct Added PC_EMULATOR capability for INTLOCK and INTLOCKSAV
06/15/99 jct Cleanup to make work in Windows NT environment. Addition
of int(n) types where n is 8,16,32,64 and addition of
unit64. Removal of OS comments and defines as this is replaced
by T_WINNT. Conditional inclusion of MAX, MIN, labs, abs,
NULL definitions. Removal of volatile from packed definition
stdlib.h included for Win32 based targets since this replaces several
of the define here. Changed out uts calls to be comet calls.
Added a defines for Windows NT targets to define away symbols
no longer supported
04/09/99 ms Lint cleanup.
04/01/99 ms Lint cleanup.
02/17/99 ms Parenthesized abs and labs.
Defined __packed to volatile to exploit lint.
12/16/98 jct Removed 80186 support
12/01/98 ms Removed definition of bsp_io_base.
11/20/98 ms Typecast to volatile pointers in inp,outp,inpw and outpw.
10/10/98 jct Honing of OS and T_ definitions, added T_WINNT as a target
which triggers something different then which OS since
we may be running REX on an NT platform, but strictly
speaking, the application software is using REX, not NT
as the OS. Changed ROM for WINNT/ARM targets to be nothing
instead of const
09/09/98 jct Updates to merge ARM support with 186 support, added some
new type aliases, added some segmented architecture macros,
updated comments, removed unused code, updated declaration
of inp/outp to have cdecl
08/01/98 jct Updates to support ARM processor
03/25/96 jah Moved SET_VECT to 80186.h
02/06/96 fkm Put ()s around Macros to Make Lint Happy
01/12/95 jah Updated dependency in MACRO INTLOCK_SAV / INTFREE_SAV.
12/20/94 jah Corrected typo in ARR_SIZE() macro comments
03/11/94 jah Added #ifdef _lint of NULL as 0 for near/far lint problem.
06/11/93 jah Changed FPOS() to cast the pointer to 'near' to avoid the
compiler complaints about lost segments.
01/28/93 twp Added ARR_SIZE macro to return number of array elements.
07/17/92 jah Changed int1 from 'char' to 'signed char'
06/10/92 jah Added WORD_LO/HI, INC_SAT
05/19/92 jah Added header comments for macros & made them lint-friendly
05/04/92 jah Added define for ROM
03/02/92 jah Added in/outp prototypes, INT* Macro comments w/lint
02/20/92 arh Added LOCAL macro and ifdef/endif around file
===========================================================================*/
/*===========================================================================
Data Declarations
===========================================================================*/
/* -----------------------------------------------------------------------
** We include target.h to get FEATURE definitions used for macro defines.
** Note we only include this if TG is defined and target.h has not been
** previously included. This allows comdef.h to be reused outside the
** scope of the target/customer featurization paradigm
** ----------------------------------------------------------------------- */
//#ifdef TG
// #include "target.h"
//#endif
/* For NT apps we want to use the Win32 definitions and/or those
** supplied by the Win32 compiler for things like NULL, MAX, MIN
** abs, labs, etc.
*/
//#ifdef T_WINNT
// #ifndef WIN32
// #define WIN32
// #endif
// #include <stdlib.h>
//#endif
/* ------------------------------------------------------------------------
** Constants
** ------------------------------------------------------------------------ */
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
#define TRUE 1 /* Boolean true value. */
#define FALSE 0 /* Boolean false value. */
#define ON 1 /* On value. */
#define OFF 0 /* Off value. */
#ifdef _lint
#define NULL 0
#endif
#ifndef NULL
#define NULL 0
#endif
/* -----------------------------------------------------------------------
** Standard Types
** ----------------------------------------------------------------------- */
/* The following definitions are the same accross platforms. This first
** group are the sanctioned types.
*/
#ifndef _ARM_ASM_
typedef unsigned char boolean; /* Boolean value type. */
typedef unsigned long int uint32; /* Unsigned 32 bit value */
typedef unsigned short uint16; /* Unsigned 16 bit value */
typedef unsigned char uint8; /* Unsigned 8 bit value */
typedef signed long int int32; /* Signed 32 bit value */
typedef signed short int16; /* Signed 16 bit value */
typedef signed char int8; /* Signed 8 bit value */
/* This group are the deprecated types. Their use should be
** discontinued and new code should use the types above
*/
typedef unsigned char byte; /* Unsigned 8 bit value type. */
typedef unsigned short word; /* Unsinged 16 bit value type. */
typedef unsigned long dword; /* Unsigned 32 bit value type. */
typedef unsigned char uint1; /* Unsigned 8 bit value type. */
typedef unsigned short uint2; /* Unsigned 16 bit value type. */
typedef unsigned long uint4; /* Unsigned 32 bit value type. */
typedef signed char int1; /* Signed 8 bit value type. */
typedef signed short int2; /* Signed 16 bit value type. */
typedef long int int4; /* Signed 32 bit value type. */
typedef signed long sint31; /* Signed 32 bit value */
typedef signed short sint15; /* Signed 16 bit value */
typedef signed char sint7; /* Signed 8 bit value */
/* ---------------------------------------------------------------------
** Compiler Keyword Macros
** --------------------------------------------------------------------- */
#if (! defined T_WINNT) && (! defined TARGET_OS_SOLARIS)
#ifndef SWIG /* The SWIG preprocessor gets confused by these */
/* Non WinNT Targets
*/
typedef signed long long int64; /* Signed 64 bit value */
typedef unsigned long long uint64; /* Unsigned 64 bit value */
#define PACKED __packed
#define INLINE __inline
#define CDECL
#endif /* SWIG */
#define far
#define near
#define _far
#define _near
#define _cdecl
#define cdecl
#define _pascal
#define _interrupt
#else /* T_WINNT || TARGET_OS_SOLARIS */
#error code not present
#endif /* T_WINNT */
#endif // #ifndef _ARM_ASM_
/* ----------------------------------------------------------------------
** Lint does not understand __packed, so we define it away here. In the
** past we did this:
** This helps us catch non-packed pointers accessing packed structures,
** for example, (although lint thinks it is catching non-volatile pointers
** accessing volatile structures).
** This does assume that volatile is not being used with __packed anywhere
** because that would make Lint see volatile volatile (grrr).
** but found it to be more trouble than it was worth as it would emit bogus
** errors
** ---------------------------------------------------------------------- */
#ifdef _lint
#define __packed
#endif
/* ----------------------------------------------------------------------
** STANDARD MACROS
** ---------------------------------------------------------------------- */
#ifndef SWIG /* these confuse the SWIG preprocessor and aren't needed for it */
/*===========================================================================
MACRO MEM_B
MACRO MEM_W
DESCRIPTION
Take an address and dereference it as a byte/word, allowing access to an
arbitrary memory byte/word.
PARAMETERS
x address to be dereferenced
DEPENDENCIES
None
RETURN VALUE
MEM_B byte at the given address
MEM_W word at the given address
SIDE EFFECTS
None
===========================================================================*/
#define MEM_B( x ) ( *( (byte *) (x) ) )
#define MEM_W( x ) ( *( (word *) (x) ) )
/*===========================================================================
MACRO MAX
MACRO MIN
DESCRIPTION
Evaluate the maximum/minimum of 2 specified arguments.
PARAMETERS
x parameter to compare to 'y'
y parameter to compare to 'x'
DEPENDENCIES
'x' and 'y' are referenced multiple times, and should remain the same
value each time they are evaluated.
RETURN VALUE
MAX greater of 'x' and 'y'
MIN lesser of 'x' and 'y'
SIDE EFFECTS
None
===========================================================================*/
#ifndef MAX
#define MAX( x, y ) ( ((x) > (y)) ? (x) : (y) )
#endif
#ifndef MIN
#define MIN( x, y ) ( ((x) < (y)) ? (x) : (y) )
#endif
/*===========================================================================
MACRO FPOS
DESCRIPTION
This macro computes the offset, in bytes, of a specified field
of a specified structure or union type.
PARAMETERS
type type of the structure or union
field field in the structure or union to get the offset of
DEPENDENCIES
None
RETURN VALUE
The byte offset of the 'field' in the structure or union of type 'type'.
SIDE EFFECTS
The lint error "Warning 545: Suspicious use of &" is suppressed within
this macro. This is due to the desire to have lint not complain when
'field' is an array.
===========================================================================*/
#define FPOS( type, field ) \
/*lint -e545 */ ( (dword) &(( type *) 0)-> field ) /*lint +e545 */
/*===========================================================================
MACRO FSIZ
DESCRIPTION
This macro computes the size, in bytes, of a specified field
of a specified structure or union type.
PARAMETERS
type type of the structure or union
field field in the structure or union to get the size of
DEPENDENCIES
None
RETURN VALUE
size in bytes of the 'field' in a structure or union of type 'type'
SIDE EFFECTS
None
===========================================================================*/
#define FSIZ( type, field ) sizeof( ((type *) 0)->field )
/*===========================================================================
MACRO FLIPW
DESCRIPTION
Takes a 2 byte array, with the most significant byte first, followed
by the least significant byte, and converts the quantity into a word
with Intel byte order (LSB first)
PARAMETERS
ray array of 2 bytes to be converted to a word
DEPENDENCIES
None
RETURN VALUE
word in Intel byte order comprised of the 2 bytes of ray.
SIDE EFFECTS
None
===========================================================================*/
#define FLIPW( ray ) ( (((word) (ray)[0]) * 256) + (ray)[1] )
/*===========================================================================
MACRO FLOPW
DESCRIPTION
Reverses bytes of word value and writes them to a 2 byte array.
Effectively the reverse of the FLIPW macro.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -