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

📄 universe_dy4.c

📁 sbc7410的vxworksbsp
💻 C
📖 第 1 页 / 共 5 页
字号:
            sysPciSlaveDesc[image].bs = UNIVERSE_LSI6_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI6_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI6_TO;            break;        case UNIVERSE_LSI7 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI7_CTL;            sysPciSlaveDesc[image].bs = UNIVERSE_LSI7_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI7_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI7_TO;            break;        default :            break;        }        sysPciSlaveDesc[image].enabled = 0;        sysPciSlaveDesc[image].vmeBase = 0;        sysPciSlaveDesc[image].size = 0;        sysPciSlaveDesc[image].localAdrs = 0;    }    for (image=0; image<NELEMENTS(sysVmeSlaveDesc);image++)    {        switch (image+UNIVERSE_VSI0)        {        case UNIVERSE_VSI0 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI0_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI0_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI0_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI0_TO;            break;        case UNIVERSE_VSI1 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI1_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI1_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI1_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI1_TO;            break;        case UNIVERSE_VSI2 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI2_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI2_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI2_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI2_TO;            break;        case UNIVERSE_VSI3 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI3_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI3_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI3_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI3_TO;            break;        case UNIVERSE_VSI4 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI4_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI4_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI4_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI4_TO;            break;        case UNIVERSE_VSI5 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI5_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI5_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI5_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI5_TO;            break;        case UNIVERSE_VSI6 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI6_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI6_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI6_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI6_TO;            break;        case UNIVERSE_VSI7 :            sysVmeSlaveDesc[image].ctl = UNIVERSE_VSI7_CTL;            sysVmeSlaveDesc[image].bs = UNIVERSE_VSI7_BS;            sysVmeSlaveDesc[image].bd = UNIVERSE_VSI7_BD;            sysVmeSlaveDesc[image].to = UNIVERSE_VSI7_TO;            break;        default :            break;        }        sysVmeSlaveDesc[image].enabled = 0;        sysVmeSlaveDesc[image].vmeBase = 0;        sysVmeSlaveDesc[image].size = 0;        sysVmeSlaveDesc[image].localAdrs = 0;    }    /* setup mpp23/gpp23 register for uart int */    GT64260_REG_RD(MPP_CTRL2, &temp); /* GPP[23] */    temp &= ~0xf0000000 ;    GT64260_REG_WR(MPP_CTRL2, temp);    /* setup gpp port */    GT64260_REG_RD(GPP_INT_MASK, &temp); /* pin 23, int masked */    temp &= ~0x00800000 ;    GT64260_REG_WR(GPP_INT_MASK, temp);    GT64260_REG_RD(GPP_INT_CAUSE, &temp); /* pin 23, int cleared */    temp &= ~0x00800000 ;    GT64260_REG_WR(GPP_INT_CAUSE, temp);    GT64260_REG_RD(GPP_IO_CTRL, &temp); /* pin 23, input */    temp &= ~0x00800000 ;    GT64260_REG_WR(GPP_IO_CTRL, temp);    GT64260_REG_RD(GPP_LVL_CTRL, &temp); /* pin 23, active low according to FPGA */    temp |= 0x00800000 ;    GT64260_REG_WR(GPP_LVL_CTRL, temp);	    /* set mpp level interrupt *//*    GT64260_REG_RD(CU_ARB_CTRL, &temp);     temp |= 0x00000400 ;    GT64260_REG_WR(CU_ARB_CTRL, temp);*/    return (OK);}/********************************************************************************* sysUniverseSlaveImageSet - set Universe slave image** This routine configures a PCI or VME slave image with the given input.** RETURNS: N/A** NOMANUAL*/STATUS sysUniverseSlaveImageSet    ( UINT32    image,          /* UNIVERSE_[LV]SI[0..7] */      UINT32    control,      UINT32    baseAdrs,      UINT32    bound,      UINT32    translationOffset      ){    SLAVE_IMAGE_STRUCT *slave;#ifdef VME_DEBUG    printf("Image    = 0x%x\n", image);    printf("Control  = 0x%x\n", control);    printf("Base     = 0x%x\n", baseAdrs);    printf("bound    = 0x%x\n", bound);    printf("Offset   = 0x%x\n", translationOffset);#endif    switch (image)    {        case UNIVERSE_LSI0 :        case UNIVERSE_LSI1 :        case UNIVERSE_LSI2 :        case UNIVERSE_LSI3 :        case UNIVERSE_LSI4 :        case UNIVERSE_LSI5 :        case UNIVERSE_LSI6 :        case UNIVERSE_LSI7 :            slave = (SLAVE_IMAGE_STRUCT*) &sysPciSlaveDesc[image];            break;        case UNIVERSE_VSI0 :        case UNIVERSE_VSI1 :        case UNIVERSE_VSI2 :        case UNIVERSE_VSI3 :        case UNIVERSE_VSI4 :        case UNIVERSE_VSI5 :        case UNIVERSE_VSI6 :        case UNIVERSE_VSI7 :            slave = (SLAVE_IMAGE_STRUCT*) &sysVmeSlaveDesc[image-UNIVERSE_VSI0];            break;        default :            printf("Image %d is invalid \n",image);            return ERROR;    }    /* Disable image first */    *slave->ctl = 0;    *(slave->bs) = (UINT32)LONGSWAP(baseAdrs);    *(slave->bd) = (UINT32)LONGSWAP(bound);    *(slave->to) = (UINT32)LONGSWAP(translationOffset);    *(slave->ctl) = (UINT32)LONGSWAP(control);    return OK;}/********************************************************************************* sysVmeA32MstrSet - set VME A32 master window** This routine is used to map a VME A32 master window to allow the CPU to access* a VME slave in the VME A32 window.  The given information is also used by* sysBusToLocalAdrs() to translate a given VME A32 address into a local address.** There are eight images (UNIVERSE_LSI[0..7]) to be used to map eight* concurrent A32 windows with a maximum combined size of VME_A32_MSTR_SIZE* (0x20000000).** Note : This routine performs minimal checking to maintain the space "allocated"* in mapping of new windows.  So the onus is on the system developer to* carefully assess the VME requirements, and map in only the required window* in order to use the space resource efficiently.** The system developer should always start the remapping process by disabling* all images, and begin mapping new windows starting with image 0.  Programming* image 0 is a reset mechanism that makes the maximum image size,* VME_A32_MSTR_SIZE, available again.** To configure the window attributes, use the prototype definitions (PCI slave* image control) defined in universe.h .  Use a value of 0 for the attribute to* disable the window/image.** RETURNS: OK, or ERROR if out of local address space to map window**/STATUS sysVmeA32MstrSet    ( UINT32    image,                  /* UNIVERSE_LSI[0..7] */      char      *vmeWindowBase,         /* Base address of VME window */      UINT32    vmeWindowSize,          /* Size of VME window */      UINT32    attributes,             /* Attributes of VME window; 0 to disable */      char      **localAdrs             /* Where to return local base address of VME window */      ){    UINT32 pciBase = 0, bound = 0, to = 0;    int lock;    if (image > (UNIVERSE_SLAVE_IMAGES - 1))    {        logMsg("Invalid image; must be 0 .. %d\n",                (UNIVERSE_SLAVE_IMAGES-1), 0,0,0,0,0);        return ERROR;    }    lock = intLock();    if ((attributes & VME_CTL_EN))    {        /* Initialize sysPciSlaveDesc[], and Universe regs */        if (sysPciSlaveDesc[image].localAdrs == 0)        {            /* Image has not been inititalized */            if (vmeWindowSize <= (DEFAULT_A32_TOP-sysLocalVmeA32Adrs))            {                sysPciSlaveDesc[image].size = vmeWindowSize;                sysPciSlaveDesc[image].localAdrs = (char*)sysLocalVmeA32Adrs;                /* adjust sysLocalVmeA32Adrs in PCI space */                sysLocalVmeA32Adrs = sysLocalVmeA32Adrs + vmeWindowSize;            }            else /* window size is bigger than available size */            {                logMsg("Max. size for current image must be <= 0x%x\n",                        DEFAULT_A32_TOP-sysLocalVmeA32Adrs,0,0,0,0,0);                intUnlock(lock);                return ERROR;            }        }        else /* Reusing an initialized image */        {            /* Programming image 0 allows remapping to use maximum master window size */            if (image == UNIVERSE_LSI0)            {                if (vmeWindowSize > VME_A32_MSTR_SIZE)                {                    logMsg("Max. size for current image must be <= 0x%x\n",                            VME_A32_MSTR_SIZE,0,0,0,0,0);                    intUnlock(lock);                    return ERROR;                }                sysPciSlaveDesc[image].localAdrs = (char*)VME_A32_MSTR_LOCAL;                sysLocalVmeA32Adrs = (UINT32)VME_A32_MSTR_LOCAL + vmeWindowSize;            }            else            {                if ((vmeWindowSize > sysPciSlaveDesc[image].size) &&                    (vmeWindowSize <= (DEFAULT_A32_TOP-sysLocalVmeA32Adrs)))                {                    /* Size bigger than current size so can't use current address;                     * Have to "allocate" new local address space at                     * sysLocalVmeA32Adrs;                     * */                    sysPciSlaveDesc[image].localAdrs = (char*)sysLocalVmeA32Adrs;                    sysLocalVmeA32Adrs = sysLocalVmeA32Adrs + vmeWindowSize;                }                else if (vmeWindowSize > (DEFAULT_A32_TOP-sysLocalVmeA32Adrs))                {                    logMsg("Max. size for current image must be <= 0x%x\n",                    DEFAULT_A32_TOP-sysLocalVmeA32Adrs,0,0,0,0,0);                    intUnlock(lock);                    return ERROR;                }            }            sysPciSlaveDesc[image].size = vmeWindowSize;        }        /* Setting control bit for PCI memory space */        attributes &= ~VME_CTL_PCI_IO;        attributes |= VME_CTL_PCI_MEM;        sysPciSlaveDesc[image].vmeBase = vmeWindowBase;        bound = (UINT32)sysPciSlaveDesc[image].localAdrs +                        sysPciSlaveDesc[image].size - VME_A32_SPACE_BASE;        pciBase = (UINT32)sysPciSlaveDesc[image].localAdrs - VME_A32_SPACE_BASE;        to = (UINT32)sysPciSlaveDesc[image].vmeBase - pciBase;        sysPciSlaveDesc[image].enabled = 1;        *localAdrs = sysPciSlaveDesc[image].localAdrs;    }    else    {        /* Clear sysPciSlaveDesc[], and Universe regs */        sysPciSlaveDesc[image].enabled = 0;        attributes = bound = pciBase = to = 0;    }    sysUniverseSlaveImageSet(image, attributes, pciBase, bound, to);    intUnlock(lock);    return OK;}/******************************************************************************** sysLocalToBusAdrs - convert a local address to a bus address** This routine returns a VMEbus address as it would be seen on the bus.* The local address that is passed into this routine is the address of* the local resource as seen by the CPU.** Notes:*  -This function supports only the default BSP VME A32/A24 slave images*  -No distinction on SUP/USR and PGM/DATA AM codes* RETURNS: OK, or ERROR if the address space is unknown or the mapping is not* possible.** SEE ALSO: sysBusToLocalAdrs()*/STATUS sysLocalToBusAdrs    (    int     adrsSpace,  /* bus address space where busAdrs resides */    char *  localAdrs,  /* local address to convert */    char ** pBusAdrs    /* where to return bus address */    ){    switch (adrsSpace)    {        /* No distinction on SUP/USR and PGM/DATA AM codes */        case VME_AM_EXT_SUP_PGM:        case VME_AM_EXT_SUP_DATA:        case VME_AM_EXT_USR_PGM:        case VME_AM_EXT_USR_DATA:            if ((UINT32)localAdrs >= (VME_A32_SLV_SIZE))               return (ERROR);            else                *pBusAdrs = (char*) ((int)localAdrs | (int)VME_A32_SLV_BUS);            return (OK);        /* No distinction on SUP/USR and PGM/DATA AM codes */        case VME_AM_STD_SUP_PGM:        case VME_AM_STD_SUP_DATA:        case VME_AM_STD_USR_PGM:        case VME_AM_STD_USR_DATA:            if ((UINT32)localAdrs >= (VME_A24_SLV_SIZE))                return (ERROR);            else                *pBusAdrs = (char*) ((int)localAdrs | (int)VME_A24_SLV_BUS);            return (OK);        /* No distinction on SUP/USR and PGM/DATA AM codes */        case VME_AM_SUP_SHORT_IO:        case VME_AM_USR_SHORT_IO:            /*             *  No A16 window             */            return (ERROR);        default:            return (ERROR);    }}/******************************************************************************** sysBusToLocalAdrs - convert a bus address to a local address** This routine returns a local address that is used to access the VMEbus.* The bus address that is passed into this routine is the VMEbus address* as it would be seen on the bus.* Notes:* -If the passed busadrs is A24 or A16, this function will use PCI Special image 0* -If the passed busAdrs exsists in Reg Access window, this function will return*  in pLocalAdrs the Universe IO Base address* -This function supports only the default BSP VME/PCI slave images* -No distinction on SUP/USR and PGM/DATA AM codes* RETURNS: OK, or ERROR if the address space is unknown or the mapping is not* possible.** SEE ALSO: sysLocalToBusAdrs()*/STATUS sysBusToLocalAdrs    (

⌨️ 快捷键说明

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