From f943a6aff4f6cc0aa0258c87660b4b1d0426b3f3 Mon Sep 17 00:00:00 2001 From: Tinku Mannan Date: Tue, 16 Apr 2013 12:55:42 -0400 Subject: [PATCH] Fixes for the following IRS: SDOCM00100482: HPLIB: hplib_VM_MemMap doesn't seem to be mapping memory properly SDOCM00100481: Function hplib_vmMemAlloc: Critical section lock not being released Added license file, COPYING.txt --- COPYING.txt | 32 ++++++++++++++++++++++++++++++++ ti/runtime/hplib/src/hplib_vm.c | 15 +++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) create mode 100755 COPYING.txt diff --git a/COPYING.txt b/COPYING.txt new file mode 100755 index 0000000..edec646 --- /dev/null +++ b/COPYING.txt @@ -0,0 +1,32 @@ +/* =========================================================================== + * Copyright (c) Texas Instruments Incorporated 2010-2013 + * + * 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. + * +*/ diff --git a/ti/runtime/hplib/src/hplib_vm.c b/ti/runtime/hplib/src/hplib_vm.c index 69224c3..39a98e4 100755 --- a/ti/runtime/hplib/src/hplib_vm.c +++ b/ti/runtime/hplib/src/hplib_vm.c @@ -106,7 +106,7 @@ void *hplib_VM_MemMap retval = sysconf(_SC_PAGE_SIZE); if (retval == -1) { - hplib_Log(">hplib_VM_MemMap: Failed to get page size err=%s\n", + hplib_Log("hplib_VM_MemMap: Failed to get page size err=%s\n", strerror(errno)); return (void *)0; } @@ -115,24 +115,24 @@ void *hplib_VM_MemMap if (size%page_sz) { - hplib_Log(">hplib_VM_MemMap: error: block size not aligned to page size\n"); + hplib_Log("hplib_VM_MemMap: error: block size not aligned to page size\n"); return (void *)0; } if ((uint32_t)addr%page_sz) { - hplib_Log(">hplib_VM_MemMap: error: addr not aligned to page size\n"); + hplib_Log("hplib_VM_MemMap: error: addr not aligned to page size\n"); return (void *)0; } - map_base = mmap(0, size, (PROT_READ|PROT_WRITE), MAP_SHARED, dev_mem_fd, (off_t)addr & ~mask); + map_base = mmap(0, size, (PROT_READ|PROT_WRITE), MAP_SHARED, dev_mem_fd, (off_t)addr); if(map_base == (void *) -1) { - hplib_Log(">hplib_VM_MemMap: Failed to mmap \"dev/mem\" err=%s\n", + hplib_Log("hplib_VM_MemMap: Failed to mmap \"dev/mem\" err=%s\n", strerror(errno)); return (void *)0; } - virt_addr = map_base + ((off_t)addr & mask); + virt_addr = map_base; return(virt_addr); } @@ -255,9 +255,8 @@ void* hplib_vmMemAlloc memset (p_block, 0, size); return p_block; } - return p_block; - Osal_hplibCsExit(key); + return p_block; } -- 2.39.2