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

📄 sysalib.s

📁 VxWorks下 Mv2100的BSP源码
💻 S
📖 第 1 页 / 共 2 页
字号:
** This function writes a word to a specified io address or to local memory.* It operates in big-endian mode and does not perform any translation* operations on either the supplied address or data.** RETURNS: N/A** void sysOutWord (UINT16 * dataPtr, UINT16 data)*/sysOutWord:        /* Write a word to address */        sthx    r4,r0,r3        /* Sync I/O operation */	sync        /* Return to caller */        bclr    20,0/******************************************************************************* sysPciInWord - reads a word from PCI I/O or Memory space** This function reads a word from a specified PCI I/O or Memory address* via the PCI bridge chip.  This function should be used for access* to the I/O or Memory mapped registers of a PCI device.  These* registers are mapped as little-endian, so we byte swap the data in order* to make the value returned look the same as it would in PCI space.** RETURNS: word from address.** UINT16 sysPciInWord (UINT16 * dataPtr)*/sysPciInWord:        /* Read word from address */        lhbrx    r3,r0,r3        /* Return to caller */        bclr    20,0/******************************************************************************* sysPciOutWord - writes a word to PCI I/O or Memory space** This function writes a word to a specified PCI I/O or Memory address* via the PCI bridge chip.  This function should be used for access* to the I/O or Memory mapped registers of a PCI device.  These* registers are mapped as little-endian, so we byte swap the data in order* to make the value written correct for the registers in PCI space.** RETURNS: N/A** void sysPciOutWord (UINT16 * dataPtr, UINT16 data)*/sysPciOutWord:        /* Write a word to the address */        sthbrx    r4,r0,r3        /* Sync I/O operation */	sync        /* Return to caller */        bclr    20,0/******************************************************************************* sysPciConfigInWord - reads a word from a PCI configuration space address.** This function reads a word from a specified PCI configuration space* address.  This function uses the indirect PCI configuration space access* method.  It writes the input configuration space address to the CAR and* then reads the data from the CDR.  All reads/writes larger than 8 bits * use byte swapping.** Register Usage* r3 - Configuration space address to read from / returned data* r4 - dummy parameter, used for holding the CAR address* r5 - dummy parameter, used for holding the CDR address** RETURNS: N/A** UINT16 sysPciConfigInWord (UINT16 * dataPtr, UINT dummy1, UINT dummy2)*/sysPciConfigInWord:        andi.   r4,r3,3                 /* save the 2 LSBs of the PCI addr */        addis   r5,r0,HIADJ(PCI_MSTR_PRIMARY_CDR)        ori     r5,r5,LO(PCI_MSTR_PRIMARY_CDR)        or      r5,r5,r4                /* add the LSBs value to the CDR */        andi.   r4,r4,0                 /* the config. space address must */        ori     r4,r4,3                 /* be 4-byte aligned */        andc    r3,r3,r4                /* mask off the 2 LSBs */        addis   r4,r0,HIADJ(PCI_MSTR_PRIMARY_CAR)        ori     r4,r4,LO(PCI_MSTR_PRIMARY_CAR)        stwbrx  r3,r0,r4                /* write config. space addr. to CAR */        sync                            /* ensure memory access is complete */	andi.	r3,r3,0        lhbrx   r3,r0,r5                /* read data out of the CDR */        bclr    20,0                    /* return to caller *//******************************************************************************* sysPciConfigOutWord - writes a word to a PCI configuration space address.** This function writes a word to a specified PCI configuration space* address.  This function uses the indirect PCI configuration space access* method.  It writes the input configuration space address to the CAR and* then writes the data to the CDR.  All writes larger than 8 bits use byte* swapping.** Register Usage* r3 - Configuration space address to write to* r4 - data to be written* r5 - dummy parameter, used for holding the CAR address* r6 - dummy parameter, used for holding the CDR address** RETURNS: N/A** void sysPciConfigOutWord (UINT16 * dataPtr, UINT16 data, *                           UINT dummy1, UINT dummy2)*/sysPciConfigOutWord:        andi.   r5,r3,3                 /* save the 2 LSBs of the PCI addr */        addis   r6,r0,HIADJ(PCI_MSTR_PRIMARY_CDR)        ori     r6,r6,LO(PCI_MSTR_PRIMARY_CDR)        or      r6,r6,r5                /* add the LSBs value to the CDR */        andi.   r5,r5,0                 /* the config. space address must */        ori     r5,r5,3                 /* be 4-byte aligned */        andc    r3,r3,r5                /* mask off the 2 LSBs */        addis   r5,r0,HIADJ(PCI_MSTR_PRIMARY_CAR)        ori     r5,r5,LO(PCI_MSTR_PRIMARY_CAR)        stwbrx  r3,r0,r5                /* write config. space addr. to CAR */        sync                            /* ensure memory access is complete */        sthbrx  r4,r0,r6                /* write data to CDR */        sync        bclr    20,0                    /* return to caller *//******************************************************************************* sysInLong - reads a long (32-bit big-endian) from an io address.** This function reads a long from a specified io address or from local memory.* It operates in big-endian mode and does not perform any translation* operations on either the supplied address or the retrieved data.** RETURNS: long (32-bit big-endian) from address** UINT32 sysInLong ( UINT32 * dataPtr)*/sysInLong:        /* Read long from address */        lwzx    r3,r0,r3        /* Return to caller */        bclr    20,0/******************************************************************************** sysOutLong - writes a long (32-bit big-endian) to an io address.** This function writes a long to a specified io address or to local memory.* It operates in big-endian mode and does not perform any translation* operations on either the supplied address or data.* This function writes a long to a specified io address.** RETURNS: N/A** void sysOutLong (UINT32 * dataPtr, UINT32 data)*/sysOutLong:        /* Write a long to address */        stwx    r4,r0,r3        /* Sync I/O operation */	sync        /* Return to caller */        bclr    20,0/******************************************************************************* sysPciInLong - reads a longword from PCI I/O or Memory space** This function reads a longword from a specified PCI I/O or Memory address* via the PCI bridge chip.  This function should be used for access* to the I/O or Memory mapped registers of a PCI device.  These* registers are mapped as little-endian, so we byte reverse the data in order* to make the value returned look the same as it would in PCI space.** RETURNS: longword from address.** UINT32 sysPciInLong (UINT32 * dataPtr)*/sysPciInLong:        /* Read a longword from the address, and reverse the bytes */        lwbrx    r3,r0,r3        /* Return to caller */        bclr    20,0/******************************************************************************* sysPciOutLong - writes a longword to PCI I/O or Memory space** This function writes a longword to a specified PCI I/O or Memory address* via the PCI bridge chip.  This function should be used for access* to the I/O or Memory mapped registers of a PCI device.  These* registers are mapped as little-endian, so we byte reverse the data in order* to make the value written correct for the registers in PCI space.** RETURNS: N/A** void sysPciOutLong (UINT32 * dataPtr, UINT32 data)*/sysPciOutLong:        /* Write a long to the address, reversing the bytes */        stwbrx    r4,r0,r3        /* Sync I/O operation */	sync        /* Return to caller */        bclr    20,0/******************************************************************************* sysPciConfigInLong - reads a longword from a PCI configuration space address.** This function reads a longword from a specified PCI configuration space* address.  This function uses the indirect PCI configuration space access* method.  It writes the input configuration space address to the CAR and* then reads the data from the CDR.  All reads/writes larger than 8 bits* use byte swapping.** Register Usage* r3 - Configuration space address to read from / returned data* r4 - dummy parameter, used for holding the CAR address* r5 - dummy parameter, used for holding the CDR address** RETURNS: N/A** UINT32 sysPciConfigInLong (UINT32 * dataPtr, UINT dummy1, UINT dummy2)*/sysPciConfigInLong:        addis   r4,r0,HIADJ(PCI_MSTR_PRIMARY_CAR)        ori     r4,r4,LO(PCI_MSTR_PRIMARY_CAR)        addis   r5,r0,HIADJ(PCI_MSTR_PRIMARY_CDR)        ori     r5,r5,LO(PCI_MSTR_PRIMARY_CDR)        stwbrx  r3,r0,r4                /* write config. space addr. to CAR */        sync                            /* ensure memory access is complete */        andi.   r3,r3,0        lwbrx   r3,r0,r5                /* read data out of the CDR */        bclr    20,0                    /* return to caller *//******************************************************************************* sysPciConfigOutLong - writes a longword to a PCI configuration space address.** This function writes a longword to a specified PCI configuration space* address.  This function uses the indirect PCI configuration space access* method.  It writes the input configuration space address to the CAR and* then writes the data to the CDR.  All writes larger than 8 bits use byte* swapping.** Register Usage* r3 - Configuration space address to write to* r4 - data to be written* r5 - dummy parameter, used for holding the CAR address* r6 - dummy parameter, used for holding the CDR address** RETURNS: N/A** void sysPciConfigOutLong (UINT32 * dataPtr, UINT32 data, *                           UINT dummy1, UINT dummy2)*/sysPciConfigOutLong:        addis   r5,r0,HIADJ(PCI_MSTR_PRIMARY_CAR)        ori     r5,r5,LO(PCI_MSTR_PRIMARY_CAR)        addis   r6,r0,HIADJ(PCI_MSTR_PRIMARY_CDR)        ori     r6,r6,LO(PCI_MSTR_PRIMARY_CDR)        stwbrx  r3,r0,r5                /* write config. space addr. to CAR */        sync                            /* ensure memory access is complete */        stwbrx	r4,r0,r6                /* write data to CDR */        sync                            /* ensure memory access is complete */        bclr    20,0                    /* return to caller *//********************************************************************************* sysMemProbeSup - sysBusProbe support routine** This routine is called to try to read byte, word, or long, as specified* by length, from the specified source to the specified destination.** RETURNS: OK if successful probe, else ERRORSTATUS sysMemProbeSup (length, src, dest)    (    int         length, // length of cell to test (1, 2, 4, 8, 16) *    char *      src,    // address to read *    char *      dest    // address to write *    )*/sysMemProbeSup:        addi    p7, p0, 0       /* save length to p7 */        xor     p0, p0, p0      /* set return status */        cmpwi   p7, 1           /* check for byte access */        bne     sbpShort        /* no, go check for short word access */        lbz     p6, 0(p1)       /* load byte from source */        stb     p6, 0(p2)       /* store byte to destination */        sync        isync                   /* enforce for immediate exception handling */        blrsbpShort:        cmpwi   p7, 2           /* check for short word access */        bne     sbpWord         /* no, check for word access */        lhz     p6, 0(p1)       /* load half word from source */        sth     p6, 0(p2)       /* store half word to destination */        sync        isync                   /* enforce for immediate exception handling */        blrsbpWord:        cmpwi   p7, 4           /* check for short word access */        bne     sysProbeExc     /* no, check for double word access */        lwz     p6, 0(p1)       /* load half word from source */        stw     p6, 0(p2)       /* store half word to destination */        sync        isync                   /* enforce for immediate exception handling */        blrsysProbeExc:        li      p0, -1          /* shouldn't ever get here, but... */        blr/******************************************************************************** sysTimeBaseLGet - Get lower half of Time Base Register** This routine will read the contents the lower half of the Time* Base Register (TBL - TBR 268).** From a C point of view, the routine is defined as follows:**    UINT32 sysTimeBaseLGet(void)** RETURNS: value of TBR 268 (in r3)*/sysTimeBaseLGet:	mftb 3	bclr 20,0/******************************************************************************** sysHid1Get - read from HID1 register SPR1009.** This routine will return the contents of the HID1 (SPR1009)** From a C point of view, the routine is defined as follows:**    UINT sysHid1Get()** RETURNS: value of SPR1009 (in r3)*/sysHid1Get:	mfspr r3,1009	bclr 20,0/******************************************************************************** sysHid2Get - read from HID2 register SPR1011.** This routine will return the contents of the HID2 (SPR1011)** From a C point of view, the routine is defined as follows:**    UINT sysHid2Get()** RETURNS: value of SPR1011 (in r3)*/sysHid2Get:        mfspr r3,1011        bclr 20,0/******************************************************************************** sysHid2Set - write data to HID2 register SPR1011.** This routine will store the contents of HID2 (SPR1011) with the data* supplied in R3.** From a C point of view, the routine is defined as follows:**    UINT sysHid2Set(UINT dataValue)** RETURNS: N/A*/sysHid2Set:        mtspr 1011,r3        bclr 20,0

⌨️ 快捷键说明

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