?? dec2155xcpci.c
字號:
/* dec2155xCpci.c - DEC 2155X (Drawbridge) PCI-to-PCI bridge library *//* Copyright 1998-2000 Motorola, Inc. All Rights Reserved *//*modification history--------------------01f 03jan01,rhk Adjust for MPC860 interrupt handler.01e,25apr00,srr Updated for WRS coding standards.01d,06dec99,rhk mask all of the Upper 32 Bits Downstream Memory 3 Setup register01c,29oct99,dmw Used TRANSLATE macro for cPCI address.01b,20oct99,srr Include hawkMpic.h only if INCLUDE_MPIC defined.01a,10jun99,rhv Written (from version 01o of mcpn750/dec2155xCcpi.c).*//*DESCRIPTIONThe routines addressed here include:Initialization of 2155x chipBus interrupt functions: - enable/disable Compact PCI interrupts - enable/disable drawbridge internal interrupts - install handlers for the drawbridge internal interrupts - generate Compact PCI bus interruptsMailbox functions: - enable mailbox interruptsPortions of this code (dec2155xInit) must run before the local PCI busenumeration been performed. As such, the 2155x BAR registers have not beeninitialized and access must be performed though the local PCI configurationspace. This is done using the pciConfigxxxx calls (in pciConfigLib.c). Oncelocal PCI bus enumeration has completed, access to most 2155x registers willbe performed using the local PCI memory space and sysPcixxxx calls.*//* includes */#include "vxWorks.h"#include "config.h"#include "vxLib.h"#ifdef INCLUDE_MPIC# include "hawkMpic.h"#else# if (CPU==PPC860)# include "ppc860Intr.h"# else# include "sl82565IntrCtl.h"# endif /* (CPU==PPC860) */#endif /* INCLUDE_MPIC */#include "intLib.h"#include "logLib.h"#include "dec2155xCpci.h"#include "pci.h"/* defines */#define DEC2155X_ENABLE_MEM_AND_IO (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)/* this section validates the upstream and downstream window parameters */#if (DEC2155X_CSR_AND_DS_MEM0_SIZE & (DEC2155X_CSR_AND_DS_MEM0_SIZE - 1))# error DEC2155X_CSR_AND_DS_MEM0_SIZE is not a power of 2#else# if (DEC2155X_CSR_AND_DS_MEM0_TRANS & (DEC2155X_CSR_AND_DS_MEM0_SIZE - 1))# error DEC2155X_CSR_AND_DS_MEM0_TRANS is not a multiple of window size# endif# if (DEC2155X_CSR_AND_DS_MEM0_SIZE & DEC2155X_MEM_TB_RSV_MSK)# error DEC2155X_CSR_AND_DS_MEM0_SIZE is less than 4KB in size# endif#endif#if (DEC2155X_DS_IO_OR_MEM1_SIZE & (DEC2155X_DS_IO_OR_MEM1_SIZE - 1))# error DEC2155X_DS_IO_OR_MEM1_SIZE is not a power of 2#else# if (DEC2155X_DS_IO_OR_MEM1_TRANS & (DEC2155X_DS_IO_OR_MEM1_SIZE - 1))# error DEC2155X_DS_IO_OR_MEM1_TRANS is not a multiple of window size# endif# if (DEC2155X_DS_IO_OR_MEM1_TYPE & PCI_BAR_SPACE_IO)# if (DEC2155X_DS_IO_OR_MEM1_SIZE & DEC2155X_IO_OR_MEM_TB_RSV_MSK)# error DEC2155X_DS_IO_OR_MEM1_SIZE is less than 64 bytes# endif# else# if (DEC2155X_DS_IO_OR_MEM1_SIZE & DEC2155X_MEM_TB_RSV_MSK)# error DEC2155X_DS_IO_OR_MEM1_SIZE is less than 4KB# endif# endif #endif#if (DEC2155X_DS_MEM2_SIZE & (DEC2155X_DS_MEM2_SIZE - 1))# error DEC2155X_DS_MEM2_SIZE is not a power of 2#else# if (DEC2155X_DS_MEM2_TRANS & (DEC2155X_DS_MEM2_SIZE - 1))# error DEC2155X_DS_MEM2_TRANS is not a multiple of window size# endif# if (DEC2155X_DS_MEM2_SIZE & DEC2155X_MEM_TB_RSV_MSK)# error DEC2155X_DS_MEM2_SIZE is less than 4KB in size# endif#endif#if (DEC2155X_DS_MEM3_SIZE & (DEC2155X_DS_MEM3_SIZE - 1))# error DEC2155X_DS_MEM3_SIZE is not a power of 2#else# if (DEC2155X_DS_MEM3_TRANS & (DEC2155X_DS_MEM3_SIZE - 1))# error DEC2155X_DS_MEM3_TRANS is not a multiple of window size# endif# if (DEC2155X_DS_MEM3_SIZE & DEC2155X_MEM_TB_RSV_MSK)# error DEC2155X_DS_MEM3_SIZE is less than 4KB in size# endif#endif#if (DEC2155X_US_IO_OR_MEM0_SIZE & (DEC2155X_US_IO_OR_MEM0_SIZE - 1))# error DEC2155X_US_IO_OR_MEM0_SIZE is not a power of 2#else# if (DEC2155X_US_IO_OR_MEM0_TRANS & (DEC2155X_US_IO_OR_MEM0_SIZE - 1))# error DEC2155X_US_IO_OR_MEM0_TRANS is not a multiple of window size# endif# if (DEC2155X_US_IO_OR_MEM0_TYPE & PCI_BAR_SPACE_IO)# if (DEC2155X_US_IO_OR_MEM0_SIZE & DEC2155X_IO_OR_MEM_TB_RSV_MSK)# error DEC2155X_US_IO_OR_MEM0_SIZE is less than 64 bytes# endif# else# if (DEC2155X_US_IO_OR_MEM0_SIZE & DEC2155X_MEM_TB_RSV_MSK)# error DEC2155X_US_IO_OR_MEM0_SIZE is less than 4KB# endif# endif #endif#if (DEC2155X_US_MEM1_SIZE & (DEC2155X_US_MEM1_SIZE - 1))# error DEC2155X_US_MEM1_SIZE is not a power of 2#else# if (DEC2155X_US_MEM1_TRANS & (DEC2155X_US_MEM1_SIZE - 1))# error DEC2155X_US_MEM1_TRANS is not a multiple of window size# endif# if (DEC2155X_US_MEM1_SIZE & DEC2155X_MEM_TB_RSV_MSK)# error DEC2155X_US_MEM1_SIZE is less than 4KB in size# endif#endif/* create window setup values */#if (DEC2155X_CSR_AND_DS_MEM0_SIZE)# define DEC2155X_CSR_AND_DS_MEM0_SETUP ( \ DEC2155X_SETUP_REG_BAR_ENABLE | \ ~(DEC2155X_CSR_AND_DS_MEM0_SIZE - 1) | \ DEC2155X_CSR_AND_DS_MEM0_TYPE)#else# define DEC2155X_CSR_AND_DS_MEM0_SETUP 0x00000000#endif#if (DEC2155X_DS_IO_OR_MEM1_SIZE)# define DEC2155X_DS_IO_OR_MEM1_SETUP ( \ DEC2155X_SETUP_REG_BAR_ENABLE | \ ~(DEC2155X_DS_IO_OR_MEM1_SIZE - 1) | \ DEC2155X_DS_IO_OR_MEM1_TYPE)#else# define DEC2155X_DS_IO_OR_MEM1_SETUP 0x00000000#endif#if (DEC2155X_DS_MEM2_SIZE)# define DEC2155X_DS_MEM2_SETUP ( \ DEC2155X_SETUP_REG_BAR_ENABLE | \ ~(DEC2155X_DS_MEM2_SIZE - 1) | \ DEC2155X_DS_MEM2_TYPE)#else# define DEC2155X_DS_MEM2_SETUP 0x00000000#endif#if (DEC2155X_DS_MEM3_SIZE)# define DEC2155X_DS_MEM3_SETUP ( \ DEC2155X_SETUP_REG_BAR_ENABLE | \ ~(DEC2155X_DS_MEM3_SIZE - 1) | \ DEC2155X_DS_MEM3_TYPE)#else# define DEC2155X_DS_MEM3_SETUP 0x00000000#endif#if (DEC2155X_US_IO_OR_MEM0_SIZE)# define DEC2155X_US_IO_OR_MEM0_SETUP ( \ DEC2155X_SETUP_REG_BAR_ENABLE | \ ~(DEC2155X_US_IO_OR_MEM0_SIZE - 1) | \ DEC2155X_US_IO_OR_MEM0_TYPE)#else# define DEC2155X_US_IO_OR_MEM0_SETUP 0x00000000#endif#if (DEC2155X_US_MEM1_SIZE)# define DEC2155X_US_MEM1_SETUP ( \ DEC2155X_SETUP_REG_BAR_ENABLE | \ ~(DEC2155X_US_MEM1_SIZE - 1) | \ DEC2155X_US_MEM1_TYPE)#else# define DEC2155X_US_MEM1_SETUP 0x00000000#endif#define DEC2155X_UPR32_DS_MEM3_SETUP 0x00000000#define DEC2155X_CFG_CHP_STS_ERR_CLR (DEC2155X_CHPSR_US_DLYD_TRNS_MSTR_TO | \ DEC2155X_CHPSR_US_DLYD_RD_TRNS_TO | \ DEC2155X_CHPSR_US_DLYD_WRT_TRNS_TO | \ DEC2155X_CHPSR_US_PSTD_WRT_DATA_DISC)#define DEC2155X_CFG_STS_ERR_CLR (DEC2155X_CFG_STS_DATA_PAR_ERR_DET | \ DEC2155X_CFG_STS_SIG_TGT_ABT | \ DEC2155X_CFG_STS_RCVD_TGT_ABT | \ DEC2155X_CFG_STS_RCVD_MSTR_ABT | \ DEC2155X_CFG_STS_SIG_SYS_ERR | \ DEC2155X_CFG_STS_DET_PAR_ERR)/* structures */typedef struct windowParameters { UINT32 windowType; /* mem or i/o */ UINT32 origBase; /* as seen from originating bus */ UINT32 trgtBase; /* as seen from target bus */ UINT32 trgtLimit; /* end of window + 1 */ } WINDOW_PARAMETERS;typedef struct windowOffsets { UINT32 bar; /* offset to base address register */ UINT32 trans; /* offset to translation or opposite base address reg */ UINT32 setup; /* offset to setup reg or pseudo-register contents */ UINT32 unuseable; /* unuseable space at start of window */ } WINDOW_OFFSETS;/* * NOTE: The Primary CSR I/O BAR, Secondary CSR Memory BAR and the Secondary * CSR I/O BAR do not have corresponding setup registers in the Dec2155x. * Also note that the first 4KB of the window mapped by the * Primary CSR and Downstream Memory 0 BAR actually references the * Dec2155x CSR set. To accommodate these hardware-defined windows, * a number of simulated setup registers are present in the offset tables * below. They can be recognized by the fact that their values are far * to large to be true register offsets. This fact is ensured because * an enabled setup register will always have bit 31 set. When the * window mapping code encounters one of large offsets, it simply uses * the emulated setup value from the table as if it had been read from * the Dec2155x itself. Please bear this in mind should any modifications * to the table be required. * * Also note that there are two table entries for the Primary CSR and * Downstream Memory 0 window. This apparent double mapping is done to * simplify the translation of addresses which lie within this window. * Addresses in the CSR register set (doorbell interrupts, doorbell * interrupt masks, etc.) are translated by looking up the address of the * register when viewed by the opposite processor while the memory area * above the CSR register space is translated using the downstream CSR * and Memory 0 translated base register. Even though these two windows * overlap for the first 4KB (the size of the CSR register image), no * conflict is created because the translation routines always check the * CSR space first. If the address resides in the CSR space, the search * will never advance to the memory portion of the window and only one * translated value is possible. If the address resides above the CSR * space, the first mapping window will lie below the address of * interest and the corresponding memory 0 mapping will be used to * translate the address. */static WINDOW_OFFSETS dsWindowOffsets [] = { /* first two entries must be at the front of the table and in order */ { DEC2155X_CFG_PRI_CSR_AND_DS_MEM0_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, DEC2155X_CFG_SEC_CSR_MEM_BAR, (~(DEC2155X_DEFAULT_MEM_WINDOW_SZ - 1) | PCI_BAR_SPACE_MEM), NULL }, { DEC2155X_CFG_PRI_CSR_AND_DS_MEM0_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, DEC2155X_CFG_DS_MEM0_TB, DEC2155X_CFG_DS_MEM0_SETUP, DEC2155X_DEFAULT_MEM_WINDOW_SZ }, { DEC2155X_CFG_PRI_CSR_IO_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, DEC2155X_CFG_SEC_CSR_IO_BAR, (~(DEC2155X_DEFAULT_IO_WINDOW_SZ - 1) | PCI_BAR_SPACE_IO), NULL }, { DEC2155X_CFG_PRI_DS_IO_OR_MEM1_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, DEC2155X_CFG_DS_IO_OR_MEM1_TB, DEC2155X_CFG_DS_IO_OR_MEM1_SETUP, NULL }, { DEC2155X_CFG_PRI_DS_MEM2_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, DEC2155X_CFG_DS_MEM2_TB, DEC2155X_CFG_DS_MEM2_SETUP, NULL }, { DEC2155X_CFG_PRI_DS_MEM3_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, DEC2155X_CFG_DS_MEM3_TB, DEC2155X_CFG_DS_MEM3_SETUP, NULL }, };static WINDOW_OFFSETS usWindowOffsets [] = { { DEC2155X_CFG_SEC_CSR_MEM_BAR, DEC2155X_CFG_PRI_CSR_AND_DS_MEM0_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, (~(DEC2155X_DEFAULT_MEM_WINDOW_SZ - 1) | PCI_BAR_SPACE_MEM), NULL }, { DEC2155X_CFG_SEC_CSR_IO_BAR, DEC2155X_CFG_PRI_CSR_IO_BAR+DEC2155X_PRI_FROM_SEC_OFFSET, (~(DEC2155X_DEFAULT_IO_WINDOW_SZ - 1) | PCI_BAR_SPACE_IO), NULL }, { DEC2155X_CFG_SEC_US_IO_OR_MEM0_BAR, DEC2155X_CFG_US_IO_OR_MEM0_TB, DEC2155X_CFG_US_IO_OR_MEM0_SETUP, NULL }, { DEC2155X_CFG_SEC_US_MEM1_BAR, DEC2155X_CFG_US_MEM1_TB, DEC2155X_CFG_US_MEM1_SETUP, NULL } };#define DS_WINDOW_COUNT (sizeof (dsWindowOffsets) / sizeof (WINDOW_OFFSETS))#define US_WINDOW_COUNT (sizeof (usWindowOffsets) / sizeof (WINDOW_OFFSETS))/* forward declarations */LOCAL FUNCPTR sysMailboxRoutine = NULL;LOCAL int sysMailboxArg = NULL;void sysDec2155xIntr (void);/* extern declarations */IMPORT int intEnable (int);IMPORT int intDisable (int);IMPORT INT_HANDLER_DESC * sysIntTbl [256]; /* Intr vector table */IMPORT STATUS pciConfigModifyLong (int, int, int, int, UINT32, UINT32);IMPORT STATUS pciConfigModifyWord (int, int, int, int, UINT16, UINT16);IMPORT STATUS pciConfigModifyByte (int, int, int, int, UINT8, UINT8);IMPORT void sysPciInsertLong (UINT32, UINT32, UINT32);IMPORT void sysPciInsertWord (UINT32, UINT16, UINT16);IMPORT void sysPciInsertByte (UINT32, UINT8, UINT8);IMPORT void sysOutByte (ULONG, UCHAR);IMPORT void sysPciOutWordConfirm (UINT32, UINT16);/* globals */UINT32 sysDec2155xCsrAdrs = 0; /* Base address of dec2155x CSR space *//* * If sysDec2155xInit finds the drawbridge in the wrong state this variable * will be set non-zero. */UINT32 sysDec2155xInitFail = 0;/* Arrays to hold the Dec2155x window translation values */WINDOW_PARAMETERS dsWindows[DS_WINDOW_COUNT] = { { 0 } };WINDOW_PARAMETERS usWindows[US_WINDOW_COUNT] = { { 0 } };/* Variables to hold the number of Dec2155x windows detected */UINT32 dsWinsValid = 0;UINT32 usWinsValid = 0;/* DEC 2155x Access macros */#ifndef DEC2155X_CSR_ADRS# define DEC2155X_CSR_ADRS(offset) (sysDec2155xCsrAdrs+offset)#endif#ifndef DEC2155X_CFG_RD_LONG# define DEC2155X_CFG_RD_LONG(offset, result) \ pciConfigInLong (0, DEC2155X_PCI_DEV_NUMBER, 0, (offset), \ (UINT32 *)(result))#endif#ifndef DEC2155X_CFG_RD_WORD# define DEC2155X_CFG_RD_WORD(offset, result) \ pciConfigInWord (0, DEC2155X_PCI_DEV_NUMBER, 0, (offset), \ (UINT16 *)(result))#endif#ifndef DEC2155X_CFG_RD_BYTE# define DEC2155X_CFG_RD_BYTE(offset, result) \ pciConfigInByte (0, DEC2155X_PCI_DEV_NUMBER, 0, (offset), \ (UINT8 *)(result))#endif#ifndef DEC2155X_CFG_WR_LONG# define DEC2155X_CFG_WR_LONG(offset, result) \ pciConfigOutLong (0, DEC2155X_PCI_DEV_NUMBER, 0, (offset), \ (UINT32)(result))#endif#ifndef DEC2155X_CFG_WR_WORD # define DEC2155X_CFG_WR_WORD(offset, result) \ pciConfigOutWord (0, DEC2155X_PCI_DEV_NUMBER, 0, (offset), \ (UINT16)(result))#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -