Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

sah_memory_mapper.c File Reference

Detailed Description

Re-creates SAHARA data structures in Kernel memory such that they are suitable for DMA. Provides support for kernel API.

This file needs to be ported.

The memory mapper gets a call at sah_Init_Mem_Map() during driver initialization.

The routine sah_Copy_Descriptors() is used to bring descriptor chains from user memory down to kernel memory, relink using physical addresses, and make sure that all user data will be accessible by the Sahara DMA. sah_Destroy_Descriptors() does the inverse.

The sah_Alloc_Block(), sah_Free_Block(), and sah_Block_Add_Page() routines implement a cache of free blocks used when allocating descriptors and links within the kernel.

The memory mapper gets a call at sah_Stop_Mem_Map() during driver shutdown.

Definition in file sah_memory_mapper.c.

#include <sah_driver_common.h>
#include <sah_kernel.h>
#include <sah_queue_manager.h>
#include <sah_memory_mapper.h>
#include <linux/mxc_scc_driver.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/dmapool.h>
#include <linux/slab.h>
#include <linux/highmem.h>

Go to the source code of this file.


struct  mem_big_block
struct  mem_block
struct  page_ctx_t


#define MEM_BIG_BLOCK_ENTRIES   (PAGE_SIZE / sizeof(Mem_Big_Block))
#define MEM_BIG_BLOCK_SIZE   sizeof(sah_Head_Desc)
#define MEM_BLOCK_ENTRIES   (PAGE_SIZE / sizeof(Mem_Block))
#define MEM_BLOCK_SIZE   sizeof(sah_Link)
#define sah_Desc_Get_Len1(desc)   (desc->len1)
#define sah_Desc_Get_Len2(desc)   (desc->len2)
#define sah_Desc_Get_LLO(desc)   (desc->header & SAH_LLO_BIT)
#define sah_Desc_Get_Next(desc)   (desc->next)
#define sah_Desc_Get_Ptr1(desc)   (desc->ptr1)
#define sah_Desc_Get_Ptr2(desc)   (desc->ptr2)
#define sah_Desc_Set_Header(desc, h)   (desc->header = (h))
#define sah_Desc_Set_Len1(desc, l1)   (desc->len1 = (l1))
#define sah_Desc_Set_Len2(desc, l2)   (desc->len2 = (l2))
#define sah_Desc_Set_Next(desc, n)   (desc->next = (n))
#define sah_Desc_Set_Ptr1(desc, p1)   (desc->ptr1 = (p1))
#define sah_Desc_Set_Ptr2(desc, p2)   (desc->ptr2 = (p2))
#define SAH_HW_DESC_LEN   24
#define SAH_HW_LINK_LEN   1
#define sah_Link_Get_Data(link)   (link->data)
#define sah_Link_Get_Flags(link)   (link->flags)
#define sah_Link_Get_Len(link)   (link->len)
#define sah_Link_Get_Next(link)   (link->next)
#define sah_Link_Set_Data(link, d)   (link->data = (d))
#define sah_Link_Set_Len(link, l)   (link->len = (l))
#define sah_Link_Set_Next(link, n)   (link->next = (n))
#define SAH_LLO_BIT   0x01000000


typedef struct mem_big_block Mem_Big_Block
typedef struct mem_block Mem_Block


os_error_code map_user_memory (struct vm_area_struct *vma, uint32_t physical_addr, uint32_t size)
static Mem_Big_Blocksah_Alloc_Big_Block (void)
 Allocate memory block.
static Mem_Blocksah_Alloc_Block (void)
 Allocate memory block.
sah_Descsah_Alloc_Descriptor (void)
 Allocate descriptor.
sah_Head_Descsah_Alloc_Head_Descriptor (void)
 Allocate Head descriptor.
sah_Linksah_Alloc_Link (void)
 Allocate link.
static void sah_Append_Big_Block (Mem_Big_Block *block)
 Append memory block to free pool.
static void sah_Append_Block (Mem_Block *block)
 Append memory block to free pool.
int sah_Block_Add_Page (int big)
 Add page of blocks to block free pool.
sah_Head_Descsah_Copy_Descriptors (fsl_shw_uco_t *user_ctx, sah_Head_Desc *user_head_desc)
 Kernel Descriptor Chain Copier.
sah_Linksah_Copy_Links (fsl_shw_uco_t *user_ctx, sah_Link *ptr)
 Kernel Link Chain Copier.
sah_Head_Descsah_DePhysicalise_Descriptors (sah_Head_Desc *first_desc)
sah_Linksah_DePhysicalise_Links (sah_Link *first_link)
 Convert physical Link chain.
void sah_Destroy_Descriptors (sah_Head_Desc *head_desc)
 Kernel Descriptor Chain Destructor.
void sah_Destroy_Links (sah_Link *link)
 Kernel Link Chain Destructor.
static void sah_Free_Big_Block (Mem_Big_Block *block)
 Free memory block.
static void sah_Free_Block (Mem_Block *block)
 Free memory block.
void sah_Free_Chained_Descriptors (sah_Head_Desc *head_desc)
 Kernel Descriptor Chain Destructor.
void sah_Free_Chained_Links (sah_Link *link)
 Kernel Link Chain Destructor.
void sah_Free_Descriptor (sah_Desc *desc)
 Free descriptor.
void sah_Free_Head_Descriptor (sah_Head_Desc *desc)
 Free Head descriptor.
void sah_Free_Link (sah_Link *link)
 Free link.
int sah_Init_Mem_Map (void)
 Initialize memory manager/mapper.
sah_Linksah_Make_Links (fsl_shw_uco_t *user_ctx, sah_Link *ptr, sah_Link **tail)
 Kernel Link Chain Constructor.
sah_Head_Descsah_Physicalise_Descriptors (sah_Head_Desc *first_desc)
sah_Linksah_Physicalise_Links (sah_Link *first_link)
 Convert kernel Link chain.
void sah_Stop_Mem_Map (void)
 Clean up memory manager/mapper.
os_error_code unmap_user_memory (uint32_t user_addr, uint32_t size)
void unwire_user_memory (void **page_ctx)
void * wire_user_memory (void *address, uint32_t length, void **page_ctx)


static Mem_Big_Blockbig_block_free_head = NULL
static Mem_Big_Blockbig_block_free_tail = NULL
static Mem_Blockblock_free_head = NULL
static Mem_Blockblock_free_tail = NULL
static os_lock_t mem_lock

Generated by  Doxygen 1.6.0   Back to index