Changeset da1bafb in mainline for kernel/genarch/src/mm/as_pt.c


Ignore:
Timestamp:
2010-05-24T18:57:31Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/mm/as_pt.c

    r666f492 rda1bafb  
    3333/**
    3434 * @file
    35  * @brief       Address space functions for 4-level hierarchical pagetables.
     35 * @brief Address space functions for 4-level hierarchical pagetables.
    3636 */
    3737
     
    4747#include <arch.h>
    4848
    49 static pte_t *ptl0_create(int flags);
    50 static void ptl0_destroy(pte_t *page_table);
     49static pte_t *ptl0_create(unsigned int);
     50static void ptl0_destroy(pte_t *);
    5151
    52 static void pt_lock(as_t *as, bool lock);
    53 static void pt_unlock(as_t *as, bool unlock);
     52static void pt_lock(as_t *, bool);
     53static void pt_unlock(as_t *, bool);
    5454
    5555as_operations_t as_pt_operations = {
     
    6767 *
    6868 * @return New PTL0.
     69 *
    6970 */
    70 pte_t *ptl0_create(int flags)
     71pte_t *ptl0_create(unsigned int flags)
    7172{
    72         pte_t *src_ptl0, *dst_ptl0;
    73         ipl_t ipl;
    74         int table_size;
    75 
    76         dst_ptl0 = (pte_t *) frame_alloc(PTL0_SIZE, FRAME_KA);
    77         table_size = FRAME_SIZE << PTL0_SIZE;
    78 
    79         if (flags & FLAG_AS_KERNEL) {
     73        pte_t *dst_ptl0 = (pte_t *) frame_alloc(PTL0_SIZE, FRAME_KA);
     74        size_t table_size = FRAME_SIZE << PTL0_SIZE;
     75       
     76        if (flags & FLAG_AS_KERNEL)
    8077                memsetb(dst_ptl0, table_size, 0);
    81         } else {
    82                 uintptr_t src, dst;
    83        
     78        else {
    8479                /*
    8580                 * Copy the kernel address space portion to new PTL0.
     81                 *
    8682                 */
    87                  
    88                 ipl = interrupts_disable();
    89                 mutex_lock(&AS_KERNEL->lock);           
    90                 src_ptl0 = (pte_t *) PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
    91 
    92                 src = (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
    93                 dst = (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
    94 
     83               
     84                ipl_t ipl = interrupts_disable();
     85                mutex_lock(&AS_KERNEL->lock);
     86               
     87                pte_t *src_ptl0 =
     88                    (pte_t *) PA2KA((uintptr_t) AS_KERNEL->genarch.page_table);
     89               
     90                uintptr_t src =
     91                    (uintptr_t) &src_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
     92                uintptr_t dst =
     93                    (uintptr_t) &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)];
     94               
    9595                memsetb(dst_ptl0, table_size, 0);
    96                 memcpy((void *) dst, (void *) src, table_size - (src - (uintptr_t) src_ptl0));
     96                memcpy((void *) dst, (void *) src,
     97                    table_size - (src - (uintptr_t) src_ptl0));
     98               
    9799                mutex_unlock(&AS_KERNEL->lock);
    98100                interrupts_restore(ipl);
    99101        }
    100 
     102       
    101103        return (pte_t *) KA2PA((uintptr_t) dst_ptl0);
    102104}
     
    107109 *
    108110 * @param page_table Physical address of PTL0.
     111 *
    109112 */
    110113void ptl0_destroy(pte_t *page_table)
    111114{
    112         frame_free((uintptr_t)page_table);
     115        frame_free((uintptr_t) page_table);
    113116}
    114117
     
    118121 * Interrupts must be disabled.
    119122 *
    120  * @param as Address space.
     123 * @param as   Address space.
    121124 * @param lock If false, do not attempt to lock the address space.
     125 *
    122126 */
    123127void pt_lock(as_t *as, bool lock)
     
    132136 * Interrupts must be disabled.
    133137 *
    134  * @param as Address space.
     138 * @param as     Address space.
    135139 * @param unlock If false, do not attempt to unlock the address space.
     140 *
    136141 */
    137142void pt_unlock(as_t *as, bool unlock)
Note: See TracChangeset for help on using the changeset viewer.