![]() |
![]() |
Source file for the KEYSTONE_MMAP component which relevent to the allocation of resources such as logical addresses and MPAX registers. More...
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <ti/runtime/mmap/mmap.h>
#include <ti/runtime/mmap/include/mmap_resource.h>
Functions | |
static void | heap_init (keystone_mmap_heap_element_t *elem_bank, uint32_t elem_idx, uint32_t addr, uint32_t size) |
static uint32_t | heap_alloc (keystone_mmap_heap_element_t *elem_bank, uint32_t elem_idx, uint32_t size, uint32_t protections) |
static uint32_t | heap_free (keystone_mmap_heap_element_t *elem_bank, uint32_t elem_idx, uint32_t addr) |
static void | heap_status (keystone_mmap_heap_element_t *elem_bank, uint32_t elem_idx, int32_t depth) |
static void | map_status (keystone_mmap_mapping_t *mapping) |
void | keystone_mmap_resource_debug (const char *function_name, keystone_mmap_resources_t *resources) |
int32_t | keystone_mmap_resource_init (uint32_t num_regs, uint32_t *xmc_regs, uint32_t *ses_regs, uint32_t num_heaps, uint32_t *heap_base, uint32_t *heap_size, keystone_mmap_resources_t *resources) |
int32_t | keystone_mmap_resource_free (uint32_t num_bufs, uint32_t *virt_addrs, uint32_t *lengths, keystone_mmap_resources_t *resources) |
int32_t | keystone_mmap_resource_alloc (uint32_t num_bufs, uint64_t *phys_addrs, uint32_t *lengths, uint32_t *protections, uint32_t *virt_addrs, keystone_mmap_resources_t *resources) |
static unsigned int | get_heap_element (keystone_mmap_heap_element_t *elem_bank) |
static void | free_heap_element (keystone_mmap_heap_element_t *elem_bank, uint32_t elem_idx) |
static void | heap_split_elem (keystone_mmap_heap_element_t *elem_bank, uint32_t elem_idx) |
static uint32_t | heap_reserve (keystone_mmap_heap_element_t *elem_bank, uint32_t elem_idx, uint32_t addr, uint32_t size) |
Source file for the KEYSTONE_MMAP component which relevent to the allocation of resources such as logical addresses and MPAX registers.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static void free_heap_element | ( | keystone_mmap_heap_element_t * | elem_bank, |
uint32_t | elem_idx | ||
) | [static] |
Free heap element back to the heap element bank.
static unsigned int get_heap_element | ( | keystone_mmap_heap_element_t * | elem_bank | ) | [static] |
Allocate heap element frmo the heap element bank.
static uint32_t heap_alloc | ( | keystone_mmap_heap_element_t * | elem_bank, |
uint32_t | elem_idx, | ||
uint32_t | size, | ||
uint32_t | protections | ||
) | [static] |
Allocates a chunk of the address space.
Recursively searches the heap to find a free element. This sub routine requires that the length be a power of 2.
static uint32_t heap_free | ( | keystone_mmap_heap_element_t * | elem_bank, |
uint32_t | elem_idx, | ||
uint32_t | addr | ||
) | [static] |
Deallocates a chunk of the address space.
Searches the leaf nodes of the heap to find the element which contains addr.
static void heap_init | ( | keystone_mmap_heap_element_t * | elem_bank, |
uint32_t | elem_idx, | ||
uint32_t | addr, | ||
uint32_t | size | ||
) | [static] |
Initialize the heap.
This function beings by finding the best power of 2 size and aligned address space which contains the requested heap space. Then the excess reserved from the heap.
static uint32_t heap_reserve | ( | keystone_mmap_heap_element_t * | elem_bank, |
uint32_t | elem_idx, | ||
uint32_t | addr, | ||
uint32_t | size | ||
) | [static] |
Reserve parts of the address space from the heap.
Recursively parses the heap to mark all elements which are contained in the reserved region as allocated.
static void heap_split_elem | ( | keystone_mmap_heap_element_t * | elem_bank, |
uint32_t | elem_idx | ||
) | [static] |
Split an element into 2 sub elements, each with half the size.
static void heap_status | ( | keystone_mmap_heap_element_t * | elem_bank, |
uint32_t | elem_idx, | ||
int32_t | depth | ||
) | [static] |
Prints the current state of the heap.
This function is intended for debugging and it will print out the information of the all of the leaf nodes of the heap tree.
int32_t keystone_mmap_resource_alloc | ( | uint32_t | num_bufs, |
uint64_t * | phys_addrs, | ||
uint32_t * | lengths, | ||
uint32_t * | protections, | ||
uint32_t * | virt_addrs, | ||
keystone_mmap_resources_t * | resources | ||
) |
Description
This functions takes physical buffers and lengths and allocates the resources required to map all of the buffer. If the allocation is successful, the array of addressable virtual address is populated along with the physical mapping configuration.
[in] | num_bufs | Number of buffers for which to allocate mapping resources. |
[in] | phys_addrs | Array of physical addresses of the base of each buffer. |
[in] | lengths | Array of lengths for each buffer. |
[in] | protections | Array containing the read/write/execute permissions along with cacheability. |
[out] | virt_addrs | An array which, upon succesful resource allocation, will be populated with the virtual addresses corresponding to the physical buffers. |
[in,out] | resources | Resource structure which manages the mapping resources. This structure contains a keystone_mmap_mapping_t structure which is the table of mapping information which should be passed to keystone_mmap_do_map() to perform the actual mapping. |
KEYSTONE_MMAP_RESOURCE_NOERR | on success. Other values correspond to an error condition. ( |
void keystone_mmap_resource_debug | ( | const char * | function_name, |
keystone_mmap_resources_t * | resources | ||
) |
Description
This function prints out debug information on the KEYSTONE_MMAP resources.
[in] | function_name | Name of the calling function. |
[in] | resources | KEYSTONE_MMAP resource structure. |
int32_t keystone_mmap_resource_free | ( | uint32_t | num_bufs, |
uint32_t * | virt_addrs, | ||
uint32_t * | lengths, | ||
keystone_mmap_resources_t * | resources | ||
) |
Description
This function frees resources associated to mapped physical buffers, The virtual addresses and lengths are supplied to this function and the corresponding mapping entries are removed.
[in] | num_bufs | number of buffers which are to be unmapped. |
[in] | virt_addrs | Array of virtual address of the buffers which are to be unmapped. |
[in] | lengths | Array of lengths of the buffers which are to be unmapped. |
[in,out] | resources | Resource structure managing the resources used for mapping. |
KEYSTONE_MMAP_RESOURCE_NOERR | on success. Other values correspond to an error condition. ( |
A single buffer may require 2 mappings to save address space resource.
Check if beginning or end of mapped region is within the actual mapping.
int32_t keystone_mmap_resource_init | ( | uint32_t | num_regs, |
uint32_t * | xmc_regs, | ||
uint32_t * | ses_regs, | ||
uint32_t | num_heaps, | ||
uint32_t * | heap_base, | ||
uint32_t * | heap_size, | ||
keystone_mmap_resources_t * | resources | ||
) |
Description
This function initializes the data structures which manage the resources used for mapping. These resources are the address space heaps and MPAX registers used for mapping.
[in] | num_regs | Number of XMC and SES register pairs available for mapping. |
[in] | xmc_regs | Array of XMC register indexes which are available for mapping. XMC registers allow the DSP core to access the mapped memory. |
[in] | ses_regs | Array of SES register indexes which are available for mapping. SES registers allows EDMA to access the mapped memory. |
[in] | num_heaps | Number of contiguous address space ranges which are available for mapping. |
[in] | heap_base | Array of base addresses of each contiguous address space range. |
[in] | heap_size | Array of sizes of each contiguous address space range. |
[out] | resources | KEYSTONE_MMAP resource strucutre which manages the resources used for mapping. |
KEYSTONE_MMAP_RESOURCE_NOERR | on success. Other values correspond to an error condition. ( |
static void map_status | ( | keystone_mmap_mapping_t * | mapping | ) | [static] |
Prints out all valid mappings maintained by KEYSTONE_MMAP.