This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于HeapMemParams.shareAddr的赋值问题。

Other Parts Discussed in Thread: SYSBIOS

HeapMemParams.shareAddr的类型在定义中为Ptr类型。

1.我的理解为该变量可以定义在shareregion中建立Heap的起始地址,这样理解对么??

2.如果是这样理解话,我在XDC中定义的ShareMem的起始地址为0x00C00000。但是打断点显示为0x008002F8。这是为什么呢??

3.我在C语言程序中定义了HeapMemParams.shareAddr=0x00C00000,但是编译报错,显示它是Ptr类型,无法用int值赋值,那该如何赋值呢??

4.shareregionID和HeapMemParams.shareAddr之间的区别,是不是在XDC中定义了shareregion,再定义了regionID,就可以不用定义HeapMemParams.shareAddr?

   尤其是两个Heap共用一个sharemem的情况。

谢谢能够帮我解答。

  • 你说的是在sysbios中使用HeapMem创建heap么?你使用的sysbios是什么版本?

    关于heapMem有下面的结构体定义,我没有看到你说的shareAddr成员定义。

    /* Params */
    struct ti_sysbios_heaps_HeapMem_Params {
    size_t __size;
    const void *__self;
    void *__fxns;
    xdc_runtime_IInstance_Params *instance;
    xdc_SizeT minBlockAlign;
    xdc_Ptr buf;
    xdc_runtime_Memory_Size size;
    xdc_runtime_IInstance_Params __iprms;
    };

  • 你好。我在heapMem的头文件中找到这段的定义:

    typedef struct HeapMemMP_Params {
        String name;
        /*!< Name of this instance.
         *
         *  The name (if not NULL) must be unique among all HeapMemMP
         *  instances in the entire system.  When creating a new
         *  heap, it is necessary to supply an instance name.
         *
         *  The name does not have to be persistent.  The supplied string is copied
         *  into persistent memory.
         */
       
        UInt16 regionId;
        /*!< Shared region ID
         *
         *  The index corresponding to the shared region from which shared memory
         *  will be allocated.
         */
       
        /*! @cond */
        Ptr sharedAddr;
        /*!< Physical address of the shared memory
         *
         *  This value can be left as 'null' unless it is required to place the
         *  heap at a specific location in shared memory.  If sharedAddr is null,
         *  then shared memory for a new instance will be allocated from the
         *  heap belonging to the region identified by
         *  #HeapMemMP_Params::regionId.
         */
        /*! @endcond */
        
        SizeT sharedBufSize;
        /*!< Size of shared buffer
         *
         *  This is the size of the buffer to be used in the HeapMemMP instance. 
         *  The actual buffer size in the created instance might actually be less
         *  than the value supplied in 'sharedBufSize' because of alignment
         *  constraints.
         *
         *  It is important to note that the total amount of shared memory required
         *  for a HeapMemMP instance will be greater than the size supplied here.
         *  Additional space will be consumed by shared instance attributes and
         *  alignment-related padding.
         */
        
        GateMP_Handle gate;
        /*!< GateMP used for critical region management of the shared memory
         *
         *  Using the default value of NULL will result in use of the GateMP
         *  system gate for context protection.
         */
       
    } HeapMemMP_Params;

    其中有Ptr sharedAddr的定义。但是我直接给它赋值0x0C000000,显示int型无法赋值给它。那我该如何处理呢??