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