Re-creates SAHARA data structures in Kernel memory such that they are suitable for DMA. Provides support for kernel API. More...
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.
typedef struct mem_big_block Mem_Big_Block |
Structure for head descriptor memory blocks in internal pool
static Mem_Big_Block * sah_Alloc_Big_Block | ( | void | ) | [static] |
Allocate memory block.
Allocate block from free pool. A block is large enough to fit either a link or descriptor.
References mem_lock, mem_big_block::next, os_lock_save_context, os_unlock_restore_context, and sah_Block_Add_Page().
Referenced by sah_Alloc_Head_Descriptor().
static Mem_Block * sah_Alloc_Block | ( | void | ) | [static] |
Allocate memory block.
Allocate block from free pool. A block is large enough to fit either a link or descriptor.
References mem_lock, mem_block::next, os_lock_save_context, os_unlock_restore_context, and sah_Block_Add_Page().
Referenced by sah_Alloc_Descriptor(), and sah_Alloc_Link().
sah_Desc* sah_Alloc_Descriptor | ( | void | ) |
Allocate descriptor.
Allocate descriptor from free pool.
References mem_block::data, mem_block::dma_addr, sah_Desc::next, sah_Desc::ptr1, sah_Desc::ptr2, and sah_Alloc_Block().
Referenced by sah_Copy_Descriptors().
sah_Head_Desc* sah_Alloc_Head_Descriptor | ( | void | ) |
Allocate Head descriptor.
Allocate Head descriptor from free pool.
References mem_big_block::data, sah_Head_Desc::desc, mem_big_block::dma_addr, sah_Desc::next, sah_Desc::ptr1, sah_Desc::ptr2, and sah_Alloc_Big_Block().
Referenced by sah_Copy_Descriptors(), and sah_HW_Reset().
sah_Link* sah_Alloc_Link | ( | void | ) |
Allocate link.
Allocate link from free pool.
References sah_Link::data, mem_block::data, mem_block::dma_addr, sah_Link::flags, sah_Link::len, sah_Link::next, and sah_Alloc_Block().
Referenced by sah_Make_Links(), and sah_Physicalise_Links().
static void sah_Append_Big_Block | ( | Mem_Big_Block * | block | ) | [static] |
Append memory block to free pool.
Append memory block to end of free pool.
block | A block entry |
References mem_big_block::next.
Referenced by sah_Block_Add_Page(), and sah_Free_Big_Block().
static void sah_Append_Block | ( | Mem_Block * | block | ) | [static] |
Append memory block to free pool.
Append memory block to end of free pool.
block | A block entry |
References mem_block::next.
Referenced by sah_Block_Add_Page(), and sah_Free_Block().
int sah_Block_Add_Page | ( | int | big | ) |
Add page of blocks to block free pool.
Add a new page to end of block free pool. This will allocate one page and fill the pool with entries, appending to the end.
big | 0 - make blocks big enough for sah_Desc non-zero - make blocks big enough for sah_Head_Desc |
References mem_block::dma_addr, mem_big_block::dma_addr, os_alloc_coherent, os_alloc_memory, os_pa, sah_Append_Big_Block(), and sah_Append_Block().
Referenced by sah_Alloc_Big_Block(), and sah_Alloc_Block().
sah_Head_Desc* sah_Copy_Descriptors | ( | fsl_shw_uco_t * | user_ctx, | |
sah_Head_Desc * | user_head_desc | |||
) |
Kernel Descriptor Chain Copier.
This function runs through a descriptor chain pointed to by a user-space address. It duplicates each descriptor in Kernel space memory and calls sah_Copy_Links() to handle any links attached to the descriptors. This function cleans-up everything that it created in the case of a failure.
fsl_shw_uco_t | The user context to act under | |
user_head_desc | A Head Descriptor pointer from user-space. |
References sah_Head_Desc::desc, FSL_RETURN_INTERNAL_ERROR_S, FSL_RETURN_NO_RESOURCE_S, FSL_RETURN_OK_S, FSL_UCO_SAVE_DESC_CHAIN, sah_Desc::header, sah_Desc::next, os_flush_cache_all, sah_Head_Desc::out1_ptr, sah_Desc::ptr1, sah_Desc::ptr2, sah_Alloc_Descriptor(), sah_Alloc_Head_Descriptor(), sah_Copy_Links(), sah_Destroy_Descriptors(), sah_Head_Desc::uco_flags, and sah_Head_Desc::user_ref.
Referenced by handle_sah_ioctl_dar().
sah_Link* sah_Copy_Links | ( | fsl_shw_uco_t * | user_ctx, | |
sah_Link * | ptr | |||
) |
Kernel Link Chain Copier.
This function runs through a link chain pointed to by a user-space address. It makes a temporary kernel-space copy of each link in the chain and calls sah_Make_Links() to create a set of kernel-side links to replace it.
ptr | A link pointer from user-space. |
References FSL_RETURN_INTERNAL_ERROR_S, FSL_RETURN_OK_S, sah_Link::len, sah_Link::next, sah_Destroy_Links(), and sah_Make_Links().
Referenced by sah_Copy_Descriptors().
sah_Head_Desc* sah_DePhysicalise_Descriptors | ( | sah_Head_Desc * | first_desc | ) |
Run through descriptors and links that have been Physicalised (sah_Physicalise_Descriptors function) and set the dma addresses back to KM virtual addresses
first_desc | Kernel virtual address of first descriptor in chain. |
Warning! This ONLY works without LLO flags in headers!!!
References sah_Head_Desc::desc, FSL_UCO_CHAIN_PREPHYSICALIZED, sah_DePhysicalise_Links(), and sah_Head_Desc::uco_flags.
Referenced by sah_blocking_mode(), sah_get_results_from_pool(), and sah_Physicalise_Descriptors().
Convert physical Link chain.
This function runs through a sah_Link chain pointed to by a physical address. It computes the virtual address for each pointer
first_link | A kernel address of a sah_Link |
first_link
References sah_Link::len, sah_Link::next, os_cache_inv_range, os_printk, sah_Free_Link(), SAH_IN_USER_KEYSTORE, SAH_LINK_INSERTED_LINK, SAH_OUTPUT_LINK, SAH_PREPHYS_DATA, and SAH_STORED_KEY_INFO.
Referenced by sah_DePhysicalise_Descriptors().
void sah_Destroy_Descriptors | ( | sah_Head_Desc * | head_desc | ) |
Kernel Descriptor Chain Destructor.
This walks through a SAHARA descriptor chain and frees everything that is not NULL. Finally it also unmaps all of the physical memory and frees the kiobuf_list Queue.
desc | A Descriptor pointer from kernel-space. This should be in bus address space. |
References sah_Desc::header, sah_Desc::len1, sah_Desc::len2, sah_Desc::next, os_flush_cache_all, sah_Desc::ptr1, sah_Desc::ptr2, sah_Destroy_Links(), sah_Free_Descriptor(), and sah_Free_Head_Descriptor().
Referenced by sah_Copy_Descriptors().
void sah_Destroy_Links | ( | sah_Link * | link | ) |
Kernel Link Chain Destructor.
This walks through a SAHARA link chain and frees everything that is not NULL excluding user-space buffers.
link | A Link pointer from kernel-space. |
References sah_Link::data, sah_Link::len, sah_Link::next, and sah_Free_Link().
Referenced by sah_Copy_Links(), sah_Destroy_Descriptors(), and sah_Make_Links().
static void sah_Free_Big_Block | ( | Mem_Big_Block * | block | ) | [static] |
Free memory block.
Free memory block back to free pool
block | A block allocated with sah_Alloc_Block(). |
References mem_lock, os_lock_save_context, os_unlock_restore_context, and sah_Append_Big_Block().
Referenced by sah_Free_Head_Descriptor().
static void sah_Free_Block | ( | Mem_Block * | block | ) | [static] |
Free memory block.
Free memory block back to free pool
block | A block allocated with sah_Alloc_Block(). |
References mem_lock, os_lock_save_context, os_unlock_restore_context, and sah_Append_Block().
Referenced by sah_Free_Descriptor(), and sah_Free_Link().
void sah_Free_Chained_Descriptors | ( | sah_Head_Desc * | head_desc | ) |
Kernel Descriptor Chain Destructor.
This walks through a SAHARA descriptor chain and free()'s everything that is not NULL. Finally it also unmaps all of the physical memory and frees the kiobuf_list Queue.
head_desc | A Descriptor pointer from kernel-space. |
References sah_Head_Desc::desc, sah_Desc::header, sah_Desc::len1, sah_Desc::len2, sah_Desc::next, sah_Desc::ptr1, sah_Desc::ptr2, sah_Free_Chained_Links(), sah_Free_Descriptor(), and sah_Free_Head_Descriptor().
Referenced by handle_sah_ioctl_dar(), and sah_get_results_pointers().
void sah_Free_Chained_Links | ( | sah_Link * | link | ) |
Kernel Link Chain Destructor.
This walks through a SAHARA link chain and frees everything that is not NULL, excluding user-space buffers.
link | A Link pointer from kernel-space. This is in bus address space. |
References sah_Link::data, sah_Link::len, sah_Link::next, sah_Link::ownerid, and sah_Free_Link().
Referenced by sah_Free_Chained_Descriptors().
void sah_Free_Descriptor | ( | sah_Desc * | desc | ) |
Free descriptor.
Free descriptor back to free pool
desc | A descriptor allocated with sah_Alloc_Descriptor(). |
References sah_Free_Block().
Referenced by sah_Destroy_Descriptors(), and sah_Free_Chained_Descriptors().
void sah_Free_Head_Descriptor | ( | sah_Head_Desc * | desc | ) |
Free Head descriptor.
Free Head descriptor back to free pool
desc | A Head descriptor allocated with sah_Alloc_Head_Descriptor(). |
References sah_Free_Big_Block().
Referenced by sah_Destroy_Descriptors(), sah_Free_Chained_Descriptors(), and sah_HW_Reset().
void sah_Free_Link | ( | sah_Link * | link | ) |
Free link.
Free link back to free pool
link | A link allocated with sah_Alloc_Link(). |
References sah_Free_Block().
Referenced by sah_DePhysicalise_Links(), sah_Destroy_Links(), sah_Free_Chained_Links(), and sah_Make_Links().
int sah_Init_Mem_Map | ( | void | ) |
Initialize memory manager/mapper.
In 2.4, this function also allocates a kiovec to be used when mapping user data to kernel space
References mem_lock, OS_ERROR_FAIL_S, OS_ERROR_OK_S, os_lock_alloc_init(), and os_printk.
Referenced by OS_DEV_INIT().
sah_Link* sah_Make_Links | ( | fsl_shw_uco_t * | user_ctx, | |
sah_Link * | ptr, | |||
sah_Link ** | tail | |||
) |
Kernel Link Chain Constructor.
This function takes an input link pointed to by a user-space address and returns a chain of links that span the physical pages pointed to by the input link.
ptr | A link pointer from user-space. | |
tail | The address of a link pointer. This is used to return the tail link created by this function. |
References sah_Link::data, sah_Link::flags, FSL_RETURN_BAD_DATA_LENGTH_S, FSL_RETURN_INTERNAL_ERROR_S, FSL_RETURN_NO_RESOURCE_S, FSL_RETURN_OK_S, sah_Link::len, sah_Link::next, os_cache_clean_range, os_cache_flush_range, sah_Link::ownerid, sah_Alloc_Link(), sah_Destroy_Links(), sah_Free_Link(), SAH_IN_USER_KEYSTORE, SAH_OUTPUT_LINK, SAH_PREPHYS_DATA, SAH_STORED_KEY_INFO, and sah_Link::slot.
Referenced by sah_Copy_Links().
sah_Head_Desc* sah_Physicalise_Descriptors | ( | sah_Head_Desc * | first_desc | ) |
Run through descriptors and links created by KM-API and set the dma addresses and 'do not free' flags.
first_desc | KERNEL VIRTUAL address of first descriptor in chain. |
Warning! This ONLY works without LLO flags in headers!!!
References sah_Head_Desc::desc, FSL_UCO_CHAIN_PREPHYSICALIZED, sah_Desc::next, sah_Head_Desc::next, os_printk, sah_DePhysicalise_Descriptors(), sah_Physicalise_Links(), and sah_Head_Desc::uco_flags.
Referenced by adaptor_Exec_Descriptor_Chain().
Convert kernel Link chain.
This function runs through a sah_Link chain pointed to by a kernel-space address. It computes the physical address for each pointer, and converts the chain to use these physical addresses.
This function needs to return some indication that the chain could not be converted. It also needs to back out any conversion already taken place on this chain of links.
Then, of course, sah_Physicalise_Descriptors() will need to recognize that an error occured, and then be able to back out any physicalization of the chain which had taken place up to that point!
first_link | A sah_Link pointer from kernel space; must not be NULL, so error case can be distinguished. |
References sah_Link::data, sah_Link::flags, FSL_RETURN_OK_S, sah_Link::len, sah_Link::next, os_cache_clean_range, os_cache_flush_range, os_pa, os_printk, sah_Alloc_Link(), SAH_IN_USER_KEYSTORE, SAH_LINK_INSERTED_LINK, SAH_OUTPUT_LINK, SAH_OWNS_LINK_DATA, SAH_PREPHYS_DATA, and SAH_STORED_KEY_INFO.
Referenced by sah_Physicalise_Descriptors().
void sah_Stop_Mem_Map | ( | void | ) |
Clean up memory manager/mapper.
In 2.4, this function also frees the kiovec used when mapping user data to kernel space.
References mem_lock, and os_lock_deallocate.
Referenced by OS_DEV_SHUTDOWN().
Mem_Big_Block* big_block_free_head = NULL [static] |
Memory block free pool - pointer to first block. Chain is protected by mem_lock.
Mem_Big_Block* big_block_free_tail = NULL [static] |
Memory block free pool - pointer to last block. Chain is protected by mem_lock. a
Mem_Block* block_free_head = NULL [static] |
Memory block free pool - pointer to first block. Chain is protected by mem_lock.
Mem_Block* block_free_tail = NULL [static] |
Memory block free pool - pointer to last block. Chain is protected by mem_lock.
Lock to protect the memory chain composed of block_free_head and block_free_tail.
Referenced by sah_Alloc_Big_Block(), sah_Alloc_Block(), sah_Free_Big_Block(), sah_Free_Block(), sah_Init_Mem_Map(), and sah_Stop_Mem_Map().
© Freescale Semiconductor, Inc., 2007.
All rights reserved. Freescale Confidential Proprietary NDA Required |
![]() |