Changes in kernel/generic/src/ddi/ddi.c [f72906c:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
rf72906c r9d58539 314 314 315 315 NO_TRACE static int dmamem_map(uintptr_t virt, size_t size, unsigned int map_flags, 316 unsigned int flags, uintptr_t*phys)316 unsigned int flags, void **phys) 317 317 { 318 318 ASSERT(TASK); … … 322 322 } 323 323 324 NO_TRACE static int dmamem_map_anonymous(size_t size, uintptr_t constraint, 325 unsigned int map_flags, unsigned int flags, uintptr_t *phys, 326 uintptr_t *virt, uintptr_t bound) 324 NO_TRACE static int dmamem_map_anonymous(size_t size, unsigned int map_flags, 325 unsigned int flags, void **phys, uintptr_t *virt, uintptr_t bound) 327 326 { 328 327 ASSERT(TASK); 329 328 330 size_t frames = SIZE2FRAMES(size); 331 *phys = frame_alloc(frames, FRAME_NO_RESERVE, constraint); 332 if (*phys == 0) 329 size_t pages = SIZE2FRAMES(size); 330 uint8_t order; 331 332 /* We need the 2^order >= pages */ 333 if (pages == 1) 334 order = 0; 335 else 336 order = fnzb(pages - 1) + 1; 337 338 *phys = frame_alloc_noreserve(order, 0); 339 if (*phys == NULL) 333 340 return ENOMEM; 334 341 335 342 mem_backend_data_t backend_data; 336 backend_data.base = *phys;337 backend_data.frames = frames;343 backend_data.base = (uintptr_t) *phys; 344 backend_data.frames = pages; 338 345 339 346 if (!as_area_create(TASK->as, map_flags, size, 340 347 AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) { 341 frame_free_noreserve( *phys, frames);348 frame_free_noreserve((uintptr_t) *phys); 342 349 return ENOMEM; 343 350 } … … 366 373 */ 367 374 368 uintptr_tphys;375 void *phys; 369 376 int rc = dmamem_map((uintptr_t) virt_ptr, size, map_flags, 370 377 flags, &phys); … … 383 390 */ 384 391 385 uintptr_t constraint; 386 int rc = copy_from_uspace(&constraint, phys_ptr, 387 sizeof(constraint)); 388 if (rc != EOK) 389 return rc; 390 391 uintptr_t phys; 392 void *phys; 392 393 uintptr_t virt = (uintptr_t) -1; 393 rc = dmamem_map_anonymous(size, constraint, map_flags, flags,394 int rc = dmamem_map_anonymous(size, map_flags, flags, 394 395 &phys, &virt, bound); 395 396 if (rc != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.