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

📄 syswindml.c

📁 cpc-1631的BSP包for VxWorks操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/* sysWindML.c - WindML BSP specific routines  */

/* Copyright 2001 Wind River Systems, Inc. */

#include "copyright_wrs.h"
/*
modification history
--------------------
01d,04dec01,jnz  added common device settings for sandpoint BSPs
01c,03dec01,jnz  modified for sandpoint BSPs
01b,29aug01,jlb  added base address 5 and 6, and pci membase to devCtrl
01a,23may01,jlb  written
*/

/* includes */

#include "vxWorks.h"
#include "memLib.h"
#include "ugl/sysWindML.h"
#include "config.h"
#include "drv/pci/pciConfigLib.h"

/*
DESCRIPTION

This library provides board-specific routines to support WindML.  This file is 
included at the end of sysLib.c when WindML functionality is to be included.

This API is designed in a general fashion, such that it is applicable to all
processor types and is bus independent.  It provides the support equally for
graphics 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 multiple graphics
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 pointer
that connects to a standard serial port (such as, /tyCo/0) is not covered by
this API.  Those devices use the standard serial drivers.

The data structure to define the graphics device is as follows:

\cs
 typedef struct windml_device
     {
    unsigned int        vendorID;  /@ vendor ID @/
    unsigned int        deviceID;  /@ device ID @/
    unsigned int        instance;  /@ instance of device @/
    unsigned int        devType;   /@ type of input device @/
    unsigned int        busType;   /@ type of bus @/
    unsigned int        regDelta;  /@ distance between adjacent registers @/
    unsigned int        intLevel;  /@ interrupt level to be used @/
    void        (** intVector)();  /@ interrupt vector @/ 
    void *      pPhysBaseAdrs0;    /@ first base address @/
    void *      pPhysBaseAdrs1;    /@ second base address @/
    void *      pPhysBaseAdrs2;    /@ third base address @/
    void *      pPhysBaseAdrs3;    /@ fourth base address @/
    void *      pPhysBaseAdrs4;    /@ fifth base address @/
    void *      pPhysBaseAdrs5;    /@ sixth base address @/
    void *      pRegBase;          /@ base address of legacy register space @/
     } WINDML_DEVICE;
\ce

 The <vendorID> and the <deviceID> are based upon the PCI bus identifiers.  In
 this case, these identifiers are extended to include the mapping for non-PCI
 devices.  The file sysWindML.h provides the identifier for supported vendor
 and device identifiers.
 
 The above structure supports devices with up to six base addresses used
 to access the device (for example, one base address for the frame buffer
 and another for the memory mapped registers).  Typically, a device 
 will only have a base address.  The <pPhysBaseAdrsX> may need to be interpreted
 based upon the busType (for example, the <pPhysBaseAdrsX> value is directly
 obtained from the PCI header which includes flag bits unrelated to the address
 value).

 The <pRegBase> field identifies the base address to use to access the I/O ports.
 This is typically the base of the ISA space.  For X86 type processors, this
 field would be set to 0.  For powerPC processors, this field would be set 
 according to the memory model used (PReP or CHRP).  The <regDelta> value only
 applies to this legacy register space.

INCLUDE FILES: ugl/sysWindML.h
*/

#ifndef KHEAP_ALLOC
#   define KHEAP_ALLOC malloc
#endif /* KHEAP_ALLOC */
#ifndef KHEAP_FREE
#   define KHEAP_FREE free
#endif /* KHEAP_FREE */

/* SP common defines */
#define KBD_INT_LVL      (0x01 + INT_NUM_IRQ0)   /* keyboard interrupt level  */
#define KBD_INT_VEC      (0x01 + INT_VEC_IRQ0)   /* keyboard interrupt vector */
#define MSE_INT_LVL      (0x0C + INT_NUM_IRQ0)   /* mouse interrupt level  */
#define MSE_INT_VEC      (0x0C + INT_VEC_IRQ0)   /* mouse interrupt vector */
#define DATA_8042        PCI_MSTR_ISA_IO_LOCAL + 0x60/*SUPER_IO_KBC_BASE_ADR*/   /* kbd/mse ctrl register base */
#define INT_VEC_GET(x)   (x+INT_VEC_IRQ0)                 /* intVector via intLine/intLevel */


/*******************************************************************************
*
* sysWindMLDevGet - configures the device
*
* This routine will determine the presence of the device and perform any device 
* configuration required.  The behaviour 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 is created for the 
* specified device.  This configuration data defines 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 device will be returned.  For example, if the <instance>
* and <vendorID> were set to zero, then the routine will return the first
* occurrence of a device.
* 
* The returned data structure provides miscellaneous data items that describe 
* the manner in which to access the device.  
*
* RETURNS:
* When device has been successfully configured, the address of the
* device data structure; otherwise NULL
*/

WINDML_DEVICE * sysWindMLDevGet 
    (
    UINT32 devType,     /* Device Type */
    UINT32 instance,    /* The instance of the device */
    UINT32 vendorID,    /* The identifier for the device manufacturer */
    UINT32 deviceID     /* The identifier for the device */
    )
    {

    WINDML_DEVICE * pDev = NULL;

#ifdef INCLUDE_PCI
    int busno;
    int devno;
    int funcno;

    UINT16 data;
    UINT32 bar = 0;
    UINT8  intLine;
#endif

    switch (devType)
        {
#ifdef INCLUDE_PCI
        case WINDML_GRAPHICS_DEVICE:
            {

            if (vendorID == 0 || deviceID == 0)
                {
                /* Specific deice not specified, probe for nearest graphics type */
                for (; ; instance++)
                    {
                    int pciClass = PCI_CLASS_DISPLAY_CTLR << 16;

                    if (pciFindClass (pciClass, instance, &busno, &devno, &funcno) != OK)
                        {
                        /* End of PCI type devices.  Create a VGA device for X86,
                         * only processor family where VGA is supported
                         */
                        return(pDev);
                        }
                    
                    if (pciConfigInWord (busno, devno, funcno, PCI_CFG_VENDOR_ID, &data) != OK)
                        return(pDev);
                    
                    if (vendorID != 0) 
                        {
                        /* No match, find next graphics type */
                        if (vendorID != data) 
                            continue;
                        }
                    vendorID = data;
                    
                    if (pciConfigInWord (busno, devno, funcno, PCI_CFG_DEVICE_ID, &data) != OK)
                        return(pDev);
                    
                    deviceID = data;
                    break;
                    }
                } 
            else
                {
                if (pciFindDevice (vendorID, deviceID, instance, &busno, &devno, &funcno) != OK)
                    return(pDev);
                }

            pDev = (WINDML_DEVICE *)KHEAP_ALLOC(sizeof(WINDML_DEVICE));
            bzero ((char *)pDev,sizeof(WINDML_DEVICE));
            if (pDev == NULL)
                return(pDev);

            /* board autoconfig'd - extract base address from config space */

            pDev->vendorID = vendorID;
            pDev->deviceID = deviceID;
            pDev->instance = instance;
            pDev->devType = devType;
            pDev->busType = BUS_TYPE_PCI;

            /* get base addresses and amount of memory needed */
            pciConfigInLong (busno, devno, funcno, PCI_CFG_BASE_ADDRESS_0, &bar);
            pDev->pPhysBaseAdrs0 = (void *) bar;
            pciConfigInLong (busno, devno, funcno, PCI_CFG_BASE_ADDRESS_1, &bar);
            pDev->pPhysBaseAdrs1 = (void *) bar;
            pciConfigInLong (busno, devno, funcno, PCI_CFG_BASE_ADDRESS_2, &bar);
            pDev->pPhysBaseAdrs2 = (void *) bar;
            pciConfigInLong (busno, devno, funcno, PCI_CFG_BASE_ADDRESS_3, &bar);
            pDev->pPhysBaseAdrs3 = (void *) bar;
            pciConfigInLong (busno, devno, funcno, PCI_CFG_BASE_ADDRESS_4, &bar);
            pDev->pPhysBaseAdrs4 = (void *) bar;
            pciConfigInLong (busno, devno, funcno, PCI_CFG_BASE_ADDRESS_5, &bar);
            pDev->pPhysBaseAdrs5 = (void *) bar;
            pciConfigInByte (busno, devno, funcno, PCI_CFG_DEV_INT_PIN, &intLine);

            pDev->intLevel = intLine;
            pDev->intVector = (void *)(INT_VEC_GET(intLine));
            pDev->pRegBase = (void *)PCI_MSTR_ISA_IO_LOCAL;

            break;
            }
#endif /* INCLUDE_PCI */

        case WINDML_KEYBOARD_DEVICE:
            {
            pDev = (WINDML_DEVICE *)KHEAP_ALLOC(sizeof(WINDML_DEVICE));
            bzero ((char *)pDev,sizeof(WINDML_DEVICE));
            if (pDev == NULL)
                return(pDev);

            pDev->devType = devType;
            pDev->regDelta = 4;
            pDev->intLevel = KBD_INT_LVL;
            pDev->intVector = (VOIDFUNCPTR *)INUM_TO_IVEC(KBD_INT_VEC);
            pDev->pRegBase = (void *)DATA_8042;

            break;
            }

        case WINDML_POINTER_DEVICE :
            {
            pDev = (WINDML_DEVICE *)KHEAP_ALLOC(sizeof(WINDML_DEVICE));
            bzero ((char *)pDev,sizeof(WINDML_DEVICE));
            if (pDev == NULL)
                return (pDev);

            pDev->devType = devType;
            pDev->regDelta = 4;
            pDev->intLevel = MSE_INT_LVL;
            pDev->intVector = (VOIDFUNCPTR *)INUM_TO_IVEC(MSE_INT_VEC);
            pDev->pRegBase = (void *)DATA_8042;

            break;
            }

#ifdef INCLUDE_PCI
        case WINDML_AUDIO_DEVICE:
            {

            if (vendorID == 0 || deviceID == 0)
                {
                int pciClass = (PCI_CLASS_MMEDIA_DEVICE << 16) |
                               (PCI_SUBCLASS_MMEDIA_AUDIO << 8);
                if (pciFindClass (pciClass, instance, &busno, &devno, &funcno) != OK)
                    return(pDev);

⌨️ 快捷键说明

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