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

📄 pagetable.s

📁 ebd9307开发板wince bsp源码,包括cs8900,lcd,nand,serial,touch,usb,gpio,wd等驱动
💻 S
字号:
;**********************************************************************
;                                                                      
; Filename: pagetable.s
;                                                                      
; Description: Sets up a pagetable so that eboot can download a lot 
;              faster
;
; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
; ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
; PARTICULAR PURPOSE.
;
; Use of this source code is subject to the terms of the Cirrus end-user
; license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
; If you did not accept the terms of the EULA, you are not authorized to 
; use this source code. For a copy of the EULA, please see the 
; EULA.RTF on your install media.
;
; Copyright(c) Cirrus Logic Corporation 2005, All Rights Reserved                       
;                                                                      
;**********************************************************************


    OPT 2   ; disable listing
    INCLUDE kxarm.h
    OPT 1   ; reenable listing
    OPT 128 ; disable listing of macro expansions

;
; This is the symbol exported to the other driver.
;
    EXPORT  MMUSetup
    EXPORT  PageTable
    
    GBLA    XCount

;
; Cache settings.
;
UNCACHED            EQU     0x00000000
WRITE_THROUGH       EQU     0x00000008
WRITE_BACK          EQU     0x0000000C

;
; Level one descriptors.
;
SECTION_HEADER      EQU     0x00000C12
COURSE_PAGETABLE    EQU     0x00000011
INVALID_DESCRIPTOR  EQU     0x00000000


;
; Level two descriptors.
;
SMALL_PAGE          EQU     0x00000FF2


        AREA |.KDATA|,DATA,NOINIT
;*****************************************************************************
;
; The MMU level one page table.
;
;*****************************************************************************
PageTable       
PTs     %       0x9000    

;*****************************************************************************
;
; Creates a section entry for a page table.
;
; PhysAddrStart = Physical start of memory to map. 
; PhysAddrEnd   = Physical end of memory to map.
; DescrAttr     = Descriptor attributes.
; EntryReg      = Register which is a pointer to the current page table
;                 entry 
;
; Uses Registers r0 - r3
;
;*****************************************************************************
    
        MACRO   
        CreateSectionEntry    $PhysAddrStart, $PhysAddrEnd, $DescrAttr, $EntryReg 
        ASSERT      $EntryReg<>r0
        ASSERT      $EntryReg<>r1
        ASSERT      $EntryReg<>r2
        ASSERT      $EntryReg<>r3

        ;
        ; r3 - Page Table compare value
        ; r2 - Current Physical Memory Value
        ; r1 - Descriptor Attributes.
        ; r0 - Calculated Descriptor Value
        ;
        ldr     r3, =$PhysAddrEnd
        ldr     r2, =$PhysAddrStart
        ldr     r1, =$DescrAttr
10

        ;
        ; Put an entry into the page table.
        ;  
        orr     r0, r2, r1
        str     r0, [$EntryReg], #4
        add     r2, r2, #0x100000

        ;
        ; See if we are done
        ;
        cmp     r2, r3
        blo     %b10
        MEND   

;*****************************************************************************
;
; Creates a entry for a small level 2 table.
;
; PhysAddrStart = Physical start of memory to map. 
; PhysAddrEnd   = Physical end of memory to map.
; DescrAttr     = Descriptor attributes.
; EntryReg      = Register which is a pointer to the current page table
;                 entry 
;
; Uses Registers r0 - r3
;
;*****************************************************************************
        MACRO
        CreateCourseEntry     $PhysAddrStart, $PhysAddrEnd, $DescrAttr, $EntryReg 
        ASSERT      $EntryReg<>r0
        ASSERT      $EntryReg<>r1
        ASSERT      $EntryReg<>r2
        ASSERT      $EntryReg<>r3
        ;
        ; r3 - Page Table compare value
        ; r2 - Current Physical Memory Value
        ; r1 - Descriptor Attributes.
        ; r0 - Calculated Descriptor Value
        ;
        ldr     r3, =$PhysAddrEnd
        ldr     r2, =$PhysAddrStart
        ldr     r1, =$DescrAttr
20

        ;
        ; Put an entry into the page table.
        ;  
        orr     r0, r2, r1
        str     r0, [$EntryReg], #4
        add     r2, r2, #0x1000

        ;
        ; See if we are done
        ;
        cmp     r2, r3
        blo     %b20
        MEND   
      


    TEXTAREA
;*****************************************************************************
;
; The function to setup the MMU.
;
; r4 - Current Pagetable pointer. Virtual Address.
; r5 - Start of Pagetable (Physical Address)
; r6 - Level 2 Course Page Table.
;
;*****************************************************************************
        LEAF_ENTRY  MMUSetup

        ;
        ; Find the start of the pagetable at an offset of 16K.
        ;
        ldr     r5, =PageTable
        ldr     r2, =0xFFFFC000
        and     r5, r5, r2
        orr     r5, r5, #0x4000
        mov     r4, r5
        add     r6, r4, #0x4000

MemoryAtZeroLocationZero


        ;
        ;  Name              Phys Start   Phys End     Descriptor Type                  r4   Virtual Address Range 
        ;-----------------  -----------  ----------  ------------------------------         ------------------------
        ;  Eboot SDRAM
        orr     r0, r6, #(COURSE_PAGETABLE)
        str     r0, [r4], #4

        CreateSectionEntry  0x00100000, 0x01FFFFFF, (SECTION_HEADER :or: UNCACHED) , r4 ; 0x00100000, 0x01FFFFFF
        CreateSectionEntry  0x04000000, 0x05FFFFFF, (SECTION_HEADER :or: UNCACHED) , r4 ; 0x02000000, 0x03FFFFFF
        CreateSectionEntry  0x04000000, 0x0FFFFFFF, (INVALID_DESCRIPTOR)           , r4 ; 0x04000000, 0x0FFFFFFF
        
        ;
        ; Make the rest of memory physical equal virtual.
        ; 
        CreateSectionEntry  0x10000000, 0xFFEFFFFF, (SECTION_HEADER :or: UNCACHED) , r4 ; 0x10000000, 0xFFEFFFFF

        ;
        ; Need to manually store the last section pagetable value.
        ;
        ldr     r0, =(0xFFF00000 :or: SECTION_HEADER :or: UNCACHED)
        str     r0, [r4], #4

        ;
        ; R4 should be equal to R6 at this point anyway.
        ;
        mov     r4, r6
        CreateCourseEntry   0x00000000, 0x0003FFFF, (SMALL_PAGE :or: UNCACHED)     , r4 ; 0x00000000, 0x0003FFFF
        CreateCourseEntry   0x00040000, 0x000FFFFF, (SMALL_PAGE :or: WRITE_BACK)   , r4 ; 0x00000000, 0x000FFFFF

        ;
        ; Set up the MMU.  Start by flushing the cache and TLB.
        ;
        ldr     r0, =0x00000000
        mcr     p15, 0, r0, c7, c7, 0
        mcr     p15, 0, r0, c8, c7, 0

        ;
        ; Set user mode access for all 16 domains.
        ;
        ldr     r0, =0x55555555
        mcr     p15, 0, r0, c3, c0, 0

        ;
        ; Tell the MMU where to find the page table.
        ;
        ;IMPORT  PageTable
        ;ldr     r0, =PageTable
        mcr     p15, 0, r5, c2, c0, 0

        ;
        ; Enable the MMU.
        ;
        ldr     r0, =0xc000107d
        mcr     p15, 0, r0, c1, c0, 0

        ;
        ; There should always be two NOP instructions following the enable or
        ; disable of the MMU.
        ;
        nop
        nop

        ;;
        ;; Return
        ;;
        mov     pc, lr


        END

⌨️ 快捷键说明

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