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

📄 universe_dy4.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* universe_dy4.c - Tundra Universe chip PCI-VME interface library *//************************************************************************** * *   Copyright (c) 2005 Curtiss-Wright Controls, Inc. All rights *   reserved.  This Source Code is the Property of Curtiss-Wright *   Controls, Inc. and can only be used in accordance with Source *   Code License Agreement(s) of Curtiss-Wright Controls, Inc. or any *   of its subsidiaries. * **************************************************************************//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------02b,25jan06,tis   - CR#2748: move some VME initialization code in sysUniverseHwInit2() out of the                     the warm boot signature guarded area since these lines of code are required in                    both warm and cold boots.                  - CR#2748: remove unneeded code from sysUniverseHwInit().02a,12dec05,gd    - CR#2748_: Major revision of VME image mapping API.01z,18nov05,rcd   - CR#12054: optimize ISR for SM mailbox mode. 0ly,10nov01,tis   - added new function sysLocalMailboxAddrGet() - CR #1176801x,10oct05,rcd   - CR#1627 moved sysBusTas and sysBusTasClear to sysBus.c.                    added sysVmeVownTasClear and sysVmeRmwTasClear01w,29Mar05,rcd   - CR#3220: remove PCI retry forever as per errata#7.  01v,20Mar05,rcd   - CR#3108: add VME interrupt error detection.  01u,05jan05,aak   - CR#2386: recode inline assembly (Diab support);                    eliminate compile warnings01t,01Sep04,rcd   - PT# 2054: change SW and HW sysBusTas to Vown and RMW. 01s,28jul04,aak   - provide identical declarations for SW and HW sysBusTas (PT#2123);                    move bus adr transl. functions to sysLib.c (PT#2089)01r,10Jun04,rcd   - PT# 2053: compile error with UNIVERSE_SW_BUSTAS.01q,10jun04,tis   - PT# 2041: update sysUniverseIntr() to fix the "Not a supported VME interrupt" Error.01p,07Jun04,rcd   - PT# 1875: improve dma pci bursts.01o,21Apr04,rcd   - PT# 1950: make all 255 vme interrupts available.01n,02Jan04,rcd   - PT# 1831: change adrs to addr in sysBusTas.01m,22Oct03,rcd   - added changes for SM_DISCOVERY2_LOCALBUS01l,20jun03,rcd   - integrated new interrupt handling structure for dy4182		          - read and swap in sysBusTas (PT#1517)01k,16jul03,aak   - fixed test and set routine PT#1315                  - integrate new optimised Universe ISR, revise interrupt connect PT#123201j,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#858   01f,08jun2001,tis Fixed sysMailboxInt to pass both data and data and arg PT#572 01e,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 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 */#define INCLUDE_VME_DMA    /* Add for proper compilation */#define A24ADRSRANGE    0x01000000#define A16ADRSRANGE    0x00010000#define RESOLUTION4k    0x00001000#define RESOLUTION64k   0x00010000#define VME_SPE_A24         1#define VME_SPE_A16         0#define VME_SPE_CTL_PGM     0x01<<12#define VME_SPE_CTL_DTA     0x00<<12#define VME_SPE_CTL_PGM_MSK 0x0F<<12#define VME_SPE_CTL_SUP     0x01<<8#define VME_SPE_CTL_USR     0x00<<8#define VME_SPE_CTL_SUP_MSK 0x0F<<12#define VME_MASTER_VAS_EXTRACT(a)    ((a >> 16) & 0x00000007)   /* extract PGM value */#define VME_MASTER_VDW_EXTRACT(a)    ((a >> 22) & 0x00000003)   /* extract VDW value */#define VME_SLAVE_VAS_EXTRACT(a)     ((a >> 16) & 0x07)         /* extract PGM value */#define VME_SLAVE_PGM_EXTRACT(a)     ((a >> 22) & 0x03)         /* extract PGM value */#define VME_SLAVE_SUPER_EXTRACT(a)   ((a >> 20) & 0x03)         /* extract SUPER value */#define VME_SLAVE_LAS_EXTRACT(a)     (a & 0x03)                 /* extract LAS value */#define VME_SPE_MASTER_PGM_EXTRACT(ctl,image)   ((ctl >> (12+image)) & 0x01) /* extract PGM value from special image */#define VME_SPE_MASTER_SUPER_EXTRACT(ctl,image) ((ctl >> (8+image)) & 0x01)  /* extract SUPER value from special image */#define VME_SPE_MASTER_VDW_EXTRACT(ctl,image)   ((ctl >> (20+image)) & 0x01) /* extract VDW value from special image */#define VME_MEM_OPTION0     0#define VME_MEM_OPTION1     1#define VME_MEM_OPTION2     2/* PREEMPT not supported on 182 */#undef INT_MODEL_PREEMPT#define INT_MODEL_NON_PREEMPT/* includes */#include "h/drv/vme/universe_dy4.h"#include "h/drv/vme/universe2_dy4.h"#ifdef VME_183#include "intCtrl183.h"#else#include "intCtrl182_dy4.h"#endif#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 UINT32 cssXGetVmeMapOption(void);IMPORT STATUS sysVmeIntDisconnect   (   VOIDFUNCPTR *vector,		/* interrupt vector to detach from */   VOIDFUNCPTR  routine	/* routine that was to be called */   );/* the VME system interrupt table */IMPORT INT_VME_HANDLER_DESC * sysVmeIntVecTbl[];#ifdef __GNUC__#define FASTLONGSWAP(in) ({ register unsigned int __out; unsigned int __in;__in=in; _WRS_ASM ("lwbrx %0,0,%1" : "=r" (__out) : "r" (&__in)); __out; })#elseasm volatile UINT32 FASTLONGSWAP(UINT32 in){% reg in!  stw     in,8(r1)                  addi    r3,r1,8                     lwbrx   r3,0,r3                                              }#endif/* forward declarations */#ifdef CPU0_IMAGELOCAL void      sysVmeInitIntrTables(void);LOCAL void      sysMailboxInt (int);LOCAL void      sysUniverseIntr (void);LOCAL void      vmePciSpaceInit (void);LOCAL char*     vmePciSpaceAlloc (UINT32 size);LOCAL STATUS    vmePciSpaceFree (char* pSection);#endifvoid            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);UINT32          vmeGetPciMemTop (void);STATUS          sysMailboxConnect (FUNCPTR, int);STATUS          sysMailboxEnable (char*);STATUS          sysMailboxDisable (char*);STATUS  sysVmeSlaveRegSet (char* vmeBaseAdrs, UINT32 attributes);STATUS  sysVmeSlaveSet ( UINT32 image, char* vmeBaseAdrs, UINT32 vmeWindowSize, UINT32 attributes, char* localBaseAdrs);STATUS  sysVmeMstrSet (UINT32 image, char *vmeWindowBase, UINT32 vmeWindowSize, UINT32 attributes, char **localAdrs);STATUS  sysVmeSpeMstrSet (UINT32 attributes);#ifdef INCLUDE_VME_SHOWvoid        sysUnivRegShow (void);#endif/* Definition used to manage VME master and slave images more efficiently  *//* sysBusToLocalAdrs and sysLocalToAdrs do not need to access the universe *//* registers directly, they access shadow copies of the images             *//* configuration registers                                                 *//* definition require to manage the PCI area allocated for VME Master windows */#define MAX_SECTIONS        UNIVERSE_PCI_SLAVE_IMAGES#define SECTION_ALIGNMENT   0x00010000              /*64K section alignment */#define UNIVERSE_VME_SLAVE_IMAGES           8#define UNIVERSE_PCI_SLAVE_IMAGES           8#define UNIVERSE_SPECIAL_PCI_SLAVE_IMAGES   4typedef 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 attributes;  /* mirrored attribute value */    char *vmeBase;      /* VME address of images */    UINT32  size;       /* size of slave image */    char *localAdrs;    /* local address of image */   } SLAVE_IMAGE_STRUCT;typedef struct{    UINT32 start;    UINT32 end;} PCI_SECTION;typedef struct{    UINT32 startAdrs;    UINT32 endAdrs;    UINT32 sectionCnt;    PCI_SECTION section[MAX_SECTIONS+1];} PCI_SLAVE_AREA_DATA;typedef struct{    UINT32 signature;/* LOCAL UINT cardType; */    UINT32 vmeA32Base;    UINT32 vmeA32Size;    UINT32 vmeA24Base;    UINT32 vmeA24Size;    SLAVE_IMAGE_STRUCT sysPciSlaveDesc[UNIVERSE_PCI_SLAVE_IMAGES]; /* PCI Slave images definition         */    SLAVE_IMAGE_STRUCT sysVmeSlaveDesc[UNIVERSE_VME_SLAVE_IMAGES]; /* VME Slave images definition         */    SLAVE_IMAGE_STRUCT sysVmeSlaveRegDesc;                         /* VME slave register image definition */    SLAVE_IMAGE_STRUCT sysPciSlaveSpeDesc;                         /* PCI Special images definition       */    UINT32  pciVmeMstrMemTop;    BOOL    pciVmeMemSpace;    PCI_SLAVE_AREA_DATA pciArea;} VME_DATA;VME_DATA *vmeData;/* Used to mark current local base address */UINT32  sysLocalVmeA32Adrs  = VME_A32_MSTR_LOCAL;#ifdef CPU0_IMAGE/* Local variable used for mailbox interrupt handling *//* This table is initialised at startup */LOCAL UINT32* sysMailboxAddr[] = {   0,   0,   0,   0};LOCAL FUNCPTR sysMailboxRoutine[] ={   NULL,   NULL,   NULL,   NULL};#endifLOCAL UINT32 const mboxvector[] = {   UNIV_MBOX0_INT_VEC,   UNIV_MBOX1_INT_VEC,   UNIV_MBOX2_INT_VEC,   UNIV_MBOX3_INT_VEC};UINT32 sysUNIVERSE_LINT_EN=0;UINT32 sysVmeIntrPreemptCnt=0;#ifdef CPU0_IMAGE/* locals *//* Change the priority of the VME interrupts by changing the order of this table */LOCAL UINT32 sysVmeIntrSrcTbl[]={                                           /* Priority */   LONGSWAP(UNIVERSE_DMA_INT),              /*00 Highest*/   LONGSWAP(UNIVERSE_ACFAIL_INT),           /*01*/   LONGSWAP(UNIVERSE_SYSFAIL_INT),          /*02*/   LONGSWAP(UNIVERSE_VERR_INT),             /*03*/   LONGSWAP(UNIVERSE_LERR_INT),             /*04*/   LONGSWAP(UNIVERSE_PCI_SW_INT),           /*05*/   LONGSWAP(UNIVERSE_VME_SW_IACK_INT),      /*06*/   LONGSWAP(UNIVERSE_LM0_INT),              /*07*/   LONGSWAP(UNIVERSE_LM1_INT),              /*08*/   LONGSWAP(UNIVERSE_LM2_INT),              /*09*/   LONGSWAP(UNIVERSE_LM3_INT),              /*10*/   LONGSWAP(UNIVERSE_MBOX0_INT),            /*11*/   LONGSWAP(UNIVERSE_MBOX1_INT),            /*12*/   LONGSWAP(UNIVERSE_MBOX2_INT),            /*13*/   LONGSWAP(UNIVERSE_MBOX3_INT),            /*14*/   (UINT32)LONGSWAP(LVL7),                  /*15*/   LONGSWAP(LVL6),                          /*16*/   LONGSWAP(LVL5),                          /*17*/   LONGSWAP(LVL4),                          /*18*/   LONGSWAP(LVL3),                          /*19*/   LONGSWAP(LVL2),                          /*20*/   LONGSWAP(LVL1),                          /*21 Lowest*/   0   /* End of table indicator */};/* These table are initialised at startup */LOCAL UINT32 sysVmeIntrMaskTbl[sizeof(sysVmeIntrSrcTbl)/sizeof(sysVmeIntrSrcTbl[0])];LOCAL UINT32 sysVmeIntrPriorityVecTbl[sizeof(sysVmeIntrSrcTbl)/sizeof(sysVmeIntrSrcTbl[0])];LOCAL UINT32 sysVmeIntrMaskStack[sizeof(sysVmeIntrSrcTbl)/sizeof(sysVmeIntrSrcTbl[0])];#endif/********************************************************************************* 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.

⌨️ 快捷键说明

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