?? hal_indirect16.c
字號:
{
UInt16 loword, hiword;
halSetProcessExclusivity( TRUE );
SetDisplayAddrSerial(addr);
*HalIndInfo.pIndex8 = SER_READ;
if (HalInfo.dwFlags & fINDIRECT_DATA16)
{
loword = *HalIndInfo.pData16;
hiword = *HalIndInfo.pData16;
}
else
{
loword = *HalIndInfo.pData8;
loword |= (UInt16)((*HalIndInfo.pData8)<<8);
hiword = *HalIndInfo.pData8;
hiword |= (UInt16)((*HalIndInfo.pData8)<<8);
}
halSetProcessExclusivity( FALSE );
return MAKELONG(loword, hiword);
}
//---------------------------------------------------------------------------
// INDIRECT FUNCTION: halpSerReadData()
// WARNING: DO NOT USE ODD ADDRESSES FOR 16-bit or 32bit ACCESSES!
//---------------------------------------------------------------------------
void halpSerReadData( int Size, UInt32 Offset, void* pData, UInt32 Count )
{
if ( Count && pData )
{
halSetProcessExclusivity( TRUE );
if ( Size == sizeof(UInt8) )
{
pUInt8 pWrite = pData;
SetDisplayAddrSerial( Offset );
*HalIndInfo.pIndex8 = SER_READ;
do
{
*pWrite++ = *HalIndInfo.pData8;
} while ( --Count );
}
else if ( Size == sizeof(UInt16) )
{
pUInt16 pWrite = pData;
UInt16 wVal;
SetDisplayAddrSerial( Offset );
*HalIndInfo.pIndex8 = SER_READ;
if (HalInfo.dwFlags & fINDIRECT_DATA16)
{
do
{
*pWrite++ = *HalIndInfo.pData16;
} while ( --Count );
} else
{
do
{
wVal = *HalIndInfo.pData8;
wVal |= (UInt16)((*HalIndInfo.pData8)<<8);
*pWrite++ = wVal;
} while ( --Count );
}
}
else if ( Size == sizeof(UInt32) )
{
UInt16 loword, hiword;
pUInt32 pWrite = pData;
SetDisplayAddrSerial( Offset );
*HalIndInfo.pIndex8 = SER_READ;
if (HalInfo.dwFlags & fINDIRECT_DATA16)
{
do
{
loword = *HalIndInfo.pData16;
hiword = *HalIndInfo.pData16;
*pWrite++ = MAKELONG(loword,hiword);
} while ( --Count );
} else
{
do
{
loword = *HalIndInfo.pData8;
loword |= (UInt16)((*HalIndInfo.pData8)<<8);
hiword = *HalIndInfo.pData8;
hiword |= (UInt16)((*HalIndInfo.pData8)<<8);
*pWrite++ = MAKELONG(loword,hiword);
} while ( --Count );
}
}
halSetProcessExclusivity( FALSE );
}
}
//---------------------------------------------------------------------------
// INDIRECT FUNCTION: halpParReadData()
// WARNING: DO NOT USE ODD ADDRESSES FOR 16-bit or 32bit ACCESSES!
//---------------------------------------------------------------------------
void halpParReadData( int Size, UInt32 Offset, void* pData, UInt32 Count )
{
if ( Count && pData )
{
halSetProcessExclusivity( TRUE );
if ( Size == sizeof(UInt8) )
{
pUInt8 pWrite = pData;
SetDisplayAddrParallel( Offset );
do
{
*pWrite++ = *HalIndInfo.pData8;
} while ( --Count );
}
else if ( Size == sizeof(UInt16) )
{
pUInt16 pWrite = pData;
SetDisplayAddrParallel( Offset );
do
{
tmp = *HalIndInfo.pData16;
//*pWrite++ = *HalIndInfo.pData16;
*pWrite++ = tmp;
} while ( --Count );
}
else if ( Size == sizeof(UInt32) )
{
UInt16 loword, hiword;
pUInt32 pWrite = pData;
SetDisplayAddrParallel( Offset );
do
{
loword = *HalIndInfo.pData16;
hiword = *HalIndInfo.pData16;
*pWrite++ = MAKELONG(loword,hiword);
} while ( --Count );
}
halSetProcessExclusivity( FALSE );
}
}
//---------------------------------------------------------------------------
// INDIRECT FUNCTION: halpSerWriteData()
// WARNING: DO NOT USE ODD ADDRESSES FOR 16-bit or 32bit ACCESSES!
//---------------------------------------------------------------------------
void halpSerWriteData( int Size, UInt32 Offset, const void* pData, UInt32 Count )
{
if ( Count && pData )
{
halSetProcessExclusivity( TRUE );
if ( Size == sizeof(UInt8) )
{
const UInt8* pRead = pData;
SetDisplayAddrSerial( Offset );
*HalIndInfo.pIndex8 = SER_WRITE;
do
{
*HalIndInfo.pData8 = *pRead++;
} while ( --Count );
}
else if ( Size == sizeof(UInt16) )
{
const UInt16* pRead = pData;
SetDisplayAddrSerial( Offset );
*HalIndInfo.pIndex8 = SER_WRITE;
if (HalInfo.dwFlags & fINDIRECT_DATA16)
{
do
{
*HalIndInfo.pData16 = LOWORD(*pRead);
pRead++;
} while ( --Count );
} else
{
UInt16 wVal;
do
{
wVal = LOWORD(*pRead);
*HalIndInfo.pData8 = LOBYTE(wVal);
*HalIndInfo.pData8 = HIBYTE(wVal);
pRead++;
} while ( --Count );
}
}
else if ( Size == sizeof(UInt32) )
{
const UInt32* pRead = pData;
SetDisplayAddrSerial( Offset );
*HalIndInfo.pIndex8 = SER_WRITE;
if (HalInfo.dwFlags & fINDIRECT_DATA16)
{
do
{
*HalIndInfo.pData16 = LOWORD(*pRead);
*HalIndInfo.pData16 = HIWORD(*pRead);
pRead++;
} while ( --Count );
} else
{
UInt32 dwVal;
UInt16 wVal;
do
{
dwVal = *pRead++;
wVal = LOWORD(dwVal);
*HalIndInfo.pData8 = LOBYTE(wVal);
*HalIndInfo.pData8 = HIBYTE(wVal);
wVal = HIWORD(dwVal);
*HalIndInfo.pData8 = LOBYTE(wVal);
*HalIndInfo.pData8 = HIBYTE(wVal);
} while ( --Count );
}
}
halSetProcessExclusivity( FALSE );
}
}
//---------------------------------------------------------------------------
// INDIRECT FUNCTION: halpParWriteData()
// WARNING: DO NOT USE ODD ADDRESSES FOR 16-bit or 32bit ACCESSES!
//---------------------------------------------------------------------------
void halpParWriteData( int Size, UInt32 Offset, const void* pData, UInt32 Count )
{
if ( Count && pData )
{
halSetProcessExclusivity( TRUE );
if ( Size == sizeof(UInt8) )
{
const UInt8* pRead = pData;
SetDisplayAddrParallel( Offset );
do
{
*HalIndInfo.pData8 = *pRead++;
} while ( --Count );
}
else if ( Size == sizeof(UInt16) )
{
const UInt16* pRead = pData;
SetDisplayAddrParallel( Offset );
do
{
//*HalIndInfo.pData16 = *pRead;
//*HalIndInfo.pData16 = *( volatile unsigned short *)0x200c000;
tmp =*pRead;
*HalIndInfo.pData16 = tmp;
pRead++;
} while ( --Count );
/*
SetDisplayAddrParallel( Offset );
do
{
if (HalInfo.dwFlags & fINDIRECT_DATA16)
*HalIndInfo.pData16 = *pRead;
else
{
*HalIndInfo.pData8 = HIBYTE(*pRead);
*HalIndInfo.pData8 = LOBYTE(*pRead);
//*HalIndInfo.pData8 = HIBYTE(0xFFFF);
//*HalIndInfo.pData8 = LOBYTE(0xFFFF);
//pRead++;
}
} while ( --Count );
*/
}
else if ( Size == sizeof(UInt32) )
{
const UInt32* pRead = pData;
SetDisplayAddrParallel( Offset );
do
{
*HalIndInfo.pData16 = LOWORD(*pRead);
*HalIndInfo.pData16 = HIWORD(*pRead);
pRead++;
} while ( --Count );
}
halSetProcessExclusivity( FALSE );
}
}
//---------------------------------------------------------------------------
// FUNCTION: IndirectSetDisplayAddr()
//
// DESCRIPTION:
// This routine sets the Host Interface Address registers to the address
// specified by addr. For the Serial Interface, this routine also sets
// the interface to read or write.
//
// PARAMETERS:
// addr - a thirty-two bit value containing the offset to the desired
// memory addrsss.
// SerialDir - for serial indirect I/O, set SerialDir to
// either SER_WRITE or SER_READ.
// For parallel indirect I/O, this parameter is ignored.
//---------------------------------------------------------------------------
void IndirectSetDisplayAddr( UInt32 addr, UInt8 SerialDir )
{
halSetProcessExclusivity( TRUE );
if (HalInfo.dwFlags & fINDIRECT_SERIAL)
{
SetDisplayAddrSerial(addr);
if (HalInfo.dwFlags & fINDIRECT_ADDR16)
*HalIndInfo.pIndex16 = SerialDir;
else
*HalIndInfo.pIndex8 = SerialDir;
}
else
SetDisplayAddrParallel(addr);
halSetProcessExclusivity( FALSE );
}
//---------------------------------------------------------------------------
// FUNCTION: SetSerialAddrParallel()
//
// DESCRIPTION:
// This routine sets the Host Interface Address registers to the address
// specified by addr.
//
// Because we don't know the last register to be accessed we must write
// the full address every time.
//
// This function MUST be called within a process exclusive block!
//
// PARAMETERS:
// addr - a thirty-two bit value containing the offset to the desired
// memory addrsss.
//---------------------------------------------------------------------------
static void SetDisplayAddrParallel( UInt32 addr )
{
// Setup the address
if (HalInfo.dwFlags & fINDIRECT_ADDR16)
{
*HalIndInfo.pIndex16 = 0x0020;
*HalIndInfo.pData8 = LOBYTE(LOWORD(addr));
*HalIndInfo.pIndex16 = 0x0021;
*HalIndInfo.pData8 = HIBYTE(LOWORD(addr));
*HalIndInfo.pIndex16 = 0x0022;
*HalIndInfo.pData8 = LOBYTE(HIWORD(addr));
*HalIndInfo.pIndex16 = 0x28;
}
else
{
*HalIndInfo.pIndex8 = 0x20;
*HalIndInfo.pIndex8 = 0x00;
*HalIndInfo.pData8 = LOBYTE(LOWORD(addr));
*HalIndInfo.pIndex8 = 0x21;
*HalIndInfo.pData8 = HIBYTE(LOWORD(addr));
*HalIndInfo.pIndex8 = 0x22;
*HalIndInfo.pData8 = LOBYTE(HIWORD(addr));
*HalIndInfo.pIndex8 = 0x28;
}
}
//---------------------------------------------------------------------------
// FUNCTION: SetDisplayAddrSerial()
//
// DESCRIPTION:
// This routine sets the Host Interface Address registers to the address
// specified by addr. After setting the address the routine points the
// 'register pointer' to the Host Interface Memory Access Port.
//
// Because we don't know the last register to be accessed we must write
// the full address every time.
//
// This function MUST be called within a process exclusive block!
//
// PARAMETERS:
// addrs - a thirty-two bit value containing the offset to the desired
// memory addrsss.
//---------------------------------------------------------------------------
static void SetDisplayAddrSerial( UInt32 addr )
{
// Setup the register address of the Host Interface Memory Address register
if (HalInfo.dwFlags & fINDIRECT_ADDR16)
{
*HalIndInfo.pIndex16 = SER_SET_ADDR;
*HalIndInfo.pData16 = 0x2000;
// Set the LSB of 'addr'
*HalIndInfo.pIndex16 = SER_WRITE;
*HalIndInfo.pData8 = LOBYTE(LOWORD(addr));
// Point to the next Host Interface Memory Address register
*HalIndInfo.pIndex16 = SER_SET_ADDR;
*HalIndInfo.pData8 = 0x21;
// Set the next byte of 'addr'
*HalIndInfo.pIndex16 = SER_WRITE;
*HalIndInfo.pData8 = HIBYTE(LOWORD(addr));
// Point to the last Host Interface Memory Address register
*HalIndInfo.pIndex16 = SER_SET_ADDR;
*HalIndInfo.pData8 = 0x22;
// Set the MSB byte of 'addr'
*HalIndInfo.pIndex16 = SER_WRITE;
*HalIndInfo.pData8 = LOBYTE(HIWORD(addr));
// Point to the Host Interface Memory Access Port
*HalIndInfo.pIndex16 = SER_SET_ADDR;
*HalIndInfo.pData8 = 0x28;
}
else
{
*HalIndInfo.pIndex8 = SER_SET_ADDR;
*HalIndInfo.pData8 = 0x20; // REG0020_HOSTMEMADDR0
*HalIndInfo.pData8 = 0x00; // MSB of 0x0020 = 0x00
// Set the LSB of 'addr'
*HalIndInfo.pIndex8 = SER_WRITE;
*HalIndInfo.pData8 = LOBYTE(LOWORD(addr));
// Point to the next Host Interface Memory Address register
*HalIndInfo.pIndex8 = SER_SET_ADDR;
*HalIndInfo.pData8 = 0x21;
// Set the next byte of 'addr'
*HalIndInfo.pIndex8 = SER_WRITE;
*HalIndInfo.pData8 = HIBYTE(LOWORD(addr));
// Point to the last Host Interface Memory Address register
*HalIndInfo.pIndex8 = SER_SET_ADDR;
*HalIndInfo.pData8 = 0x22;
// Set the MSB byte of 'addr'
*HalIndInfo.pIndex8 = SER_WRITE;
*HalIndInfo.pData8 = LOBYTE(HIWORD(addr));
// Point to the Host Interface Memory Access Port
*HalIndInfo.pIndex8 = SER_SET_ADDR;
*HalIndInfo.pData8 = 0x28;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -