Changeset da1bafb in mainline for kernel/generic/src/mm/page.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/generic/src/mm/page.c

    r666f492 rda1bafb  
    3333/**
    3434 * @file
    35  * @brief       Virtual Address Translation subsystem.
     35 * @brief Virtual Address Translation subsystem.
    3636 *
    3737 * This file contains code for creating, destroying and searching
     
    3939 * Functions here are mere wrappers that call the real implementation.
    4040 * They however, define the single interface.
     41 *
    4142 */
    4243
     
    5556 * will do an implicit serialization by virtue of running the TLB shootdown
    5657 * interrupt handler.
     58 *
    5759 */
    5860
     
    8385 * of page boundaries.
    8486 *
    85  * @param s             Address of the structure.
    86  * @param size          Size of the structure.
     87 * @param addr Address of the structure.
     88 * @param size Size of the structure.
     89 *
    8790 */
    88 void map_structure(uintptr_t s, size_t size)
     91void map_structure(uintptr_t addr, size_t size)
    8992{
    90         int i, cnt, length;
    91 
    92         length = size + (s - (s & ~(PAGE_SIZE - 1)));
    93         cnt = length / PAGE_SIZE + (length % PAGE_SIZE > 0);
    94 
     93        size_t length = size + (addr - (addr & ~(PAGE_SIZE - 1)));
     94        size_t cnt = length / PAGE_SIZE + (length % PAGE_SIZE > 0);
     95       
     96        size_t i;
    9597        for (i = 0; i < cnt; i++)
    96                 page_mapping_insert(AS_KERNEL, s + i * PAGE_SIZE,
    97                     s + i * PAGE_SIZE, PAGE_NOT_CACHEABLE | PAGE_WRITE);
    98 
     98                page_mapping_insert(AS_KERNEL, addr + i * PAGE_SIZE,
     99                    addr + i * PAGE_SIZE, PAGE_NOT_CACHEABLE | PAGE_WRITE);
     100       
    99101        /* Repel prefetched accesses to the old mapping. */
    100102        memory_barrier();
     
    108110 * The page table must be locked and interrupts must be disabled.
    109111 *
    110  * @param as            Address space to wich page belongs.
    111  * @param page          Virtual address of the page to be mapped.
    112  * @param frame         Physical address of memory frame to which the mapping is
    113  *                      done.
    114  * @param flags         Flags to be used for mapping.
     112 * @param as    Address space to wich page belongs.
     113 * @param page  Virtual address of the page to be mapped.
     114 * @param frame Physical address of memory frame to which the mapping is
     115 *              done.
     116 * @param flags Flags to be used for mapping.
     117 *
    115118 */
    116 void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
     119void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
     120    unsigned int flags)
    117121{
    118122        ASSERT(page_mapping_operations);
     
    133137 * The page table must be locked and interrupts must be disabled.
    134138 *
    135  * @param as            Address space to wich page belongs.
    136  * @param page          Virtual address of the page to be demapped.
     139 * @param as   Address space to wich page belongs.
     140 * @param page Virtual address of the page to be demapped.
     141 *
    137142 */
    138143void page_mapping_remove(as_t *as, uintptr_t page)
     
    142147       
    143148        page_mapping_operations->mapping_remove(as, page);
    144 
     149       
    145150        /* Repel prefetched accesses to the old mapping. */
    146151        memory_barrier();
     
    153158 * The page table must be locked and interrupts must be disabled.
    154159 *
    155  * @param as            Address space to wich page belongs.
    156  * @param page          Virtual page.
     160 * @param as   Address space to wich page belongs.
     161 * @param page Virtual page.
    157162 *
    158  * @return              NULL if there is no such mapping; requested mapping
    159  *                      otherwise.
     163 * @return NULL if there is no such mapping; requested mapping
     164 *         otherwise.
     165 *
    160166 */
    161167pte_t *page_mapping_find(as_t *as, uintptr_t page)
     
    163169        ASSERT(page_mapping_operations);
    164170        ASSERT(page_mapping_operations->mapping_find);
    165 
     171       
    166172        return page_mapping_operations->mapping_find(as, page);
    167173}
Note: See TracChangeset for help on using the changeset viewer.