📄 ioport.cpp
字号:
/*
* $Workfile: IOPORT.CPP $
* $Revision: 3 $
* $Date: 4/07/00 8:50a $
* $Modtime: 4/07/00 8:37a $
* $Author: Sarma $
*
* Copyright (c) 1998 National Semiconductor Corporation.
* All Rights Reserved.
*
* This software is the confidential and proprietary information of National
* Semiconductor Corporation. ("Confidential Information").
* You shall not disclose such Confidential Information and shall use it only
* in accordance with the terms of the license agreement you entered into
* with National Semiconductor Corporation.
* This code is supplied as is.
*
*/
/*
*$Log: /CE/Platform/Nsc/Drivers/Video/gxvideo/base/IOPORT.CPP $
*
* 3 4/07/00 8:50a Sarma
* Removed Cyrix Corporation from the legal/confidentail information.
*
* 2 11/12/98 3:14p Sarma
* Added Confidential copyright to files with VSS keywords for
* log/history.
*$History: IOPORT.CPP $
*
* ***************** Version 3 *****************
* User: Sarma Date: 4/07/00 Time: 8:50a
* Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
* Removed Cyrix Corporation from the legal/confidentail information.
*
* ***************** Version 2 *****************
* User: Sarma Date: 11/12/98 Time: 3:14p
* Updated in $/wince/v2.1/gxvideo
* Added Confidential copyright to files with VSS keywords for
* log/history.
*/
#include "precomp.h"
void Port::Map( unsigned short port, PortRange *&pFirstRange )
{
DEBUGMSG(GPE_ZONE_INIT,(TEXT("Mapping port @ 0x%08x to port 0x%04x\r\n"),this,port));
PortRange **ppRange = &pFirstRange;
PortRange *pRange;
while( pRange = *ppRange ) // deliberate assignment
{
if( port >= pRange->m_nFirstPortNo
&& port < pRange->m_nFirstPortNo + PORT_RANGE_SIZE )
break;
ppRange = &(pRange->m_pNextRange);
}
if( !pRange )
{
// Need to create a new range of mapped in ports
DEBUGMSG(GPE_ZONE_INIT,(TEXT("Creating new port range\r\n")));
pRange = *ppRange = new PortRange;
if( !pRange )
{
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("New: failed to create new PortRange\r\n")));
return;
}
pRange->m_nFirstPortNo = port - ( port % PORT_RANGE_SIZE );
pRange->m_pNextRange = (PortRange *)NULL;
PHYSICAL_ADDRESS ioPhysicalBase = { pRange->m_nFirstPortNo, 0 };
ULONG inIoSpace = 1;
if (HalTranslateBusAddress(Isa, 0, ioPhysicalBase, &inIoSpace,
&ioPhysicalBase))
{
if (!inIoSpace)
{
DEBUGMSG(GPE_ZONE_INIT,(TEXT("New port range is not in iospace\r\n")));
if ((pRange->m_nPortBase = (PUCHAR)MmMapIoSpace(ioPhysicalBase,
PORT_RANGE_SIZE, FALSE)) == NULL)
{
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("failed to map new port range\r\n")));
return;
}
}
else
{
DEBUGMSG(GPE_ZONE_INIT,(TEXT("New port range is in iospace\r\n")));
pRange->m_nPortBase = (PUCHAR)ioPhysicalBase.LowPart;
}
}
else
{
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("failed to determine bus address for port\r\n")));
return;
}
}
m_pPort = pRange->m_nPortBase + ( port % PORT_RANGE_SIZE );
DEBUGMSG(GPE_ZONE_INIT,(TEXT("m_pPort = 0x%08x\r\n"), m_pPort));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -