Changeset c520034 in mainline for kernel/arch/arm32


Ignore:
Timestamp:
2011-12-31T18:19:35Z (14 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
Location:
kernel/arch/arm32
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/Makefile.inc

    r852052d rc520034  
    5353        arch/$(KARCH)/src/debug/stacktrace.c \
    5454        arch/$(KARCH)/src/debug/stacktrace_asm.S \
     55        arch/$(KARCH)/src/mm/km.c \
    5556        arch/$(KARCH)/src/mm/as.c \
    5657        arch/$(KARCH)/src/mm/frame.c \
  • kernel/arch/arm32/include/mach/integratorcp/integratorcp.h

    r852052d rc520034  
    103103extern void icp_cpu_halt(void);
    104104extern void icp_irq_exception(unsigned int, istate_t *);
    105 extern void icp_get_memory_extents(uintptr_t *, uintptr_t *);
     105extern void icp_get_memory_extents(uintptr_t *, size_t *);
    106106extern void icp_frame_init(void);
    107107extern size_t icp_get_irq_count(void);
  • kernel/arch/arm32/include/mach/testarm/testarm.h

    r852052d rc520034  
    7171extern void gxemul_cpu_halt(void);
    7272extern void gxemul_irq_exception(unsigned int, istate_t *);
    73 extern void gxemul_get_memory_extents(uintptr_t *, uintptr_t *);
     73extern void gxemul_get_memory_extents(uintptr_t *, size_t *);
    7474extern void gxemul_frame_init(void);
    7575extern size_t gxemul_get_irq_count(void);
  • kernel/arch/arm32/include/machine_func.h

    r852052d rc520034  
    5050        void (*machine_timer_irq_start)(void);
    5151        void (*machine_cpu_halt)(void);
    52         void (*machine_get_memory_extents)(uintptr_t *, uintptr_t *);
     52        void (*machine_get_memory_extents)(uintptr_t *, size_t *);
    5353        void (*machine_irq_exception)(unsigned int, istate_t *);
    5454        void (*machine_frame_init)(void);
     
    8181 * @param size          Place to store memory size.
    8282 */
    83 extern void machine_get_memory_extents(uintptr_t *start, uintptr_t *size);
     83extern void machine_get_memory_extents(uintptr_t *start, size_t *size);
    8484
    8585/** Interrupt exception handler.
  • kernel/arch/arm32/include/mm/frame.h

    r852052d rc520034  
    6161#endif
    6262
    63 extern uintptr_t last_frame;
    64 
    65 extern void frame_arch_init(void);
     63extern void frame_low_arch_init(void);
     64extern void frame_high_arch_init(void);
    6665extern void boot_page_table_free(void);
    6766#define physmem_print()
  • kernel/arch/arm32/include/mm/page.h

    r852052d rc520034  
    5454
    5555/* Number of entries in each level. */
    56 #define PTL0_ENTRIES_ARCH       (2 << 12)       /* 4096 */
     56#define PTL0_ENTRIES_ARCH       (1 << 12)       /* 4096 */
    5757#define PTL1_ENTRIES_ARCH       0
    5858#define PTL2_ENTRIES_ARCH       0
    5959/* coarse page tables used (256 * 4 = 1KB per page) */
    60 #define PTL3_ENTRIES_ARCH       (2 << 8)        /* 256 */
     60#define PTL3_ENTRIES_ARCH       (1 << 8)        /* 256 */
    6161
    6262/* Page table sizes for each level. */
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    r852052d rc520034  
    6565static void gta02_timer_irq_start(void);
    6666static void gta02_cpu_halt(void);
    67 static void gta02_get_memory_extents(uintptr_t *start, uintptr_t *size);
     67static void gta02_get_memory_extents(uintptr_t *start, size_t *size);
    6868static void gta02_irq_exception(unsigned int exc_no, istate_t *istate);
    6969static void gta02_frame_init(void);
     
    123123 * @param size          Place to store memory size.
    124124 */
    125 static void gta02_get_memory_extents(uintptr_t *start, uintptr_t *size)
     125static void gta02_get_memory_extents(uintptr_t *start, size_t *size)
    126126{
    127127        *start = GTA02_MEMORY_START + GTA02_MEMORY_SKIP;
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    r852052d rc520034  
    220220 * @param size          Place to store memory size.
    221221 */
    222 void icp_get_memory_extents(uintptr_t *start, uintptr_t *size)
     222void icp_get_memory_extents(uintptr_t *start, size_t *size)
    223223{
    224224        *start = 0;
  • kernel/arch/arm32/src/mach/testarm/testarm.c

    r852052d rc520034  
    202202 * @param size          Place to store memory size.
    203203 */
    204 void gxemul_get_memory_extents(uintptr_t *start, uintptr_t *size)
     204void gxemul_get_memory_extents(uintptr_t *start, size_t *size)
    205205{
    206206        *start = 0;
    207         *size = *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET));
     207        *size = *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET));
    208208}
    209209
  • kernel/arch/arm32/src/machine_func.c

    r852052d rc520034  
    8585 * @param size          Place to store memory size.
    8686 */
    87 void machine_get_memory_extents(uintptr_t *start, uintptr_t *size)
     87void machine_get_memory_extents(uintptr_t *start, size_t *size)
    8888{
    8989        (machine_ops->machine_get_memory_extents)(start, size);
  • kernel/arch/arm32/src/mm/frame.c

    r852052d rc520034  
    3939#include <config.h>
    4040#include <align.h>
     41#include <macros.h>
    4142
    42 /** Address of the last frame in the memory. */
    43 uintptr_t last_frame = 0;
     43static void frame_common_arch_init(bool low)
     44{
     45        uintptr_t base;
     46        size_t size;
    4447
    45 /** Creates memory zones. */
    46 void frame_arch_init(void)
     48        machine_get_memory_extents(&base, &size);
     49        base = ALIGN_UP(base, FRAME_SIZE);
     50        size = ALIGN_DOWN(size, FRAME_SIZE);
     51       
     52        if (!frame_adjust_zone_bounds(low, &base, &size))
     53                return;
     54
     55        if (low) {
     56                zone_create(ADDR2PFN(base), SIZE2FRAMES(size),
     57                    BOOT_PAGE_TABLE_START_FRAME +
     58                    BOOT_PAGE_TABLE_SIZE_IN_FRAMES,
     59                    ZONE_AVAILABLE | ZONE_LOWMEM);
     60        } else {
     61                pfn_t conf = zone_external_conf_alloc(SIZE2FRAMES(size));
     62
     63                zone_create(ADDR2PFN(base), SIZE2FRAMES(size), conf,
     64                    ZONE_AVAILABLE | ZONE_HIGHMEM);
     65        }
     66       
     67}
     68
     69/** Create low memory zones. */
     70void frame_low_arch_init(void)
    4771{
    48         uintptr_t mem_start, mem_size;
    49         uintptr_t first_frame;
    50         uintptr_t num_frames;
     72        frame_common_arch_init(true);
    5173
    52         machine_get_memory_extents(&mem_start, &mem_size);
    53         first_frame = ALIGN_UP(mem_start, FRAME_SIZE);
    54         last_frame = ALIGN_DOWN(mem_start + mem_size, FRAME_SIZE);
    55         num_frames = (last_frame - first_frame) >> FRAME_WIDTH;
    56        
    57         /* All memory as one zone */
    58         zone_create(first_frame >> FRAME_WIDTH, num_frames,
    59             BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0);
    60        
    6174        /* blacklist boot page table */
    6275        frame_mark_unavailable(BOOT_PAGE_TABLE_START_FRAME,
     
    6477
    6578        machine_frame_init();
     79}
     80
     81/** Create high memory zones. */
     82void frame_high_arch_init(void)
     83{
     84        frame_common_arch_init(false);
    6685}
    6786
  • 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.