Ejemplo n.º 1
0
/*
 * Close a previously opened PCI slot.
 */
XIA_EXPORT int XIA_API plx_close_slot(HANDLE h)
{
    PLX_STATUS status;
    PLX_DEVICE_OBJECT device_object;

    unsigned long idx;


    ASSERT(h);

    status = _plx_find_handle_index(h, &idx);

    if (status != PLX_SUCCESS) {
        _plx_log_DEBUG("Unable to find HANDLE %p\n", h);
        return status;
    }

    device_object = V_MAP.device[idx];

    status = _plx_remove_slot_from_map(idx);

    if (status != PLX_SUCCESS) {
        _plx_log_DEBUG("Error unmapping device (h = %p)\n", h);
        return status;
    }

    status = PlxPci_DeviceClose(&device_object);

    if (status != ApiSuccess) {
        _plx_log_DEBUG("Error closing device (h = %p)\n", h);
        _plx_print_more(status);
        return status;
    }

    return PLX_SUCCESS;
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
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 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);
}
Ejemplo n.º 4
0
/*********************************************************************
 *
 * Function   : SelectDevice_DMA
 *
 * Description: Asks the user which PLX DMA device to select
 *
 * Returns    : Total devices found
 *              -1,  if user cancelled the selection
 *
 ********************************************************************/
S16
SelectDevice_DMA(
    PLX_DEVICE_KEY *pKey
    )
{
    S32               i;
    S32               NumDevices;
    BOOLEAN           bAddDevice;
    PLX_STATUS        status;
    PLX_DEVICE_KEY    DevKey;
    PLX_DEVICE_KEY    DevKey_DMA[MAX_DEVICES_TO_LIST];
    PLX_DRIVER_PROP   DriverProp;
    PLX_DEVICE_OBJECT Device;


    Cons_printf("\n");

    i          = 0;
    NumDevices = 0;

    do
    {
        // Setup for next device
        memset(&DevKey, PCI_FIELD_IGNORE, sizeof(PLX_DEVICE_KEY));

        // Check if device exists
        status =
            PlxPci_DeviceFind(
                &DevKey,
                (U16)i
                );

        if (status == ApiSuccess)
        {
            // Default to add device
            bAddDevice = TRUE;

            if (bAddDevice)
            {
                // Verify supported chip type
                switch (DevKey.PlxChip)
                {
                    default:
                        if ((DevKey.PlxChip & 0xF000) == 0x8000)
                        {
                            // DMA is always function 1 or higher
                            if (DevKey.function == 0)
                                bAddDevice = FALSE;
                        }
                        else
                        {
                            bAddDevice = FALSE;
                        }
                        break;
                }
            }

            if (bAddDevice)
            {
                // Open device to get its properties
                PlxPci_DeviceOpen(
                    &DevKey,
                    &Device
                    );
            }

            // Verify driver used is PnP and not Service driver
            if (bAddDevice)
            {
                PlxPci_DriverProperties(
                    &Device,
                    &DriverProp
                    );

                if (DriverProp.bIsServiceDriver)
                {
                    bAddDevice = FALSE;
                }
            }

            // Close device
            PlxPci_DeviceClose(
                &Device
                );

            if (bAddDevice)
            {
                // Copy device key info
                DevKey_DMA[NumDevices] = DevKey;

                Cons_printf(
                    "\t\t  %2d. %04x [b:%02x s:%02x f:%x]\n",
                    (NumDevices + 1), DevKey.PlxChip,
                    DevKey.bus, DevKey.slot, DevKey.function
                    );

                // Increment device count
                NumDevices++;
            }
        }

        // Go to next devices
        i++;
    }
    while ((status == ApiSuccess) && (NumDevices < MAX_DEVICES_TO_LIST));

    if (NumDevices == 0)
        return 0;

    Cons_printf(
        "\t\t   0. Cancel\n\n"
        );

    do
    {
        Cons_printf("\t  Device Selection --> ");
        Cons_scanf("%d", &i);
    }
    while (i > NumDevices);

    if (i == 0)
        return -1;

    // Return selected device information
    *pKey = DevKey_DMA[i - 1];

    return (S16)NumDevices;
}
Ejemplo n.º 5
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;
}