📄 cardservice.c
字号:
switch (funcId)
{
case CIS_FunctionMulti: return ("Multi");
case CIS_FunctionMemory: return ("Memory");
case CIS_FunctionSerial: return ("Serial");
case CIS_FunctionParallel: return ("Parallel");
case CIS_FunctionFixedDisk: return ("Disk");
case CIS_FunctionVideo: return ("Video");
case CIS_FunctionNetwork: return ("Network");
case CIS_FunctionAIMS: return ("AIMS");
}
return ("???");
}
/*
*******************************************************************************
*
* FUNCTION:
* displayCISInfo
*
* DESCRIPTION:
* Display the Card Information Structure
*
* INPUT PARAMETERS:
* CIS_EntryT * cisP - Pointer to the CIS entry
*
* RETURNS:
* None.
*
* GLOBAL EFFECTS:
* None.
*
* ASSUMPTIONS:
* None.
*
* CALLS:
* decodeFuncID, printf
*
* CALLED BY:
* CardServices_DisplayCIS
*
* PROTOTYPE:
* static
* VOID displayCISInfo(CIS_EntryT * cisP);
*
*******************************************************************************
*/
static
VOID displayCISInfo(CIS_EntryT * cisP)
{
INT i,j;
if (cisP->manName)
{
printf("%s\r\n", cisP->manName);
}
if (cisP->prodName)
{
printf("%s\r\n", cisP->prodName);
}
if (cisP->prodVersion)
{
printf("%s\r\n", cisP->prodVersion);
}
if (cisP->prodLot)
{
printf("%s\r\n", cisP->prodLot);
}
printf("Config base %08X\r\n", cisP->radrBase);
printf("Function type %s\r\n", decodeFuncId(cisP->funcType));
printf("\r\nVoltage\tIO Range\tMemory Range\tIRQ Settings\r\n");
for (i=0; i < cisP->configCount; i++)
{
printf("%d.%02dV\t%d:%04X/%02d\t%d:%04X/%02d\t%d:%04X/%02d\r\n",
cisP->config[i].vcc.nomVoltage / 1000000,
(cisP->config[i].vcc.nomVoltage % 1000000) / 10000,
cisP->config[i].numIoRange,
cisP->config[i].ioRange[0].base,
cisP->config[i].ioRange[0].length+1,
cisP->config[i].numMemRange,
cisP->config[i].memRange[0].base,
cisP->config[i].numMemRange ?
cisP->config[i].memRange[0].length+1 : 0,
cisP->config[i].irqLevel,
cisP->config[i].irqMask,
cisP->config[i].irqValue);
for (j=1; (j < cisP->config[i].numIoRange) ||
(j < cisP->config[i].numMemRange); j++)
{
printf("\t%d:%04X/%02d\t%d:%04X/%02d\r\n",
cisP->config[i].numIoRange-j >=0 ?
cisP->config[i].numIoRange-j : 0,
cisP->config[i].numIoRange-j >=0 ?
cisP->config[i].ioRange[j].base : 0,
cisP->config[i].numIoRange-j >=0 ?
cisP->config[i].ioRange[j].length+1 : 0,
cisP->config[i].numMemRange-j >= 0 ?
cisP->config[i].numMemRange-j : 0,
cisP->config[i].numMemRange-j >= 0 ?
cisP->config[i].memRange[j].base : 0,
cisP->config[i].numMemRange ?
cisP->config[i].memRange[j].length+1 : 0);
}
}
}
/*
*******************************************************************************
*
* FUNCTION:
* dumpNextTuple
*
* DESCRIPTION:
* Display the next tuple
*
* INPUT PARAMETERS:
* PUINT16 p - Pointer to the CIS tuple.
*
* RETURNS:
* The pointer to the next CIS tuple.
*
* GLOBAL EFFECTS:
* None.
*
* ASSUMPTIONS:
* None.
*
* CALLS:
* sprintf, strcpy, printf
*
* CALLED BY:
* CardServices_DumpCIS
*
* PROTOTYPE:
* static
* PUINT16 dumpNextTuple(PUINT16 p);
*
*******************************************************************************
*/
static
PUINT16 dumpNextTuple(PUINT16 p)
{
INT code = p[0] & 0xff;
INT len = p[1] & 0xff;
static CHAR buffer[255];
INT i;
if ((code == 0) && (len == 0))
{
return (NULL);
}
if (code == 0xFF)
{
len = 0;
}
for (i=0; (i < len+2) && (i < screenWidth/3); i++)
{
sprintf(&buffer[i*3], "%02X ", p[i] & 0xff);
}
if (i != (len+2))
{
strcpy(&buffer[(i-1)*3],"...");
}
buffer[i*3] = '\0';
printf(buffer);
printf("\r\n");
if (code == 0xff)
{
return (NULL);
}
return (p + len + 2);
}
/*
*******************************************************************************
*
* FUNCTION:
* CardServices_Shutdown
*
* DESCRIPTION:
* Shutdown the PC card socket.
*
* INPUT PARAMETERS:
* PVOID *ctxP - Pointer the the PCMCIA socket Device Context Structure
* PCHAR arg - Pointer to the agrument.
*
* RETURNS:
* 0 - Success
* non-zero - Error
*
* GLOBAL EFFECTS:
* PC card inserted into the socket is enabled.
*
* ASSUMPTIONS:
* None.
*
* CALLS:
* The platform specific PCMCIA device driver.
* statSocket, decodeCIS, findConfig.
*
* CALLED BY:
* Any test code and device drivers needing access to a PC Card.
*
* PROTOTYPE:
* INT CardServices_Shutdown(PVOID ctxP, PCHAR arg)
*
*******************************************************************************
*/
INT CardServices_Shutdown(PVOID ctxP, PCHAR arg)
{
// Get pointer to the PCMCIA drivers DCS.
XS_PCMCIA_DCST * XsPcmciaCtxP = (XS_PCMCIA_DCST *)ctxP;
// Shutdown the PCMCIA socket.
XsPcmciaCtxP->XsPcmciaHWShutdownFnP(XsPcmciaCtxP);
return (0);
}
/*
*******************************************************************************
*
* FUNCTION:
* CardServices_DisplayCIS
*
* DESCRIPTION:
* Display the Card Information Structure
*
* INPUT PARAMETERS:
* PVOID *ctxP - Pointer the the PCMCIA socket Device Context Structure
* PVOID arg - Pointer to the agrument.
*
* RETURNS:
* None.
*
* GLOBAL EFFECTS:
* None.
*
* ASSUMPTIONS:
* None.
*
* CALLS:
* The platform specific PCMCIA device driver.
* DM_StartTest, statSocket, decodeCIS, displayCISInfo,
* DM_Error, printf, DM_StopTest, DM_AnyKeyToContinue, DM_FinishTest
*
* CALLED BY:
* Test menu for Card Services.
*
* PROTOTYPE:
* VOID CardServices_DisplayCIS(PVOID ctxP, PCHAR arg);
*
*******************************************************************************
*/
VOID CardServices_DisplayCIS(PVOID ctxP, PCHAR arg)
{
// Get pointer to the driver DCS.
XS_PCMCIA_DCST * XsPcmciaCtxP;
UINT socket;
SocketStatusT * infoP;
CIS_EntryT * cisP;
UINT32 status;
DM_StartTest("Display CIS Test");
// Get parameters
if (GetParameters(&XsPcmciaCtxP, arg, &socket))
{
return;
}
DM_CwDbgPrintf(DM_CW_SK_PCMCIA_0,
"PCMCIA: XsPcmciaCtxP: %08x", XsPcmciaCtxP);
DM_CwDbgPrintf(DM_CW_SK_PCMCIA_0, "PCMCIA: socket: %d", socket);
// Initialize pointers.
infoP = &XsPcmciaCtxP->status;
cisP = &XsPcmciaCtxP->cis;
// Clear card info.
memset(cisP, 0, sizeof(CIS_EntryT));
// Initialize the PCMCIA socket.
status = XsPcmciaCtxP->XsPcmciaHWSetupFnP(XsPcmciaCtxP);
if (status)
{
XllpUtilityOutputError(status);
return;
}
if ((status = statSocket(XsPcmciaCtxP, socket, 0)) == CS_NoError)
{
DM_CwDbgPrintf(DM_CW_SK_PCMCIA_0, "PCMCIA: decoding CIS");
// Decode the Card Information Structures
decodeCIS(infoP, cisP);
cisP->socket = socket;
// Now display the result
displayCISInfo(cisP);
}
if (!DM_StopTest(NULL))
{
DM_AnyKeyToContinue("Hit any key to continue...");
}
DM_FinishTest("Display CIS Test Complete");
}
/*
*******************************************************************************
*
* FUNCTION:
* CardServices_DumpCIS
*
* DESCRIPTION:
* Dump the Card Information Structure
*
* INPUT PARAMETERS:
* PVOID *ctxP - Pointer the the PCMCIA socket Device Context Structure
* PVOID arg - Pointer to the agrument.
*
* RETURNS:
* None.
*
* GLOBAL EFFECTS:
* None.
*
* ASSUMPTIONS:
* None.
*
* CALLS:
* The platform specific PCMCIA device driver,
* DM_StartTest, statSocket, decodeCIS, dumpNextTuple,
* DM_StopTest, DM_AnyKeyToContinue, DM_FinishTest
*
* CALLED BY:
* <Who calls this procedure here>
*
* PROTOTYPE:
* VOID CardServices_DumpCIS(PVOID ctxP, PCHAR arg)
*
*******************************************************************************
*/
VOID CardServices_DumpCIS(PVOID ctxP, PCHAR arg)
{
// Get pointer to the drivers DCS.
XS_PCMCIA_DCST * XsPcmciaCtxP;
UINT socket;
SocketStatusT * infoP;
PUINT16 attSpaceP;
UINT32 status;
DM_StartTest("Dump CIS Test");
// Get parameters
if (GetParameters(&XsPcmciaCtxP, arg, &socket))
{
return;
}
// Initialize pointers.
infoP = &XsPcmciaCtxP->status;
DM_StartTest("Dump CIS Test");
// Clear out the configuration record
memset(infoP, 0, sizeof(SocketStatusT));
// Initialize the PCMCIA socket.
status = XsPcmciaCtxP->XsPcmciaHWSetupFnP(XsPcmciaCtxP);
if (status)
{
XllpUtilityOutputError(status);
return;
}
if ((status = statSocket(XsPcmciaCtxP, socket, 0)) == 0) {
// Decode the configuration records
attSpaceP = (unsigned short*)infoP->attSpaceP;
while((attSpaceP=dumpNextTuple(attSpaceP)) != NULL) ;
}
if (!DM_StopTest(NULL))
{
DM_AnyKeyToContinue("Hit any key to continue...");
}
DM_FinishTest("Dump CIS Test Complete");
}
/*
*******************************************************************************
*
* FUNCTION:
* CardServices_DumpRegs
*
* DESCRIPTION:
* Dump IO space registers
*
* INPUT PARAMETERS:
* PVOID *ctxP - Pointer the the PCMCIA socket Device Context Structure
* PVOID arg - Pointer to the agrument.
*
* RETURNS:
* None.
*
* GLOBAL EFFECTS:
* None.
*
* ASSUMPTIONS:
* None.
*
* CALLS:
* The platform specific PCMCIA device driver,
* DM_StartTest, statSocket, dumpNextTuple, DM_StopTest, DM_AnyKeyToContinue,
* DM_FinishTest
*
* CALLED BY:
* <Who calls this procedure here>
*
* PROTOTYPE:
* VOID CardServices_DumpRegs(PVOID ctxP, PCHAR arg);
*
*******************************************************************************
*/
VOID CardServices_DumpRegs(PVOID ctxP, PCHAR arg)
{
// Get pointer to the drivers DCS.
XS_PCMCIA_DCST * XsPcmciaCtxP;
UINT socket;
SocketStatusT * infoP;
CIS_EntryT * cisP;
INT i;
UINT32 status;
DM_StartTest("Display CIS Test");
// Get parameters
if (GetParameters(&XsPcmciaCtxP, arg, &socket))
{
return;
}
// Initialize pointers.
infoP = &XsPcmciaCtxP->status;
cisP = &XsPcmciaCtxP->cis;
// Clear card info.
memset(cisP, 0, sizeof(CIS_EntryT));
// Initialize the PCMCIA socket.
status = XsPcmciaCtxP->XsPcmciaHWSetupFnP(XsPcmciaCtxP);
if (status)
{
XllpUtilityOutputError(status);
return;
}
if ((status = statSocket(XsPcmciaCtxP, socket, 0)) == 0)
{
// Decode the Card Information Structures
decodeCIS(infoP, cisP);
cisP->socket = socket;
}
// Find a basic configuration so we can dump the registers
if (!findConfig(infoP, cisP))
{
DM_Error("Failed to find suitable configuration\r\n");
}
else
{
int regNum = cisP->config[cisP->selectIndex].ioRange[0].length;
printf("IO address: %08X\r\n", cisP->ioBase[0]);
printf("\r\n16-Bit Registers:\r\n");
if (regNum > 32)
{
regNum = 32;
}
// And dump the IO registers as 16 bit registers
for (i=0; i < regNum; i += 8)
{
PUINT16 p = (unsigned short *)cisP->ioBase[0];
printf("Offset %02X: %04X\t%04X\t%04X\t%04X\r\n", i, p[i], p[i+1], p[i+2], p[i+3]);
}
printf("\r\n8-Bit Registers:\r\n");
// And dump the IO registers as 8 bit registers
for (i=0; i < regNum; i += 8)
{
PUCHAR p = (unsigned char *)cisP->ioBase[0];
printf("Offset %02X: %02X %02X %02X %02X %02X %02X %02X %02X\r\n",
i, p[i+0], p[i+1], p[i+2], p[i+3],
p[i+4], p[i+5], p[i+6], p[i+7]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -