Commit 5108f6ca authored by Hari Kanigeri's avatar Hari Kanigeri

plug dmm with proc module

this patch plugs the dmm module with Proc4430 driver
and procmgr module. This provides both Map and Unmap
functionality.
Signed-off-by: default avatarHari Kanigeri <h-kanigeri2@ti.com>
parent cec97e15
...@@ -116,6 +116,11 @@ ...@@ -116,6 +116,11 @@
#define DSP_MAPVMALLOCADDR 0x00000080 #define DSP_MAPVMALLOCADDR 0x00000080
#define PG_MASK(pg_size) (~((pg_size)-1))
#define PG_ALIGN_LOW(addr, pg_size) ((addr) & PG_MASK(pg_size))
#define PG_ALIGN_HIGH(addr, pg_size) (((addr)+(pg_size)-1) & PG_MASK(pg_size))
struct mmu_entry { struct mmu_entry {
u32 ul_phy_addr ; u32 ul_phy_addr ;
u32 ul_virt_addr ; u32 ul_virt_addr ;
...@@ -153,5 +158,6 @@ void dbg_print_ptes(bool ashow_inv_entries, bool ashow_repeat_entries); ...@@ -153,5 +158,6 @@ void dbg_print_ptes(bool ashow_inv_entries, bool ashow_repeat_entries);
int ducati_setup(void); int ducati_setup(void);
void ducati_destroy(void); void ducati_destroy(void);
u32 get_ducati_virt_mem(); u32 get_ducati_virt_mem();
int ducati_mem_map(u32 va, u32 da, u32 num_bytes, u32 map_attr);
int ducati_mem_unmap(u32 da, u32 num_bytes);
#endif /* _DDUCATIMMU_ENABLER_H_*/ #endif /* _DDUCATIMMU_ENABLER_H_*/
...@@ -112,7 +112,7 @@ extern hw_status hw_mmu_pte_set(const u32 pg_tbl_va, ...@@ -112,7 +112,7 @@ extern hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
u32 page_size, u32 page_size,
struct hw_mmu_map_attrs_t *map_attrs); struct hw_mmu_map_attrs_t *map_attrs);
extern hw_status hw_mmu_pt_clear(const u32 pg_tbl_va, extern hw_status hw_mmu_pte_clear(const u32 pg_tbl_va,
u32 pg_size, u32 pg_size,
u32 virtual_addr); u32 virtual_addr);
......
...@@ -225,7 +225,7 @@ func_exit: ...@@ -225,7 +225,7 @@ func_exit:
* Purpose: * Purpose:
*Free a chunk of reserved DSP/IVA address space. *Free a chunk of reserved DSP/IVA address space.
*/ */
int dmm_unreserve_memory(u32 rsv_addr) int dmm_unreserve_memory(u32 rsv_addr, u32 *psize)
{ {
struct map_page *chunk; struct map_page *chunk;
int status = 0; int status = 0;
...@@ -239,6 +239,7 @@ int dmm_unreserve_memory(u32 rsv_addr) ...@@ -239,6 +239,7 @@ int dmm_unreserve_memory(u32 rsv_addr)
WARN_ON(status < 0); WARN_ON(status < 0);
if (status == 0) { if (status == 0) {
chunk->b_reserved = false; chunk->b_reserved = false;
*psize = chunk->region_size * PAGE_SIZE;
/* NOTE: We do NOT coalesce free regions here. /* NOTE: We do NOT coalesce free regions here.
* Free regions are coalesced in get_region(), as it traverses * Free regions are coalesced in get_region(), as it traverses
*the whole mapping table *the whole mapping table
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
int dmm_reserve_memory(u32 size, u32 *p_rsv_addr); int dmm_reserve_memory(u32 size, u32 *p_rsv_addr);
int dmm_unreserve_memory(u32 rsv_addr); int dmm_unreserve_memory(u32 rsv_addr, u32 *psize);
void dmm_destroy(void); void dmm_destroy(void);
......
...@@ -104,17 +104,7 @@ enum hw_mmu_pgsiz_t { ...@@ -104,17 +104,7 @@ enum hw_mmu_pgsiz_t {
* Identifier : base_address * Identifier : base_address
* Type : const u32 * Type : const u32
* Description : Base Address of instance of MMU module * Description : Base Address of instance of MMU module
*
* RETURNS:
*
* Type : hw_status
* Description : RET_OK -- No errors occured
* RET_BAD_NULL_PARAM -- A Pointer Paramater was set to NULL
*
* PURPOSE: : Flush the TLB entry pointed by the lock counter register
* even if this entry is set protected
*
* METHOD: : Check the Input parameter and Flush a single entry in the TLB.
------------------------------------------------------------------------- -------------------------------------------------------------------------
*/ */
...@@ -147,15 +137,6 @@ static hw_status mmu_flsh_entry(const u32 base_address); ...@@ -147,15 +137,6 @@ static hw_status mmu_flsh_entry(const u32 base_address);
* Type : const u32 * Type : const u32
* Description : virtual Address * Description : virtual Address
* *
* RETURNS:
*
* Type : hw_status
* Description : RET_OK -- No errors occured
* RET_BAD_NULL_PARAM -- A Pointer Paramater was set to NULL
* RET_PARAM_OUT_OF_RANGE -- Input Parameter out of Range
*
* PURPOSE: : Set MMU_CAM reg
*
* METHOD: : Check the Input parameters and set the CAM entry. * METHOD: : Check the Input parameters and set the CAM entry.
------------------------------------------------------------------------- -------------------------------------------------------------------------
*/ */
...@@ -193,13 +174,7 @@ static hw_status mme_set_cam_entry(const u32 base_address, ...@@ -193,13 +174,7 @@ static hw_status mme_set_cam_entry(const u32 base_address,
* Type : hw_mmu_mixed_size_t * Type : hw_mmu_mixed_size_t
* Description : Element Size to follow CPU or TLB * Description : Element Size to follow CPU or TLB
* *
* RETURNS:
*
* Type : hw_status
* Description : RET_OK -- No errors occured
* RET_BAD_NULL_PARAM -- A Pointer Paramater was set to NULL
* RET_PARAM_OUT_OF_RANGE -- Input Parameter out of Range
*
* PURPOSE: : Set MMU_CAM reg * PURPOSE: : Set MMU_CAM reg
* *
* METHOD: : Check the Input parameters and set the RAM entry. * METHOD: : Check the Input parameters and set the RAM entry.
...@@ -431,9 +406,9 @@ hw_status hw_mmu_tlb_flush(const u32 base_address, ...@@ -431,9 +406,9 @@ hw_status hw_mmu_tlb_flush(const u32 base_address,
/* Generate the 20-bit tag from virtual address */ /* Generate the 20-bit tag from virtual address */
virt_addr_tag = ((virtual_addr & MMU_ADDR_MASK) >> 12); virt_addr_tag = ((virtual_addr & MMU_ADDR_MASK) >> 12);
mme_set_cam_entry (base_address, pg_sizeBits, 0, 0, virt_addr_tag); mme_set_cam_entry(base_address, pg_sizeBits, 0, 0, virt_addr_tag);
mmu_flsh_entry (base_address); mmu_flsh_entry(base_address);
return status; return status;
} }
...@@ -502,7 +477,8 @@ hw_status hw_mmu_tlb_add(const u32 base_address, ...@@ -502,7 +477,8 @@ hw_status hw_mmu_tlb_add(const u32 base_address,
/* currentVictim between lockedBaseValue and (MMU_Entries_Number - 1) */ /* currentVictim between lockedBaseValue and (MMU_Entries_Number - 1) */
mmu_lck_crnt_vctmwite32(base_address, entryNum); mmu_lck_crnt_vctmwite32(base_address, entryNum);
/* Enable loading of an entry in TLB by writing 1 into LD_TLB_REG register */ /* Enable loading of an entry in TLB by writing 1 into LD_TLB_REG
register */
mmu_ld_tlbwrt_reg32(base_address, MMU_LOAD_TLB); mmu_ld_tlbwrt_reg32(base_address, MMU_LOAD_TLB);
...@@ -527,7 +503,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va, ...@@ -527,7 +503,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
switch (page_size) { switch (page_size) {
case HW_PAGE_SIZE_4KB: case HW_PAGE_SIZE_4KB:
pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va, virtual_addr & MMU_SMALL_PAGE_MASK); pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va, virtual_addr &
MMU_SMALL_PAGE_MASK);
pte_val = ((physical_addr & MMU_SMALL_PAGE_MASK) | pte_val = ((physical_addr & MMU_SMALL_PAGE_MASK) |
(map_attrs->endianism << 9) | (map_attrs->endianism << 9) |
(map_attrs->element_size << 4) | (map_attrs->element_size << 4) |
...@@ -537,7 +514,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va, ...@@ -537,7 +514,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
case HW_PAGE_SIZE_64KB: case HW_PAGE_SIZE_64KB:
num_entries = 16; num_entries = 16;
pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va, virtual_addr & MMU_LARGE_PAGE_MASK); pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va, virtual_addr &
MMU_LARGE_PAGE_MASK);
pte_val = ((physical_addr & MMU_LARGE_PAGE_MASK) | pte_val = ((physical_addr & MMU_LARGE_PAGE_MASK) |
(map_attrs->endianism << 9) | (map_attrs->endianism << 9) |
(map_attrs->element_size << 4) | (map_attrs->element_size << 4) |
...@@ -546,7 +524,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va, ...@@ -546,7 +524,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
break; break;
case HW_PAGE_SIZE_1MB: case HW_PAGE_SIZE_1MB:
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va, virtual_addr & MMU_SECTION_ADDR_MASK); pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va, virtual_addr &
MMU_SECTION_ADDR_MASK);
pte_val = ((((physical_addr & MMU_SECTION_ADDR_MASK) | pte_val = ((((physical_addr & MMU_SECTION_ADDR_MASK) |
(map_attrs->endianism << 15) | (map_attrs->endianism << 15) |
(map_attrs->element_size << 10) | (map_attrs->element_size << 10) |
...@@ -557,7 +536,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va, ...@@ -557,7 +536,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
case HW_PAGE_SIZE_16MB: case HW_PAGE_SIZE_16MB:
num_entries = 16; num_entries = 16;
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va, virtual_addr & MMU_SSECTION_ADDR_MASK); pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va, virtual_addr &
MMU_SSECTION_ADDR_MASK);
pte_val = (((physical_addr & MMU_SSECTION_ADDR_MASK) | pte_val = (((physical_addr & MMU_SSECTION_ADDR_MASK) |
(map_attrs->endianism << 15) | (map_attrs->endianism << 15) |
(map_attrs->element_size << 10) | (map_attrs->element_size << 10) |
...@@ -567,7 +547,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va, ...@@ -567,7 +547,8 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
break; break;
case HW_MMU_COARSE_PAGE_SIZE: case HW_MMU_COARSE_PAGE_SIZE:
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va, virtual_addr & MMU_SECTION_ADDR_MASK); pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va, virtual_addr &
MMU_SECTION_ADDR_MASK);
pte_val = (physical_addr & MMU_PAGE_TABLE_MASK) | 1; pte_val = (physical_addr & MMU_PAGE_TABLE_MASK) | 1;
break; break;
...@@ -583,7 +564,7 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va, ...@@ -583,7 +564,7 @@ hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
} }
EXPORT_SYMBOL(hw_mmu_pte_set); EXPORT_SYMBOL(hw_mmu_pte_set);
hw_status hw_mmu_pt_clear(const u32 pg_tbl_va, hw_status hw_mmu_pte_clear(const u32 pg_tbl_va,
u32 virtual_addr, u32 virtual_addr,
u32 pg_size) u32 pg_size)
{ {
...@@ -624,7 +605,7 @@ hw_status hw_mmu_pt_clear(const u32 pg_tbl_va, ...@@ -624,7 +605,7 @@ hw_status hw_mmu_pt_clear(const u32 pg_tbl_va,
return status; return status;
} }
EXPORT_SYMBOL(hw_mmu_pt_clear); EXPORT_SYMBOL(hw_mmu_pte_clear);
/* ============================================================================ /* ============================================================================
* LOCAL FUNCTIONS * LOCAL FUNCTIONS
...@@ -653,7 +634,7 @@ static hw_status mmu_flsh_entry(const u32 base_address) ...@@ -653,7 +634,7 @@ static hw_status mmu_flsh_entry(const u32 base_address)
EXPORT_SYMBOL(mmu_flsh_entry); EXPORT_SYMBOL(mmu_flsh_entry);
/* /*
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
NAME : mme_set_cam_entry - NAME : mme_set_cam_entry
----------------------------------------------------- -----------------------------------------------------
*/ */
static hw_status mme_set_cam_entry(const u32 base_address, static hw_status mme_set_cam_entry(const u32 base_address,
...@@ -670,7 +651,8 @@ static hw_status mme_set_cam_entry(const u32 base_address, ...@@ -670,7 +651,8 @@ static hw_status mme_set_cam_entry(const u32 base_address,
RES_MMU_BASE + RES_INVALID_INPUT_PARAM); RES_MMU_BASE + RES_INVALID_INPUT_PARAM);
mmuCamReg = (virt_addr_tag << 12); mmuCamReg = (virt_addr_tag << 12);
mmuCamReg = (mmuCamReg) | (page_size) | (valid_bit << 2) | (preserve_bit << 3); mmuCamReg = (mmuCamReg) | (page_size) | (valid_bit << 2)
| (preserve_bit << 3);
/* write values to register */ /* write values to register */
MMUMMU_CAMWriteRegister32(base_address, mmuCamReg); MMUMMU_CAMWriteRegister32(base_address, mmuCamReg);
...@@ -679,8 +661,8 @@ static hw_status mme_set_cam_entry(const u32 base_address, ...@@ -679,8 +661,8 @@ static hw_status mme_set_cam_entry(const u32 base_address,
} }
EXPORT_SYMBOL(mme_set_cam_entry); EXPORT_SYMBOL(mme_set_cam_entry);
/* /*
----------------------------------------------------------------------------- ----------------------------------------------------
NAME : mmu_set_ram_entry - NAME : mmu_set_ram_entry
----------------------------------------------------- -----------------------------------------------------
*/ */
static hw_status mmu_set_ram_entry(const u32 base_address, static hw_status mmu_set_ram_entry(const u32 base_address,
...@@ -695,12 +677,14 @@ static hw_status mmu_set_ram_entry(const u32 base_address, ...@@ -695,12 +677,14 @@ static hw_status mmu_set_ram_entry(const u32 base_address,
/*Check the input Parameters*/ /*Check the input Parameters*/
CHECK_INPUT_PARAM(base_address, 0, RET_BAD_NULL_PARAM, CHECK_INPUT_PARAM(base_address, 0, RET_BAD_NULL_PARAM,
RES_MMU_BASE + RES_INVALID_INPUT_PARAM); RES_MMU_BASE + RES_INVALID_INPUT_PARAM);
CHECK_INPUT_RANGE_MIN0(element_size, MMU_ELEMENTSIZE_MAX, RET_PARAM_OUT_OF_RANGE, CHECK_INPUT_RANGE_MIN0(element_size, MMU_ELEMENTSIZE_MAX,
RET_PARAM_OUT_OF_RANGE,
RES_MMU_BASE + RES_INVALID_INPUT_PARAM); RES_MMU_BASE + RES_INVALID_INPUT_PARAM);
mmuRamReg = (physical_addr & MMU_ADDR_MASK); mmuRamReg = (physical_addr & MMU_ADDR_MASK);
mmuRamReg = (mmuRamReg) | ((endianism << 9) | (element_size << 7) | (mixedSize << 6)); mmuRamReg = (mmuRamReg) | ((endianism << 9) | (element_size << 7)
| (mixedSize << 6));
/* write values to register */ /* write values to register */
MMUMMU_RAMWriteRegister32(base_address, mmuRamReg); MMUMMU_RAMWriteRegister32(base_address, mmuRamReg);
...@@ -737,11 +721,9 @@ long hw_mmu_tlb_dump(const u32 base_address, bool shw_inv_entries) ...@@ -737,11 +721,9 @@ long hw_mmu_tlb_dump(const u32 base_address, bool shw_inv_entries)
if ((cam & 0x4) != 0) { if ((cam & 0x4) != 0) {
printk(KERN_ALERT "TLB Entry [0x%x]: VA = 0x%x PA = 0x%x\ printk(KERN_ALERT "TLB Entry [0x%x]: VA = 0x%x PA = 0x%x"
Protected = 0x%x\n)", "Protected = 0x%x\n)",
i, i, (cam & MMU_ADDR_MASK), (ram & MMU_ADDR_MASK),
(cam & MMU_ADDR_MASK),
(ram & MMU_ADDR_MASK),
(cam & 0x8) ? 1 : 0); (cam & 0x8) ? 1 : 0);
} else if (shw_inv_entries != false) { } else if (shw_inv_entries != false) {
...@@ -781,13 +763,3 @@ u32 hw_mmu_pte_phyaddr(u32 pte_val, u32 pte_size) ...@@ -781,13 +763,3 @@ u32 hw_mmu_pte_phyaddr(u32 pte_val, u32 pte_size)
return ret_val; return ret_val;
} }
EXPORT_SYMBOL(hw_mmu_pte_phyaddr); EXPORT_SYMBOL(hw_mmu_pte_phyaddr);
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "../procmgr.h" #include "../procmgr.h"
#include "../procmgr_drvdefs.h" #include "../procmgr_drvdefs.h"
#include "proc4430.h" #include "proc4430.h"
#include "dmm4430.h"
#include <syslink/multiproc.h> #include <syslink/multiproc.h>
#include <syslink/ducatienabler.h> #include <syslink/ducatienabler.h>
...@@ -229,6 +229,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params) ...@@ -229,6 +229,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
handle->proc_fxn_table.translateAddr = handle->proc_fxn_table.translateAddr =
&proc4430_translate_addr; &proc4430_translate_addr;
handle->proc_fxn_table.map = &proc4430_map; handle->proc_fxn_table.map = &proc4430_map;
handle->proc_fxn_table.unmap = &proc4430_unmap;
handle->state = PROC_MGR_STATE_UNKNOWN; handle->state = PROC_MGR_STATE_UNKNOWN;
handle->object = vmalloc handle->object = vmalloc
(sizeof(struct proc4430_object)); (sizeof(struct proc4430_object));
...@@ -475,9 +476,48 @@ int proc4430_translate_addr(void *handle, ...@@ -475,9 +476,48 @@ int proc4430_translate_addr(void *handle,
* function also maps the specified address to slave MMU space. * function also maps the specified address to slave MMU space.
*/ */
int proc4430_map(void *handle, u32 proc_addr, int proc4430_map(void *handle, u32 proc_addr,
u32 size, u32 *mapped_addr, u32 *mapped_size) u32 size, u32 *mapped_addr, u32 *mapped_size, u32 map_attribs)
{ {
int retval = 0; int retval = 0;
/* TODO */ u32 da_align;
u32 da;
u32 va_align;
u32 size_align;
dmm_reserve_memory(size, &da);
/* Calculate the page-aligned PA, VA and size */
da_align = PG_ALIGN_LOW((u32)da, PAGE_SIZE);
va_align = PG_ALIGN_LOW(proc_addr, PAGE_SIZE);
size_align = PG_ALIGN_HIGH(size + (u32)proc_addr - va_align, PAGE_SIZE);
retval = ducati_mem_map(va_align, da_align, size_align, map_attribs);
/* Mapped address = MSB of DA | LSB of VA */
*mapped_addr = (da_align | (proc_addr & (PAGE_SIZE - 1)));
return retval; return retval;
} }
/*=================================================
* Function to unmap slave address to host address space
*
* UnMap the provided slave address to master address space. This
* function also unmaps the specified address to slave MMU space.
*/
int proc4430_unmap(void *handle, u32 mapped_addr)
{
int da_align;
int ret_val = 0;
int size_align;
da_align = PG_ALIGN_LOW((u32)mapped_addr, PAGE_SIZE);
ret_val = dmm_unreserve_memory(da_align, &size_align);
if (WARN_ON(ret_val < 0))
goto error_exit;
ret_val = ducati_mem_unmap(da_align, size_align);
if (WARN_ON(ret_val < 0))
goto error_exit;
return 0;
error_exit:
printk(KERN_WARNING "proc4430_unmap failed !!!!\n");
return ret_val;
}
...@@ -101,7 +101,10 @@ int proc4430_translate_addr(void *handle, void **dst_addr, ...@@ -101,7 +101,10 @@ int proc4430_translate_addr(void *handle, void **dst_addr,
/* Function to map slave address to host address space */ /* Function to map slave address to host address space */
int proc4430_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr, int proc4430_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
u32 *mapped_size); u32 *mapped_size, u32 map_attribs);
/* Function to unmap the slave address to host address space */
int proc4430_unmap(void *handle, u32 mapped_addr);
/* ================================================= /* =================================================
* APIs * APIs
......
...@@ -118,7 +118,13 @@ typedef int (*processor_translate_addr_fxn) (void *handle, void **dst_addr, ...@@ -118,7 +118,13 @@ typedef int (*processor_translate_addr_fxn) (void *handle, void **dst_addr,
* address space * address space
*/ */
typedef int (*processor_map_fxn) (void *handle, u32 proc_addr, u32 size, typedef int (*processor_map_fxn) (void *handle, u32 proc_addr, u32 size,
u32 *mapped_addr, u32 *mapped_size); u32 *mapped_addr, u32 *mapped_size, u32 map_attribs);
/*
*Function pointer type for the function to map address to slave
* address space
*/
typedef int (*processor_unmap_fxn) (void *handle, u32 mapped_addr);
/* ============================= /* =============================
* Function table interface * Function table interface
...@@ -146,6 +152,8 @@ struct processor_fxn_table { ...@@ -146,6 +152,8 @@ struct processor_fxn_table {
/* Function to translate between address ranges */ /* Function to translate between address ranges */
processor_map_fxn map; processor_map_fxn map;
/* Function to map slave addresses to master address space */ /* Function to map slave addresses to master address space */
processor_unmap_fxn unmap;
/* Function to unmap slave addresses to master address space */
}; };
/* ============================= /* =============================
...@@ -163,7 +171,7 @@ struct processor_object { ...@@ -163,7 +171,7 @@ struct processor_object {
/* State of the slave processor */ /* State of the slave processor */
enum proc_mgr_boot_mode boot_mode; enum proc_mgr_boot_mode boot_mode;
/* Boot mode for the slave processor. */ /* Boot mode for the slave processor. */
void * object; void *object;
/* Pointer to Processor-specific object. */ /* Pointer to Processor-specific object. */
u16 proc_id; u16 proc_id;
/* Processor ID addressed by this Processor instance. */ /* Processor ID addressed by this Processor instance. */
......
...@@ -315,7 +315,7 @@ inline int processor_translate_addr(void *handle, void **dst_addr, ...@@ -315,7 +315,7 @@ inline int processor_translate_addr(void *handle, void **dst_addr,
* and returns the mapped address and size. * and returns the mapped address and size.
*/ */
inline int processor_map(void *handle, u32 proc_addr, u32 size, inline int processor_map(void *handle, u32 proc_addr, u32 size,
u32 *mapped_addr, u32 *mapped_size) u32 *mapped_addr, u32 *mapped_size, u32 map_attribs)
{ {
int retval = 0; int retval = 0;
struct processor_object *proc_handle = struct processor_object *proc_handle =
...@@ -329,10 +329,24 @@ inline int processor_map(void *handle, u32 proc_addr, u32 size, ...@@ -329,10 +329,24 @@ inline int processor_map(void *handle, u32 proc_addr, u32 size,
BUG_ON(proc_handle->proc_fxn_table.map == NULL); BUG_ON(proc_handle->proc_fxn_table.map == NULL);
retval = proc_handle->proc_fxn_table.map(handle, proc_addr, retval = proc_handle->proc_fxn_table.map(handle, proc_addr,
size, mapped_addr, mapped_size); size, mapped_addr, mapped_size, map_attribs);
return retval; return retval;
} }
/*
* Function to unmap address to slave address space.
*
* This function unmap the provided slave address
*/
inline int processor_unmap(void *handle, u32 mapped_addr)
{
int retval = 0;
struct processor_object *proc_handle =
(struct processor_object *)handle;
retval = proc_handle->proc_fxn_table.unmap(handle, mapped_addr);
return retval;
}
/* /*
* Function that registers for notification when the slave * Function that registers for notification when the slave
......
...@@ -64,7 +64,9 @@ int processor_translate_addr(void *handle, void **dst_addr, ...@@ -64,7 +64,9 @@ int processor_translate_addr(void *handle, void **dst_addr,
/* Function to map address to slave address space */ /* Function to map address to slave address space */
int processor_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr, int processor_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
u32 *mapped_size); u32 *mapped_size, u32 map_attribs);
/* Function to unmap address to slave address space */
int processor_unmap(void *handle, u32 mapped_addr);
/* Function that registers for notification when the slave processor /* Function that registers for notification when the slave processor
* transitions to any of the states specified. * transitions to any of the states specified.
......
...@@ -650,7 +650,7 @@ EXPORT_SYMBOL(proc_mgr_translate_addr); ...@@ -650,7 +650,7 @@ EXPORT_SYMBOL(proc_mgr_translate_addr);
* *
*/ */
int proc_mgr_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr, int proc_mgr_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
u32 *mapped_size, enum proc_mgr_map_type type) u32 *mapped_size, u32 map_attribs)
{ {
int retval = 0; int retval = 0;
struct proc_mgr_object *proc_mgr_handle = struct proc_mgr_object *proc_mgr_handle =
...@@ -664,13 +664,35 @@ int proc_mgr_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr, ...@@ -664,13 +664,35 @@ int proc_mgr_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
/* Map to host address space. */ /* Map to host address space. */
retval = processor_map(proc_mgr_handle->proc_handle, proc_addr, retval = processor_map(proc_mgr_handle->proc_handle, proc_addr,
size, mapped_addr, mapped_size); size, mapped_addr, mapped_size, map_attribs);
WARN_ON(retval < 0); WARN_ON(retval < 0);
mutex_unlock(proc_mgr_obj_state.gate_handle); mutex_unlock(proc_mgr_obj_state.gate_handle);
return retval;; return retval;;
} }
EXPORT_SYMBOL(proc_mgr_map); EXPORT_SYMBOL(proc_mgr_map);
/*============================================
* Function to unmap address to slave address space.
*
* This function unmaps the provided slave address to a host address
*
*/
int proc_mgr_unmap(void *handle, u32 mapped_addr)
{
int retval = 0;
struct proc_mgr_object *proc_mgr_handle =
(struct proc_mgr_object *)handle;
WARN_ON(mutex_lock_interruptible(proc_mgr_obj_state.gate_handle));
/* Map to host address space. */
retval = processor_unmap(proc_mgr_handle->proc_handle, mapped_addr);
WARN_ON(retval < 0);
mutex_unlock(proc_mgr_obj_state.gate_handle);
return retval;;
}
EXPORT_SYMBOL(proc_mgr_unmap);
/*================================= /*=================================
* Function that registers for notification when the slave * Function that registers for notification when the slave
* processor transitions to any of the states specified. * processor transitions to any of the states specified.
......
...@@ -165,10 +165,10 @@ typedef int (*proc_mgr_callback_fxn)(u16 proc_id, void *handle, ...@@ -165,10 +165,10 @@ typedef int (*proc_mgr_callback_fxn)(u16 proc_id, void *handle,
enum proc_mgr_state from_state, enum proc_mgr_state to_state); enum proc_mgr_state from_state, enum proc_mgr_state to_state);
/* Function to get the default configuration for the ProcMgr module. */ /* Function to get the default configuration for the ProcMgr module. */
void proc_mgr_get_config(struct proc_mgr_config*cfg); void proc_mgr_get_config(struct proc_mgr_config *cfg);
/* Function to setup the ProcMgr module. */ /* Function to setup the ProcMgr module. */
int proc_mgr_setup(struct proc_mgr_config*cfg); int proc_mgr_setup(struct proc_mgr_config *cfg);
/* Function to destroy the ProcMgr module. */ /* Function to destroy the ProcMgr module. */
int proc_mgr_destroy(void); int proc_mgr_destroy(void);
...@@ -240,7 +240,10 @@ int proc_mgr_translate_addr(void *handle, void **dst_addr, ...@@ -240,7 +240,10 @@ int proc_mgr_translate_addr(void *handle, void **dst_addr,
/* Function that maps the specified slave address to master address space. */ /* Function that maps the specified slave address to master address space. */
int proc_mgr_map(void *handle, u32 proc_addr, u32 size, int proc_mgr_map(void *handle, u32 proc_addr, u32 size,
u32 *mappedAddr, u32 *mapped_size, enum proc_mgr_map_type type); u32 *mappedAddr, u32 *mapped_size, u32 map_attribs);
/* Function that unmaps the specified slave address to master address space. */
int proc_mgr_unmap(void *handle, u32 mapped_addr);
/* Function that registers for notification when the slave processor /* Function that registers for notification when the slave processor
* transitions to any of the states specified. * transitions to any of the states specified.
......
...@@ -74,10 +74,10 @@ static void __exit proc_mgr_drv_finalize_module(void); ...@@ -74,10 +74,10 @@ static void __exit proc_mgr_drv_finalize_module(void);
/* /*
* name DriverOps * name DriverOps
* *
* desc Function to invoke the APIs through ioctl. * desc Function to invoke the APIs through ioctl
* *
*/ */
static struct file_operations procmgr_fops = { static const struct file_operations procmgr_fops = {
.open = proc_mgr_drv_open, .open = proc_mgr_drv_open,
.ioctl = proc_mgr_drv_ioctl, .ioctl = proc_mgr_drv_ioctl,
.release = proc_mgr_drv_release, .release = proc_mgr_drv_release,
...@@ -498,7 +498,7 @@ static int proc_mgr_drv_ioctl(struct inode *inode, struct file *filp, ...@@ -498,7 +498,7 @@ static int proc_mgr_drv_ioctl(struct inode *inode, struct file *filp,
src_args.proc_addr, src_args.size, src_args.proc_addr, src_args.size,
&(src_args.mapped_addr), &(src_args.mapped_addr),
&(src_args.mapped_size), &(src_args.mapped_size),
src_args.type); src_args.map_attribs);
if (WARN_ON(retval < 0)) if (WARN_ON(retval < 0))
goto func_exit; goto func_exit;
retval = copy_to_user((void *)(args), retval = copy_to_user((void *)(args),
...@@ -508,6 +508,21 @@ static int proc_mgr_drv_ioctl(struct inode *inode, struct file *filp, ...@@ -508,6 +508,21 @@ static int proc_mgr_drv_ioctl(struct inode *inode, struct file *filp,
} }
break; break;
case CMD_PROCMGR_UNMAP:
{
struct proc_mgr_cmd_args_unmap src_args;
/* Copy the full args from user-side. */
retval = copy_from_user((void *)&src_args,
(const void *)(args),
sizeof(struct proc_mgr_cmd_args_unmap));
if (WARN_ON(retval < 0))
goto func_exit;
retval = proc_mgr_unmap(src_args.handle,
(src_args.mapped_addr));
WARN_ON(retval < 0);
}
case CMD_PROCMGR_REGISTERNOTIFY: case CMD_PROCMGR_REGISTERNOTIFY:
{ {
struct proc_mgr_cmd_args_register_notify src_args; struct proc_mgr_cmd_args_register_notify src_args;
...@@ -555,8 +570,7 @@ func_exit: ...@@ -555,8 +570,7 @@ func_exit:
/* Set the retval and copy the common args to user-side. */ /* Set the retval and copy the common args to user-side. */
command_args.api_status = retval; command_args.api_status = retval;
retval = copy_to_user((void *)cmd_args, retval = copy_to_user((void *)cmd_args,
(const void *) &command_args, (const void *)&command_args, sizeof(struct proc_mgr_cmd_args));
sizeof(struct proc_mgr_cmd_args));
WARN_ON(retval < 0); WARN_ON(retval < 0);
return retval; return retval;
......
...@@ -171,6 +171,12 @@ struct proc_mgr_cmd_args { ...@@ -171,6 +171,12 @@ struct proc_mgr_cmd_args {
*/ */
#define CMD_PROCMGR_GETPROCINFO (PROCMGR_BASE_CMD + 26) #define CMD_PROCMGR_GETPROCINFO (PROCMGR_BASE_CMD + 26)
/*
* Command for ProcMgr_unmap
*/
#define CMD_PROCMGR_UNMAP (PROCMGR_BASE_CMD + 27)
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Command arguments for ProcMgr * Command arguments for ProcMgr
...@@ -460,10 +466,22 @@ struct proc_mgr_cmd_args_map { ...@@ -460,10 +466,22 @@ struct proc_mgr_cmd_args_map {
/*Return parameter: Mapped address in host address space */ /*Return parameter: Mapped address in host address space */
u32 mapped_size; u32 mapped_size;
/*Return parameter: Mapped size */ /*Return parameter: Mapped size */
enum proc_mgr_map_type type; u32 map_attribs;
/*Type of mapping. */ /*Type of mapping. */
}; };
/*
* Command arguments for ProcMgr_map
*/
struct proc_mgr_cmd_args_unmap {
struct proc_mgr_cmd_args commond_args;
/*Common command args */
void *handle;
/*Handle to the ProcMgr object */
u32 mapped_addr;
/* Mapped address in host address space */
};
/* /*
* Command arguments for ProcMgr_registerNotify * Command arguments for ProcMgr_registerNotify
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment