Ignore:
File:
1 edited

Legend:

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

    r8f80c77 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
     
    3939 * Functions here are mere wrappers that call the real implementation.
    4040 * They however, define the single interface.
    41  *
    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 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(interrupts_disabled());
    121         ASSERT(page_table_locked(as));
    122        
    123118        ASSERT(page_mapping_operations);
    124119        ASSERT(page_mapping_operations->mapping_insert);
    125 
     120       
    126121        page_mapping_operations->mapping_insert(as, page, frame, flags);
    127122       
     
    136131 * this call visible.
    137132 *
    138  * @param as   Address space to wich page belongs.
    139  * @param page Virtual address of the page to be demapped.
     133 * The page table must be locked and interrupts must be disabled.
    140134 *
     135 * @param as            Address space to wich page belongs.
     136 * @param page          Virtual address of the page to be demapped.
    141137 */
    142138void page_mapping_remove(as_t *as, uintptr_t page)
    143139{
    144         ASSERT(interrupts_disabled());
    145         ASSERT(page_table_locked(as));
    146        
    147140        ASSERT(page_mapping_operations);
    148141        ASSERT(page_mapping_operations->mapping_remove);
    149142       
    150143        page_mapping_operations->mapping_remove(as, page);
    151        
     144
    152145        /* Repel prefetched accesses to the old mapping. */
    153146        memory_barrier();
     
    158151 * Find mapping for virtual page.
    159152 *
    160  * @param as   Address space to wich page belongs.
    161  * @param page Virtual page.
     153 * The page table must be locked and interrupts must be disabled.
    162154 *
    163  * @return NULL if there is no such mapping; requested mapping
    164  *         otherwise.
     155 * @param as            Address space to wich page belongs.
     156 * @param page          Virtual page.
    165157 *
     158 * @return              NULL if there is no such mapping; requested mapping
     159 *                      otherwise.
    166160 */
    167161pte_t *page_mapping_find(as_t *as, uintptr_t page)
    168162{
    169         ASSERT(interrupts_disabled());
    170         ASSERT(page_table_locked(as));
    171        
    172163        ASSERT(page_mapping_operations);
    173164        ASSERT(page_mapping_operations->mapping_find);
    174        
     165
    175166        return page_mapping_operations->mapping_find(as, page);
    176167}
Note: See TracChangeset for help on using the changeset viewer.