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

📄 syswindml.c

📁 VMware上运行vxWorks的BSP
💻 C
📖 第 1 页 / 共 3 页
字号:
        }    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_2, &barSave);    pDev->pPhysBaseAdrs2 = (void *) barSave;    pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_2, 0xffffffff);    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_2, &barRead);    if (barRead != 0)        {        pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_2, barSave);        if ((barRead & PCI_BASE_IO) != PCI_BAR_SPACE_IO)            {            barSave  &= PCI_MEMBASE_MASK;            barRead  &= PCI_MEMBASE_MASK;            if (sysMmuMapAdd ((void *) barSave, (1 << (ffsLsb (barRead) - 1)),                VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO) == ERROR)                {                retVal = ERROR;                goto WINDML_MAP_DEV_RETURN;                }            }        }    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_3, &barSave);    pDev->pPhysBaseAdrs3 = (void *) barSave;    pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_3, 0xffffffff);    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_3, &barRead);    if (barRead != 0)        {        pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_3, barSave);        if ((barRead & PCI_BASE_IO) != PCI_BAR_SPACE_IO)            {            barSave  &= PCI_MEMBASE_MASK;            barRead  &= PCI_MEMBASE_MASK;            if (sysMmuMapAdd ((void *) barSave, (1 << (ffsLsb (barRead) - 1)),                VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO) == ERROR)                {                retVal = ERROR;                goto WINDML_MAP_DEV_RETURN;                }            }        }    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_4, &barSave);    pDev->pPhysBaseAdrs4 = (void *) barSave;    pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_4, 0xffffffff);    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_4, &barRead);    if (barRead != 0)        {        pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_4, barSave);        if ((barRead & PCI_BASE_IO) != PCI_BAR_SPACE_IO)            {            barSave  &= PCI_MEMBASE_MASK;            barRead  &= PCI_MEMBASE_MASK;            if (sysMmuMapAdd ((void *) barSave, (1 << (ffsLsb (barRead) - 1)),                VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO) == ERROR)                {                retVal = ERROR;                goto WINDML_MAP_DEV_RETURN;                }            }        }    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_5, &barSave);    pDev->pPhysBaseAdrs5 = (void *) barSave;    pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_5, 0xffffffff);    pciConfigInLong  (bus, dev, func, PCI_CFG_BASE_ADDRESS_5, &barRead);    if (barRead != 0)        {        pciConfigOutLong (bus, dev, func, PCI_CFG_BASE_ADDRESS_5, barSave);        if ((barRead & PCI_BASE_IO) != PCI_BAR_SPACE_IO)            {            barSave  &= PCI_MEMBASE_MASK;            barRead  &= PCI_MEMBASE_MASK;            if (sysMmuMapAdd ((void *) barSave, (1 << (ffsLsb (barRead) - 1)),                VM_STATE_MASK_FOR_ALL, VM_STATE_FOR_IO) == ERROR)                {                retVal = ERROR;                }            }        }WINDML_MAP_DEV_RETURN:    /* restore PCI device command word register */    pciConfigOutWord (bus, dev, func, PCI_CFG_COMMAND, cmdSave);    return retVal;    }/********************************************************************************* sysWindMlPciInit - initialize PCI display devices** This routine allocates and initializes WINDML_DEVICE descriptors for PCI* display and multimedia class devices.  The interface is constructed such* that this function can be invoked via pciConfigForeachFunc().** For each PCI device specified by the <bus>, <dev>, and <func> parameters,* this routine tests the 24-bit PCI class code value (class/subclass/prog_if).* If WindML supports the specified function, a WINDML_DEVICE descriptor will* be allocated and initialzed with the device attributes.  Memory regions of* the required location, size, and type will be mapped into the host* processor's address space for functions implementing memory decoders.** The <devType> field of a new WINDML_DEVICE descriptor will be set to* one of the following constants indicating the WindML device type:** \is* \i WINDML_GRAPHICS_DEVICE*        All PCI display controller class devices.** \i WINDML_AUDIO_DEVICE*        All PCI multimedia class and audio sub-class devices.* \ie** INTERNAL* This callback will terminate pciConfigForeachFunc() if it returns ERROR.* So, this routine returns OK always such that a failure to config one* device will not prevent attempts to initialize other devices.** This routine could be extended to create and configure WINDML_DEVICE* descriptors for mouse and keyboard input PCI device classes.** WindML supports an Epson display device which does not identify the* device function in the PCI class code register.  Specifically, the class* code register is set to 0xff which, according to the PCI spec, should be* used when the device does not fit any of the defined class codes.  These* special-case Epson display devices are identified by their PCI Device ID,* 0x1300, along with the Epson PCI Vendor ID.** In the case of PCI devices, the <instance> field in a WINDML_DEVICE* descriptor specifies the ordinal value of a particular kind of device, as* specified by PCI Vendor and device IDs, installed on the system.** RETURNS: OK always.** NOMANUAL*/LOCAL STATUS sysWindMlPciInit    (    UINT32     bus,              /* store a PCI bus number */    UINT32     dev,              /* store a PCI device number */    UINT32     func,             /* store a PCI function number */    void *     pArg              /* reserved argument */    )    {    UINT32     vendorId;         /* store a PCI vendor ID */    UINT32     deviceId;         /* store a PCI device ID */    UINT32     classCode;        /* store a PCI class code value */    UINT32     subClassCode;     /* store a PCI sub-class code value */    UINT32     devType = NONE;   /* store a WindML device type */    pciConfigInLong (bus, dev, func, PCI_CFG_VENDOR_ID, &vendorId);    deviceId = ((vendorId >> 16) & 0x0000ffff);    vendorId = (vendorId & 0x0000ffff);    pciConfigInLong (bus, dev, func, PCI_CFG_REVISION, &classCode);    subClassCode = (classCode >> 16) & 0x000000ff;    classCode    = (classCode >> 24);    if ((classCode == PCI_CLASS_DISPLAY_CTLR) ||        ((vendorId == VENDOR_PCI_EPSON) &&         (deviceId == DEVICE_ID_EPSON_13XXX)))        {        devType = WINDML_GRAPHICS_DEVICE;        }    else if ((classCode == PCI_CLASS_MMEDIA_DEVICE) &&             (subClassCode == PCI_SUBCLASS_MMEDIA_AUDIO))        {        devType = WINDML_AUDIO_DEVICE;        }    if ((devType == WINDML_GRAPHICS_DEVICE) || (devType == WINDML_AUDIO_DEVICE))        {        UINT8  intLine;       /* store a PCI interrupt line value */        /* allocate a WINDML_DEVICE descriptor for the device */        WINDML_DEVICE * const pDev = sysWindMlDescAlloc ();        if (pDev == NULL)            {            return OK;            }        /* initialize the new WINDML_DEVICE attributes */        bzero ((char *) pDev, sizeof (WINDML_DEVICE));        pDev->vendorID = vendorId;        pDev->deviceID = deviceId;        pDev->devType  = devType;        pDev->busType  = BUS_TYPE_PCI;        pciConfigInByte (bus, dev, func, PCI_CFG_DEV_INT_LINE, &intLine);        pDev->intLevel  = intLine;        pDev->intVector = (VOIDFUNCPTR *)(INUM_TO_IVEC (INT_NUM_GET (intLine)));        /* get base addresses and map into address space */        if (sysWindMlPciDevMap (pDev, bus, dev, func) == ERROR)            {            sysWindMlDescFree (pDev);            return OK;            }        /* initialized the device - move on to the next one */        if (devType == WINDML_GRAPHICS_DEVICE)            {            int i = 0;            int j = 0;            for (; i < pciDisplayDevNo; ++i)                {                if (((pciDisplayDevs[i])->vendorID == vendorId) &&                    ((pciDisplayDevs[i])->deviceID == deviceId))                    ++j;                }            pDev->instance = j;            pciDisplayDevs [pciDisplayDevNo++] = pDev;            }        else if (devType == WINDML_AUDIO_DEVICE)            {            int i = 0;            int j = 0;            for (;i < pciMmAudioDevNo; ++i)                {                if (((pciMmAudioDevs[i])->vendorID == vendorId) &&                    ((pciMmAudioDevs[i])->deviceID == deviceId))                    ++j;                }            pDev->instance = j;            pciMmAudioDevs [pciMmAudioDevNo++] = pDev;            }        return OK;        }    return OK;    }/********************************************************************************* sysWindMLHwInit - Initialize unique multimedia components** This routine initializes specific multimedia hardware devices that* are not normally initialized by the BSP.** RETURNS: OK or ERROR.*/STATUS sysWindMLHwInit ()    {#ifdef    SYS_WINDML_STATIC_MEM_POOL    bufPoolInit (&windMlBufPool, (char *) &windMlDevPool[0],                 WINDML_MAX_DEV, sizeof (WINDML_DEVICE));#endif /* SYS_WINDML_STATIC_MEM_POOL */    /* initialize PCI display controllers starting from Bus 0 */    pciConfigForeachFunc (0, TRUE, (PCI_FOREACH_FUNC) sysWindMlPciInit, NULL);    return (OK);    }#ifdef SYS_WINDML_PCI_SHOW/********************************************************************************* sysWindMlPciShow - show the contents of the PCI device table** This routine prints a formatted detail of the WindML PCI device table* contents to the standard output device.** RETURNS: N/A** NOMANUAL*/void sysWindMlPciShow (void)    {    WINDML_DEVICE const * pDev;    int i;    for (i = 0; i < pciDisplayDevNo; ++i)        {        pDev = pciDisplayDevs[i];        puts ("\n______________");        printf ("\nWINDML_GRAPHICS_DEVICE, instance %d\n", pDev->instance);        printf ("\nPCI Vendor ID 0x%x", pDev->vendorID);        printf ("\nPCI Device ID 0x%x", pDev->deviceID);        printf ("\n\nInterrupt level %u, vector %p\n",                pDev->intLevel, pDev->intVector);        printf ("\n PCI BAR 0 %p", pDev->pPhysBaseAdrs0);        printf ("\n PCI BAR 1 %p", pDev->pPhysBaseAdrs1);        printf ("\n PCI BAR 2 %p", pDev->pPhysBaseAdrs2);        printf ("\n PCI BAR 3 %p", pDev->pPhysBaseAdrs3);        printf ("\n PCI BAR 4 %p", pDev->pPhysBaseAdrs4);        printf ("\n PCI BAR 5 %p", pDev->pPhysBaseAdrs5);        }    for (i = 0; i < pciMmAudioDevNo; ++i)        {        pDev = pciMmAudioDevs[i];        puts ("\n______________");        printf ("\nWINDML_AUDIO_DEVICE, instance %d\n", pDev->instance);        printf ("\nPCI Vendor ID 0x%x", pDev->vendorID);        printf ("\nPCI Device ID 0x%x", pDev->deviceID);        printf ("\n\nInterrupt level %u, vector %p\n",                pDev->intLevel, pDev->intVector);        printf ("\n PCI BAR 0 %p", pDev->pPhysBaseAdrs0);        printf ("\n PCI BAR 1 %p", pDev->pPhysBaseAdrs1);        printf ("\n PCI BAR 2 %p", pDev->pPhysBaseAdrs2);        printf ("\n PCI BAR 3 %p", pDev->pPhysBaseAdrs3);        printf ("\n PCI BAR 4 %p", pDev->pPhysBaseAdrs4);        printf ("\n PCI BAR 5 %p", pDev->pPhysBaseAdrs5);        }    putchar ('\n');    }#endif  /* SYS_WINDML_PCI_SHOW */

⌨️ 快捷键说明

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