⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen_typs.h

📁 RAID卡的测试程序
💻 H
📖 第 1 页 / 共 2 页
字号:
	void SGTableInitialize(bpSGTABLE pSgTbl,U16 maxSgCount);
 */

#define SGTableInitialize(pSgTbl,maxSgCount) do {	\
	(pSgTbl)->SGCount = 0;							\
	(pSgTbl)->MaxSGCount = (maxSgCount);			\
	(pSgTbl)->SizeInByte = 0;						\
} while(0)

/**
	void SGTableStandardInitialize(bpSGTABLE pSgTbl);
 */
#define SGTableStandardInitialize(pSgTbl)	SGTableInitialize(pSgTbl,MAX_SG_ITEM_PER_TABLE)

void SGTableAppend(
	IN bpSGTABLE pTblSrc,
	IN OUT bpSGTABLE pTblDest,
	IN U32 offset,
	IN U32 countInByte
	);

BoOL SGTableAppendItem(
	bpSGTABLE	pSgTable,
	PTR_SIZE	StartAddress,
	U32			ByteLength,
	U8			CtrlFlags 
	);

/********************************************************************************/


/********************************************************************************/
/** following functions are defined for compatiblity for compilers that doesn't support
    64 bit operation. We should use this functions instead of direct 64 bit operation even
	if the compiler supports 64 bit operation to keep compatiblity. */
U64 U64_Add(U64 addend1, U64 addend2);
U64 U64_Add_U32(U64 addend1, U32 addend2);
U64 U64_Subtract(U64 Minuend, U64 Subtrahend);
U64 U64_Subtract_U32(U64 Minuend, U32 Subtrahend);
/* isaac add for PCM using */
#if defined(DT64BSUPPORTED)
_U64
u64_divide_u32(_U64 Dividend, U32 Divisor, U32* Remainder);
#endif

U64 U64_Divide(U64 Dividend, U64 Divisor, U64* Remainder);
U64 U64_Divide_U32(U64 Dividend, U32 Divisor, U32* Remainder);
U64 U64_Multiply_U32(U64 Multiplicand, U32 Multiplier);
U32 U64_2_U32(U64 value);
I32 U64_Compare(U64 value1, U64 value2);
U64 U64_Abs_Diff(U64 value1, U64 value2);
#define U64_Zerolize(value) do { value.Low = value.High = 0; } while(0)
#define U64_Maximize(value)	do { value.Low = value.High = U32_MAX; } while(0)
#define U64_AssignU32(value, U32Value) do { value.Low = (U32Value); value.High = 0; } while(0)
/********************************************************************************/


/********************************************************************************/
/** Common component interface definitions */
struct _MEMORY_REQUIREMENT;
typedef struct _MEMORY_REQUIREMENT MEMORY_REQUIREMENT, buf_space *bpMEMORY_REQUIREMENT;

struct _MEMORY_AVAILABLE;
typedef struct _MEMORY_AVAILABLE MEMORY_AVAILABLE, buf_space* bpMEMORY_AVAILABLE;

struct _MEMORY_REQUIREMENT
{
	U32 MinRequirement;
	U32 MaxRequirement;
};

struct _MEMORY_AVAILABLE
{
	bpVOID ComponentExtension;
	bpVOID DMASafeAddress;
	U32 DMASafeSize;
	U32 ComponentExtensionSize;
	PHYADDR DMASafePhysicalAddress;
};

/* return values of xxx_ComponentState */
#define COMP_STATE_UNINITIALIZED	0x00000000
#define COMP_STATE_INITIALIZED		0x00000001
#define COMP_STATE_STARTING			0x00000002
#define COMP_STATE_STOPPED			0x00000004
#define COMP_STATE_STARTED			0x00000005

/* bist flags for xxx_ComponentBist */
#define BIST_CONTROLLER_STOPPED		0x00000000

/** End of common component interface definitions */
/********************************************************************************/


/********************************************************************************/
/* miscellaneous definitions */
#if defined(_64BPLATFORM)
	#define ALSZ	8
#else
	#define ALSZ	4
#endif

#define ALIGN_ROUND(x, align)	( (((x)+(align)-1) / (align)) * (align) )
#define HOST_ALIGN_ROUND(x)		ALIGN_ROUND(x,ALSZ)
#define DIMM_ALIGN_ROUND(x)		ALIGN_ROUND(x,8)	/* always 8 byte alignment for DIMM */
#define ROUNDING(x,align)		(((x)+(align)-1)/(align))

#define OFFSET_OF(type,field)	((U32)(PTR_SIZE)&(((type *)0)->field))
#if defined(_OS_LINUX)
#define FIELD_OFFSET(type,field)	((U32)(PTR_SIZE)&(((type *)0)->field))
#endif

#if defined(_X8616B)
#define BASEATTR __based(__segname("_CODE")) 
#else
#define BASEATTR app_space
#endif

/** never force alignment unless absolutely necessary */
#if defined (_COMPILER_GCC_COMPATIBLE)
	#define PACKED __attribute__((packed))
#elif defined(_SHASTAFW)
	//#define PACKED __attribute__((aligned(1)))
	#define PACKED __attribute__((packed))
#else
	#define PACKED
#endif

#define bit(x)				(1 << x)
#define bits(x)				((1 << (x + 1)) - 1)

#define Max(x,y)			(((x) > (y)) ? (x) : (y))
#define Min(x,y)			(((x) < (y)) ? (x) : (y))

#define MAKEU32(hi,lo)		((((U32)(hi))<<16)|(lo))

#define CARRAY_DIM(x)		(sizeof(x)/sizeof((x)[0]))

#define TEST_FLAG(x,flag)	((x)&(flag))

#define IS_EVEN( a )		( ((a)&0x01)==0 )

#define GetPowerOf( a, v )			 \
	do								 \
	{								 \
		U16 temp = ( a );			 \
		( v ) = 0;					 \
		while( ((temp) >>= 1) != 0 ) \
		{							 \
			( v )++;				 \
		}							 \
	} while( 0 )

/*
//
// This structure is used to convert little endian
// ULONGs to SCSI CDB big endians values.
//
*/
typedef union _U64_BYTE {

    struct {
        U8 Byte0;
        U8 Byte1;
        U8 Byte2;
        U8 Byte3;
        U8 Byte4;
        U8 Byte5;
        U8 Byte6;
        U8 Byte7;
    } AsByte;
#if defined(DT64BSUPPORTED)
    _U64 AsULongLong;
#endif /* DT64BSUPPORTED */
} U64_BYTE, *PU64_BYTE;


typedef union _U32_BYTE {

    struct {
        U8 Byte0;
        U8 Byte1;
        U8 Byte2;
        U8 Byte3;
    } AsByte;

    U32 AsULong;
} U32_BYTE, *PU32_BYTE;

typedef union _U16_BYTE {

    struct {
        U8 Byte0;
        U8 Byte1;
    } AsByte;

    U16 AsUShort;
} U16_BYTE, *PU16_BYTE;

/*
//
// Byte reversing macro for converting
// between big- and little-endian formats
//
*/

#define REVERSE_BYTES_U64(Destination, Source) {			\
    PU64_BYTE d = (PU64_BYTE)(Destination);					\
    PU64_BYTE s = (PU64_BYTE)(Source);						\
    d->AsByte.Byte7 = s->AsByte.Byte0;                      \
    d->AsByte.Byte6 = s->AsByte.Byte1;                      \
    d->AsByte.Byte5 = s->AsByte.Byte2;                      \
    d->AsByte.Byte4 = s->AsByte.Byte3;                      \
    d->AsByte.Byte3 = s->AsByte.Byte4;                      \
    d->AsByte.Byte2 = s->AsByte.Byte5;                      \
    d->AsByte.Byte1 = s->AsByte.Byte6;                      \
    d->AsByte.Byte0 = s->AsByte.Byte7;                      \
}


#define REVERSE_BYTES_U32(Destination, Source) {            \
    PU32_BYTE d = (PU32_BYTE)(Destination);					\
    PU32_BYTE s = (PU32_BYTE)(Source);						\
    d->AsByte.Byte3 = s->AsByte.Byte0;                      \
    d->AsByte.Byte2 = s->AsByte.Byte1;                      \
    d->AsByte.Byte1 = s->AsByte.Byte2;                      \
    d->AsByte.Byte0 = s->AsByte.Byte3;                      \
}

#define REVERSE_BYTES_U16(Destination, Source) {            \
    PU16_BYTE d = (PU16_BYTE)(Destination);                 \
    PU16_BYTE s = (PU16_BYTE)(Source);                      \
    d->AsByte.Byte1 = s->AsByte.Byte0;                      \
    d->AsByte.Byte0 = s->AsByte.Byte1;                      \
}

/*
//
// Byte reversing macro for converting
// USHORTS from big to little endian in place
//
*/
#define REVERSE_U16(Short) {            \
    U8 tmp;								\
    PU16_BYTE w = (PU16_BYTE)(Short);   \
    tmp = w->AsByte.Byte0;              \
    w->AsByte.Byte0 = w->AsByte.Byte1;  \
    w->AsByte.Byte1 = tmp;              \
    }
/*
//
// Byte reversing macro for convering
// ULONGS between big & little endian in place
//
*/
#define REVERSE_U32(Long) {				\
    U8 tmp;								\
    PU32_BYTE l = (PU32_BYTE)(Long);	\
    tmp = l->AsByte.Byte3;              \
    l->AsByte.Byte3 = l->AsByte.Byte0;  \
    l->AsByte.Byte0 = tmp;              \
    tmp = l->AsByte.Byte2;              \
    l->AsByte.Byte2 = l->AsByte.Byte1;  \
    l->AsByte.Byte1 = tmp;              \
    }

#define ASSIGN_U32_UNALIGNED(p, v)	do {	\
	bpBUF psrc = (bpBUF)(v);				\
	bpBUF pdst = (bpBUF)(p);				\
	pdst[0] = psrc[0];						\
	pdst[1] = psrc[1];						\
	pdst[2] = psrc[2];						\
	pdst[3] = psrc[3];						\
} while(0)

#define ASSIGN_U16_UNALIGNED(p, v)	do {	\
	bpBUF psrc = (bpBUF)(v);				\
	bpBUF pdst = (bpBUF)(p);				\
	pdst[0] = psrc[0];						\
	pdst[1] = psrc[1];						\
} while(0)

#ifndef _X8616B
extern const U64 BASEATTR U64_ZERO;
#endif

#define U8_MAX		0xff
#define U16_MAX		0xffff
#define U32_MAX		0xffffffffL	/* L postfix is necessary for 16 bit compiler */
#define I32_MAX		0x7fffffffL

/* End of miscellaneous definitions */
/********************************************************************************/

/*
 * Export support for BIOS
 */
#define GEN_EXPORT		GEN_FAR

#if defined(USE_EXPORT)
#define GEN_CALLBACK	GEN_EXPORT
#else
#define GEN_CALLBACK
#endif

#define GEN_PCALLBACK	void GEN_EXPORT*

#if defined(USE_EXPORT)
#define EXP_API(funcName) EXP_##funcName
#else
#define EXP_API(funcName) funcName
#endif

#define DECLARE_EXP(funcName) GEN_EXPORT EXP_API(funcName)

#if defined(_X8616B)
#define PSEUDOBASE // __based(__segname("_CODE")) 
#else	/* _X8616B */
#define PSEUDOBASE app_space
#endif	/* _X8616B */

#define STATIC

#if defined(_X8616B)
/* macros to break C "far" pointers into their segment and offset components
 */

#define GEN_FP_SEG(fp) (*((U16 GEN_FAR *)&(fp)+1))
#define GEN_FP_OFF(fp) (*((U16 GEN_FAR *)&(fp)))

/* macro to construct a far pointer from segment and offset values
 */

#define GEN_MK_FP(seg, offset) (void GEN_FAR *)(((U32)seg << 16) \
    + (U32)(unsigned)offset)

#endif /* _X8616B */


#if defined(_X8616B) && defined(USE_EXPORT)

#define GEN_MK_CALLBACKF( pCallback, funcName ) {	\
	U16 off, curCS;					\
	U16 *p = (U16*) &pCallback;		\
	{								\
	__asm mov off , OFFSET funcName	\
	__asm mov curCS , cs			\
	}								\
	p[0] = off;						\
	p[1] = curCS;					\
}

#else

#define GEN_MK_CALLBACKF(pCallback, funcName)	pCallback = funcName

#endif

#if !defined(externC)
	#if defined(__cplusplus)
		#define externC extern "C"
	#else	/* __cplusplus */
		#define externC
	#endif
#endif	/* externC */

#if defined(_SHASTAFW)
#define VOLATILE volatile
#else
#define VOLATILE 
#endif

#endif /* GEN_DATA_TYPES_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -