Changeset 3f03199 in mainline for kernel/generic/src/ddi/ddi.c
- Timestamp:
- 2013-09-15T06:33:53Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9348862
- Parents:
- dd7078c (diff), 1c0cef0 (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/ddi/ddi.c
rdd7078c r3f03199 314 314 315 315 NO_TRACE static int dmamem_map(uintptr_t virt, size_t size, unsigned int map_flags, 316 unsigned int flags, void **phys)316 unsigned int flags, uintptr_t *phys) 317 317 { 318 318 ASSERT(TASK); … … 322 322 } 323 323 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) 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) 326 327 { 327 328 ASSERT(TASK); 328 329 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, FRAME_DMA); 339 if (*phys == NULL) 330 size_t frames = SIZE2FRAMES(size); 331 *phys = frame_alloc(frames, FRAME_NO_RESERVE, constraint); 332 if (*phys == 0) 340 333 return ENOMEM; 341 334 342 335 mem_backend_data_t backend_data; 343 backend_data.base = (uintptr_t)*phys;344 backend_data.frames = pages;336 backend_data.base = *phys; 337 backend_data.frames = frames; 345 338 346 339 if (!as_area_create(TASK->as, map_flags, size, 347 340 AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) { 348 frame_free_noreserve( (uintptr_t) *phys);341 frame_free_noreserve(*phys, frames); 349 342 return ENOMEM; 350 343 } … … 361 354 NO_TRACE static int dmamem_unmap_anonymous(uintptr_t virt) 362 355 { 363 // TODO: This is an ugly hack 364 as_t *as = TASK->as; 365 366 mutex_lock(&as->lock); 367 as_area_t *area = find_locked_area(as, virt); 368 if (!area) { 369 mutex_unlock(&as->lock); 370 return ENOENT; 371 } 372 frame_free_noreserve(area->backend_data.base); 373 area->backend_data.base = 0; 374 area->backend_data.frames = 0; 375 mutex_unlock(&area->lock); 376 mutex_unlock(&as->lock); 377 378 return as_area_destroy(as, virt); 356 // TODO: implement unlocking & unmap 357 return EOK; 379 358 } 380 359 … … 387 366 */ 388 367 389 void *phys;368 uintptr_t phys; 390 369 int rc = dmamem_map((uintptr_t) virt_ptr, size, map_flags, 391 370 flags, &phys); … … 404 383 */ 405 384 406 void *phys; 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; 407 392 uintptr_t virt = (uintptr_t) -1; 408 int rc = dmamem_map_anonymous(size, map_flags, flags,393 rc = dmamem_map_anonymous(size, constraint, map_flags, flags, 409 394 &phys, &virt, bound); 410 395 if (rc != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.