simple_buffer_example: code cleanup
authorSam Nelson <sam.nelson@ti.com>
Fri, 24 Feb 2017 21:27:22 +0000 (16:27 -0500)
committerSam Nelson <sam.nelson@ti.com>
Fri, 24 Feb 2017 21:27:22 +0000 (16:27 -0500)
- Added new bigdataxlat functions and common files

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
host_bios/simple_buffer_example/dsp/Server.c
host_bios/simple_buffer_example/dsp/makefile
host_bios/simple_buffer_example/host/App.c
host_bios/simple_buffer_example/host/makefile
host_bios/simple_buffer_example/shared/AppCommon.h
host_bios/simple_buffer_example/shared/bigdataxlat/bios/bigdataxlat.c [new file with mode: 0644]
host_bios/simple_buffer_example/shared/bigdataxlat/bios/bigdataxlat.h [new file with mode: 0644]

index 2bb3cfbd7eb481472d998f4f75f2f285de26ae58..9705ad4f35ede6af30bca68e9da6f1d4945b037d 100644 (file)
@@ -133,9 +133,11 @@ Int Server_exec()
     IHeap_Handle srHeap;
     Memory_Stats stats;
     HeapMemMP_ExtendedStats extStats;
-    Uint32 *bigDataPtr;
+    Uint32 *bigDataLocalPtr;
     Int j;
     UInt32 errorCount=0;
+    Int retVal;
+    bigDataLocalDesc_t bigDataLocalDesc;
 
     Log_print0(Diags_ENTRY | Diags_INFO, "--> Server_exec:");
 
@@ -172,47 +174,46 @@ Int Server_exec()
             Log_print1(Diags_ENTRY | Diags_INFO, "msg->cmd=App_CMD_BIGDATA,msg->ptr=0x%x",
                 (IArg)msg->u.bigDataBuffer.sharedPtr);
 #endif
-            if (msg->u.bigDataBuffer.sharedPtr) {
-                /* Translate Address to local address */
-                bigDataPtr =  SharedRegion_getPtr(msg->u.bigDataBuffer.sharedPtr);
-                
-                /* If enabled Invalidate Cache */
-                if (SharedRegion_isCacheEnabled(msg->regionId)) {
-                    Cache_inv(bigDataPtr,
-                        msg->u.bigDataBuffer.size, Cache_Type_ALL, TRUE);
-                }
+
+            /* Translate to local descriptor */
+            retVal = bigDataXlatetoLocalAndSync(msg->regionId,
+                &msg->u.bigDataSharedDesc, &bigDataLocalDesc);
+            if (retVal) {
+                status = -1;
+                goto leave;
+            }
+            bigDataLocalPtr = (Uint32 *)bigDataLocalDesc.localPtr;
 #ifdef DEBUG
-                /* print message from buffer */
-                Log_print1(Diags_INFO, " Received message %d", msg->id);
-                Log_print0(Diags_INFO, " First 8 bytes: ");
-                for ( j = 0; j < 8 && j < msg->u.bigDataBuffer.size/sizeof(uint32_t); j+=4)
-                    Log_print4(Diags_INFO, "0x%x, 0x%x, 0x%x, 0x%x",
-                        bigDataPtr[j], bigDataPtr[j+1], bigDataPtr[j+2], bigDataPtr[j+3]);
-                Log_print0(Diags_INFO, " Last 8 bytes: ");
-                for ( j = (msg->u.bigDataBuffer.size/sizeof(uint32_t))-8 ;
-                     j < msg->u.bigDataBuffer.size/sizeof(uint32_t); j+=4)
-                    Log_print4(Diags_INFO, "0x%x, 0x%x, 0x%x, 0x%x",
-                        bigDataPtr[j], bigDataPtr[j+1], bigDataPtr[j+2], bigDataPtr[j+3]);
+            /* print message from buffer */
+            Log_print1(Diags_INFO, " Received message %d", msg->id);
+            Log_print0(Diags_INFO, " First 8 bytes: ");
+            for ( j = 0; j < 8 && j < bigDataLocalDesc.size/sizeof(uint32_t); j+=4)
+                Log_print4(Diags_INFO, "0x%x, 0x%x, 0x%x, 0x%x",
+                    bigDataLocalPtr[j], bigDataLocalPtr[j+1], bigDataLocalPtr[j+2], bigDataLocalPtr[j+3]);
+            Log_print0(Diags_INFO, " Last 8 bytes: ");
+            for ( j = (bigDataLocalDesc.size/sizeof(uint32_t))-8 ;
+                 j < bigDataLocalDesc.size/sizeof(uint32_t); j+=4)
+                Log_print4(Diags_INFO, "0x%x, 0x%x, 0x%x, 0x%x",
+                    bigDataLocalPtr[j], bigDataLocalPtr[j+1], bigDataLocalPtr[j+2], bigDataLocalPtr[j+3]);
 #endif
-                /* Check values to see expected results */
-                for( j=0; j < msg->u.bigDataBuffer.size/sizeof(uint32_t); j++) {
-                    if ( bigDataPtr[j] != (msg->id+j) ) {
-                        errorCount++;
-                    }
+            /* Check values to see expected results */
+            for( j=0; j < bigDataLocalDesc.size/sizeof(uint32_t); j++) {
+                if ( bigDataLocalPtr[j] != (msg->id+j) ) {
+                    errorCount++;
                 }
+            }
 
-                /* Fill new data */
-                for ( j=0; j < msg->u.bigDataBuffer.size/sizeof(uint32_t); j++)
-                    bigDataPtr[j] = msg->id + 10 +j;
-
-                /* Writeback if cache enabled */
-                if (SharedRegion_isCacheEnabled(msg->regionId)) {
-                    Cache_wb(bigDataPtr,
-                        msg->u.bigDataBuffer.size, Cache_Type_ALL, TRUE);
-                }
-                msg->u.bigDataBuffer.sharedPtr = SharedRegion_getSRPtr(bigDataPtr, msg->regionId);
-             }
+            /* Fill new data */
+            for ( j=0; j < bigDataLocalDesc.size/sizeof(uint32_t); j++)
+                bigDataLocalPtr[j] = msg->id + 10 +j;
 
+            /* Translate to Shared Descriptor and Sync */
+            retVal = bigDataXlatetoGlobalAndSync(msg->regionId,
+                &bigDataLocalDesc, &msg->u.bigDataSharedDesc);
+            if (retVal) {
+                status = -1;
+                goto leave;
+            }    
         break;
 
         case App_CMD_SHUTDOWN:
index f457f41654db28583698a73d697cb29ab6ae978d..97d0fba48c6d2c84e3d9d7fc5079b3da5bd54299 100644 (file)
@@ -41,11 +41,16 @@ srcs = MainDsp.c Server.c
 objs = $(addprefix bin/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oe66,$(srcs)))
 CONFIG = bin/$(PLATFORM)/$(PROFILE)/configuro
 
+HOSTOS = bios
+locallibsrcs = shared/bigdataxlat/$(HOSTOS)/bigdataxlat.c
+locallibobjs = $(addprefix bin/shared/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oe66,$(locallibsrcs)))
+
 PKGPATH := $(BIOS_INSTALL_DIR)/packages
 PKGPATH := $(PKGPATH)+$(IPC_INSTALL_DIR)/packages
 PKGPATH := $(PKGPATH)+$(XDC_INSTALL_DIR)/packages
 
 -include $(addprefix bin/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oe66.dep,$(srcs)))
+-include $(addprefix bin/shared/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oe66.dep,$(locallibsrcs)))
 
 .PRECIOUS: %/compiler.opt %/linker.cmd
 
@@ -61,7 +66,7 @@ release:
 server_dsp.x: bin/$(PLATFORM)/$(PROFILE)/server_dsp.xe66
        echo executing server_dsp.x
 
-bin/$(PLATFORM)/$(PROFILE)/server_dsp.xe66: $(objs) $(libs) $(CONFIG)/linker.cmd
+bin/$(PLATFORM)/$(PROFILE)/server_dsp.xe66: $(objs) $(locallibobjs) $(libs) $(CONFIG)/linker.cmd
        @$(ECHO) "#"
        @$(ECHO) "# Making $@ ..."
        $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
@@ -71,6 +76,11 @@ bin/$(PLATFORM)/$(PROFILE)/obj/%.oe66: %.c $(CONFIG)/compiler.opt
        @$(ECHO) "# Making $@ ..."
        $(CC) $(CPPFLAGS) $(CFLAGS) --output_file=$@ -fc $<
 
+bin/shared/$(PLATFORM)/$(PROFILE)/obj/%.oe66: ../%.c $(CONFIG)/compiler.opt
+       @$(ECHO) "#"
+       @$(ECHO) "# Making $@ ..."
+       $(CC) $(CPPFLAGS) $(CFLAGS) --output_file=$@ -fc $<
+
 %/compiler.opt: %/linker.cmd ;
 %/linker.cmd: Dsp.cfg ../shared/$(PLATFORM)/config.bld
        @$(ECHO) "#"
@@ -118,6 +128,7 @@ LD = $(CGTOOLS)/bin/cl6x -z
 
 CPPFLAGS =
 CFLAGS = -qq -pdsw225 -ppd=$@.dep -ppa $(CCPROFILE_$(PROFILE)) -@$(CONFIG)/compiler.opt -I.
+CFLAGS += -I../shared/bigdataxlat/bios
 
 LDFLAGS = -w -q -c -m $(@D)/obj/$(@F).map
 LDLIBS = -l $(CGTOOLS)/lib/rts6600_elf.lib
@@ -147,6 +158,7 @@ ifneq (clean,$(MAKECMDGOALS))
 ifneq (,$(PROFILE))
 ifeq (,$(wildcard bin/$(PLATFORM)/$(PROFILE)/obj))
     $(shell $(MKDIR) -p bin/$(PLATFORM)/$(PROFILE)/obj)
+    $(shell $(MKDIR) -p bin/shared/$(PLATFORM)/$(PROFILE)/obj/shared/bigdataxlat/bios)
 endif
 endif
 endif
index e3233b50243e8321abdfec23f1ccb4563ba68b1b..cf96c938e97be50fa4a704e0e07c2afb49e0c3e1 100644 (file)
@@ -61,7 +61,7 @@
 #define ROUNDUP(size, align) \
     (UInt32)(((UInt32)(size) + ((UInt32)(align) - 1)) & ~((UInt32)(align) - 1))
 
-#define NUM_MSGS 4
+#define MAX_NUM_MSGS 4
 
 /* module structure */
 typedef struct {
@@ -104,7 +104,7 @@ Int App_create(UInt16 remoteProcId)
     Module.msgSize = ROUNDUP(sizeof(App_Msg), align);
 
     /* compute message pool size */
-    Module.poolSize = Module.msgSize * NUM_MSGS;
+    Module.poolSize = Module.msgSize * MAX_NUM_MSGS;
 
     /* acquire message pool memory */
     srHeap = (IHeap_Handle)SharedRegion_getHeap(0);
@@ -113,7 +113,7 @@ Int App_create(UInt16 remoteProcId)
     /* create a heap in shared memory for message pool */
     HeapBuf_Params_init(&heapParams);
     heapParams.blockSize = Module.msgSize;
-    heapParams.numBlocks = NUM_MSGS;
+    heapParams.numBlocks = MAX_NUM_MSGS;
     heapParams.bufSize = Module.poolSize;
     heapParams.align = align;
     heapParams.buf = Module.store;
@@ -208,8 +208,7 @@ Int App_exec(Void)
 {
     Int         status;
     App_Msg *   msg;
-    Uint32 *bigDataPtr;
-    SharedRegion_SRPtr bigDataSharedPtr;
+    Uint32 *bigDataLocalPtr;
     Int16 i,j;
     UInt16  regionId1;
     Memory_Stats stats;
@@ -220,6 +219,8 @@ Int App_exec(Void)
     Uint16 regionId;
     HeapMemMP_Handle srHeap;
     UInt32 errorCount=0;
+    Int retVal;
+    bigDataLocalDesc_t bigDataLocalDesc;
 
     Log_print0(Diags_INFO, "App_exec: -->");
 
@@ -301,7 +302,7 @@ Int App_exec(Void)
 
         /* Now this section of code starts receiving messages
            See the next section for the code for sending further messages */
-        /* Receive messages: Start======================================= */
+        /* Receive messages: Start <======================================= */
 
         /* wait for return message */
         status = MessageQ_get(Module.hostQue, (MessageQ_Msg *)&msg,
@@ -313,38 +314,37 @@ Int App_exec(Void)
 
         /* extract message payload */
 
-        if ((msg->cmd == App_CMD_BIGDATA) && (msg->u.bigDataBuffer.sharedPtr) ) {
+        if (msg->cmd == App_CMD_BIGDATA) {
 
-            /* Translate to local address */
-            bigDataPtr = (Uint32 *)SharedRegion_getPtr(msg->u.bigDataBuffer.sharedPtr);
-
-            /* If shared region is configured for cache enabled do cache operation */
-            if (SharedRegion_isCacheEnabled(msg->regionId)) {
-                Cache_inv(bigDataPtr,
-                    msg->u.bigDataBuffer.size, Cache_Type_ALL, TRUE);
+            retVal = bigDataXlatetoLocalAndSync(msg->regionId,
+                &msg->u.bigDataSharedDesc, &bigDataLocalDesc);
+            if (retVal) {
+                status = -1;
+                goto leave;
             }
+            bigDataLocalPtr = (Uint32 *)bigDataLocalDesc.localPtr;
 #ifdef DEBUG
             /* print data from big data buffer */
             Log_print1(Diags_INFO, " Received back buffer %d", msg->id);
             Log_print0(Diags_INFO, " First 8 bytes: ");
-            for ( j = 0; j < 8 && j < msg->u.bigDataBuffer.size/sizeof(uint32_t); j+=4)
+            for ( j = 0; j < 8 && j < bigDataLocalDesc.size/sizeof(uint32_t); j+=4)
                 Log_print4(Diags_INFO, "0x%x, 0x%x, 0x%x, 0x%x",
-                    bigDataPtr[j], bigDataPtr[j+1], bigDataPtr[j+2], bigDataPtr[j+3]);
+                    bigDataLocalPtr[j], bigDataLocalPtr[j+1], bigDataLocalPtr[j+2], bigDataLocalPtr[j+3]);
             Log_print0(Diags_INFO, " Last 8 bytes: ");
-            for ( j = (msg->u.bigDataBuffer.size/sizeof(uint32_t))-8 ;
-                 j < msg->u.bigDataBuffer.size/sizeof(uint32_t); j+=4)
+            for ( j = (bigDataLocalDesc.size/sizeof(uint32_t))-8 ;
+                 j < bigDataLocalDesc.size/sizeof(uint32_t); j+=4)
                 Log_print4(Diags_INFO, "0x%x, 0x%x, 0x%x, 0x%x",
-                    bigDataPtr[j], bigDataPtr[j+1], bigDataPtr[j+2], bigDataPtr[j+3]);
+                    bigDataLocalPtr[j], bigDataLocalPtr[j+1], bigDataLocalPtr[j+2], bigDataLocalPtr[j+3]);
 #endif
             /* Check values to see expected results */
-            for( j=0; j < msg->u.bigDataBuffer.size/sizeof(uint32_t); j++) {
-                if ( bigDataPtr[j] != (msg->id+10+j) ) {
+            for( j=0; j < bigDataLocalDesc.size/sizeof(uint32_t); j++) {
+                if ( bigDataLocalPtr[j] != (msg->id+10+j) ) {
                     errorCount++;
                 }
             }
 
             /* Free big data buffer */
-            HeapMemMP_free(srHeap, bigDataPtr, msg->u.bigDataBuffer.size);
+            HeapMemMP_free(srHeap, bigDataLocalPtr, bigDataLocalDesc.size);
         }
 
         /* free the message */
@@ -352,9 +352,9 @@ Int App_exec(Void)
 
         Log_print1(Diags_INFO, "App_exec: message received, sending message %d",
                 (IArg)i);
-        /* Receive messages: End ======================================= */
+        /* Receive messages: End =======================================> */
 
-        /* Send messages: Start  ======================================= */
+        /* Send messages: Start  <======================================= */
 
         /* allocate message */
         msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);
@@ -376,28 +376,28 @@ Int App_exec(Void)
             msg->id = i;
 
             /* Allocate buffer from HeapMemMP */
-            bigDataPtr = (Uint32 *)(HeapMemMP_alloc(srHeap, BIGDATA_SIZE, BIGDATA_ALIGN));
+            bigDataLocalPtr = (Uint32 *)(HeapMemMP_alloc(srHeap, BIGDATA_SIZE, BIGDATA_ALIGN));
 
-            if ( ! bigDataPtr ) {
+            if (!bigDataLocalPtr) {
                 status = -1;
                 goto leave;
             }
 
             /* Fill Big data buffer */
             for(j=0; j< BIGDATA_SIZE/sizeof(uint32_t); j++) {
-               bigDataPtr[j] = j+i;
-            }
-
-            /* Cache write back data buffer */
-            if (SharedRegion_isCacheEnabled(regionId)) {
-                Cache_wb(bigDataPtr, BIGDATA_SIZE, Cache_Type_ALL, TRUE);
+               bigDataLocalPtr[j] = j+i;
             }
 
-            /* Translate Address to Shared address */
-            bigDataSharedPtr = SharedRegion_getSRPtr(bigDataPtr, regionId);
+            /* Populate the Local descriptor */
+            bigDataLocalDesc.localPtr = (Ptr)bigDataLocalPtr;
+            bigDataLocalDesc.size = BIGDATA_SIZE;
 
-            msg->u.bigDataBuffer.sharedPtr = bigDataSharedPtr;
-            msg->u.bigDataBuffer.size = BIGDATA_SIZE;
+            retVal = bigDataXlatetoGlobalAndSync(regionId,
+                &bigDataLocalDesc, &msg->u.bigDataSharedDesc);
+            if (retVal) {
+                status = -1;
+                goto leave;
+            }
             msg->regionId = regionId;
         } else {
             if (i == 16) {
@@ -414,7 +414,7 @@ Int App_exec(Void)
         /* send message */
         MessageQ_put(Module.slaveQue, (MessageQ_Msg)msg);
 
-        /* Send messages: End  ======================================= */
+        /* Send messages: End  =======================================> */
 
     }
 
index 4c1626e584047768507290362bb9206f6bb681c8..bf94b921cbe54305d5e46d8442503e9697e8e5d3 100644 (file)
 EXBASE = ..
 include $(EXBASE)/products.mak
 
-srcs = MainHost.c App.c
+srcs = MainHost.c App.c 
 objs = $(addprefix bin/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg,$(srcs)))
 CONFIG = bin/$(PLATFORM)/$(PROFILE)/configuro
 
+HOSTOS = bios
+locallibsrcs = shared/bigdataxlat/$(HOSTOS)/bigdataxlat.c
+locallibobjs = $(addprefix bin/shared/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg,$(locallibsrcs)))
+
 -include $(addprefix bin/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg.dep,$(srcs)))
+-include $(addprefix bin/shared/$(PLATFORM)/$(PROFILE)/obj/,$(patsubst %.c,%.oa15fg.dep,$(locallibsrcs)))
 
 .PRECIOUS: %/compiler.opt %/linker.cmd
 
@@ -55,10 +60,10 @@ debug:
        $(MAKE) PROFILE=debug app_host.x
 
 app_host.x: bin/$(PLATFORM)/$(PROFILE)/app_host.xa15fg
-bin/$(PLATFORM)/$(PROFILE)/app_host.xa15fg: $(objs) $(libs) $(CONFIG)/linker.cmd
+bin/$(PLATFORM)/$(PROFILE)/app_host.xa15fg: $(objs) $(locallibobjs) $(libs) $(CONFIG)/linker.cmd
        @$(ECHO) "#"
        @$(ECHO) "# Making $@ ..."
-       $(LD) -o $@ $(LDFLAGS) $(objs) $(libs) -Wl,-T,$(CONFIG)/linker.cmd \
+       $(LD) -o $@ $(LDFLAGS) $(objs) $(locallibobjs) $(libs) -Wl,-T,$(CONFIG)/linker.cmd \
                -lgcc -lc -lm -lnosys $(LDLIBS)
 
 bin/$(PLATFORM)/$(PROFILE)/obj/%.oa15fg: %.c $(CONFIG)/compiler.opt
@@ -66,6 +71,11 @@ bin/$(PLATFORM)/$(PROFILE)/obj/%.oa15fg: %.c $(CONFIG)/compiler.opt
        @$(ECHO) "# Making $@ ..."
        $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<
 
+bin/shared/$(PLATFORM)/$(PROFILE)/obj/%.oa15fg: ../%.c $(CONFIG)/compiler.opt
+       @$(ECHO) "#"
+       @$(ECHO) "# Making $@ ..."
+       $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
 %/compiler.opt: %/linker.cmd ;
 %/linker.cmd: Host.cfg ../shared/$(PLATFORM)/config.bld
        @$(ECHO) "#"
@@ -118,6 +128,7 @@ LD = $(gnu.targets.arm.A15F)/bin/arm-none-eabi-gcc
 
 CPPFLAGS = -Dfar= -D__DYNAMIC_REENT__
 CFLAGS = -Wall -Wunused -Wunknown-pragmas -ffunction-sections -fdata-sections $(CCPROFILE_$(PROFILE)) @$(CONFIG)/compiler.opt -I.
+CFLAGS += -I../shared/bigdataxlat/bios
 CFLAGS += -DSERVER=\"$(SERVER)\" -DPLATFORM_$(PLATFORM)
 
 LDFLAGS = $(LDPROFILE_$(PROFILE)) -mfloat-abi=hard -nostartfiles -Wl,-static -Wl,--gc-sections -Wl,-Map=$(@D)/obj/$(@F).map
@@ -149,8 +160,9 @@ endif
 #  ======== create output directories ========
 ifneq (clean,$(MAKECMDGOALS))
 ifneq (,$(PROFILE))
-ifeq (,$(wildcard bin/$(PROFILE)/obj))
+ifeq (,$(wildcard bin/$(PLATFORM)/$(PROFILE)/obj))
     $(shell $(MKDIR) -p bin/$(PLATFORM)/$(PROFILE)/obj)
+    $(shell $(MKDIR) -p bin/shared/$(PLATFORM)/$(PROFILE)/obj/shared/bigdataxlat/bios)
 endif
 endif
 endif
index f25724963eb337d62ff6df2ac9314e8870396ce3..33c22b9cf2a621a8fd79bcf24c70d8067fae3ea0 100644 (file)
@@ -40,6 +40,7 @@
 #if defined (__cplusplus)
 extern "C" {
 #endif
+#include "bigdataxlat.h"
 
 /*
  *  ======== Application Configuration ========
@@ -52,11 +53,6 @@ extern "C" {
 #define App_CMD_BIGDATA                0x00000002
 #define App_CMD_SHUTDOWN               0x02000000
 
-typedef struct {
-    SharedRegion_SRPtr  sharedPtr;
-    UInt32              size;
-} BigDataBuffer;
-
 typedef struct {
     UInt64              base;
     UInt64              size;
@@ -69,7 +65,7 @@ typedef struct {
     UInt16              regionId;
     union {
         SharedRegionInitCfg sharedRegionInitCfg;
-        BigDataBuffer bigDataBuffer;
+        bigDataSharedDesc_t bigDataSharedDesc;
     } u;
 } App_Msg;
 
diff --git a/host_bios/simple_buffer_example/shared/bigdataxlat/bios/bigdataxlat.c b/host_bios/simple_buffer_example/shared/bigdataxlat/bios/bigdataxlat.c
new file mode 100644 (file)
index 0000000..ca378ad
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * 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.
+ */
+#include "bigdataxlat.h"
+#include <ti/sysbios/hal/Cache.h>
+
+Int bigDataXlatetoGlobalAndSync(UInt16  regionId,
+    bigDataLocalDesc_t *localDesc,
+    bigDataSharedDesc_t *SharedDesc) {
+
+    if (localDesc->localPtr == NULL)
+        return -1;
+
+    /* Cache write back data buffer */
+    if (SharedRegion_isCacheEnabled(regionId)) {
+        Cache_wb(localDesc->localPtr, localDesc->size, Cache_Type_ALL, TRUE);
+    }
+
+    /* Translate Address to Shared address */
+    SharedDesc->sharedPtr = SharedRegion_getSRPtr(localDesc->localPtr, regionId);
+    SharedDesc->size = localDesc->size;
+    return(0);
+}
+
+Int bigDataXlatetoLocalAndSync(UInt16  regionId,
+    bigDataSharedDesc_t *SharedDesc,
+    bigDataLocalDesc_t *localDesc) {
+
+    if (SharedDesc->sharedPtr == NULL)
+        return -1;
+
+    /* Translate to local address */
+    localDesc->localPtr = SharedRegion_getPtr(SharedDesc->sharedPtr);
+    localDesc->size = SharedDesc->size;
+
+    /* If shared region is configured for cache enabled do cache operation */
+    if (SharedRegion_isCacheEnabled(regionId)) {
+        Cache_inv(localDesc->localPtr,
+        localDesc->size, Cache_Type_ALL, TRUE);
+    }
+
+    return(0);
+}
+
diff --git a/host_bios/simple_buffer_example/shared/bigdataxlat/bios/bigdataxlat.h b/host_bios/simple_buffer_example/shared/bigdataxlat/bios/bigdataxlat.h
new file mode 100644 (file)
index 0000000..21e1852
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2017, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * 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.
+ */
+#include <xdc/std.h>
+#include <ti/ipc/SharedRegion.h>
+
+typedef struct {
+    Ptr *localPtr;
+    UInt32            size;
+} bigDataLocalDesc_t;
+
+typedef struct {
+    SharedRegion_SRPtr  sharedPtr;
+    UInt32              size;
+} bigDataSharedDesc_t;
+
+Int bigDataXlatetoGlobalAndSync(UInt16  regionId,
+    bigDataLocalDesc_t *localDesc,
+    bigDataSharedDesc_t *SharedDesc);
+
+Int bigDataXlatetoLocalAndSync(UInt16  regionId,
+    bigDataSharedDesc_t *SharedDesc,
+    bigDataLocalDesc_t *localDesc);