SharedRegion: Update to use linker symbols instead of platform map
authorSam Nelson <sam.nelson@ti.com>
Thu, 5 Oct 2017 01:07:58 +0000 (21:07 -0400)
committerSam Nelson <sam.nelson@ti.com>
Thu, 9 Aug 2018 20:01:32 +0000 (16:01 -0400)
The Keystone3 platform in sysbios does not support memory maps. The
memory map needs to be done using the custom linker command file.
And hence changed Shared Region module to optionally accept
linker symbols for base and length of shared region.

platform.dataMemory is no longer supported. Need to use linker.cmd
to place sections

Update types to generic types: Previous code assumed UInt32 for Pointer

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
packages/ti/sdo/ipc/SharedRegion.c
packages/ti/sdo/ipc/SharedRegion.xdc
packages/ti/sdo/ipc/SharedRegion.xs
packages/ti/sdo/ipc/linkcmd.xdt

index 61c6bbc3a9e89c3ac98536a3ffe5c46b4001089e..63dab584e938474d4dd73bf1c07c4f95542b2502 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (c) 2012-2018 Texas Instruments Incorporated - http://www.ti.com
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -107,7 +107,7 @@ Int SharedRegion_clearEntry(UInt16 id)
     /* clear region to their defaults */
     region->entry.isValid       = FALSE;
     region->entry.base          = NULL;
-    region->entry.len           = 0;
+    region->entry.len           = NULL;
     region->entry.ownerProcId   = 0;
     region->entry.cacheEnable   = TRUE;
     region->entry.cacheLineSize = ti_sdo_ipc_SharedRegion_cacheLineSize;
@@ -183,7 +183,7 @@ Int SharedRegion_getEntry(UInt16 id, SharedRegion_Entry *entry)
     region = &(SharedRegion_module->regions[id]);
 
     entry->base          = region->entry.base;
-    entry->len           = region->entry.len;
+    entry->len           = (SizeT)(region->entry.len);
     entry->ownerProcId   = region->entry.ownerProcId;
     entry->isValid       = region->entry.isValid;
     entry->cacheEnable   = region->entry.cacheEnable;
@@ -225,7 +225,7 @@ UInt16 SharedRegion_getId(Ptr addr)
         key = Hwi_disable();
 
         if ((region->entry.isValid) && (addr >= region->entry.base) &&
-            (addr < (Ptr)((UInt32)region->entry.base + region->entry.len))) {
+            (addr < (Ptr)((uintptr_t)region->entry.base + (SizeT)region->entry.len))) {
             regionId = i;
 
             /* leave the gate */
@@ -295,7 +295,7 @@ Ptr SharedRegion_getPtr(SharedRegion_SRPtr srPtr)
     UInt16 regionId;
 
     if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
-        returnPtr = (Ptr)srPtr;
+        returnPtr = (Ptr)(uintptr_t)(srPtr);
     }
     else if (srPtr == ti_sdo_ipc_SharedRegion_INVALIDSRPTR) {
         returnPtr = NULL;
@@ -314,8 +314,8 @@ Ptr SharedRegion_getPtr(SharedRegion_SRPtr srPtr)
         Assert_isTrue(region->entry.isValid == TRUE,
                 ti_sdo_ipc_SharedRegion_A_regionInvalid);
 
-        returnPtr = (Ptr)((srPtr & ti_sdo_ipc_SharedRegion_offsetMask) +
-                          (UInt32)region->entry.base);
+        returnPtr = (Ptr)(uintptr_t)((srPtr & ti_sdo_ipc_SharedRegion_offsetMask) +
+                          (uintptr_t)region->entry.base);
     }
 
     return (returnPtr);
@@ -333,7 +333,7 @@ SharedRegion_SRPtr SharedRegion_getSRPtr(Ptr addr, UInt16 id)
 
     /* if translate == false, set SRPtr to addr */
     if (ti_sdo_ipc_SharedRegion_translate == FALSE) {
-        retPtr = (SharedRegion_SRPtr)addr;
+        retPtr = (SharedRegion_SRPtr)(uintptr_t)addr;
     }
     else if (addr == NULL) {
         retPtr = ti_sdo_ipc_SharedRegion_INVALIDSRPTR;
@@ -356,8 +356,8 @@ SharedRegion_SRPtr SharedRegion_getSRPtr(Ptr addr, UInt16 id)
          *            ==> address 0x3fffffff would be invalid because the
          *                SRPtr for this address is 0xffffffff
          */
-        if (((UInt32)addr >= (UInt32)region->entry.base) &&
-            ((UInt32)addr < ((UInt32)region->entry.base + region->entry.len))) {
+        if (((uintptr_t)addr >= (uintptr_t)region->entry.base) &&
+            ((uintptr_t)addr < ((uintptr_t)region->entry.base + (SizeT)region->entry.len))) {
             retPtr = (SharedRegion_SRPtr)((id << ti_sdo_ipc_SharedRegion_numOffsetBits)
                      | ((UInt32)addr - (UInt32)region->entry.base));
         }
@@ -425,7 +425,7 @@ Int SharedRegion_setEntry(UInt16 id, SharedRegion_Entry *entry)
     region = &(SharedRegion_module->regions[id]);
 
     /* make sure region does not overlap existing ones */
-    status = SharedRegion_checkOverlap(entry->base, entry->len);
+    status = SharedRegion_checkOverlap(entry->base, (SizeT)entry->len);
 
     if (status == SharedRegion_S_SUCCESS) {
         /* region entry should be invalid at this point */
@@ -447,7 +447,7 @@ Int SharedRegion_setEntry(UInt16 id, SharedRegion_Entry *entry)
 
         /* set specified region id to entry values */
         region->entry.base          = entry->base;
-        region->entry.len           = entry->len;
+        region->entry.len           = (Ptr)entry->len;
         region->entry.ownerProcId   = entry->ownerProcId;
         region->entry.cacheEnable   = entry->cacheEnable;
         region->entry.cacheLineSize = entry->cacheLineSize;
@@ -470,7 +470,7 @@ Int SharedRegion_setEntry(UInt16 id, SharedRegion_Entry *entry)
 
                 HeapMemMP_Params_init(&params);
                 params.sharedAddr = sharedAddr;
-                params.sharedBufSize = region->entry.len -
+                params.sharedBufSize = (SizeT)(region->entry.len) -
                                        region->reservedSize;
 
                 /*
@@ -531,7 +531,7 @@ Int SharedRegion_checkOverlap(Ptr base, SizeT len)
         if (region->entry.isValid) {
             if (base >= region->entry.base) {
                 if (base < (Ptr)((UInt32)region->entry.base +
-                    region->entry.len)) {
+                    (SizeT)region->entry.len)) {
                     Hwi_restore(key);
                     Assert_isTrue(FALSE, ti_sdo_ipc_SharedRegion_A_overlap);
                     return (SharedRegion_E_FAIL);
@@ -753,7 +753,7 @@ Ptr ti_sdo_ipc_SharedRegion_reserveMemory(UInt16 id, SizeT size)
     newSize = _Ipc_roundup(size, minAlign);
 
     /* Need to make sure (curSize + newSize) is smaller than region len */
-    Assert_isTrue((region->entry.len >= (curSize + newSize)),
+    Assert_isTrue(((SizeT)(region->entry.len) >= (curSize + newSize)),
                    ti_sdo_ipc_SharedRegion_A_reserveTooMuch);
 
     /* Add the new size to current size */
@@ -813,7 +813,7 @@ Int ti_sdo_ipc_SharedRegion_start(Void)
             /*  Create the HeapMemMP in the region. */
             HeapMemMP_Params_init(&params);
             params.sharedAddr = sharedAddr;
-            params.sharedBufSize = region->entry.len - region->reservedSize;
+            params.sharedBufSize = (SizeT)(region->entry.len) - region->reservedSize;
 
             /* Adjust to account for the size of HeapMemMP_Attrs */
             params.sharedBufSize -= (HeapMemMP_sharedMemReq(&params)
index be0c674e9a6404a4c0c53f4da8041dd9ee3bcc25..126f0abe36fb5888462be6d7f34ce8aac6f55436 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2018, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -264,6 +264,18 @@ module SharedRegion
      *  @field(name)          The name associated with the region.
      */
     struct Entry {
+        Ptr    base;
+        Ptr    len;
+        UInt16 ownerProcId;
+        Bool   isValid;
+        Bool   cacheEnable;
+        SizeT  cacheLineSize;
+        Bool   createHeap;
+        String name;
+    };
+    metaonly struct MetaEntry {
+        String base_symbol;
+        String len_symbol;
         Ptr    base;
         SizeT  len;
         UInt16 ownerProcId;
@@ -441,7 +453,7 @@ module SharedRegion
      *  @param(id)          Region id.
      *  @param(entry)       Entry fields about the region.
      */
-    metaonly Void setEntryMeta(UInt16 id, Entry entry);
+    metaonly Void setEntryMeta(UInt16 id, MetaEntry metaentry);
 
     /*! @_nodoc
      *  ======== start ========
index d05a1ff3af87d1fee815d6db4c38bb127baf4e6a..19677701019b3d0d6fbf94158352b6a3d45f3164 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2018, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -155,7 +155,7 @@ function module$static$init(mod, params)
  *  at the end of module$static$init() because the number of entries
  *  cannot be initialize until after user's configuration is executed.
  */
-function setEntryMeta(id, entry)
+function setEntryMeta(id, metaentry)
 {
     var num = SharedRegion.entryCount;
 
@@ -173,48 +173,56 @@ function setEntryMeta(id, entry)
     SharedRegion.entry[num].createHeap    = true;
     SharedRegion.entry[num].name          = String(null);
 
-    /* check to see region does not overlap */
-    checkOverlap(entry);
+/* Check overlap not doable with symbol in entry, base address not yet availble so deprecated */
+        /* check to see region does not overlap */
+    if (metaentry.base) {
+        checkOverlap(metaentry);
+   }
 
     /* squirrel away entry information to be processed in module$static$init */
     idArray[num]                          = id;
-    SharedRegion.entry[num].base          = $addr(entry.base);
-    SharedRegion.entry[num].len           = entry.len;
+    if (metaentry.base) {
+        SharedRegion.entry[num].base          = $addr(metaentry.base);
+        SharedRegion.entry[num].len           = metaentry.len;
+    } else {
+        SharedRegion.entry[num].base          = $externPtr(metaentry.base_symbol);
+        SharedRegion.entry[num].len           = $externPtr(metaentry.len_symbol);
+    }
 
     /* set 'ownerProcId' if defined otherwise no default owner */
-    if (entry.ownerProcId != undefined) {
-        SharedRegion.entry[num].ownerProcId   = entry.ownerProcId;
+    if (metaentry.ownerProcId != undefined) {
+        SharedRegion.entry[num].ownerProcId   = metaentry.ownerProcId;
     }
 
     /* set 'name' field if defined otherwise name is null */
-    if (entry.name != undefined) {
-        SharedRegion.entry[num].name = entry.name;
+    if (metaentry.name != undefined) {
+        SharedRegion.entry[num].name = metaentry.name;
     }
 
     /* set 'isValid' field if defined otherwise its false */
-    if (entry.isValid != undefined) {
-        SharedRegion.entry[num].isValid = entry.isValid;
+    if (metaentry.isValid != undefined) {
+        SharedRegion.entry[num].isValid = metaentry.isValid;
     }
 
     /* set the 'cacheEnable' field if defined otherwise is true */
-    if (entry.cacheEnable != undefined) {
-        SharedRegion.entry[num].cacheEnable = entry.cacheEnable;
+    if (metaentry.cacheEnable != undefined) {
+        SharedRegion.entry[num].cacheEnable = metaentry.cacheEnable;
     }
 
     /* set the 'createHeap' field if defined otherwise use default */
-    if (entry.createHeap != undefined) {
-        SharedRegion.entry[num].createHeap = entry.createHeap;
+    if (metaentry.createHeap != undefined) {
+        SharedRegion.entry[num].createHeap = metaentry.createHeap;
     }
 
     /* set the 'cacheLineSize' field if defined otherwise its the default */
-    if (entry.cacheLineSize != undefined) {
+    if (metaentry.cacheLineSize != undefined) {
         /* Error if cacheEnable but cacheLineSize set to 0 */
-        if (SharedRegion.entry[num].cacheEnable && (entry.cacheLineSize == 0)) {
+        if (SharedRegion.entry[num].cacheEnable && (metaentry.cacheLineSize == 0)) {
             SharedRegion.$logError("cacheEnable is set to true for " +
                 "region: " + id + " cacheLineSize it set to 0.", SharedRegion);
         }
         else {
-            SharedRegion.entry[num].cacheLineSize = entry.cacheLineSize;
+            SharedRegion.entry[num].cacheLineSize = metaentry.cacheLineSize;
         }
     }
 
@@ -231,12 +239,15 @@ function setEntryMeta(id, entry)
         SharedRegion.entry[num].cacheLineSize = 8;
     }
 
-    if (entry.base % SharedRegion.entry[num].cacheLineSize != 0) {
-        /* Error if base address not aligned to cache boundary */
-        SharedRegion.$logError("Base Address of 0x" +
-            Number(entry.base).toString(16) +
-            " is not aligned to cache boundary (" +
-            SharedRegion.entry[num].cacheLineSize + ")", SharedRegion);
+/* Check base address not doable as it is not yet availble. So deprecated */
+    if (metaentry.base) {
+        if (metaentry.base % SharedRegion.entry[num].cacheLineSize != 0) {
+            /* Error if base address not aligned to cache boundary */
+            SharedRegion.$logError("Base Address of 0x" +
+                Number(entry.base).toString(16) +
+                " is not aligned to cache boundary (" +
+                SharedRegion.entry[num].cacheLineSize + ")", SharedRegion);
+        }
     }
 }
 
index 624ac6fb63f09d3e9a1f43b89c2b1b7f9220bebf..22f8017a1e6dfd27c17e7d05a0dcb026dcc32975 100644 (file)
@@ -1,6 +1,6 @@
 %%{
 /*
- * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * Copyright (c) 2012-2018, Texas Instruments Incorporated
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -52,11 +52,14 @@ SECTIONS
 %            (regions[i].entry.ownerProcId != SharedRegion.DEFAULTOWNERID) &&
 %            (SharedRegion.genSectionInLinkCmd[i])) {
 %            var sectName = "ti.sdo.ipc.SharedRegion_" + i;
-%            var len  = utils.toHex(regions[i].entry.len);
+%            var len  = utils.toHex(Number(regions[i].entry.len));
 %            var base = utils.toHex(Number(regions[i].entry.base));
 %            if (Program.build.target.$name.match(/ARP32/)) {
     `sectName`:  { . += `len`;} run > `base` PAGE 1, type = NOLOAD
 %            }
+%            else if ((Program.build.target.$name.match(/R5F/)) ||
+%                     (Program.build.target.$name.match(/A53F/))) {
+%            }
 %            else {
     `sectName`:  { . += `len`;} run > `base`, type = NOLOAD
 %            }
@@ -68,6 +71,8 @@ SECTIONS
 
 %            if (Program.build.target.$name.match(/ARP32/)) {
     ti_sdo_ipc_init: load > `Program.platform.dataMemory` PAGE 1, type = NOINIT
+%            } else if ((Program.build.target.$name.match(/R5F/)) ||
+%                       (Program.build.target.$name.match(/A53F/))) {
 %            }
 %            else {
     ti_sdo_ipc_init: load > `Program.platform.dataMemory`, type = NOINIT