Ejemplo n.º 1
0
/*----------------------------------------------------------------------------
*Function: CMM_Init

*Parameters:         dwContext        :
*Return Value:        True/False
*Implementation Notes: Initialize JPEG Hardware 
-----------------------------------------------------------------------------*/
DWORD
CMM_Init(
    DWORD dwContext
    )
{
    HANDLE            h_Mutex;
    FREE_MEM_T *    freenode;
    ALLOC_MEM_T *   allocnode;
    PHYSICAL_ADDRESS    ioPhysicalBase = {0,0};

    printD("\n[CMM_Init]\n");

    
    // Mutex initialization
    h_Mutex = CreateCMMmutex();
    if (h_Mutex == NULL) 
    {
        RETAILMSG(1, (TEXT("[CMM_Init] CMM Mutex Initialize error : %d \r\n"),GetLastError()));    
        return FALSE;
    }

    ioPhysicalBase.LowPart = CODEC_MEM_START;
    CachedVirAddr = (UINT8 *)MmMapIoSpace(ioPhysicalBase, CODEC_MEM_SIZE, TRUE);
    if (CachedVirAddr == NULL)
    {
        RETAILMSG(1, (TEXT("[CMM_Init] MmMapIoSpace failed: %d\r\n"),GetLastError()));    
        return FALSE;
    }

    // init alloc list, if(AllocMemHead == AllocMemTail) then, the list is NULL
    allocnode = (ALLOC_MEM_T *)malloc(sizeof(ALLOC_MEM_T));
    memset(allocnode, 0x00, sizeof(ALLOC_MEM_T));
    allocnode->next = allocnode;
    allocnode->prev = allocnode;
    AllocMemHead = allocnode;
    AllocMemTail = AllocMemHead;

    // init free list, if(FreeMemHead == FreeMemTail) then, the list is NULL
    freenode = (FREE_MEM_T *)malloc(sizeof(FREE_MEM_T));
    memset(freenode, 0x00, sizeof(FREE_MEM_T));
    freenode->next = freenode;
    freenode->prev = freenode;
    FreeMemHead = freenode;
    FreeMemTail = FreeMemHead;

    freenode = (FREE_MEM_T *)malloc(sizeof(FREE_MEM_T));
    memset(freenode, 0x00, sizeof(FREE_MEM_T));
    freenode->startAddr = CODEC_MEM_START;
    freenode->size = CODEC_MEM_SIZE;
    InsertNodeToFreeList(freenode, -1);

    return TRUE;
}
Ejemplo n.º 2
0
static int __init s3c_cmm_init(void)
{
	HANDLE 		h_Mutex;
	int			ret;
	FREE_MEM_T	*node;
	ALLOC_MEM_T	*alloc_node;
	
	
	printk(banner);

	// Mutex initialization
	h_Mutex = CreateCMMmutex();
	if (h_Mutex == NULL) 
	{
		LOG_MSG(LOG_ERROR, "s3c_cmm_init", "DD::CMM Mutex Initialize error\r\n");
		return FALSE;
	}

	ret = LockCMMMutex();

	ret = misc_register(&s3c_cmm_miscdev);


	// First 4MB will use cacheable memory
	CachedVirAddr = (unsigned char *)ioremap_cached( (unsigned long)CODEC_MEM_START, 		\
					(int)CODEC_CACHED_MEM_SIZE );

	// Second 4MB will use non-cacheable memory
	NonCachedVirAddr = (unsigned char *)ioremap_nocache( (unsigned long)(CODEC_MEM_START + 	\
					CODEC_CACHED_MEM_SIZE), (int)CODEC_NON_CACHED_MEM_SIZE );

	// init alloc list, if(AllocMemHead == AllocMemTail) then, the list is NULL
	alloc_node = (ALLOC_MEM_T *)kmalloc(sizeof(ALLOC_MEM_T), GFP_KERNEL);
	memset(alloc_node, 0x00, sizeof(ALLOC_MEM_T));
	alloc_node->next = alloc_node;
	alloc_node->prev = alloc_node;
	AllocMemHead = alloc_node;
	AllocMemTail = AllocMemHead;

	// init free list, if(FreeMemHead == FreeMemTail) then, the list is NULL
	node = (FREE_MEM_T *)kmalloc(sizeof(FREE_MEM_T), GFP_KERNEL);
	memset(node, 0x00, sizeof(FREE_MEM_T));
	node->next = node;
	node->prev = node;
	FreeMemHead = node;
	FreeMemTail = FreeMemHead;

	node = (FREE_MEM_T *)kmalloc(sizeof(FREE_MEM_T), GFP_KERNEL);
	memset(node, 0x00, sizeof(FREE_MEM_T));
	node->startAddr = CODEC_MEM_START;
	node->cacheFlag = 1;
	node->size = CODEC_CACHED_MEM_SIZE;
	InsertNodeToFreeList(node, -1);

	node = (FREE_MEM_T *)kmalloc(sizeof(FREE_MEM_T), GFP_KERNEL);
	memset(node, 0x00, sizeof(FREE_MEM_T));
	node->startAddr = CODEC_MEM_START + CODEC_CACHED_MEM_SIZE;
	node->cacheFlag = 0;
	node->size = CODEC_NON_CACHED_MEM_SIZE;
	InsertNodeToFreeList(node, -1);

	UnlockCMMMutex();

	return 0;
}