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

📄 universe_dy4.c

📁 sbc7410的vxworksbsp
💻 C
📖 第 1 页 / 共 5 页
字号:
/* universe_dy4.c - Tundra Universe chip PCI-VME interface library *//* Copyright 2001-2002 Dy 4 Systems, Inc. *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01j,05Nov02,tis   - updated sysUniverseRest() to disable all VSI and LSI images PT#1271                  - updated sysBusToLocalAdrs() to support the Universe Reg adrs PT#1222                  - updated sysVmeMapShow to display Universe Reg access window PT#1222.                  - updated sysUnivRegShow()to display UnivII Register01i,18apr02,aak   replace printf with logMsg in sysBusIntGen, PT#103201h,05feb02,aak   fix sysLocalToBusAdrs, PT#943                  fix sysUniverseIntr, PT#94801g,25oct01,tis   -fix sysUniverseIntr PT#222 to clear the interrupt after                   processing it.                  -fix sysUniverseIntr PT#663 to solve the lost VME DMA                   problem.                  -Update sysUniverseIntr PT#798 to mask the current interrupt                   level and lower priority interrupts while a higher priority                   interrupt is being processed.                  -Fixed sysBusIntGen PT#786 to check the VINT_STAT status                   register before generating a new interrupt.                  -Added sysUniverseReset PT#800 to reset VENT_STAT and                   LENT_STAT registers upon a warm reboot.                  -Fixed sysBusToLocalAdrs to check if the given VME address                   is local to the current card PT#85801f,08jun2001,tis Fixed sysMailboxInt to pass both data and data and arg PT#57201e,30Jun1999,    Informission Transport code for SVME17901d,07Jan1999,NFH@AMI Added DMA support01c,07may98,jcc   added mailbox support01b,18mar98,jcc   updated for Universe 2; added sysVmeA32MstrSet(),                  sysVmeMapShow(), sysUniverseSlaveImageSet()01a,30jul97,dy4   created from (mv2604/universe.c rev 01f)*//* ------------------------------------------------------------------------ *\    Filename:              $Source: D:\tornadoppc\target\config\dy4179+\src\drv\vme\universe_dy4.c    Current Revision:      $Revision: 1.9 $    Last Updated:          $Date: 1999/06/30 14:01:44 $    Last Modified by:      $Author: DUD Informission $    Currently Locked by:   $Locker:  $    Change History:    $Log: universe.c,v $    Revision 1.9  1999/06/30 14:01:44  DUD Informission    - Transport all functions to SVME-179.    Revision 1.8  1999/01/26 18:59:44  Neil.Hamilton    - Removed the async and mutex semaphores. Mutexes may NOT be      given or taken in an ISR. Use only the original binary semaphore for      both the blocking and non-blocking DMA functions.    Revision 1.7  1999/01/26 13:50:00  Neil.Hamilton    - Added support for non-blocking DMA transfers. Still having problems      with semaphores.    Revision 1.6  1999/01/20 19:04:20  Neil.Hamilton    - As delivered to DY4 15Jan1999.    Revision 1.5  1999/01/15 14:09:24  Neil.Hamilton    - Added comments around the DMA interrupt handler section.    Revision 1.4  1999/01/13 19:21:12  Neil.Hamilton    - Added init of DMA driver from sysUniverseHwInit2.    Revision 1.3  1999/01/13 19:10:29  Neil.Hamilton    - Added curly braces around original interrupt code from within the DMA      define section to prevent the entry into default interrupt handler.    Revision 1.2  1999/01/12 20:05:43  Neil.Hamilton    - Reworked interrupt function.    Revision 1.1  1999/01/07 18:39:05  Neil.Hamilton    Initial revision\* ------------------------------------------------------------------------ *//*DESCRIPTIONThe routines addressed here include:Initialization of Universe chipBus interrupt functions:    - enable/disable VMEbus interrupt levels    - generate bus interrupts    - enable mailbox/location monitor interrupts*//* defines for sysBusTas() and sysBusTasClear() */#define VME_DEBUG#define VMEBUS_OWNER        (*UNIVERSE_MAST_CTL & LONGSWAP(MAST_CTL_VOWN_ACK))#define CPU_CLOCKS_PER_LOOP 10#define LOCK_TIMEOUT        10#define UNLOCK_TIMEOUT      10000#define VME_SW_OFFSET       (24)        /* Offset to VME_SW bits */#undef INCLUDE_VME_DMA    /* Add for proper compilation*/ /* omitted by fzz *//*#define VME_INT_DEBUG*//* includes */#include "drv/vme/universe_dy4.h"#include "drv/vme/universe2_dy4.h"#if  defined(INCLUDE_VME_DMA)#include "h/drv/vme/universeDmaVme_dy4.h"#include "universeDmaVme_dy4.c"#endif/* external declarations */IMPORT int intEnable (int);IMPORT int intDisable (int);IMPORT UINT sysVmeA32AddrGet (void);IMPORT UINT sysVmeA24AddrGet (void);IMPORT INT_HANDLER_DESC * sysIntTbl [];/* forward declarations */void    sysUniverseReset (void);STATUS  sysUniverseHwInit (void);void    sysUniverseHwInit2 (void);STATUS  sysIntDisable (int);STATUS  sysIntEnable (int);STATUS  sysBusIntAck (int);STATUS  sysBusIntGen (int, int);STATUS  sysUnivIntEnable (int);STATUS  sysUnivIntDisable (int);LOCAL   void sysMailboxInt (int);STATUS  sysMailboxConnect (FUNCPTR, int);STATUS  sysMailboxEnable (char*);STATUS  sysMailboxDisable (char*);void    sysUniverseIntr (void);void    maskLevel(int intMask);#ifdef  INCLUDE_VME_SHOWvoid    sysUnivRegShow (void);#endiftypedef struct{    UINT32 *ctl;        /* control register address of image */    UINT32 *bs;         /* base address register address of image */    UINT32 *bd;         /* bound register address of image */    UINT32 *to;         /* translation offset register address of image */    UINT32 enabled;     /* 0 indicates image is disabled */    char   *vmeBase;    /* VME address of images */    UINT32 size;        /* size of slave image */    char   *localAdrs;  /* local address of image */} SLAVE_IMAGE_STRUCT;#define UNIVERSE_SLAVE_IMAGES   (8)SLAVE_IMAGE_STRUCT sysPciSlaveDesc[UNIVERSE_SLAVE_IMAGES];SLAVE_IMAGE_STRUCT sysVmeSlaveDesc[UNIVERSE_SLAVE_IMAGES];/* Used to mark current local base address */UINT32  sysLocalVmeA32Adrs  = VME_A32_MSTR_LOCAL;UINT32  sysMailbox0;UINT32  sysMailbox1;UINT32  sysMailbox2;UINT32  sysMailbox3;int lastMailboxData = 0;/* locals */LOCAL FUNCPTR sysMailbox0Routine  = NULL;LOCAL int sysMailbox0Arg          = (int)NULL;LOCAL FUNCPTR sysMailbox1Routine  = NULL;LOCAL int sysMailbox1Arg          = (int)NULL;LOCAL FUNCPTR sysMailbox2Routine  = NULL;LOCAL int sysMailbox2Arg          = (int)NULL;LOCAL FUNCPTR sysMailbox3Routine  = NULL;LOCAL int sysMailbox3Arg          = (int)NULL;/********************************************************************************* sysMailboxAddrGet - get mailbox address** This routine returns the VME address of the Universe chip's mailbox.* The given mailbox id must be one of SYS_MAILBOX[0..3]).** SYS_MAILBOX_0 is reserved for shared memory networking use, and applications* may the remaining mailboxes as necessary.* Refer to the Universe manual for information on mailbox operation.** Note: To use this address from the local CPU, use sysBusToLocalAdrs()* to translate the mailbox address to the local address space.** RETURNS: OK, always.** SEE ALSO: sysBusToLocalAdrs*/UINT sysMailboxAddrGet        (        int mailboxId       /* one of SYS_MAILBOX[0..3] */        ){    UINT mailboxAddr;    switch (mailboxId)    {        case SYS_MAILBOX0 :            mailboxAddr = (DEFAULT_VRAI_BS + UNIVERSE_MBOX0_OFFSET);            break;        case SYS_MAILBOX1 :            mailboxAddr = (DEFAULT_VRAI_BS + UNIVERSE_MBOX1_OFFSET);            break;        case SYS_MAILBOX2 :            mailboxAddr = (DEFAULT_VRAI_BS + UNIVERSE_MBOX2_OFFSET);            break;        case SYS_MAILBOX3 :            mailboxAddr = (DEFAULT_VRAI_BS + UNIVERSE_MBOX3_OFFSET);            break;        default :            return ERROR;    }    return mailboxAddr;}/********************************************************************************* sysUniverseReset - reset the Universe VME chip** This routine performs the reseting of the Universe chip.  All functions* and VME mapping are disabled.** RETURNS: N/A*/void sysUniverseReset (void){    UINT32  reg;    /* initialize registers with defaults and disable mapping */    sysOutLong((UINT32)UNIVERSE_SCYC_CTL,  0);    sysOutLong((UINT32)UNIVERSE_SCYC_ADDR, 0);    sysOutLong((UINT32)UNIVERSE_SCYC_EN,   0);    sysOutLong((UINT32)UNIVERSE_LMISC,     LMISC_CRT_128_USEC);    sysOutLong((UINT32)UNIVERSE_DCTL,      0);    sysOutLong((UINT32)UNIVERSE_DTBC,      0);    sysOutLong((UINT32)UNIVERSE_DLA,       0);    sysOutLong((UINT32)UNIVERSE_DVA,       0);    sysOutLong((UINT32)UNIVERSE_DCPP,      0);    sysOutLong((UINT32)UNIVERSE_LINT_EN,   0);    sysOutLong((UINT32)UNIVERSE_LINT_MAP0, 0);    sysOutLong((UINT32)UNIVERSE_LINT_MAP1, 0);    sysOutLong((UINT32)UNIVERSE_LINT_MAP2, 0);    sysOutLong((UINT32)UNIVERSE_VINT_EN,   0);    sysOutLong((UINT32)UNIVERSE_VINT_MAP0, 0);    sysOutLong((UINT32)UNIVERSE_VINT_MAP1, 0);    sysOutLong((UINT32)UNIVERSE_VINT_MAP2, 0);    sysOutLong((UINT32)UNIVERSE_VSI0_CTL,  0);    sysOutLong((UINT32)UNIVERSE_VSI1_CTL,  0);    sysOutLong((UINT32)UNIVERSE_VSI2_CTL,  0);    sysOutLong((UINT32)UNIVERSE_VSI3_CTL,  0);    sysOutLong((UINT32)UNIVERSE_VSI4_CTL,  0);    sysOutLong((UINT32)UNIVERSE_VSI5_CTL,  0);    sysOutLong((UINT32)UNIVERSE_VSI6_CTL,  0);    sysOutLong((UINT32)UNIVERSE_VSI7_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI0_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI1_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI2_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI3_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI4_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI5_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI6_CTL,  0);    sysOutLong((UINT32)UNIVERSE_LSI7_CTL,  0);    /* clear the SYSFAIL signal */    sysOutLong((UINT32)UNIVERSE_VCSR_CLR,  VCSR_CLR_SYSFAIL);    /* clear any outstanding interrupts/error conditions */    sysOutLong((UINT32)UNIVERSE_LINT_STAT, LINT_STAT_RESET);    sysOutLong((UINT32)UNIVERSE_VINT_STAT, VINT_STAT_RESET);    sysOutLong((UINT32)UNIVERSE_V_AMERR, V_AMERR_V_STAT);    reg = sysInLong((UINT32)UNIVERSE_PCI_CSR);    reg |= PCI_CSR_D_PE | PCI_CSR_S_SERR | PCI_CSR_R_MA |           PCI_CSR_R_TA | PCI_CSR_S_TA;    sysOutLong((UINT32)UNIVERSE_PCI_CSR, reg);    sysOutLong((UINT32)UNIVERSE_L_CMDERR, L_CMDERR_L_ENABLE);    sysOutLong((UINT32)UNIVERSE_DGCS, DGCS_STOP | DGCS_HALT | DGCS_DONE |                  DGCS_LERR | DGCS_VERR | DGCS_P_ERR);}/********************************************************************************* sysHostLmAddress - Returns address of location monitor for drivers.** This routine returns the location monitor address of a host card. This* function is to support old drivers (e.g. 739).** RETURNS:** NOMANUAL*/UINT sysHostLmAddress( void ){    return ( sysMailboxAddrGet(SYS_MAILBOX1) );}/********************************************************************************* sysUniverseHwInit - initialize the Universe VME chip** This routine performs the initialization of the Universe chip registers,* and the slave image structures.  It should only be called in sysHwInit().** RETURNS: OK, always.** NOMANUAL*/STATUS sysUniverseHwInit (void){    UINT32  temp;    int image;    /* Put vme chip into a power-up/reset state */    sysUniverseReset ();    /* Enable Bus Master, IO and Memory Space */    *UNIVERSE_PCI_CSR = LONGSWAP(PCI_CSR_MS |                                 PCI_CSR_IOS |                                 PCI_CSR_BM);    *UNIVERSE_MAST_CTL = LONGSWAP(MAST_CTL_RTRY_FOREVER |                                 MAST_CTL_PWON_4096 |                                 MAST_CTL_VRL3 |                                 MAST_CTL_VRM_DEMAND |                                 MAST_CTL_VREL_RWD |                                 MAST_CTL_PABS_32 );    temp = LONGSWAP( *UNIVERSE_MISC_CTL );    /* maintain power-up option bits */    temp &= ( MISC_CTL_SYSCON | MISC_CTL_V64AUTO );    temp |= ( MISC_CTL_VBTO_256USEC |            MISC_CTL_VARB_RROBIN |            MISC_CTL_VARBTO_256USEC |            MISC_CTL_RESCIND );    *UNIVERSE_MISC_CTL = LONGSWAP( temp );    /* clear the SYSFAIL signal */    *UNIVERSE_VCSR_CLR = LONGSWAP(VCSR_CLR_SYSFAIL);    /* set the latency timer to max value */    *UNIVERSE_PCI_MISC0 = LONGSWAP( PCI_MISC0_LATENCY_TIMER );    for (image=0; image<NELEMENTS(sysPciSlaveDesc);image++)    {        switch (image)        {        case UNIVERSE_LSI0 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI0_CTL;            sysPciSlaveDesc[image].bs = UNIVERSE_LSI0_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI0_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI0_TO;            break;        case UNIVERSE_LSI1 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI1_CTL;            sysPciSlaveDesc[image].bs = UNIVERSE_LSI1_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI1_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI1_TO;            break;        case UNIVERSE_LSI2 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI2_CTL;            sysPciSlaveDesc[image].bs = UNIVERSE_LSI2_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI2_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI2_TO;            break;        case UNIVERSE_LSI3 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI3_CTL;            sysPciSlaveDesc[image].bs = UNIVERSE_LSI3_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI3_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI3_TO;            break;        case UNIVERSE_LSI4 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI4_CTL;            sysPciSlaveDesc[image].bs = UNIVERSE_LSI4_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI4_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI4_TO;            break;        case UNIVERSE_LSI5 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI5_CTL;            sysPciSlaveDesc[image].bs = UNIVERSE_LSI5_BS;            sysPciSlaveDesc[image].bd = UNIVERSE_LSI5_BD;            sysPciSlaveDesc[image].to = UNIVERSE_LSI5_TO;            break;        case UNIVERSE_LSI6 :            sysPciSlaveDesc[image].ctl = UNIVERSE_LSI6_CTL;

⌨️ 快捷键说明

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