Ignore:
File:
1 edited

Legend:

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

    r97bdb4a rd99c1d2  
    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.
    41  *
     40 * They however, define the single interface.
    4241 */
    4342
     
    5655 * will do an implicit serialization by virtue of running the TLB shootdown
    5756 * interrupt handler.
    58  *
    5957 */
    6058
     
    8583 * of page boundaries.
    8684 *
    87  * @param addr Address of the structure.
    88  * @param size Size of the structure.
    89  *
     85 * @param s             Address of the structure.
     86 * @param size          Size of the structure.
    9087 */
    91 void map_structure(uintptr_t addr, size_t size)
     88void map_structure(uintptr_t s, size_t size)
    9289{
    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;
     90        int i, cnt, length;
     91
     92        length = size + (s - (s & ~(PAGE_SIZE - 1)));
     93        cnt = length / PAGE_SIZE + (length % PAGE_SIZE > 0);
     94
    9795        for (i = 0; i < cnt; i++)
    98                 page_mapping_insert(AS_KERNEL, addr + i * PAGE_SIZE,
    99                     addr + i * PAGE_SIZE, PAGE_NOT_CACHEABLE | PAGE_WRITE);
    100        
     96                page_mapping_insert(AS_KERNEL, s + i * PAGE_SIZE,
     97                    s + i * PAGE_SIZE, PAGE_NOT_CACHEABLE | PAGE_WRITE);
     98
    10199        /* Repel prefetched accesses to the old mapping. */
    102100        memory_barrier();
     
    108106 * using flags. Allocate and setup any missing page tables.
    109107 *
    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.
     108 * The page table must be locked and interrupts must be disabled.
    115109 *
     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.
    116115 */
    117 NO_TRACE void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
    118     unsigned int flags)
     116void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame, int flags)
    119117{
    120         ASSERT(page_table_locked(as));
    121        
    122118        ASSERT(page_mapping_operations);
    123119        ASSERT(page_mapping_operations->mapping_insert);
    124 
     120       
    125121        page_mapping_operations->mapping_insert(as, page, frame, flags);
    126122       
     
    135131 * this call visible.
    136132 *
    137  * @param as   Address space to wich page belongs.
    138  * @param page Virtual address of the page to be demapped.
     133 * The page table must be locked and interrupts must be disabled.
    139134 *
     135 * @param as            Address space to wich page belongs.
     136 * @param page          Virtual address of the page to be demapped.
    140137 */
    141 NO_TRACE void page_mapping_remove(as_t *as, uintptr_t page)
     138void page_mapping_remove(as_t *as, uintptr_t page)
    142139{
    143         ASSERT(page_table_locked(as));
    144        
    145140        ASSERT(page_mapping_operations);
    146141        ASSERT(page_mapping_operations->mapping_remove);
    147142       
    148143        page_mapping_operations->mapping_remove(as, page);
    149        
     144
    150145        /* Repel prefetched accesses to the old mapping. */
    151146        memory_barrier();
     
    156151 * Find mapping for virtual page.
    157152 *
    158  * @param as   Address space to wich page belongs.
    159  * @param page Virtual page.
     153 * The page table must be locked and interrupts must be disabled.
    160154 *
    161  * @return NULL if there is no such mapping; requested mapping
    162  *         otherwise.
     155 * @param as            Address space to wich page belongs.
     156 * @param page          Virtual page.
    163157 *
     158 * @return              NULL if there is no such mapping; requested mapping
     159 *                      otherwise.
    164160 */
    165 NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page)
     161pte_t *page_mapping_find(as_t *as, uintptr_t page)
    166162{
    167         ASSERT(page_table_locked(as));
    168        
    169163        ASSERT(page_mapping_operations);
    170164        ASSERT(page_mapping_operations->mapping_find);
    171        
     165
    172166        return page_mapping_operations->mapping_find(as, page);
    173167}
Note: See TracChangeset for help on using the changeset viewer.