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

📄 psp_pci_bios_sample_main.c

📁 DM6437评估版BIOS下的PCI驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
**+-------------------------------------------------------------------------+**
**|                            ****                                         |**
**|                            ****                                         |**
**|                            ******o***                                   |**
**|                      ********_///_****                                  |**
**|                      ***** /_//_/ ****                                  |**
**|                       ** ** (__/ ****                                   |**
**|                           *********                                     |**
**|                            ****                                         |**
**|                            ***                                          |**
**|                                                                         |**
**|         Copyright (c) 1998-2006 Texas Instruments Incorporated          |**
**|                        ALL RIGHTS RESERVED                              |**
**|                                                                         |**
**| Permission is hereby granted to licensees of Texas Instruments          |**
**| Incorporated (TI) products to use this computer program for the sole    |**
**| purpose of implementing a licensee product based on TI products.        |**
**| No other rights to reproduce, use, or disseminate this computer         |**
**| program, whether in part or in whole, are granted.                      |**
**|                                                                         |**
**| TI makes no representation or warranties with respect to the            |**
**| performance of this computer program, and specifically disclaims        |**
**| any responsibility for any damages, special or consequential,           |**
**| connected with the use of this program.                                 |**
**|                                                                         |**
**+-------------------------------------------------------------------------+**
******************************************************************************/
/**
 *  \file   psp_pci_bios_sample_main.c
 *
 *  \brief  Test application to test PCI driver for DM6437/C6424 EVM.
 *
 *  This file contains test application for PCI driver.
 *  Steps to run PCI sample application:
 *  1. Fit EVMDM6437/EVMC6424 card into the PCI slot of a linux machine having linux
 *     kernel 2.6.9(RHEL 4 AS).
 *  2. Connect USB emulator to JTAG port of DM6437/C6424 EVM. Connect the USB cable
 *        to other PC having CCS on that.
 *    3. Power on Linux machine. BIOS of linux machine should not boot.
 *    4. Open CCS 3.3 on the PC and try to connect to DM6437/C6424 EVM. When the board
 *       will be connected to CCS, BIOS of linux machine will boot up.
 *    5. Press Ctrl+Alt+F1 to go to console in linux machine
 *    6. Enter username and password for "root" user
 *    7. Copy Makefile and pcidrv.c from "pspdrivers\pal_sys\pci\docs\linuxapp"
 *       folder to "/home" directory of linux machine.
 *    8. Go to "/home" directory by giving "cd /home" command
 *    9. Give "make" command. This will generate the object file of a PCI host
 *       driver for linux. Driver will be generated by module name "pcidriver.ko"
 *       in same directory.
 *    10.Give "insmod pcidriver.ko" command. This will insert the driver as a
 *       module
 *    11.This will give some print messages on linux machine. Give "dmesg" command
 *       on linux console to see the print messages of linux driver for PCI.
 *    12.There will be a print message saying "Address to write from DSP = 0x518000".
 *       Note this address(0x518000).
 *    13.Open \pspdrivers\system\c6424\bios\evm6424\pci\build\psp_pci_bios_sample_c6424.pjt for
 *       C6424 project and \pspdrivers\system\dm6437\bios\evmdm6437\pci\build\psp_pci_bios_sample_dm6437.pjt
 *       for DM6437 in CCS. Open \pspdrivers\pal_sys\pci\sample\psp_pci_bios_sample_main.c
 *    14.Build CCS project and run the out file.
 *    15.Out file will generate a host interrupt on linux machine. On generation of
 *       host interrupt there will be print messages saying "Interrupt received from
 *       DSP". This indicates that DSP to Host interrupt is generated.
 *    16.Sample application loaded on EVM DM6437/C6424 through CCS will also perform read/
 *       write test. A pop up will come to fetch the address for read write. Enter
 *       the address for read write printed on the consol of Linux host machine
 *       noted in step 12.The sample application will perform read write and print
 *       the message of success or failure on STDOUT
 *
 *  \version    0.1     Rinkal Shah   Created
 */


/*
 * Include files
 */
#include <std.h>
#include <stdio.h>
#include <mem.h>
#include <tsk.h>
#include <log.h>
#include <gio.h>
#include <string.h>
#include <bcache.h>

#ifdef CHIP_DM6437
#include <ti/sdo/pspdrivers/soc/dm6437/dsp/soc.h>
#include <ti/sdo/pspdrivers/soc/dm6437/dsp/cslr_pci.h>
#include <ti/sdo/pspdrivers/soc/dm6437/dsp/cslr_sys.h>
#include <ti/sdo/pspdrivers/pal_sys/dm6437/pal_sys.h>
#include <ti/sdo/pspdrivers/pal_sys/dm6437/pal_sys_soc.h>
#endif

#ifdef CHIP_C6424
#include <ti/sdo/pspdrivers/soc/c6424/dsp/soc.h>
#include <ti/sdo/pspdrivers/soc/c6424/dsp/cslr_pci.h>
#include <ti/sdo/pspdrivers/soc/c6424/dsp/cslr_sys.h>
#include <ti/sdo/pspdrivers/pal_sys/c6424/pal_sys.h>
#include <ti/sdo/pspdrivers/pal_sys/c6424/pal_sys_soc.h>
#endif

#include <ti/sdo/pspdrivers/pal_sys/pci/pal_syspci.h>

#define PCI_DEBUG   printf
#define PCI_CONTROLLER_INSTANCE     (0u)
#define TRIGGER_DSPINT_MASK            (0x80000000u)
#define ENABLE_SOFTINT3_MASK        (0x08000000u)
/*
 * This test application demonstrates usage of PCI driver for DM6437/C6424. The test
 * application demonstrates master mode read and write operation. Application
 * will write data to the host space of linux machine and read the data back.
 */
#define SIZE_OF_MEMORY_SPACE_OF_NW_CARD     (256)

#define NUM_OF_TEST_ITERATION   (100)

extern LOG_Obj trace;

CSL_SysRegsOvly  sysCtlRegs  =   (CSL_SysRegsOvly)CSL_SYS_0_REGS;
CSL_PciRegsOvly        pciRegs = (CSL_PciRegsOvly)CSL_PCI_0_REGS;

Ptr initPCI();
void deInitPCI(Ptr hPci);
Int32 readData(Ptr hPci, Uint8* srcAddr, Uint8* dstAddr, Uint32 readCount);
Int32 writeData(Ptr hPci,Uint8* srcAddr, Uint8* dstAddr, Uint32 writeCount);
void generateHostInterrupt();


/*
 * Global variables
 */
Ptr         pciHandle;
extern LOG_Obj trace;
extern Int32  extHeap;
extern Int32  intHeap;
Uint8 interruptCalled = 0;
void tskDataExchange();

Uint8 pciReadBuff[SIZE_OF_MEMORY_SPACE_OF_NW_CARD];
Uint8 pciWriteBuff[SIZE_OF_MEMORY_SPACE_OF_NW_CARD];
Ptr pciBusAddressOfNewCard;

void main()
{
    if(PAL_sysModuleClkCtrl(PAL_SYS_CLK_MODULE_PCI,PAL_SYS_MODULE_CLK_ENABLE) != PAL_SOK)
    {
        PCI_DEBUG("ERROR: Unable to power up PCI module\n");
        return;
    }
    /*
     * Initialize the PCI driver and hardware
     */
    pciHandle = initPCI();
}

void tskDataExchange()
{

    Uint32  noOfByteXfered = SIZE_OF_MEMORY_SPACE_OF_NW_CARD;
    Int status = 0;
    Uint32 initVal = 0;
    Uint32 initCount = 0;
    Uint32 loopCount = 0;
    Uint32 checkLoopCount   =   0;
    Uint32 interruptMask = 0;

    /*
     * Enable software interrupts of PCI driver
     */
    status  =    PAL_sysPCIGetMemMapReg(pciHandle,
                                        PAL_SYSPCI_DSP_INT_ENABLE_SET,
                                        PAL_SYS_PCI_READ_WRITE_SIZE_WORD,
                                        &interruptMask);
    if(PAL_SOK  !=  status)
    {
        PCI_DEBUG("ERROR: Unable to read the Backend configuration register\r\n");
    }
    interruptMask    |= ENABLE_SOFTINT3_MASK;
    status  =    PAL_sysPCISetMemMapReg(pciHandle,
                                        PAL_SYSPCI_DSP_INT_ENABLE_SET,
                                        PAL_SYS_PCI_READ_WRITE_SIZE_WORD,
                                        interruptMask);
    if(PAL_SOK  !=  status)
    {
        PCI_DEBUG("ERROR: Unable to read the Backend configuration register\r\n");
    }

  	generateHostInterrupt();
    PCI_DEBUG("DSP to Host Interrupt generated\n");
    /*
     * If PCI driver handle is NULL, don't move ahead
     */
    if(NULL == pciHandle)
    {
        PCI_DEBUG("ERROR: PCI driver handle not created\n");
        return;
    }
    memset(pciReadBuff,     0x0, SIZE_OF_MEMORY_SPACE_OF_NW_CARD);
    memset(pciWriteBuff,    0x0, SIZE_OF_MEMORY_SPACE_OF_NW_CARD);

    printf("Enter the pci address of memory space for read write in hex (the address printed out on the linux host machine)\n");
	scanf("%x", &pciBusAddressOfNewCard);

    for(loopCount = 0; loopCount < NUM_OF_TEST_ITERATION; loopCount++)
    {
        /*
         * If the transfer count is non-zero that go ahead
         */
        if(0 != noOfByteXfered)
        {
            /*
             * Initialize the write buffer by new values for every iteration of
             * test
             */
            initVal =   loopCount;
            for(initCount = 0; initCount < SIZE_OF_MEMORY_SPACE_OF_NW_CARD;
                            initCount++)
            {
                pciWriteBuff[initCount] = initVal++;
            }
            /*
             * Write back data to DDR from Cache
             */
            BCACHE_wb(pciWriteBuff, SIZE_OF_MEMORY_SPACE_OF_NW_CARD, TRUE);
            /*
             * Write data onto network card
             */
            status = writeData( pciHandle,
                                pciWriteBuff,
                                pciBusAddressOfNewCard,
                                SIZE_OF_MEMORY_SPACE_OF_NW_CARD);
            if(status < 0)
            {
                PCI_DEBUG( "ERROR: GIO_write unsuccessful status == %d; Size == %u\n",status, noOfByteXfered);
                PCI_DEBUG( "ERROR: PCI test failed in write. Iteration : %d\n",loopCount);
                break;
            }

            /*
             * Read data from network card
             */
            status = readData(  pciHandle,
                                pciBusAddressOfNewCard,
                                pciReadBuff,
                                SIZE_OF_MEMORY_SPACE_OF_NW_CARD);
            if(status < 0)
            {
                PCI_DEBUG( "ERROR: GIO_read unsuccessful status == %d; Size == %u\n",status, noOfByteXfered);
                PCI_DEBUG( "ERROR: PCI test failed in read. Iteration : %d\n",loopCount);
                break;
            }
            /*
             * Write back data to DDR from Cache
             */
            BCACHE_wb(pciReadBuff, SIZE_OF_MEMORY_SPACE_OF_NW_CARD, TRUE);
            /*
             * Verify the data of read and write operation.
             */
            for(checkLoopCount = 0; checkLoopCount < SIZE_OF_MEMORY_SPACE_OF_NW_CARD;
                checkLoopCount++)
            {
                /*
                 * Check whether read buffer and write buffer are same or not
                 */
                if(pciReadBuff[checkLoopCount] != pciWriteBuff[checkLoopCount])
                {
                    PCI_DEBUG( "ERROR: PCI test failed. Test iteration = %d, Failed at = %d\n", loopCount, checkLoopCount);
                    return;
                }
            }
        }
    }

    if(1==  interruptCalled)
    {
        PCI_DEBUG("Host to DSP interrupt test successfully\n");

⌨️ 快捷键说明

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