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

📄 syswindml.c

📁 vxworks bsp for pc pentium3 开发环境为tornado2.2 for pentium。
💻 C
📖 第 1 页 / 共 3 页
字号:
/* sysWindML.c - WindML BSP specific routines  *//* Copyright 2002 Wind River Systems, Inc. *//*modification history--------------------01f,29may02,pai  Added special-case device discovery for Epson display                 devices.  All memory BARs are now mapped as uncacheable.                 Corrected use of <instance> variables in sysWindMLDevGet()                 and sysWindMlPciInit().01e,17may02,pai  Add PCI device discovery and initialization routines.01d,02nov01,pai  Removed const pointers in API for backward compatibility.                 Removed the #include of copyright_wrs, as this file picks                 up that defintion by virtue of inclusion in sysLib.01c,04oct01,pai  Replaced pciConfigInByte() PCI_CFG_DEV_INT_PIN parameter with                 PCI_CFG_DEV_INT_LINE.  Removed CPU_FAMILY conditional                 compilation block.  Funtion name typo corrected.                 Removed const pointers in API for backward compatibility.01b,29aug01,jlb  added base address 5 and 6, and pci membase to devCtrl01a,23may01,jlb  written*//*DESCRIPTIONThis library provides board-specific routines to support WindML.  This API is designed in a general fashion, such that it is applicable to allprocessor types and is bus independent.  It provides the support equally forgraphics devices that are integral to a processor (such as with the PPC823) and graphics devices that are present on a PCI bus.The API provides support for configurations where a system has multiplegraphics devices and input devices.A data structure allocated within the BSP provides information describing the graphics, input (keyboard and pointer), and audio devices.  A serial pointerthat connects to a standard serial port (such as, /tyCo/0) is not covered bythis API.  Those devices use the standard serial drivers.The data structure to define the graphics device is as follows:\cs typedef struct windml_device     {     UINT32        vendorID,        /@ PCI vendor ID @/     UINT32        deviceID,        /@ PCI device ID @/     UINT32        instance,        /@ device instance @/     UINT32        devType,         /@ WindML device type @/     UINT32        busType;         /@ bus type @/     UINT32        regDelta;        /@ distance between adjacent registers @/     UINT32        intLevel;        /@ device interrupt level @/     VOIDFUNCPTR * intVector;       /@ device interrupt vector @/     void *        pPhysBaseAdrs0;  /@ PCI base address 0 @/     void *        pPhysBaseAdrs1;  /@ PCI base address 1 @/     void *        pPhysBaseAdrs2;  /@ PCI base address 2 @/     void *        pPhysBaseAdrs3;  /@ PCI base address 3 @/     void *        pPhysBaseAdrs4;  /@ PCI base address 4 @/     void *        pPhysBaseAdrs5;  /@ PCI base address 5 @/     void *        pRegBase;        /@ register space base address @/     } WINDML_DEVICE;\ceThe <vendorID> and the <deviceID> are based upon the PCI bus identifiers.  Inthis case, these identifiers are extended to include the mapping for non-PCIdevices.  The file sysWindML.h provides the identifier for supported vendorand device identifiers. The above structure provides space for up to four memory segments that areused to access the device (for example, one segment for the frame bufferand another for the memory mapped registers).  Typically, a device will only have a single memory segment.  The size field identifies the numberof bytes present within the memory segment.The <pRegBase> field identifies the base address to use to access theI/O ports.  This is typically the base of the ISA space.  For X86 typeprocessors, this field would be set to 0.  For powerPC processors, thisfield would be set according to the memory model used (PRep or CHRP).INCLUDE FILES: sysWindML.h*//* includes */#include <vxWorks.h>#include <memPartLib.h>#include <ugl/sysWindML.h>#include <drv/pci/pciConfigLib.h>#include "config.h"/* defines */#define FRAME_BUFF_ADDR_VGA  ((void *)(0xa0000))  /* default VGA frame buffer */#define WINDML_MAX_DEV       (32)/* local configuration options */#undef  SYS_WINDML_PCI_SHOW#define SYS_WINDML_STATIC_MEM_POOL#ifdef    SYS_WINDML_STATIC_MEM_POOL#include <bufLib.h>LOCAL BUF_POOL        windMlBufPool;LOCAL WINDML_DEVICE   windMlDevPool  [WINDML_MAX_DEV];#endif /* SYS_WINDML_STATIC_MEM_POOL *//* locals *//* store handles to allocated WINDML_DEVICE PCI device instances */LOCAL WINDML_DEVICE * pciDisplayDevs [WINDML_MAX_DEV];LOCAL WINDML_DEVICE * pciMmAudioDevs [WINDML_MAX_DEV];/* specifies the number of allocated WINDML_DEVICE PCI device instances */LOCAL int pciDisplayDevNo = 0;LOCAL int pciMmAudioDevNo = 0;/* imports */IMPORT STATUS sysMmuMapAdd (void *, UINT, UINT, UINT);IMPORT int    ffsLsb (UINT32);/* forward declarations */LOCAL STATUS sysWindMlPciDevMap (WINDML_DEVICE *, UINT32, UINT32, UINT32);LOCAL STATUS sysWindMlPciInit (UINT32, UINT32, UINT32, void *);/********************************************************************************* sysWindMlDescAlloc - allocate a WINDML_DEVICE descriptor** This routine allocates a WINDML_DEVICE descriptor from a memory pool for* use by the system.** INTERNAL* This interface facilitates changing the underlying implementation to suit* system requirements.  The current implementation uses a simple static pool* of WINDML_DEVICE descriptors.  This makes it safe to use from sysHwInit().* However, future versions may require allocation out of the system memory* partition (kernel heap in AE) or a dedicated non-system memory partition.** RETURNS: A pointer to the allocated descriptor, or a null pointer if* there is an error.** NOMANUAL*/__inline__ static WINDML_DEVICE * sysWindMlDescAlloc (void)    {#ifdef SYS_WINDML_STATIC_MEM_POOL    return (WINDML_DEVICE *) bufAlloc (&windMlBufPool);#else    return (WINDML_DEVICE *) KHEAP_ALLOC (sizeof (WINDML_DEVICE));#endif /* SYS_WINDML_STATIC_MEM_POOL */    }/********************************************************************************* sysWindMlDescFree - free a WINDML_DEVICE descriptor** This routine releases a previously allocated WINDML_DEVICE descriptor* back to the memory pool from which it was allocated via a call to* sysWindMlDescAlloc().** INTERNAL* This interface facilitates changing the underlying implementation to suit* system requirements.  The current implementation uses a simple static pool* of WINDML_DEVICE descriptors.  This makes it safe to use from sysHwInit().* However, future versions may require allocation out of the system memory* partition (kernel heap in AE) or a dedicated non-system memory partition.** RETURNS: N/A** NOMANUAL*/__inline__ static void sysWindMlDescFree    (    WINDML_DEVICE * pWindMlDev    /* pointer to the descriptor to free */    )    {#ifdef SYS_WINDML_STATIC_MEM_POOL    bufFree (&windMlBufPool, (char *) pWindMlDev);#else    KHEAP_FREE ((char *) pWindMlDev);#endif /* SYS_WINDML_STATIC_MEM_POOL */    }/********************************************************************************* sysWindMLDevGet - configures the device** This routine will determine the presence of a specified WindML <devType>* device and perform any device configuration required.  The behavior of* this function varies depending on the type of device configuration (such* as a PCI device, integral, device controller, etc.).  A device* configuration data structure of type WINDML_DEVICE is created for the* specified device.  This configuration data defines, among other things,* the access mechanism for the device.    ** The <vendorID> and <deviceID> identify the vendor and device identifiers* in the PCI environment.  In the case of non-PCI type devices, these* identifiers provide identifiers of the device outside of the range of PCI* identifiers.  If these values are set to zero, then the <instance>* occurrence of a <devType> device will be returned.* * The returned data structure provides miscellaneous data items that* describe the manner in which to access the device.  ** RETURNS:* The address of a WINDML_DEVICE descriptor, else NULL when a device* configuration cannot be obtained.*/WINDML_DEVICE * sysWindMLDevGet     (    UINT32     devType,     /* WindML device type */    UINT32     instance,    /* instance of WindML device type */    UINT32     vendorID,    /* the PCI Vendor ID for the device */    UINT32     deviceID     /* the PCI Device ID for the device */    )    {    LOCAL BOOL vgaCreated = FALSE;    WINDML_DEVICE * pDev  = NULL;    switch (devType)        {        case WINDML_GRAPHICS_DEVICE:            {            if ((vendorID == 0) && (deviceID == 0))                {                /* If there are no PCI display class devices, create one                 * VGA device (i80X86/PentiumX processor families only).                 */                if (pciDisplayDevNo == 0)                    {                    if ((vgaCreated == FALSE) &&                        ((pDev = sysWindMlDescAlloc ()) != NULL))                        {                        bzero ((char *) pDev, sizeof (WINDML_DEVICE));                         pDev->vendorID       = VENDOR_GENERIC_VGA;                        pDev->deviceID       = DEVICE_VGA;                        pDev->instance       = instance;                        pDev->devType        = devType;                        pDev->pPhysBaseAdrs0 = FRAME_BUFF_ADDR_VGA;                        pDev->regDelta       = 0;                        pDev->intLevel       = 0;                        pDev->intVector      = NULL;                        pDev->pRegBase       = 0;                        vgaCreated           = TRUE;                        }                    }                else if ((instance >= 0) && (instance < pciDisplayDevNo))                    {                    return (pciDisplayDevs[instance]);                    }                 return (pDev);                }            else if (deviceID == 0)                {                /* Find the specified <instance> of the specified PCI                 * <vendorID> value.                 */                int i;                for (i = 0; i < pciDisplayDevNo; ++i)                    {                    if (((pciDisplayDevs[i])->vendorID == vendorID) &&                        (instance-- == 0))                        {                        return (pciDisplayDevs[i]);                        }                    }                }            else                {                /* Find the specified <instance> of the specified PCI                 * <vendorID> and <deviceID> values.                 */                int i;                for (i = 0; i < pciDisplayDevNo; ++i)                    {                    if (((pciDisplayDevs[i])->vendorID == vendorID) &&                        ((pciDisplayDevs[i])->deviceID == deviceID) &&                        (instance-- == 0))                        {                        return (pciDisplayDevs[i]);                        }                    }                }            break;            }        case WINDML_KEYBOARD_DEVICE:            {            if ((pDev = sysWindMlDescAlloc ()) != NULL)                {                bzero ((char *) pDev, sizeof (WINDML_DEVICE));                pDev->instance  = instance;                pDev->devType   = devType;                pDev->regDelta  = 4;                pDev->intLevel  = KBD_INT_LVL;                pDev->intVector = (VOIDFUNCPTR *)                                  (INUM_TO_IVEC (INT_NUM_GET (KBD_INT_LVL)));                pDev->pRegBase  = (void *)(DATA_8042);                }            return (pDev);            }        case WINDML_POINTER_DEVICE :            {            if ((pDev = sysWindMlDescAlloc ()) != NULL)                {                bzero ((char *) pDev, sizeof (WINDML_DEVICE));                pDev->instance  = instance;                pDev->devType   = devType;                pDev->regDelta  = 4;                pDev->intLevel  = MSE_INT_LVL;                pDev->intVector = (VOIDFUNCPTR *)                                  (INUM_TO_IVEC (INT_NUM_GET (MSE_INT_LVL)));                pDev->pRegBase  = (void *)(DATA_8042);                }            return (pDev);            }

⌨️ 快捷键说明

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