MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_dma_alloc

Function rt_dma_alloc

components/drivers/dma/dma_pool.c:410–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410void *rt_dma_alloc(struct rt_device *dev, rt_size_t size,
411 rt_ubase_t *dma_handle, rt_ubase_t flags)
412{
413 void *dma_buffer = RT_NULL;
414 rt_ubase_t dma_handle_s = 0;
415 const struct rt_dma_map_ops *ops;
416
417 if (!dev || !size)
418 {
419 return RT_NULL;
420 }
421
422 ops = device_dma_ops(dev);
423
424 if (ops->alloc)
425 {
426 dma_buffer = ops->alloc(dev, size, &dma_handle_s, flags);
427 }
428 else
429 {
430 dma_buffer = dma_alloc(dev, size, &dma_handle_s, flags);
431 }
432
433 if (!dma_buffer)
434 {
435 return dma_buffer;
436 }
437
438 if (dma_handle)
439 {
440 *dma_handle = dma_handle_s;
441 }
442
443 return dma_buffer;
444}
445
446void rt_dma_free(struct rt_device *dev, rt_size_t size,
447 void *cpu_addr, rt_ubase_t dma_handle, rt_ubase_t flags)

Callers 2

nvme_alloc_queueFunction · 0.85
rt_dma_alloc_coherentFunction · 0.85

Calls 2

device_dma_opsFunction · 0.85
dma_allocFunction · 0.85

Tested by

no test coverage detected