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

Function dma_pool_install

components/drivers/dma/dma_pool.c:508–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506}
507
508static struct rt_dma_pool *dma_pool_install(rt_region_t *region)
509{
510 rt_err_t err;
511 struct rt_dma_pool *pool;
512
513 if (!(pool = rt_calloc(1, sizeof(*pool))))
514 {
515 LOG_E("Install pool[%p, %p] error = %s",
516 region->start, region->end, rt_strerror(-RT_ENOMEM));
517
518 return RT_NULL;
519 }
520
521 rt_memcpy(&pool->region, region, sizeof(*region));
522
523 pool->flags |= RT_DMA_F_LINEAR;
524
525 if (region->end < 4UL * SIZE_GB)
526 {
527 pool->flags |= RT_DMA_F_32BITS;
528 }
529
530 pool->start = RT_ALIGN(pool->region.start, ARCH_PAGE_SIZE);
531 pool->bits = (pool->region.end - pool->start) / ARCH_PAGE_SIZE;
532
533 if (!pool->bits)
534 {
535 err = -RT_EINVAL;
536 goto _fail;
537 }
538
539 pool->map = rt_calloc(RT_BITMAP_LEN(pool->bits), sizeof(*pool->map));
540
541 if (!pool->map)
542 {
543 err = -RT_ENOMEM;
544 goto _fail;
545 }
546
547 rt_list_init(&pool->list);
548
549 region_pool_lock();
550 rt_list_insert_before(&dma_pool_nodes, &pool->list);
551 region_pool_unlock();
552
553 return pool;
554
555_fail:
556 rt_free(pool);
557
558 LOG_E("Install pool[%p, %p] error = %s",
559 region->start, region->end, rt_strerror(err));
560
561 return RT_NULL;
562}
563
564struct rt_dma_pool *rt_dma_pool_install(rt_region_t *region)
565{

Callers 2

ofw_device_dma_opsFunction · 0.85
rt_dma_pool_installFunction · 0.85

Calls 8

rt_callocFunction · 0.85
rt_strerrorFunction · 0.85
rt_memcpyFunction · 0.85
rt_list_initFunction · 0.85
region_pool_lockFunction · 0.85
rt_list_insert_beforeFunction · 0.85
region_pool_unlockFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected