Changeset 6645a14 in mainline
- Timestamp:
- 2011-12-16T21:09:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2718e1
- Parents:
- 01e39cbe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/page.c
r01e39cbe r6645a14 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. … … 74 74 #include <syscall/copy.h> 75 75 #include <errno.h> 76 #include <align.h> 76 77 77 78 /** Virtual operations for page subsystem. */ … … 176 177 } 177 178 179 int page_find_mapping(uintptr_t virt, void **phys) 180 { 181 mutex_lock(&AS->lock); 182 183 pte_t *pte = page_mapping_find(AS, virt, false); 184 if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) { 185 mutex_unlock(&AS->lock); 186 return ENOENT; 187 } 188 189 *phys = (void *) PTE_GET_FRAME(pte) + 190 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 191 192 mutex_unlock(&AS->lock); 193 194 return EOK; 195 } 196 178 197 /** Syscall wrapper for getting mapping of a virtual page. 179 * 180 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node 181 * contains correct values. 182 * @retval ENOENT Virtual address has no mapping. 183 */ 184 sysarg_t sys_page_find_mapping(uintptr_t virt_address, 185 uintptr_t *uspace_frame) 186 { 187 mutex_lock(&AS->lock); 188 189 pte_t *pte = page_mapping_find(AS, virt_address, false); 190 if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) { 191 mutex_unlock(&AS->lock); 192 193 return (sysarg_t) ENOENT; 194 } 195 196 uintptr_t phys_address = PTE_GET_FRAME(pte); 197 198 mutex_unlock(&AS->lock); 199 200 int rc = copy_to_uspace(uspace_frame, 201 &phys_address, sizeof(phys_address)); 202 if (rc != EOK) { 203 return (sysarg_t) rc; 204 } 205 206 return EOK; 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; 207 212 } 208 213
Note:
See TracChangeset
for help on using the changeset viewer.