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

📄 xllp_wmmx_regs.s

📁 Intel PXA270底层设备驱动代码
💻 S
📖 第 1 页 / 共 2 页
字号:
;******************************************************************************
;
; INTEL CONFIDENTIAL
; Copyright 2002-2003 Intel Corporation All Rights Reserved.
;
; The source code contained or described herein and all documents
; related to the source code (Material) are owned by Intel Corporation
; or its suppliers or licensors.  Title to the Material remains with
; Intel Corporation or its suppliers and licensors. The Material contains
; trade secrets and proprietary and confidential information of Intel
; or its suppliers and licensors. The Material is protected by worldwide
; copyright and trade secret laws and treaty provisions. No part of the
; Material may be used, copied, reproduced, modified, published, uploaded,
; posted, transmitted, distributed, or disclosed in any way without Intel's
; prior express written permission.
;
; No license under any patent, copyright, trade secret or other intellectual
; property right is granted to or conferred upon you by disclosure or
; delivery of the Materials, either expressly, by implication, inducement,
; estoppel or otherwise. Any license under such intellectual property rights
; must be express and approved by Intel in writing.
;
;
;*********************************************************************************
;
;  FILENAME:       xllp_WMMX_Regs.s
;
;  PURPOSE:        Provides assembly level code to support thread level
;                  context saving and restoration for the
;                  Bulverde processor's WMMX registers.
;
;  LAST MODIFIED:  11-Nov-2003
;******************************************************************************
;
; NOTES:
;
;    None.
;
;******************************************************************************

        AREA    |.text|, CODE, READONLY, ALIGN=5        ; Align =5 required for "ALIGN 32" to work
;
; List of Low Level Init functions in this source code include:
;
        EXPORT Xllp_Read_CoProc_Access
        EXPORT Xllp_Set_CoProc_Access
        EXPORT Xllp_Save_WMMX_Regs
        EXPORT Xllp_Restore_WMMX_Regs
        EXPORT Xllp_Store_All_WMMX_Regs
        EXPORT Xllp_Restore_All_WMMX_Regs


;******************************************************************************
;
;       ***************************
;       *                         *
;       * Xllp_Read_CoProc_Access *
;       *                         *
;       ***************************
;
; This routine is used to return the coprocessor access bits located in
; coprocessor 15, register 15.  It returns it to the location specified in
; r0
;
;******************************************************************************
Xllp_Read_CoProc_Access  FUNCTION

        stmdb   sp!, {r0 - r2, r14}

        mrc     p15, 0, r1, c15, c1, 0    ;Get Reg15 of CP15 for Access to CP0

        ;CPWAIT  r2                       ;Now 'stall' so the value can have time to be read
        MRC     P15, 0, r2, C2, C0, 0     ; arbitrary read of CP15
        MOV     r2, r2                    ; wait for it (foward dependency)
        SUB     PC, PC, #4                ; branch to next instruction

        str  r1, [r0]
        ldmia   sp!, {r0 - r2, r14}

        IF Interworking :LOR: Thumbing
            bx  lr
        ELSE
            mov  pc, lr          ; return
        ENDIF ; IF Interworking :LOR: Thumbing

        ENDFUNC


;******************************************************************************
;
;       ***************************
;       *                         *
;       * Xllp_Set_CoProc_Access  *
;       *                         *
;       ***************************
;
;
; This routine enables the access bits to Coprocessors 0 & 1
;
; Uses R0, R1. R2
;
;******************************************************************************
Xllp_Set_CoProc_Access  FUNCTION

        stmdb   sp!, {r0 - r2, r14}

        mrc     p15, 0, r0, c15, c1, 0    ;Get Reg15 of CP15 for Access to CP0
        mov     r1, #0x3                  ;Load R2 with mask for setting lowest bit
        orr     r2, r0, r1                ;OR current value with 1 to set the lowest bit
        mcr     p15, 0, r2, c15, c1, 0    ;Now set the value back into R15 of CP15

        ;CPWAIT  r0                       ;Now 'stall' so the value can have time to be written
        MRC     P15, 0, r0, C2, C0, 0     ; arbitrary read of CP15
        MOV     r0, r0                    ; wait for it (foward dependency)
        SUB     PC, PC, #4                ; branch to next instruction

        ldmia   sp!, {r0 - r2, r14}

        IF Interworking :LOR: Thumbing
            bx  lr
        ELSE
            mov  pc, lr          ; return
        ENDIF ; IF Interworking :LOR: Thumbing

        ENDFUNC


;******************************************************************************
;
;       ***************************
;       *                         *
;       * Xllp_Save_WMMX_Regs     *
;       *                         *
;       ***************************
;
;
; This routine is expected to be the entry point for the "SaveAll".  It checks
; the CUP and MUP bits in the control register to see if we need to save, if it
; is unnecessary, then we simply dump out of the routine.  If it is necessary,
; it sets a flag at the start of the save area and calls "SaveAll" to save all
; the WMMX registers.
;
; Uses r0, - R0 contains a pointer to the alloced memory buffer of 8 bytes long
;
;******************************************************************************
Xllp_Save_WMMX_Regs   FUNCTION

        stmdb   sp!, {r0 - r4, r14}         ;Store registers so we don't stomp anything (INC LR)

        mov     r4, r0                    ;Save R0 to R4, so pointer value doesn't get killed by CPWAIT

        tmrc    r1, wC1                   ;Grab the CUP & MUP bits in CP1, Reg1

        ;CPWAIT  r0                       ;Now 'stall' so the value can have time to be written
        MRC     P15, 0, r0, C2, C0, 0     ; arbitrary read of CP15
        MOV     r0, r0                    ; wait for it (foward dependency)
        SUB     PC, PC, #4                ; branch to next instruction

        ands    r1, r1, #0x3              ;We only are concerned with the lowest 2 bits

        ;if flag == 0 then no change since last save, skip save functionality
        beq  Finish_Save

        mov     r0, #0x1                  ;Set a flag in the memory area indicating we have actually SAVED
        str     r0, [r4], #4              ;Save & increment pointer

        ; Now branch to the 'save' function, R0 = pointer to save area
        mov     r0, r4
        bl      Xllp_Store_All_WMMX_Regs

Finish_Save
        ldmia   sp!, {r0 - r4, r14}         ;Now restore the regsiters we stacked3

        IF Interworking :LOR: Thumbing
            bx  lr
        ELSE
            mov  pc, lr          ; return
        ENDIF ; IF Interworking :LOR: Thumbing


        ENDFUNC

;******************************************************************************
;
;       ***************************
;       *                         *
;       * Xllp_Restore_WMMX_Regs  *
;       *                         *
;       ***************************
;
; This function is used to restore the WMMX registers.  It checks the flags saved in
; the beginning of the saved area to see if a restore is necessary.  If it is unnecessary
; the routine dumps out, otherwise it calls the "RestoreAll" function.
;
;       Uses r0 - pointer to the memory buffer containing the WMMX saved area
;
;******************************************************************************
Xllp_Restore_WMMX_Regs   FUNCTION

        stmdb   sp!, {r0 - r4, r14}         ;stack the registers used, so don't munge anything

        ldr     r1, [r0], #4              ;Load the first 4 bytes containing 'if saving' flag
        cmp     r1, #0
        beq     Skip_Restore

        ;Branch to the 'Restore' Function, R0= pointer to save/restore memory area
        bl      Xllp_Restore_All_WMMX_Regs

Skip_Restore
        ldmia     sp!, {r0 - r4, r14}

        IF Interworking :LOR: Thumbing
            bx  lr
        ELSE
            mov  pc, lr          ; return
        ENDIF ; IF Interworking :LOR: Thumbing


        ENDFUNC


;******************************************************************************
;
;       *******************************
;       *                             *

⌨️ 快捷键说明

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