Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/page.c

    rd99c1d2 r97bdb4a  
    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
    3838 * mappings between virtual addresses and physical addresses.
    3939 * Functions here are mere wrappers that call the real implementation.
    40  * They however, define the single interface.
     40 * 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();
     
    106108 * using flags. Allocate and setup any missing page tables.
    107109 *
    108  * The page table must be locked and interrupts must be disabled.
     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.
    109115 *
    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.
    115116 */
    116 void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
     117NO_TRACE void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
     118    unsigned int flags)
    117119{
     120        ASSERT(page_table_locked(as));
     121       
    118122        ASSERT(page_mapping_operations);
    119123        ASSERT(page_mapping_operations->mapping_insert);
    120        
     124
    121125        page_mapping_operations->mapping_insert(as, page, frame, flags);
    122126       
     
    131135 * this call visible.
    132136 *
    133  * The page table must be locked and interrupts must be disabled.
     137 * @param as   Address space to wich page belongs.
     138 * @param page Virtual address of the page to be demapped.
    134139 *
    135  * @param as            Address space to wich page belongs.
    136  * @param page          Virtual address of the page to be demapped.
    137140 */
    138 void page_mapping_remove(as_t *as, uintptr_t page)
     141NO_TRACE void page_mapping_remove(as_t *as, uintptr_t page)
    139142{
     143        ASSERT(page_table_locked(as));
     144       
    140145        ASSERT(page_mapping_operations);
    141146        ASSERT(page_mapping_operations->mapping_remove);
    142147       
    143148        page_mapping_operations->mapping_remove(as, page);
    144 
     149       
    145150        /* Repel prefetched accesses to the old mapping. */
    146151        memory_barrier();
     
    151156 * Find mapping for virtual page.
    152157 *
    153  * The page table must be locked and interrupts must be disabled.
     158 * @param as   Address space to wich page belongs.
     159 * @param page Virtual page.
    154160 *
    155  * @param as            Address space to wich page belongs.
    156  * @param page          Virtual page.
     161 * @return NULL if there is no such mapping; requested mapping
     162 *         otherwise.
    157163 *
    158  * @return              NULL if there is no such mapping; requested mapping
    159  *                      otherwise.
    160164 */
    161 pte_t *page_mapping_find(as_t *as, uintptr_t page)
     165NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page)
    162166{
     167        ASSERT(page_table_locked(as));
     168       
    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.