Changes in kernel/generic/src/mm/page.c [6645a14:404be7c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/page.c
r6645a14 r404be7c 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. … … 65 65 #include <arch/mm/asid.h> 66 66 #include <mm/as.h> 67 #include <mm/km.h> 67 68 #include <mm/frame.h> 68 69 #include <arch/barrier.h> … … 177 178 } 178 179 179 int page_find_mapping(uintptr_t virt, void **phys) 180 uintptr_t hw_map(uintptr_t physaddr, size_t size) 181 { 182 uintptr_t virtaddr; 183 size_t asize; 184 pfn_t i; 185 186 asize = ALIGN_UP(size, PAGE_SIZE); 187 virtaddr = km_page_alloc(asize, PAGE_SIZE); 188 189 page_table_lock(AS_KERNEL, true); 190 for (i = 0; i < ADDR2PFN(asize); i++) { 191 uintptr_t addr = PFN2ADDR(i); 192 page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, 193 PAGE_NOT_CACHEABLE | PAGE_WRITE); 194 } 195 page_table_unlock(AS_KERNEL, true); 196 197 return virtaddr; 198 } 199 200 201 /** Syscall wrapper for getting mapping of a virtual page. 202 * 203 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node 204 * contains correct values. 205 * @retval ENOENT Virtual address has no mapping. 206 */ 207 sysarg_t sys_page_find_mapping(uintptr_t virt_address, 208 uintptr_t *uspace_frame) 180 209 { 181 210 mutex_lock(&AS->lock); 182 211 183 pte_t *pte = page_mapping_find(AS, virt , false);184 if ( (!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) {212 pte_t *pte = page_mapping_find(AS, virt_address, false); 213 if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) { 185 214 mutex_unlock(&AS->lock); 186 return ENOENT; 215 216 return (sysarg_t) ENOENT; 187 217 } 188 218 189 *phys = (void *) PTE_GET_FRAME(pte) + 190 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 219 uintptr_t phys_address = PTE_GET_FRAME(pte); 191 220 192 221 mutex_unlock(&AS->lock); 193 222 223 int rc = copy_to_uspace(uspace_frame, 224 &phys_address, sizeof(phys_address)); 225 if (rc != EOK) { 226 return (sysarg_t) rc; 227 } 228 194 229 return EOK; 195 230 } 196 231 197 /** Syscall wrapper for getting mapping of a virtual page.198 *199 * @return EOK on success.200 * @return ENOENT if no virtual address mapping found.201 *202 */203 sysarg_t sys_page_find_mapping(uintptr_t virt, void *phys_ptr)204 {205 void *phys;206 int rc = page_find_mapping(virt, &phys);207 if (rc != EOK)208 return rc;209 210 rc = copy_to_uspace(phys_ptr, &phys, sizeof(phys));211 return (sysarg_t) rc;212 }213 214 232 /** @} 215 233 */
Note:
See TracChangeset
for help on using the changeset viewer.