Ignore:
File:
1 edited

Legend:

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

    r0428f77 r235e6c7  
    5353 * We assume that the other processors are either not using the mapping yet
    5454 * (i.e. during the bootstrap) or are executing the TLB shootdown code.  While
    55  * we don't care much about the former case, the processors in the latter case
     55 * we don't care much about the former case, the processors in the latter case 
    5656 * will do an implicit serialization by virtue of running the TLB shootdown
    5757 * interrupt handler.
     
    6060
    6161#include <mm/page.h>
    62 #include <genarch/mm/page_ht.h>
    63 #include <genarch/mm/page_pt.h>
    6462#include <arch/mm/page.h>
    6563#include <arch/mm/asid.h>
     
    7270#include <debug.h>
    7371#include <arch.h>
    74 #include <syscall/copy.h>
    75 #include <errno.h>
    76 #include <align.h>
    7772
    7873/** Virtual operations for page subsystem. */
     
    8277{
    8378        page_arch_init();
     79}
     80
     81/** Map memory structure
     82 *
     83 * Identity-map memory structure
     84 * considering possible crossings
     85 * of page boundaries.
     86 *
     87 * @param addr Address of the structure.
     88 * @param size Size of the structure.
     89 *
     90 */
     91void map_structure(uintptr_t addr, size_t size)
     92{
     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;
     97        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       
     101        /* Repel prefetched accesses to the old mapping. */
     102        memory_barrier();
    84103}
    85104
     
    153172}
    154173
    155 /** Make the mapping shared by all page tables (not address spaces).
    156  *
    157  * @param base Starting virtual address of the range that is made global.
    158  * @param size Size of the address range that is made global.
    159  */
    160 void page_mapping_make_global(uintptr_t base, size_t size)
    161 {
    162         ASSERT(page_mapping_operations);
    163         ASSERT(page_mapping_operations->mapping_make_global);
    164        
    165         return page_mapping_operations->mapping_make_global(base, size);
    166 }
    167 
    168 int page_find_mapping(uintptr_t virt, void **phys)
    169 {
    170         page_table_lock(AS, true);
    171        
    172         pte_t *pte = page_mapping_find(AS, virt, false);
    173         if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) {
    174                 page_table_unlock(AS, true);
    175                 return ENOENT;
    176         }
    177        
    178         *phys = (void *) PTE_GET_FRAME(pte) +
    179             (virt - ALIGN_DOWN(virt, PAGE_SIZE));
    180        
    181         page_table_unlock(AS, true);
    182        
    183         return EOK;
    184 }
    185 
    186 /** Syscall wrapper for getting mapping of a virtual page.
    187  *
    188  * @return EOK on success.
    189  * @return ENOENT if no virtual address mapping found.
    190  *
    191  */
    192 sysarg_t sys_page_find_mapping(uintptr_t virt, void *phys_ptr)
    193 {
    194         void *phys;
    195         int rc = page_find_mapping(virt, &phys);
    196         if (rc != EOK)
    197                 return rc;
    198        
    199         rc = copy_to_uspace(phys_ptr, &phys, sizeof(phys));
    200         return (sysarg_t) rc;
    201 }
    202 
    203174/** @}
    204175 */
Note: See TracChangeset for help on using the changeset viewer.