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

📄 cardservice.c

📁 PXA270CF卡代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    }

    *pow = v;
    return (p);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodePower
*
* DESCRIPTION:
*    Decode a power field from a Card Information Structure (CIS) Configuration
*    Tuple. Refer to the PC Card Standard, Volume 4, Metaformat Specification
*    for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the power configuration entry
*    CIS_PowerT * powP - The return pointer to the power configuration
*
* RETURNS:
*    The pointer to the next power entry.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    decodePowerValue
*
* CALLED BY:
*    decodeCFTableEntry
*
* PROTOTYPE:
*    static
*    PUCHAR decodePower(PUCHAR p, CIS_PowerT * powP);
*
*******************************************************************************
*/
static
PUCHAR decodePower(PUCHAR p, CIS_PowerT * powP)
{
    INT mask = *p++;

    if (mask & (1 << 0))
    {
        powP->mask |= (1 << CIS_PowerNomVoltage);
        p = decodePowerValue(p, CIS_PowerVoltage, &powP->nomVoltage);
    }

    if (mask & (1 << 1))
    {
        powP->mask |= (1 << CIS_PowerMinVoltage);
        p = decodePowerValue(p, CIS_PowerVoltage, &powP->minVoltage);
    }

    if (mask & (1 << 2))
    {
        powP->mask |= (1 << CIS_PowerMaxVoltage);
        p = decodePowerValue(p, CIS_PowerVoltage, &powP->maxVoltage);
    }

    if (mask & (1 << 3))
    {
        powP->mask |= (1 << CIS_PowerStaticCurrent);
        p = decodePowerValue(p, CIS_PowerCurrent, &powP->staticCurrent);
    }

    if (mask & (1 << 4))
    {
        powP->mask |= (1 << CIS_PowerAverageCurrent);
        p = decodePowerValue(p, CIS_PowerCurrent, &powP->averageCurrent);
    }

    if (mask & (1 << 5))
    {
        powP->mask |= (1 << CIS_PowerPeakCurrent);
        p = decodePowerValue(p, CIS_PowerCurrent, &powP->peakCurrent);
    }

    if (mask & (1 << 6))
    {
        powP->mask |= (1 << CIS_PowerPdownCurrent);
        p = decodePowerValue(p, CIS_PowerCurrent, &powP->powerDownCurrent);
    }

    return (p);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodeTimingTuple
*
* DESCRIPTION:
*    Decode a timing value from a Card Information Structure (CIS) Configuration
*    Tuple. Refer to the PC Card Standard, Volume 4, Metaformat Specification
*    for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the timing value
*    CIS_TimingT * t - Pointer to the retuned timing entry
*    INT scaleX - The index into the timing conversion table
*
* RETURNS:
*    The pointer to the next timing value.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    None.
*
* CALLED BY:
*    decodeTiming
*
* PROTOTYPE:
*    static
*    PUCHAR decodeTimingValue(PUCHAR p, CIS_TimingT * t, INT scaleX)
*
*******************************************************************************
*/
static
PUCHAR decodeTimingValue(PUCHAR p, CIS_TimingT * t, INT scaleX)
{
    INT mult = timeMult[*p & 7];
    INT v = timeTab[(*p >> 3) & 15];

    t->time = (v * mult)/10; /* 1 ns units */
    t->scale = timeMult[scaleX];
    while (*p & (1 << 7)) /* Eat all extended speed bytes */
    {
        p++;
    }

    return (p + 1);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodeTiming
*
* DESCRIPTION:
*    Decode a timing field from a Card Information Structure (CIS) Configuration
*    Tuple. Refer to the PC Card Standard, Volume 4, Metaformat Specification
*    for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the timing configuration entry
*    CIS_ConfigT * cfgP - The return pointer to the timing configuration
*
* RETURNS:
*    The pointer to the next timing entry.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    decodeTimingValue
*
* CALLED BY:
*    decodeCFTableEntry
*
* PROTOTYPE:
*    static
*    PUCHAR decodeTiming(PUCHAR p, CIS_ConfigT * cfgP);
*
*******************************************************************************
*/
static
PUCHAR decodeTiming(PUCHAR p, CIS_ConfigT * cfgP)
{
    INT mask = p[0];

    p++;

    if ((mask & 3) != 3)
    {
        p = decodeTimingValue(p, &cfgP->waitTime, mask & 3);
    }

    if (((mask >> 2) & 7) != 7)
    {
        p = decodeTimingValue(p, &cfgP->busyTime, (mask >> 2) & 7);
    }

    if (((mask >> 5) & 7) != 7)
    {
        p = decodeTimingValue(p, &cfgP->initialTime, (mask >> 5) & 7);
    }

    return (p);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodeIO
*
* DESCRIPTION:
*    Decode an IO field from a Card Information Structure (CIS) Configuration
*    Tuple. Refer to the PC Card Standard, Volume 4, Metaformat Specification
*    for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the IO configuration entry
*    CIS_ConfigT * cfgP - The return pointer to the IO configuration
*
* RETURNS:
*    The pointer to the next IO entry.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    decodeAddrValue
*
* CALLED BY:
*    decodeCFTableEntry
*
* PROTOTYPE:
*    static
*    PUCHAR decodeIO(PUCHAR p, CIS_ConfigT * cfgP)
*
*******************************************************************************
*/
static
PUCHAR decodeIO(PUCHAR p, CIS_ConfigT * cfgP)
{
    INT ioAddrDec = p[0];
    INT ioAddrReq = p[1];
    INT addrSize = (ioAddrReq >> 4) & 3;
    INT lenSize = (ioAddrReq >> 6) & 3;
    INT i;

    p++;
    cfgP->numIoAddrBits = ioAddrDec & 31;
    cfgP->ioMode = (ioAddrDec >> 5) & 3;
    cfgP->numIoRange = ((ioAddrDec & (1 << 7)) ? (ioAddrReq & 15)+1 : 0);
    if (ioAddrDec & (1 << 7))
    {
        p++;
    }

    for (i=0; i < cfgP->numIoRange; i++)
    {
        p = decodeAddrValue(p, addrSize, &cfgP->ioRange[i].base);
        p = decodeAddrValue(p, lenSize, &cfgP->ioRange[i].length);
    }

    return (p);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodeIRQ
*
* DESCRIPTION:
*    Decode an interrupt field from a Card Information Structure (CIS)
*    Configuration Tuple. Refer to the PC Card Standard, Volume 4, Metaformat
*    Specification for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the interrupt configuration entry
*    CIS_ConfigT * cfgP - The return pointer to the interrupt configuration
*
* RETURNS:
*    The pointer to the next interrupt entry.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    None.
*
* CALLED BY:
*    decodeCFTableEntry
*
* PROTOTYPE:
*    static
*    PUCHAR decodeIRQ(PUCHAR p, CIS_ConfigT * cfgP);
*
*******************************************************************************
*/
static
PUCHAR decodeIRQ(PUCHAR p, CIS_ConfigT * cfgP)
{
    cfgP->irqPresent = 1;
    cfgP->irqShare = (p[0] >> 7) & 1;
    cfgP->irqPulse = (p[0] >> 6) & 1;
    cfgP->irqLevel = (p[0] >> 5) & 1;
    cfgP->irqValue = p[0] & 15;

    if (p[0] & (1 << 4))
    {
        cfgP->irqMask = p[1] | (p[2] << 8);
        p += 2;
    }

    return (p+1);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodeMemory
*
* DESCRIPTION:
*    Decode a memory field from a Card Information Structure (CIS) Configuration
*    Tuple. Refer to the PC Card Standard, Volume 4, Metaformat Specification
*    for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the memory configuration entry
*    CIS_ConfigT * cfgP - The return pointer to the memory configuration
*    INT mask
*
* RETURNS:
*    The pointer to the next memory entry.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    decodeAddrValue
*
* CALLED BY:
*    decodeCFTableEntry
*
* PROTOTYPE:
*    static
*    PUCHAR decodeMemory(PUCHAR p, CIS_ConfigT * cfgP, INT mask);
*
*******************************************************************************
*/
static
PUCHAR decodeMemory(PUCHAR p, CIS_ConfigT * cfgP, INT mask)
{
    INT addrSize;
    INT lenSize;
    INT hostAddrPresent;
    INT i;

    if (mask == 1)
    {
        addrSize = 0;
        lenSize = 2;
        hostAddrPresent = 0;
        cfgP->numMemRange = 1;
    }
    else if (mask == 2)
    {
        addrSize = 2;
        lenSize = 2;
        hostAddrPresent = 0;
        cfgP->numMemRange = 1;
    }
    else if (mask == 3)
    {
        addrSize = (*p >> 5) & 3;
        lenSize = (*p >> 3) & 3;
        hostAddrPresent = *p & (1 << 7);
        cfgP->numMemRange = (*p & 7) + 1;
        p++;
    }

    for (i=0; i < cfgP->numMemRange; i++)
    {
        if (lenSize)
        {
            p = decodeAddrValue(p, lenSize, &cfgP->memRange[i].length);
        }

        if (addrSize)
        {
            p = decodeAddrValue(p, addrSize, &cfgP->memRange[i].base);
        }

        if (hostAddrPresent && addrSize)
        {
            p = decodeAddrValue(p, addrSize, &cfgP->memRange[i].host);
        }
    }

    return (p);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodeMisc
*
* DESCRIPTION:
*    Decode a mics field from a Card Information Structure (CIS) Configuration
*    Tuple. Refer to the PC Card Standard, Volume 4, Metaformat Specification
*    for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the misc configuration entry
*    CIS_ConfigT * cfgP - The return pointer to the misc configuration
*
* RETURNS:
*    The pointer to the next entry.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    None.
*
* CALLED BY:
*    decodeCFTableEntry
*
* PROTOTYPE:
*    static
*    PUCHAR decodeMisc(PUCHAR p, CIS_ConfigT * cisP)
*
*******************************************************************************
*/
static
PUCHAR decodeMisc(PUCHAR p, CIS_ConfigT * cisP)
{
    return (p+1);
}

/*
*******************************************************************************
*
* FUNCTION:
*    decodeCFTableEntry
*
* DESCRIPTION:
*    Decode a Card Information Structure (CIS) Configuration Tuple. Refer to
*    the PC Card Standard, Volume 4, Metaformat Specification for details.
*
* INPUT PARAMETERS:
*    PUCHAR p - Pointer to the configuration entry
*    CIS_ConfigT * cfgP - The return pointer to the configuration
*
* RETURNS:
*    The pointer to the next entry.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    The pointer to the tuple is a valid virtual address.
*    The return pointer is a valid virtual address.
*
* CALLS:
*    decodePower, decodeTiming, decodeIO, decodeIRQ, decodeMemory, decodeMisc
*
* CALLED BY:
*    decodeTuple
*
* PROTOTYPE:
*    static
*    PUCHAR decodeCFTableEntry(PUCHAR p, CIS_ConfigT * cfgP);
*
*******************************************************************************
*/
static
PUCHAR decodeCFTableEntry(PUCHAR p, CIS_ConfigT * cfgP)
{
    INT len = p[1];
    PUCHAR endP = p+len+2;
    INT mask;

    // If this is not a default descriptor copy the defaults from the last one
    if (((p[2] & (1 << 6)) == 0) && defaultCfgP)
    {
        *cfgP = *defaultCfgP;
    }

    // Save the entry number and get the interface mask
    cfgP->isValid = 1;
    cfgP->entryNum = p[2] & 0x3f;
    cfgP->isDefault = ((p[2] & (1 << 6)) != 0);
    mask = p[2]; p += 3;

⌨️ 快捷键说明

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