Changes in kernel/generic/src/mm/page.c [235e6c7:0428f77] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/page.c
r235e6c7 r0428f77 53 53 * We assume that the other processors are either not using the mapping yet 54 54 * (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 56 56 * will do an implicit serialization by virtue of running the TLB shootdown 57 57 * interrupt handler. … … 60 60 61 61 #include <mm/page.h> 62 #include <genarch/mm/page_ht.h> 63 #include <genarch/mm/page_pt.h> 62 64 #include <arch/mm/page.h> 63 65 #include <arch/mm/asid.h> … … 70 72 #include <debug.h> 71 73 #include <arch.h> 74 #include <syscall/copy.h> 75 #include <errno.h> 76 #include <align.h> 72 77 73 78 /** Virtual operations for page subsystem. */ … … 77 82 { 78 83 page_arch_init(); 79 }80 81 /** Map memory structure82 *83 * Identity-map memory structure84 * considering possible crossings85 * of page boundaries.86 *87 * @param addr Address of the structure.88 * @param size Size of the structure.89 *90 */91 void 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();103 84 } 104 85 … … 172 153 } 173 154 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 174 203 /** @} 175 204 */
Note:
See TracChangeset
for help on using the changeset viewer.