Changes in kernel/generic/src/mm/as.c [315b7e3:ae6021d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/as.c
r315b7e3 rae6021d 574 574 * @param backend_data NULL or a pointer to custom backend data. 575 575 * @param base Starting virtual address of the area. 576 * If set to -1, a suitable mappable area is found. 577 * @param bound Lowest address bound if base is set to -1. 576 * If set to AS_AREA_ANY, a suitable mappable area is 577 * found. 578 * @param bound Lowest address bound if base is set to AS_AREA_ANY. 578 579 * Otherwise ignored. 579 580 * … … 585 586 mem_backend_data_t *backend_data, uintptr_t *base, uintptr_t bound) 586 587 { 587 if ((*base != (uintptr_t) -1) && !IS_ALIGNED(*base, PAGE_SIZE))588 if ((*base != (uintptr_t) AS_AREA_ANY) && !IS_ALIGNED(*base, PAGE_SIZE)) 588 589 return NULL; 589 590 … … 601 602 mutex_lock(&as->lock); 602 603 603 if (*base == (uintptr_t) -1) {604 if (*base == (uintptr_t) AS_AREA_ANY) { 604 605 *base = as_get_unmapped_area(as, bound, size, guarded); 605 606 if (*base == (uintptr_t) -1) { … … 888 889 889 890 for (; i < node_size; i++) { 890 pte_t *pte = page_mapping_find(as, 891 ptr + P2SZ(i), false); 891 pte_t pte; 892 bool found = page_mapping_find(as, 893 ptr + P2SZ(i), false, &pte); 892 894 893 ASSERT( pte);894 ASSERT(PTE_VALID( pte));895 ASSERT(PTE_PRESENT( pte));895 ASSERT(found); 896 ASSERT(PTE_VALID(&pte)); 897 ASSERT(PTE_PRESENT(&pte)); 896 898 897 899 if ((area->backend) && … … 899 901 area->backend->frame_free(area, 900 902 ptr + P2SZ(i), 901 PTE_GET_FRAME( pte));903 PTE_GET_FRAME(&pte)); 902 904 } 903 905 … … 1002 1004 1003 1005 for (size = 0; size < (size_t) node->value[i]; size++) { 1004 pte_t *pte = page_mapping_find(as, 1005 ptr + P2SZ(size), false); 1006 pte_t pte; 1007 bool found = page_mapping_find(as, 1008 ptr + P2SZ(size), false, &pte); 1006 1009 1007 ASSERT( pte);1008 ASSERT(PTE_VALID( pte));1009 ASSERT(PTE_PRESENT( pte));1010 ASSERT(found); 1011 ASSERT(PTE_VALID(&pte)); 1012 ASSERT(PTE_PRESENT(&pte)); 1010 1013 1011 1014 if ((area->backend) && … … 1013 1016 area->backend->frame_free(area, 1014 1017 ptr + P2SZ(size), 1015 PTE_GET_FRAME( pte));1018 PTE_GET_FRAME(&pte)); 1016 1019 } 1017 1020 … … 1314 1317 1315 1318 for (size = 0; size < (size_t) node->value[i]; size++) { 1316 pte_t *pte = page_mapping_find(as, 1317 ptr + P2SZ(size), false); 1319 pte_t pte; 1320 bool found = page_mapping_find(as, 1321 ptr + P2SZ(size), false, &pte); 1318 1322 1319 ASSERT( pte);1320 ASSERT(PTE_VALID( pte));1321 ASSERT(PTE_PRESENT( pte));1323 ASSERT(found); 1324 ASSERT(PTE_VALID(&pte)); 1325 ASSERT(PTE_PRESENT(&pte)); 1322 1326 1323 old_frame[frame_idx++] = PTE_GET_FRAME( pte);1327 old_frame[frame_idx++] = PTE_GET_FRAME(&pte); 1324 1328 1325 1329 /* Remove old mapping */ … … 1451 1455 * we need to make sure the mapping has not been already inserted. 1452 1456 */ 1453 pte_t *pte; 1454 if ((pte = page_mapping_find(AS, page, false))) { 1455 if (PTE_PRESENT(pte)) { 1456 if (((access == PF_ACCESS_READ) && PTE_READABLE(pte)) || 1457 (access == PF_ACCESS_WRITE && PTE_WRITABLE(pte)) || 1458 (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(pte))) { 1457 pte_t pte; 1458 bool found = page_mapping_find(AS, page, false, &pte); 1459 if (found) { 1460 if (PTE_PRESENT(&pte)) { 1461 if (((access == PF_ACCESS_READ) && PTE_READABLE(&pte)) || 1462 (access == PF_ACCESS_WRITE && PTE_WRITABLE(&pte)) || 1463 (access == PF_ACCESS_EXEC && PTE_EXECUTABLE(&pte))) { 1459 1464 page_table_unlock(AS, false); 1460 1465 mutex_unlock(&area->lock); … … 2182 2187 2183 2188 sysarg_t sys_as_area_create(uintptr_t base, size_t size, unsigned int flags, 2184 uintptr_t bound )2189 uintptr_t bound, as_area_pager_info_t *pager_info) 2185 2190 { 2186 2191 uintptr_t virt = base; 2192 mem_backend_t *backend; 2193 mem_backend_data_t backend_data; 2194 2195 if (pager_info == AS_AREA_UNPAGED) 2196 backend = &anon_backend; 2197 else { 2198 backend = &user_backend; 2199 if (copy_from_uspace(&backend_data.pager_info, pager_info, 2200 sizeof(as_area_pager_info_t)) != EOK) { 2201 return (sysarg_t) AS_MAP_FAILED; 2202 } 2203 } 2187 2204 as_area_t *area = as_area_create(AS, flags, size, 2188 AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, bound);2205 AS_AREA_ATTR_NONE, backend, &backend_data, &virt, bound); 2189 2206 if (area == NULL) 2190 return (sysarg_t) -1;2207 return (sysarg_t) AS_MAP_FAILED; 2191 2208 2192 2209 return (sysarg_t) virt;
Note:
See TracChangeset
for help on using the changeset viewer.