Changeset c520034 in mainline for kernel/arch/arm32/src/mm/page.c


Ignore:
Timestamp:
2011-12-31T18:19:35Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
295f658, 77c2b02, 96cd5b4
Parents:
852052d (diff), 22f0561 (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:

Support for kernel non-identity mappings, phase I.

  • identity/non-identity kernel memory split on all architectures
  • low/high physical memory split on all architectures
  • frame allocator understands low/high memory
  • high physical memory currently unused (Phase II)
  • more compact frame_t
  • zone conf frames, pte_t, kernel stacks allocated from low memory
  • lockless TLB-miss handlers everywhere (newly sparc64, ia64)
  • preallocate PTL1 page tables for non-identity and prevent their deallocation
  • hw_map() unification
  • new resource allocator used for allocating kernel virtual addresses

Breakage:

  • sparc64/sun4v creates too large kernel identity; not fixed because of lack of testing hw
  • ppc32's tlb_refill() seems wrong as it creates too large kernel identity, but appears unused and the architecture works normally

Not implemented yet (phase II):

  • allow high memory to be used for common kernel allocations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/mm/page.c

    r852052d rc520034  
    3737#include <genarch/mm/page_pt.h>
    3838#include <mm/page.h>
     39#include <arch/mm/frame.h>
    3940#include <align.h>
    4041#include <config.h>
     
    4243#include <typedefs.h>
    4344#include <interrupt.h>
    44 #include <arch/mm/frame.h>
     45#include <macros.h>
    4546
    4647/** Initializes page tables.
     
    5758       
    5859        uintptr_t cur;
     60
    5961        /* Kernel identity mapping */
    60         for (cur = PHYSMEM_START_ADDR; cur < last_frame; cur += FRAME_SIZE)
     62        for (cur = PHYSMEM_START_ADDR;
     63            cur < min(config.identity_size, config.physmem_end);
     64            cur += FRAME_SIZE)
    6165                page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags);
    6266       
    6367        /* Create mapping for exception table at high offset */
    6468#ifdef HIGH_EXCEPTION_VECTORS
     69        // XXX: fixme to use proper non-identity page
    6570        void *virtaddr = frame_alloc(ONE_FRAME, FRAME_KA);
    66         page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr), flags);
     71        page_mapping_insert(AS_KERNEL, EXC_BASE_ADDRESS, KA2PA(virtaddr),
     72            flags);
    6773#else
    6874#error "Only high exception vector supported now"
     
    7884}
    7985
    80 /** Maps device into the kernel space.
    81  *
    82  * Maps physical address of device into kernel virtual address space (so it can
    83  * be accessed only by kernel through virtual address).
    84  *
    85  * @param physaddr Physical address where device is connected.
    86  * @param size Length of area where device is present.
    87  *
    88  * @return Virtual address where device will be accessible.
    89  */
    90 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    91 {
    92         if (last_frame + ALIGN_UP(size, PAGE_SIZE) >
    93             KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH)) {
    94                 panic("Unable to map physical memory %p (%d bytes).",
    95                     (void *) physaddr, size);
    96         }
    97        
    98         uintptr_t virtaddr = PA2KA(last_frame);
    99         pfn_t i;
    100 
    101         page_table_lock(AS_KERNEL, true);
    102         for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) {
    103                 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i),
    104                     physaddr + PFN2ADDR(i),
    105                     PAGE_NOT_CACHEABLE | PAGE_READ | PAGE_WRITE | PAGE_KERNEL);
    106         }
    107         page_table_unlock(AS_KERNEL, true);
    108        
    109         last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
    110         return virtaddr;
    111 }
    112 
    11386/** @}
    11487 */
Note: See TracChangeset for help on using the changeset viewer.