예제 #1
0
    void NodeIdRangeTests::TestSubtract(NodeIdRange const & range, NodeIdRange const & exclude)
    {
        NodeIdRange range1, range2;
        range.Subtract(exclude, range1, range2);

        Trace.WriteInfo(TraceRangeTest, "Range {0} exclude {1} returned {2} and {3}",
            range, exclude, range1, range2);

        if (!range1.IsEmpty)
        {
            VERIFY_IS_TRUE(range.Contains(range1) && exclude.Disjoint(range1));
            if (!range2.IsEmpty)
            {
                VERIFY_IS_TRUE(range1.Disjoint(range2) && !range1.IsSuccAdjacent(range2) && !range1.IsPredAdjacent(range2));
            }
        }

        if (!range2.IsEmpty)
        {
            VERIFY_IS_TRUE((range2.IsEmpty || range.Contains(range2)) && exclude.Disjoint(range2));
        }

        VERIFY_IS_TRUE(GetRangeSize(range) == GetOverlapSize(range, exclude) + GetRangeSize(range1) + GetRangeSize(range2));
    }
예제 #2
0
    void NodeIdRangeTests::TestSubtractRanges(NodeIdRange const & range, vector<NodeIdRange> const & excludes)
    {
        vector<NodeIdRange> result;

        range.Subtract(excludes, result);
        Trace.WriteInfo(TraceRangeTest, "Range {0} exclude {1} returned {2}",
            range, excludes, result);

        LargeInteger overlapSize = LargeInteger::Zero;
        for (size_t i = 0; i < result.size(); i++)
        {
            VERIFY_IS_TRUE(!result[i].IsEmpty);
            VERIFY_IS_TRUE(range.Contains(result[i]));

            for (size_t j = 0; j < excludes.size(); j++)
            {
                VERIFY_IS_TRUE(result[i].Disjoint(excludes[j]));
            }

            overlapSize = overlapSize + GetOverlapSize(range, result[i]);
        }

        for (size_t i = 0; i + 1 < result.size(); i++)
        {
            for (size_t j = i + 1; j < result.size(); j++)
            {
                VERIFY_IS_TRUE(result[i].Disjoint(result[j]));
            }
        }

        for (size_t i = 0; i < excludes.size(); i++)
        {
            overlapSize = overlapSize + GetOverlapSize(range, excludes[i]);
        }

        VERIFY_IS_TRUE(GetRangeSize(range) == overlapSize);
    }
예제 #3
0
/* The following routine filles resource array of a physical device object. */
static VOID PciFillDevResources(DWORD dwConfigReg,__PHYSICAL_DEVICE* lpPhyDev)
{
	DWORD dwTmp = 0, dwOrg = 0;
	DWORD dwSize = 0;
	DWORD dwIndex = 0;
	DWORD dwLoop = 0;

	if ((0 == dwConfigReg) || (NULL == lpPhyDev))
	{
		return;
	}

	dwConfigReg &= 0xFFFFFF00;    //Clear the offset part.
	dwConfigReg += PCI_CONFIG_OFFSET_BASE1;  //Pointing to the first base address register.
	for(dwLoop = 0;dwLoop < 6;dwLoop ++)  //Read resources.
	{
		__outd(CONFIG_REGISTER,dwConfigReg);
		/* Read and save the original value. */
		dwOrg = __ind(DATA_REGISTER);
		__outd(DATA_REGISTER,0xFFFFFFFF);
		dwTmp = __ind(DATA_REGISTER);
		/* This base address register is not used. */
		if((0 == dwTmp) || (0xFFFFFFFF == dwTmp))
		{
			dwConfigReg += 4;
			/* Restore original value. */
			__outd(DATA_REGISTER,dwOrg);
			continue;
		}

		/* Restore original value. */
		__outd(DATA_REGISTER,dwOrg);
		if(dwOrg & 0x00000001)
		{
			/* IO Port range. */
			dwSize = GetRangeSize(dwTmp);
			dwOrg &= 0xFFFFFFFE;   //Clear the lowest bit.
			lpPhyDev->Resource[dwIndex].dwResType = RESOURCE_TYPE_IO;
			lpPhyDev->Resource[dwIndex].Dev_Res.IOPort.wStartPort = (WORD)dwOrg;
			lpPhyDev->Resource[dwIndex].Dev_Res.IOPort.wEndPort   = 
				(WORD)(dwOrg + dwSize - 1);
		}
		else
		{
			/* Memory map range. */
			dwOrg &= 0xFFFFFFF0;    //Clear the lowest 4 bits.
			dwSize = GetRangeSize(dwTmp);
			lpPhyDev->Resource[dwIndex].dwResType = RESOURCE_TYPE_MEMORY;
			lpPhyDev->Resource[dwIndex].Dev_Res.MemoryRegion.lpStartAddr = (LPVOID)dwOrg;
			lpPhyDev->Resource[dwIndex].Dev_Res.MemoryRegion.lpEndAddr   = 
				(LPVOID)(dwOrg + dwSize - 1);
		}
		dwIndex ++;
		dwConfigReg += 4;
	}

	/* Obtain interrupt vector information from configure space. */
	dwConfigReg &= 0xFFFFFF00;
	dwConfigReg += PCI_CONFIG_OFFSET_INTLINE;
	__outd(CONFIG_REGISTER,dwConfigReg);
	dwTmp = __ind(DATA_REGISTER);
	/* No interrupt vector is present. */
	if (0xFF == (UCHAR)dwTmp)
	{
		return;
	}
	lpPhyDev->Resource[dwIndex].dwResType = RESOURCE_TYPE_INTERRUPT;
	lpPhyDev->Resource[dwIndex].Dev_Res.ucVector  = (UCHAR)dwTmp;
	return;
}