Ignore:
File:
1 edited

Legend:

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

    rd99c1d2 r8f80c77  
    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();
     
    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)
     117void page_mapping_insert(as_t *as, uintptr_t page, uintptr_t frame,
     118    unsigned int flags)
    117119{
     120        ASSERT(interrupts_disabled());
     121        ASSERT(page_table_locked(as));
     122       
    118123        ASSERT(page_mapping_operations);
    119124        ASSERT(page_mapping_operations->mapping_insert);
    120        
     125
    121126        page_mapping_operations->mapping_insert(as, page, frame, flags);
    122127       
     
    131136 * this call visible.
    132137 *
    133  * The page table must be locked and interrupts must be disabled.
     138 * @param as   Address space to wich page belongs.
     139 * @param page Virtual address of the page to be demapped.
    134140 *
    135  * @param as            Address space to wich page belongs.
    136  * @param page          Virtual address of the page to be demapped.
    137141 */
    138142void page_mapping_remove(as_t *as, uintptr_t page)
    139143{
     144        ASSERT(interrupts_disabled());
     145        ASSERT(page_table_locked(as));
     146       
    140147        ASSERT(page_mapping_operations);
    141148        ASSERT(page_mapping_operations->mapping_remove);
    142149       
    143150        page_mapping_operations->mapping_remove(as, page);
    144 
     151       
    145152        /* Repel prefetched accesses to the old mapping. */
    146153        memory_barrier();
     
    151158 * Find mapping for virtual page.
    152159 *
    153  * The page table must be locked and interrupts must be disabled.
     160 * @param as   Address space to wich page belongs.
     161 * @param page Virtual page.
    154162 *
    155  * @param as            Address space to wich page belongs.
    156  * @param page          Virtual page.
     163 * @return NULL if there is no such mapping; requested mapping
     164 *         otherwise.
    157165 *
    158  * @return              NULL if there is no such mapping; requested mapping
    159  *                      otherwise.
    160166 */
    161167pte_t *page_mapping_find(as_t *as, uintptr_t page)
    162168{
     169        ASSERT(interrupts_disabled());
     170        ASSERT(page_table_locked(as));
     171       
    163172        ASSERT(page_mapping_operations);
    164173        ASSERT(page_mapping_operations->mapping_find);
    165 
     174       
    166175        return page_mapping_operations->mapping_find(as, page);
    167176}
Note: See TracChangeset for help on using the changeset viewer.