/****************************************************************************** * * Function : main * * Description: The main entry point * *****************************************************************************/ int main( void ) { S16 DeviceSelected; PLX_STATUS rc; PLX_DEVICE_KEY DeviceKey; PLX_DEVICE_OBJECT Device; ConsoleInitialize(); Cons_clear(); Cons_printf( "\n\n" "\t\t PLX DMA Sample Application\n\n" ); /************************************ * Select Device ************************************/ DeviceSelected = SelectDevice_DMA( &DeviceKey ); if (DeviceSelected == -1) { ConsoleEnd(); exit(0); } rc = PlxPci_DeviceOpen( &DeviceKey, &Device ); if (rc != ApiSuccess) { Cons_printf("\n ERROR: Unable to find or select a PLX device\n"); PlxSdkErrorDisplay(rc); _Pause; ConsoleEnd(); exit(-1); } Cons_clear(); Cons_printf( "\nSelected: %04x %04x [b:%02x s:%02x f:%x]\n\n", DeviceKey.DeviceId, DeviceKey.VendorId, DeviceKey.bus, DeviceKey.slot, DeviceKey.function ); /************************************ * Perform the DMA ************************************/ if (((DeviceKey.PlxChip & 0xF000) == 0x8000) && (DeviceKey.PlxChip != 0x8311)) { PerformDma_8000( &Device ); } else { Cons_printf( "ERROR: DMA not supported by the selected device (%04X)\n", DeviceKey.PlxChip ); goto _Exit_App; } /************************************ * Close the Device ***********************************/ _Exit_App: PlxPci_DeviceClose( &Device ); _Pause; Cons_printf("\n\n"); ConsoleEnd(); exit(0); }
/****************************************************************************** * * Function : main * * Description: The main entry point * *****************************************************************************/ int main( void ) { S16 DeviceSelected; PLX_STATUS rc; PLX_DEVICE_KEY DeviceKey; PLX_DEVICE_OBJECT Device; ConsoleInitialize(); Cons_clear(); Cons_printf( "\n\n" "\t\t PLX Local->PCI Interrupt Sample Application\n" "\t\t January 2008\n\n" ); /************************************ * Select Device ************************************/ DeviceSelected = SelectDevice( &DeviceKey ); if (DeviceSelected == -1) { ConsoleEnd(); exit(0); } rc = PlxPci_DeviceOpen( &DeviceKey, &Device ); if (rc != ApiSuccess) { Cons_printf("\n ERROR: Unable to find or select a PLX device\n"); PlxSdkErrorDisplay(rc); _Pause; ConsoleEnd(); exit(-1); } Cons_clear(); Cons_printf( "\nSelected: %04x %04x [b:%02x s:%02x f:%x]\n\n", DeviceKey.DeviceId, DeviceKey.VendorId, DeviceKey.bus, DeviceKey.slot, DeviceKey.function ); // Verify chip is supported switch (DeviceKey.PlxChip) { case 0x9050: case 0x9030: case 0x9080: case 0x9054: case 0x9056: case 0x9656: case 0x8311: break; default: Cons_printf( "ERROR: Device (%04X) does not support generic Local-to-PCI interrupt\n", DeviceKey.PlxChip ); goto _Exit_App; } /************************************ * Perform the DMA ************************************/ InterruptTest( &Device ); /************************************ * Close the Device ***********************************/ _Exit_App: PlxPci_DeviceClose( &Device ); _Pause; Cons_printf("\n\n"); ConsoleEnd(); exit(0); }
/****************************************************************************** * * Function : Do_DMA_Test * * Description: The main entry point * *****************************************************************************/ int Do_DMA_Test( U32 NTSrcAddr, U32 NTDestAddr, U32 NTSize, PLX_DEVICE_OBJECT *pNTDevice ) { S8 DeviceSelected; PLX_STATUS rc; PLX_DEVICE_KEY DeviceKey; PLX_DEVICE_OBJECT Device; U16 LutIndex = 0xffff; U16 ReqId; U32 flags = 0; /************************************ * Select Device ***********************************/ DeviceSelected = SelectDevice_DMA( &DeviceKey ); if (DeviceSelected == -1) { ConsoleEnd(); exit(0); } rc = PlxPci_DeviceOpen( &DeviceKey, &Device ); if (rc != ApiSuccess) { Cons_printf("\n ERROR: Unable to find or select a PLX device\n"); PlxSdkErrorDisplay(rc); _Pause; ConsoleEnd(); exit(-1); } Cons_printf( "\nSelected: %04x %04x [b:%02x s:%02x f:%x]\n\n", DeviceKey.DeviceId, DeviceKey.VendorId, DeviceKey.bus, DeviceKey.slot, DeviceKey.function ); // Must add the DMA device ReqID to the NT LUT ReqId = ((U16)DeviceKey.bus << 8) | (DeviceKey.slot << 3) | (DeviceKey.function & 0x03); PlxPci_Nt_LutAdd( pNTDevice, &LutIndex, ReqId, flags ); /************************************ * Perform the DMA ************************************/ if (((DeviceKey.PlxChip & 0xF000) == 0x8000) && (DeviceKey.PlxChip != 0x8311)) { PerformDma_8000( &Device, NTSrcAddr, NTDestAddr, NTSize ); } else { Cons_printf( "ERROR: DMA not supported by the selected device (%04X)\n", DeviceKey.PlxChip ); goto _Exit_App; } /************************************ * Close the Device ***********************************/ _Exit_App: PlxPci_DeviceClose( &Device ); _Pause; Cons_printf("\n\n"); return 0; }