Changeset 7aaed09 in mainline for kernel/generic/src/mm/page.c
- Timestamp:
- 2011-12-18T14:02:30Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c868e2d
- Parents:
- 3b71e84d (diff), 1761268 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/page.c
r3b71e84d r7aaed09 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. … … 198 198 } 199 199 200 int page_find_mapping(uintptr_t virt, void **phys) 201 { 202 mutex_lock(&AS->lock); 203 204 pte_t *pte = page_mapping_find(AS, virt, false); 205 if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) { 206 mutex_unlock(&AS->lock); 207 return ENOENT; 208 } 209 210 *phys = (void *) PTE_GET_FRAME(pte) + 211 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 212 213 mutex_unlock(&AS->lock); 214 215 return EOK; 216 } 200 217 201 218 /** 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) 209 { 210 mutex_lock(&AS->lock); 211 212 pte_t *pte = page_mapping_find(AS, virt_address, false); 213 if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) { 214 mutex_unlock(&AS->lock); 215 216 return (sysarg_t) ENOENT; 217 } 218 219 uintptr_t phys_address = PTE_GET_FRAME(pte); 220 221 mutex_unlock(&AS->lock); 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 229 return EOK; 219 * 220 * @return EOK on success. 221 * @return ENOENT if no virtual address mapping found. 222 * 223 */ 224 sysarg_t sys_page_find_mapping(uintptr_t virt, void *phys_ptr) 225 { 226 void *phys; 227 int rc = page_find_mapping(virt, &phys); 228 if (rc != EOK) 229 return rc; 230 231 rc = copy_to_uspace(phys_ptr, &phys, sizeof(phys)); 232 return (sysarg_t) rc; 230 233 } 231 234
Note:
See TracChangeset
for help on using the changeset viewer.