📄 universe_dy4.c
字号:
** 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 (UINT)ERROR; } return mailboxAddr;}/********************************************************************************* sysLocalMailboxAddrGet - get local mailbox address** This routine returns the local VME address of the Universe chip's mailbox.* The given mailbox id must be one of SYS_MAILBOX[0..3]).** RETURNS: localMailboxAddr, ERROR if mailboxId is not in the rage 0 - 3** SEE ALSO: sysMailboxAddrGet*/UINT sysLocalMailboxAddrGet ( int mailboxId /* one of SYS_MAILBOX[0..3] */ ){ UINT localMailboxAddr; switch (mailboxId) { case SYS_MAILBOX0 : localMailboxAddr = (sysGetUniverseIoBaseAdrs() + UNIVERSE_MBOX0_OFFSET); break; case SYS_MAILBOX1 : localMailboxAddr = (sysGetUniverseIoBaseAdrs() + UNIVERSE_MBOX1_OFFSET); break; case SYS_MAILBOX2 : localMailboxAddr = (sysGetUniverseIoBaseAdrs() + UNIVERSE_MBOX2_OFFSET); break; case SYS_MAILBOX3 : localMailboxAddr = (sysGetUniverseIoBaseAdrs() + UNIVERSE_MBOX3_OFFSET); break; default : return ERROR; } return localMailboxAddr;}/********************************************************************************* 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) {#ifndef CPU0_IMAGE return;#else UINT32 reg; sysUNIVERSE_LINT_EN=0; /* 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);#endif }/********************************************************************************* 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) {#ifndef CPU0_IMAGE /* Allocate memory for structure required to manage VME slave and Master images */ vmeData=(VME_DATA*)VME_SHARED_DATA; return(ERROR);#else UINT32 temp; /* Allocate memory for structure required to manage VME slave and Master images */ vmeData=(VME_DATA*)VME_SHARED_DATA; /* if this is a warm boot the signature will still be there and the data valid */ if (vmeData->signature == VME_SHARED_DATA_SIG) { /* VME should already be initialised return immediatly */ return (OK); } /* Otherwise proceed with initialisation. */#ifdef OVERIDE_DY4_AUTOID /* User defined CPU's VME A24/A32 base address */ vmeA32Base = (UINT)USER_VME_A32_BASE; vmeA24Base = (UINT)USER_VME_A24_BASE; vmeA32Size = (UINT)VME_A32_SLV_SIZE; vmeA24Size = (UINT)VME_A24_SLV_SIZE;#else /* Get addresses from FFW */ cssGetVmeA32Image( (char**) ((UINT)&vmeData->vmeA32Base), &vmeData->vmeA32Size); cssGetVmeA24Image( (char**) ((UINT)&vmeData->vmeA24Base), &vmeData->vmeA24Size);#endif /* 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_DEFAULT | MAST_CTL_PWON_4096 | MAST_CTL_VRL3 | MAST_CTL_VRM_DEMAND | MAST_CTL_VREL_RWD | MAST_CTL_PABS_128 ); 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); return (OK); #endif }/********************************************************************************* sysVmeSlaveRegSet - set VME special master image** This routine configures VME register images (VME slave or inbound) with the given input.** RETURNS: OK if successfull* ERROR if illegal parameters is found** NOMANUAL*/STATUS sysVmeSlaveRegSet ( char* vmeBaseAdrs, UINT32 attributes ){#ifndef CPU0_IMAGE return(ERROR);#else UINT32 lock; /* If the image is to be disabled, set to 0 */ if ((attributes & VRAI_CTL_EN) == 0) { lock=intLock(); /* disable the image */ vmeData->sysVmeSlaveRegDesc.attributes = 0; vmeData->sysVmeSlaveRegDesc.vmeBase = 0; vmeData->sysVmeSlaveRegDesc.size = 0; vmeData->sysVmeSlaveRegDesc.localAdrs = 0; *(vmeData->sysVmeSlaveRegDesc.ctl) = 0; *(vmeData->sysVmeSlaveRegDesc.bs) = 0; intUnlock(lock); return (OK); } /* Only A16/24/32 modes are supported */ if (((attributes & VME_SLV_CTL_VAS_MSK) != VME_SLV_CTL_A16) && ((attributes & VME_SLV_CTL_VAS_MSK) != VME_SLV_CTL_A24) && ((attributes & VME_SLV_CTL_VAS_MSK) != VME_SLV_CTL_A32) ) { /* Not A16/24/32 Incompatible image */ return (ERROR); } /* Check for valid PGM and SUPER attribute code */ if (((attributes & VME_SLV_CTL_PGM_MSK) == 0) || ((attributes & VME_SLV_CTL_SUP_MSK) == 0)) { /* Illegal PGM or SUPER attribute */ return (ERROR); } /* Address resolution is 4K */ if (((UINT32)vmeBaseAdrs % 0x1000)!=0) { /* Illegal windows resolution */ return (ERROR); } lock=intLock(); /* Update local data */ vmeData->sysVmeSlaveRegDesc.attributes = VRAI_CTL_EN | attributes; vmeData->sysVmeSlaveRegDesc.vmeBase = (char*)vmeBaseAdrs; vmeData->sysVmeSlaveRegDesc.size = UNIVERSE_VRAI_SIZE; vmeData->sysVmeSlaveRegDesc.localAdrs = (char*)sysGetUniverseIoBaseAdrs(); /* Update hardware register */ *(vmeData->sysVmeSlaveRegDesc.ctl) = LONGSWAP(vmeData->sysVmeSlaveRegDesc.attributes); *(vmeData->sysVmeSlaveRegDesc.bs) = LONGSWAP((UINT32)vmeData->sysVmeSlaveRegDesc.vmeBase); intUnlock(lock); return (OK);#endif}/********************************************************************************* sysVmeSlaveSet - set VME slave image** This routine configures a VME slave image with the given input.* Note: the resolution for images 0 and 4 are 4k and are the only images* available for A16 images. All other images have a resolution of 64K.** RETURNS: OK if successfull* ERROR if illegal parameters is found** NOMANUAL*/STATUS sysVmeSlaveSet ( UINT32 image, /* UNIVERSE_[LV]SI[0..7] */ char* vmeBaseAdrs, UINT32 vmeWindowSize, UINT32 attributes, char* localBaseAdrs ){#ifndef CPU0_IMAGE return(ERROR);#else UINT32 lock; /* Validate all parameters */ /* Windows 0 to 7 only*/ if ((image < UNIVERSE_VSI0) || (image > UNIVERSE_VSI7)) { return (ERROR); } /* If the attribute is set to 0 */ if ((attributes & VME_SLV_CTL_EN) == 0) { lock=intLock(); /* disable the window */ vmeData->sysVmeSlaveDesc[image].attributes = 0; vmeData->sysVmeSlaveDesc[image].vmeBase = 0; vmeData->sysVmeSlaveDesc[image].size = 0; vmeData->sysVmeSlaveDesc[image].localAdrs = 0; *(vmeData->sysVmeSlaveDesc[image].ctl) = 0; *(vmeData->sysVmeSlaveDesc[image].bs) = 0; *(vmeData->sysVmeSlaveDesc[image].bd) = 0; *(vmeData->sysVmeSlaveDesc[image].to) = 0; intUnlock(lock); return (OK); } /* Address and size resolution is 4K for windows 0 and 4, 64 K for other*/ if ((image != UNIVERSE_VSI0) || (image != UNIVERSE_VSI4)) { if ((((UINT32)vmeBaseAdrs % RESOLUTION4k)!=0) || (((UINT32)vmeWindowSize % RESOLUTION4k)!=0) || (((UINT32)localBaseAdrs % RESOLUTION4k)!=0) ) { /* Illegal windows resolution */ return (ERROR); } } else { if ((((UINT32)vmeBaseAdrs % RESOLUTION64k)!=0) ||
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -