1170 views|0 replies

6580

Posts

0

Resources
The OP
 

DM365 CMEM allocated memory [Copy link]

#define ALIGN(x, y)          (((x + (y-1))/y)*y)     // 内存对齐数,不设可分配任意大小
struct buf_info {
    void *user_addr;
    unsigned long phy_addr;
};
struct buf_info dhavbuffer;

static int allocate_dhavbuffer(int size)  
{
    CMEM_AllocParams  alloc_params;

    alloc_params.type   = CMEM_POOL;
    alloc_params.flags   = CMEM_NONCACHED;
    alloc_params.alignment  = 32;

if(size > 0 ){
  printf("Allocating input buffer :buf size = %d \n", size);
     dhavbuffer.user_addr = CMEM_alloc(ALIGN(size,4096), &alloc_params);
     if (dhavbuffer.user_addr) {
         dhavbuffer.phy_addr = CMEM_getPhys(dhavbuffer.user_addr);
         if (0 == dhavbuffer.phy_addr) {
             printf("Failed to get phy cmem buffer address\n");
             return -1;
         }
     } else {
         printf("Failed to allocate cmem buffer\n");
         return -1;
     }
     printf("Got %p from CMEM, phy = %p\n", dhavbuffer.user_addr, (void *)dhavbuffer.phy_addr);
}

    return 1;
}

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list