Changes in kernel/generic/src/ddi/ddi.c [a17cced:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ddi/ddi.c
ra17cced r9d58539 121 121 backend_data.base = phys; 122 122 backend_data.frames = pages; 123 backend_data.anonymous = false;124 123 125 124 /* … … 315 314 316 315 NO_TRACE static int dmamem_map(uintptr_t virt, size_t size, unsigned int map_flags, 317 unsigned int flags, uintptr_t*phys)316 unsigned int flags, void **phys) 318 317 { 319 318 ASSERT(TASK); … … 323 322 } 324 323 325 NO_TRACE static int dmamem_map_anonymous(size_t size, uintptr_t constraint, 326 unsigned int map_flags, unsigned int flags, uintptr_t *phys, 327 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) 328 326 { 329 327 ASSERT(TASK); 330 328 331 size_t frames = SIZE2FRAMES(size); 332 *phys = frame_alloc(frames, FRAME_ATOMIC, constraint); 333 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) 334 340 return ENOMEM; 335 341 336 342 mem_backend_data_t backend_data; 337 backend_data.base = *phys; 338 backend_data.frames = frames; 339 backend_data.anonymous = true; 343 backend_data.base = (uintptr_t) *phys; 344 backend_data.frames = pages; 340 345 341 346 if (!as_area_create(TASK->as, map_flags, size, 342 347 AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) { 343 frame_free (*phys, frames);348 frame_free_noreserve((uintptr_t) *phys); 344 349 return ENOMEM; 345 350 } … … 356 361 NO_TRACE static int dmamem_unmap_anonymous(uintptr_t virt) 357 362 { 358 return as_area_destroy(TASK->as, virt); 363 // TODO: implement unlocking & unmap 364 return EOK; 359 365 } 360 366 … … 367 373 */ 368 374 369 uintptr_tphys;375 void *phys; 370 376 int rc = dmamem_map((uintptr_t) virt_ptr, size, map_flags, 371 377 flags, &phys); … … 384 390 */ 385 391 386 uintptr_t constraint; 387 int rc = copy_from_uspace(&constraint, phys_ptr, 388 sizeof(constraint)); 389 if (rc != EOK) 390 return rc; 391 392 uintptr_t phys; 392 void *phys; 393 393 uintptr_t virt = (uintptr_t) -1; 394 rc = dmamem_map_anonymous(size, constraint, map_flags, flags,394 int rc = dmamem_map_anonymous(size, map_flags, flags, 395 395 &phys, &virt, bound); 396 396 if (rc != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.