Changeset 8ab339e in mainline for boot/arch/arm32/src/mm.c


Ignore:
Timestamp:
2013-02-26T10:58:29Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b04ca9c
Parents:
1935591 (diff), 088b334 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/arm32/src/mm.c

    r1935591 r8ab339e  
    3838#include <arch/mm.h>
    3939
     40/** Disable the MMU */
     41static void disable_paging(void)
     42{
     43        asm volatile (
     44                "mrc p15, 0, r0, c1, c0, 0\n"
     45                "bic r0, r0, #1\n"
     46                "mcr p15, 0, r0, c1, c0, 0\n"
     47                ::: "r0"
     48        );
     49}
     50
    4051/** Check if caching can be enabled for a given memory section.
    4152 *
     
    5667        else
    5768                return 1;
    58 #else
     69#elif defined MACHINE_beagleboardxm
     70        const unsigned long address = section << PTE_SECTION_SHIFT;
     71        if (address >= BBXM_RAM_START && address < BBXM_RAM_END)
     72                return 1;
     73#elif defined MACHINE_beaglebone
     74        const unsigned long address = section << PTE_SECTION_SHIFT;
     75        if (address >= AM335x_RAM_START && address < AM335x_RAM_END)
     76                return 1;
     77#endif
    5978        return 0;
    60 #endif
    6179}
    6280
     
    85103        pte->tex = 0;
    86104        pte->access_permission_1 = 0;
     105        pte->shareable = 0;
    87106        pte->non_global = 0;
    88107        pte->should_be_zero_2 = 0;
     
    99118        for (page = 0; page < split_page; page++)
    100119                init_ptl0_section(&boot_pt[page], page);
    101        
    102         /*
    103          * Create 1:1 virtual-physical mapping in kernel space
    104          * (upper 2 GB), physical addresses start from 0.
    105          */
    106         /* BeagleBoard-xM (DM37x) memory starts at 2GB border,
    107          * thus mapping only lower 2GB is not not enough.
    108          * Map entire AS 1:1 instead and hope it works. */
    109         for (page = split_page; page < PTL0_ENTRIES; page++)
    110 #ifndef MACHINE_beagleboardxm
    111                 init_ptl0_section(&boot_pt[page], page - split_page);
    112 #else
    113                 init_ptl0_section(&boot_pt[page], page);
    114 #endif
    115120       
    116121        asm volatile (
     
    129134                "ldr r0, =0x55555555\n"
    130135                "mcr p15, 0, r0, c3, c0, 0\n"
    131                
    132 #ifdef PROCESSOR_armv7_a
    133                 /* Read Auxiliary control register */
    134                 "mrc p15, 0, r0, c1, c0, 1\n"
    135                 /* Mask to enable L2 cache */
    136                 "ldr r1, =0x00000002\n"
    137                 "orr r0, r0, r1\n"
    138                 /* Store Auxiliary control register */
    139                 "mrc p15, 0, r0, c1, c0, 1\n"
    140 #endif
     136
    141137                /* Current settings */
    142138                "mrc p15, 0, r0, c1, c0, 0\n"
    143139               
    144 #ifdef PROCESSOR_armv7_a
    145                 /* Mask to enable paging, caching */
    146                 "ldr r1, =0x00000005\n"
    147 #else
    148 #ifdef MACHINE_gta02
    149                 /* Mask to enable paging (bit 0),
    150                    D-cache (bit 2), I-cache (bit 12) */
    151                 "ldr r1, =0x00001005\n"
    152 #else
    153                 /* Mask to enable paging */
    154                 "ldr r1, =0x00000001\n"
    155 #endif
    156 #endif
     140                /* Enable ICache, DCache, BPredictors and MMU,
     141                 * we disable caches before jumping to kernel
     142                 * so this is safe for all archs.
     143                 */
     144                "ldr r1, =0x00001805\n"
     145               
    157146                "orr r0, r0, r1\n"
     147
     148                /* Invalidate the TLB content before turning on the MMU.
     149                 * ARMv7-A Reference manual, B3.10.3
     150                 */
     151                "mcr p15, 0, r0, c8, c7, 0\n"
    158152               
    159                 /* Store settings */
     153                /* Store settings, enable the MMU */
    160154                "mcr p15, 0, r0, c1, c0, 0\n"
    161155                ::: "r0", "r1"
     
    165159/** Start the MMU - initialize page table and enable paging. */
    166160void mmu_start() {
     161        disable_paging();
    167162        init_boot_pt();
    168163        enable_paging();
Note: See TracChangeset for help on using the changeset viewer.