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

📄 universe_dy4.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
            (((UINT32)vmeWindowSize % RESOLUTION64k)!=0) ||            (((UINT32)localBaseAdrs % RESOLUTION64k)!=0)           )        {            /* Illegal windows resolution */            return (ERROR);        }    }    if ((attributes & VME_SLV_CTL_VAS_MSK) == VME_SLV_CTL_A32)    {        /* vme window boundary in A32 mode should not exceed 4Gig (check for overflow)*/        if ((((UINT32)vmeBaseAdrs+vmeWindowSize) < (UINT32)vmeBaseAdrs)  ||            (((UINT32)localBaseAdrs+vmeWindowSize) < (UINT32)localBaseAdrs))        {            /* A32 window to large */            return (ERROR);        }    }    if ((attributes & VME_SLV_CTL_VAS_MSK) == VME_SLV_CTL_A24)     {        /* vme window boundary in A24 mode should not exceed 64K or should not overflow top of memory*/        if ((((UINT32)vmeBaseAdrs+vmeWindowSize) > A24ADRSRANGE) ||            (((UINT32)localBaseAdrs+vmeWindowSize) < (UINT32)localBaseAdrs))        {            /* A24 window to large */             return (ERROR);        }    }    /* Validate parameters for A16 mode */    if ((attributes & VME_SLV_CTL_VAS_MSK) == VME_SLV_CTL_A16)    {        /* A16 mode is only supported for window 0 and 4 */        if ((image != UNIVERSE_VSI0) && (image != UNIVERSE_VSI4))        {           /* A16 Incompatible image */            return (ERROR);        }        /* vme window boundary in A16 mode should not exceed 64K or should not overflow top of memory*/        if ((((UINT32)vmeBaseAdrs+vmeWindowSize) > A16ADRSRANGE) ||            (((UINT32)localBaseAdrs+vmeWindowSize) < (UINT32)localBaseAdrs))        {            /* A16 window to large */            return (ERROR);        }    }    /* Check for valid PGM and SUPER attribute code */    if (((attributes & VME_SLV_CTL_PGM_MSK) == 0) || ((attributes & VME_SLV_CTL_SUP_MSK) == 0))    {        /* Illegal PGM or SUPER attribute */        return (ERROR);    }    lock = intLock();    /* Set the slave window has requested */    /* Setting control bit for PCI memory space */    attributes &= ~VME_SLV_CTL_LAS_MSK;    attributes |= VME_SLV_CTL_MEM | VME_SLV_CTL_EN;    vmeData->sysVmeSlaveDesc[image].vmeBase    = vmeBaseAdrs;    vmeData->sysVmeSlaveDesc[image].size       = vmeWindowSize;    vmeData->sysVmeSlaveDesc[image].localAdrs  = localBaseAdrs;    vmeData->sysVmeSlaveDesc[image].attributes = attributes;    /* first disable the image */    *(vmeData->sysVmeSlaveDesc[image].ctl) = 0;    /* Update the hardware with the new setup */    *(vmeData->sysVmeSlaveDesc[image].bs)  = LONGSWAP((UINT32)vmeBaseAdrs);    *(vmeData->sysVmeSlaveDesc[image].bd)  = LONGSWAP((UINT32)vmeBaseAdrs + (UINT32)vmeWindowSize);    *(vmeData->sysVmeSlaveDesc[image].to)  = LONGSWAP((UINT32)localBaseAdrs- (UINT32)vmeBaseAdrs);    *(vmeData->sysVmeSlaveDesc[image].ctl) = LONGSWAP(attributes);    intUnlock(lock);    return (OK);#endif}/********************************************************************************* sysVmeSlaveRegSet - set VME special master image** This routine configures a special master images (PCI slave or outbound) with the given input.** RETURNS: N/A** NOMANUAL*/STATUS sysVmeSpeMstrSet    (    UINT32    attributes    ){#ifndef CPU0_IMAGE    return(ERROR);#else    UINT32 lock;    /* Is the image to be disabled ? */    if ((attributes & SLSI_EN)== 0)    {        lock=intLock();        /* yes, disable the window */        vmeData->sysPciSlaveSpeDesc.attributes= 0;        vmeData->sysPciSlaveSpeDesc.localAdrs = 0;        *(vmeData->sysPciSlaveSpeDesc.ctl) = 0;        intUnlock(lock);        return (OK);    }    attributes &= ~(SLSI_BS_MASK | SLSI_PCI_IO);    attributes |= (SLSI_EN |                    DEFAULT_SLSI_BS |                    (vmeData->pciVmeMemSpace ? SLSI_PCI_MEM : SLSI_PCI_IO));    lock=intLock();    vmeData->sysPciSlaveSpeDesc.attributes = attributes;                                                vmeData->sysPciSlaveSpeDesc.localAdrs  = (char*)(CPU_PCI_SLSI_BASE);    *(vmeData->sysPciSlaveSpeDesc.ctl)     = LONGSWAP(vmeData->sysPciSlaveSpeDesc.attributes);    intUnlock(lock);    return (OK);#endif;}/********************************************************************************* sysVmeMstrSet - set VME Master images** This routine configures VME Master images (PCI Slave or outbound) with the given input.** Note: the resolution for images 0 and 4 are 4k and are the only images* available for A16 images. All other images have a resolution of 64K.** NOMANUAL*/STATUS sysVmeMstrSet    ( 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 */      ){#ifndef CPU0_IMAGE    return(ERROR);#else    char* localBaseAdrs=NULL;    UINT32 lock;    /* Validate all parameters */    /* Windows 0 to 7 only*/    if ((image < UNIVERSE_LSI0) || (image > UNIVERSE_LSI7))    {        if (localAdrs != NULL)        {            *localAdrs = NULL;        }        return (ERROR);    }    /* Is the image to be disabled ? */    if ((attributes & VME_CTL_EN) == 0)    {        /* if the window is currently enabled, disable it */        if (vmeData->sysPciSlaveDesc[image].attributes & VME_CTL_EN)        {            lock=intLock();            /* disable the window */            localBaseAdrs= vmeData->sysPciSlaveDesc[image].localAdrs;            vmeData->sysPciSlaveDesc[image].attributes = 0;            vmeData->sysPciSlaveDesc[image].vmeBase    = 0;            vmeData->sysPciSlaveDesc[image].size       = 0;            vmeData->sysPciSlaveDesc[image].localAdrs  = 0;            *(vmeData->sysPciSlaveDesc[image].ctl) = 0;            *(vmeData->sysPciSlaveDesc[image].bs)  = 0;            *(vmeData->sysPciSlaveDesc[image].bd)  = 0;            *(vmeData->sysPciSlaveDesc[image].to)  = 0;            /* Return used up VME PCI space to pool */            if (vmePciSpaceFree(localBaseAdrs) == ERROR)            {                /* FATAL error, block not previously allocated */                if (localAdrs != NULL)                {                    *localAdrs = NULL;                }                intUnlock(lock);                return (ERROR);            }            intUnlock(lock);        }        return (OK);    }    if (vmeWindowSize == 0)    {        /* VME window size must be > 0 */        if (localAdrs != NULL)        {            *localAdrs = NULL;        }        return (ERROR);    }    if ((attributes & VME_CTL_VAS_MSK) == VME_CTL_A32)    {        /* vme window boundary in A32 mode should not exceed 4Gig (check for overflow)*/        if (((UINT32)vmeWindowBase+vmeWindowSize) < (UINT32)vmeWindowBase)        {            /* A32 window to large */            if (localAdrs != NULL)            {                *localAdrs = NULL;            }            return (ERROR);        }    }    if ((attributes & VME_CTL_VAS_MSK) == VME_CTL_A24)     {        /* vme window boundary in A24 mode should not exceed 64K */        if (((UINT32)vmeWindowBase+vmeWindowSize) > 0x01000000)        {            /* A24 window to large */            if (localAdrs != NULL)            {                *localAdrs = NULL;            }            return (ERROR);        }    }    /* Validate parameters for A16 mode */    if ((attributes & VME_CTL_VAS_MSK) == VME_CTL_A16)    {        /* A16 mode is only supported for window 0 and 4 */        if ((image != UNIVERSE_LSI0) && (image != UNIVERSE_LSI4))        {            /* A16 Incompatible image */            if (localAdrs != NULL)            {                *localAdrs = NULL;            }            return (ERROR);        }        /* vme window boundary in A16 mode should not exceed 64K */        if (((UINT32)vmeWindowBase+vmeWindowSize) > 0x00010000)        {            /* A16 window to large */            if (localAdrs != NULL)            {                *localAdrs = NULL;            }            return (ERROR);        }    }    /* Address and size resolution is 4K for windows 0 and 4, 64 K for other*/    if ((image != UNIVERSE_LSI0) || (image != UNIVERSE_LSI4))     {        if ((((UINT32)vmeWindowBase % 0x1000)!=0) ||            (((UINT32)vmeWindowSize % 0x1000)!=0)           )        {            /* Illegal windows resolution */            if (localAdrs != NULL)            {                *localAdrs = NULL;            }            return (ERROR);        }    }    else    {        if ((((UINT32)vmeWindowBase % 0x10000)!=0) ||            (((UINT32)vmeWindowSize % 0x10000)!=0)           )        {            /* Illegal windows resolution */            if (localAdrs != NULL)            {                *localAdrs = NULL;            }            return (ERROR);        }    }    lock = intLock();    /* All parameters are valid, disable the window if previously        enabled */    if (vmeData->sysPciSlaveDesc[image].attributes & VME_CTL_EN)    {        /* disable the window */        localBaseAdrs= vmeData->sysPciSlaveDesc[image].localAdrs;        vmeData->sysPciSlaveDesc[image].attributes = 0;        vmeData->sysPciSlaveDesc[image].vmeBase    = 0;        vmeData->sysPciSlaveDesc[image].size       = 0;        vmeData->sysPciSlaveDesc[image].localAdrs  = 0;        *(vmeData->sysPciSlaveDesc[image].ctl) = 0;        *(vmeData->sysPciSlaveDesc[image].bs)  = 0;        *(vmeData->sysPciSlaveDesc[image].bd)  = 0;        *(vmeData->sysPciSlaveDesc[image].to)  = 0;        /* Return used up VME PCI space to pool */        if (vmePciSpaceFree(localBaseAdrs) == ERROR)        {            /* FATAL error, block not previously allocated */            intUnlock(lock);            if (localAdrs != NULL)            {                *localAdrs = NULL;            }            return (ERROR);        }    }    /* Get VME PCI space for this window */       localBaseAdrs=vmePciSpaceAlloc(vmeWindowSize);    if (localBaseAdrs == NULL)    {        /* Not enough PCI space available for this window */        intUnlock(lock);        return(ERROR);    }    /* Set the slave window has requested */    /* Setting control bit for PCI memory space */    attributes &= ~VME_CTL_LAS_MSK;    attributes |= ((vmeData->pciVmeMemSpace ? VME_CTL_PCI_MEM : VME_CTL_PCI_IO) |                    VME_CTL_EN);    vmeData->sysPciSlaveDesc[image].vmeBase    = vmeWindowBase;    vmeData->sysPciSlaveDesc[image].size       = vmeWindowSize;    vmeData->sysPciSlaveDesc[image].localAdrs  = localBaseAdrs;    vmeData->sysPciSlaveDesc[image].attributes = attributes;    /* first disable the image */    *(vmeData->sysPciSlaveDesc[image].ctl) = 0;    /* Update the hardware with the new setup */    *(vmeData->sysPciSlaveDesc[image].bs)  = LONGSWAP((UINT32)localBaseAdrs);    *(vmeData->sysPciSlaveDesc[image].bd)  = LONGSWAP((UINT32)localBaseAdrs + vmeWindowSize);    *(vmeData->sysPciSlaveDesc[image].to)  = LONGSWAP((UINT32)vmeWindowBase-(UINT32)localBaseAdrs);    *(vmeData->sysPciSlaveDesc[image].ctl) = LONGSWAP(attributes);    intUnlock(lock);    /* if a valid pointer was passed, return the local address */    if (localAdrs != NULL)    {        *localAdrs = localBaseAdrs;    }    return (OK);#endif}/******************************************************************************** vmeFindBusAdrs - determine the bus address corresponding to a local adrs** This private 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. The mask and value passed to this routine* are used to compare with slave window control attributes.** RETURNS: OK, or ERROR if the address space is unknown or the mapping is not* possible.** SEE ALSO: sysBusToLocalAdrs()*/LOCAL STATUS vmeFindBusAdrs(                                UINT32  mask,       /* Control register mask */                                UINT32  value,      /* Control register expected value */                                char *  localAdrs,  /* local address to convert */                                char ** pBusAdrs    /* where to return bus address */                            ){    UINT32 image;    /* return bus address variable should not point to NULL */    if (pBusAdrs == NULL)    {

⌨️ 快捷键说明

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