コード例 #1
0
ファイル: CMMDriver.c プロジェクト: HITEG/TenByTen6410_SLC
static ALLOC_MEM_T * GetCodecVirAddr(UINT8 inst_no, CMM_ALLOC_PRAM_T *in_param)
{
    DWORD                    p_startAddr;
    ALLOC_MEM_T             *p_allocMem;

    printD("GetCodecVirAddr \n");

    p_startAddr = GetMemArea((UINT32)in_param->size, inst_no);

    if(!p_startAddr)
    {
        RETAILMSG(1, (L"[CMM:ERR] There is no more memory\n\r"));
        return NULL;
    }

    p_allocMem = (ALLOC_MEM_T *)malloc(sizeof(ALLOC_MEM_T));
    memset(p_allocMem, 0x00, sizeof(ALLOC_MEM_T));

    // We need to keep only the cached addresses here.
    // If the user requests uncached address, we can do that by specifying
    // PAGE_NOCACHE to VirtualCopy
    //
    p_allocMem->cached_p_addr = p_startAddr;
    p_allocMem->v_addr =  CachedVirAddr + (p_allocMem->cached_p_addr - CODEC_MEM_START);

    printD("v_addr : 0x%x p_addr : 0x%x\n", p_allocMem->v_addr, p_allocMem->cached_p_addr);

    p_allocMem->size = (UINT32)in_param->size;
    p_allocMem->inst_no = inst_no;
    p_allocMem->cacheFlag = in_param->cacheFlag;

    InsertNodeToAllocList(p_allocMem, inst_no);

    return(p_allocMem);
}
コード例 #2
0
static ALLOC_MEM_T * GetCodecVirAddr(int inst_no, CODEC_MEM_ALLOC_ARG *in_param)
{

	unsigned int			p_startAddr;
	ALLOC_MEM_T 			*p_allocMem;
	

	// if user request cachable area, allocate from reserved area
	// if user request uncachable area, allocate dynamically	
	p_startAddr = GetMemArea((int)in_param->buffSize, inst_no, in_param->cacheFlag);

	if(!p_startAddr){
		LOG_MSG(LOG_TRACE, "GetCodecVirAddr", "There is no more memory\n\r");
		in_param->out_addr = -1;
		return NULL;
	}

	p_allocMem = (ALLOC_MEM_T *)kmalloc(sizeof(ALLOC_MEM_T), GFP_KERNEL);
	memset(p_allocMem, 0x00, sizeof(ALLOC_MEM_T));
		

	if(in_param->cacheFlag) {
		p_allocMem->cached_p_addr = p_startAddr;
		p_allocMem->v_addr = CachedVirAddr + (p_allocMem->cached_p_addr - CODEC_MEM_START);
		p_allocMem->u_addr = (unsigned char *)(in_param->cached_mapped_addr + (p_allocMem->cached_p_addr - CODEC_MEM_START));
		
		if (p_allocMem->v_addr == NULL) {
			LOG_MSG(LOG_ERROR, "GetCodecVirAddr", "Mapping Failed [PA:0x%08x]\n\r", p_allocMem->cached_p_addr);
			return NULL;
		}
	}
	else {
		p_allocMem->uncached_p_addr = p_startAddr;
		p_allocMem->v_addr = NonCachedVirAddr + (p_allocMem->uncached_p_addr - CODEC_MEM_START - CODEC_CACHED_MEM_SIZE);
		p_allocMem->u_addr = (unsigned char *)(in_param->non_cached_mapped_addr + (p_allocMem->uncached_p_addr - CODEC_MEM_START - CODEC_CACHED_MEM_SIZE));
		
		if (p_allocMem->v_addr == NULL)
		{
			LOG_MSG(LOG_ERROR, "GetCodecVirAddr", "Mapping Failed [PA:0x%08x]\n\r", p_allocMem->uncached_p_addr);
			return NULL;
		}
	}

	in_param->out_addr = (unsigned int)p_allocMem->u_addr;
	LOG_MSG(LOG_TRACE, "GetCodecVirAddr", "u_addr : 0x%x v_addr : 0x%x cached_p_addr : 0x%x, uncached_p_addr : 0x%x\n", 	\
			p_allocMem->u_addr, p_allocMem->v_addr, p_allocMem->cached_p_addr, p_allocMem->uncached_p_addr);
		

	p_allocMem->size = (int)in_param->buffSize;
	p_allocMem->inst_no = inst_no;
	p_allocMem->cacheFlag = in_param->cacheFlag;
	
	InsertNodeToAllocList(p_allocMem, inst_no);

	return(p_allocMem);
}