.. _developer_notes_remote_core_memory_map_updates:

How To Take Care Of Remote Core Memory Map Updates
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Introduction
==============

The use of DDR memory for remote core firmware image needs to be accounted for on
the A-Core side running QNX.  Whenever there are updates to the memory usage by the
PSDK RTOS, we would need to take care of the below on the PSDK QNX side.


.. ifconfig:: CONFIG_part_variant in ('J721E')

    .. NOTE::
       See the file *${PSDK_RTOS_PATH}/vision_apps/platform/j721e/rtos/system_memory_map.html* for memory map used by
       Vision App Remote Core Images.

.. ifconfig:: CONFIG_part_variant in ('J721S2')

    .. NOTE::
       See the file *${PSDK_RTOS_PATH}/vision_apps/platform/j721s2/rtos/system_memory_map.html* for memory map used by
       Vision App Remote Core Images.

.. ifconfig:: CONFIG_part_variant in ('J784S4')

    .. NOTE::
       See the file *${PSDK_RTOS_PATH}/vision_apps/platform/j784s4/rtos/system_memory_map.html* for memory map used by
       Vision App Remote Core Images.

.. ifconfig:: CONFIG_part_variant in ('J742S2')

    .. NOTE::
       See the file *${PSDK_RTOS_PATH}/vision_apps/platform/j742s2/rtos/system_memory_map.html* for memory map used by
       Vision App Remote Core Images.

.. ifconfig:: CONFIG_part_variant in ('J722S')

    .. NOTE::
       See the file *${PSDK_RTOS_PATH}/vision_apps/platform/j722s/rtos/system_memory_map.html* for memory map used by
       Vision App Remote Core Images.

.. ifconfig:: CONFIG_part_variant in ('TDA54')

    .. NOTE::
       See the file *${PSDK_RTOS_PATH}/vision_apps/platform/tda54/rtos/system_memory_map.html* for memory map used by
       Vision App Remote Core Images.


- Make sure QNX Kernel is aware of the usage so that these regions of memory is reserved for
  remote core use only.

- The QNX IPC resource manager used for communication between processors in a multi-processor environment
  need to be aware of the VRING memory to be used to communicate with the remote cores.

- The Shared Memory Allocator resource manager (shmemallocator) make use of shared memory region
  that need to be in-sync with the remote core usage.



PSDK QNX memory map updates
=============================

Memory Carveout entry to QNX Startup
-------------------------------------

Memory sections with pre-defined physical addresses must be set aside in the QNX BSP IFS build file so
that the memory is not given to other programs and can be used solely by the remote cores

Specify a section to be set aside by modifying the startup line to use the “-r” option. For example, to
reserve 0x30000000 bytes, at physical address 0xA0000000, on QNX BSP, the build file the arguments
would be (highlighted below):

    .. code:: bash

        -r0xA0000000,0x30000000,1

.. ifconfig:: CONFIG_part_variant in ('J721E')

    For J721E QNX BSP **standalone BSP** with U-boot loaded DM and no other remote core image loaded would required 16MB
    of carveout reserved at address 0xA0000000.

    .. code:: bash

        [+keeplinked] startup-j721e-evm -v -r0xA0000000,0x1000000,1

    For J721E QNX BSP with U-boot loaded DM and *Vision Apps* remote core images loaded would required
    carevout as below. The same carveout can be specified when loading the *EthFW* or *IPC ECHO TEST* remote core images
    though their requirements may be lesser.

    .. code:: bash

        [+keeplinked] startup-j721e-evm -v -r0xA0000000,0x60000000,1 -r0x880000000,0x10000000,1

.. ifconfig:: CONFIG_part_variant in ('J7200')

    For J7200 QNX BSP **standalone BSP** with U-boot loaded DM and no other remote core image loaded would required 16MB
    of carveout reserved at address 0xA0000000.

    .. code:: bash

        [+keeplinked] startup-j7200-evm -v -r0xA0000000,0x1000000,1

    For J7200 QNX BSP with U-boot loaded DM and *EthFW* remote core images loaded would required
    carevout as below. The same carveout can be specified when loading the *IPC ECHO TEST* remote core images though
    their requirements may be lesser.

    .. code:: bash

        [+keeplinked] startup-j7200-evm -v -r0xA0000000,0x5C000000,1


.. ifconfig:: CONFIG_part_variant in ('J721S2')

    For J721S2 QNX BSP **standalone BSP** with U-boot loaded DM and no other remote core image loaded would required 16MB
    of carveout reserved at address 0xA0000000.

    .. code:: bash

        [+keeplinked] startup-j721s2-evm -v -r0xA0000000,0x1000000,1

    For J721S2 QNX BSP with U-boot loaded DM and *Vision Apps* remote core images loaded would required
    carevout as below. The same carveout can be specified when loading the *EthFW* or *IPC ECHO TEST* remote core images
    though their requirements may be lesser. Note that below example includes additional carveout required for CnM codec. Please refer
    :ref:`qnx_sdk_components_|dev_platform|` for details.

    .. code:: bash

        [+keeplinked] startup-j721s2-evm -v -r0xA0000000,0x60000000,1 -r0x880000000,0x10000000,1 -r0x940000000,0x60000000,1

.. ifconfig:: CONFIG_part_variant in ('J784S4')

    For J784S4 QNX BSP **standalone BSP** with U-boot loaded DM and no other remote core image loaded would required 16MB
    of carveout reserved at address 0xA0000000.

    .. code:: bash

        [+keeplinked] startup-j784s4-evm -v -r0xA0000000,0x1000000,1

    For J784S4 QNX BSP with U-boot loaded DM and *Vision Apps* remote core images loaded would required
    carevout as below. The same carveout can be specified when loading the *EthFW* or *IPC ECHO TEST* remote core images
    though their requirements may be lesser. Note that below example includes additional carveout required for CnM codec. Please refer
    :ref:`qnx_sdk_components_|dev_platform|` for details.

    .. code:: bash

        [+keeplinked] startup-j784s4-evm -v -r0xA0000000,0x60000000,1 -r0x880000000,0x30000000,1 -r0x940000000,0x60000000,1

.. ifconfig:: CONFIG_part_variant in ('J742S2')

    For J742S2 QNX BSP **standalone BSP** with U-boot loaded DM and no other remote core image loaded would required 16MB
    of carveout reserved at address 0xA0000000.

    .. code:: bash

        [+keeplinked] startup-j742s2-evm -v -r0xA0000000,0x1000000,1

    For J742S2 QNX BSP with U-boot loaded DM and *Vision Apps* remote core images loaded would required
    carevout as below. The same carveout can be specified when loading the *EthFW* or *IPC ECHO TEST* remote core images
    though their requirements may be lesser. Note that below example includes additional carveout required for CnM codec. Please refer
    :ref:`qnx_sdk_components_|dev_platform|` for details.

    .. code:: bash

        [+keeplinked] startup-j742s2-evm -v -r0xA0000000,0x60000000,1 -r0x880000000,0x30000000,1 -r0x940000000,0x60000000,1

.. ifconfig:: CONFIG_part_variant in ('J722S')

    For J722S QNX BSP **standalone BSP** with U-boot loaded DM and no other remote core image loaded would required 16MB
    of carveout reserved at address 0xA0000000.

    .. code:: bash

        [+keeplinked] startup-j722s-evm -v -r0xA0000000,0x1000000,1

    For J722S QNX BSP with U-boot loaded DM and *Vision Apps* remote core images loaded would required
    carevout as below. The same carveout can be specified when loading the *IPC ECHO TEST* remote core images
    though their requirements may be lesser. Note that below example includes additional carveout required for CnM codec. Please refer
    :ref:`qnx_sdk_components_|dev_platform|` for details.

    .. code:: bash

        [+keeplinked] startup-j722s-evm -v -r0xA0000000,0x60000000,1 -r0x880000000,0x30000000,1 -r0x940000000,0x60000000,1

.. ifconfig:: CONFIG_part_variant in ('TDA54')

    For TDA54 QNX BSP **standalone BSP** with U-boot loaded DM and no other remote core image loaded would required 16MB
    of carveout reserved at address 0xA0000000.

    .. code:: bash

        [+keeplinked] startup-tda54-vdk -v -r0xA0000000,0x1000000,1

    For TDA54 QNX BSP with U-boot loaded DM and *Vision Apps* remote core images loaded would required
    carevout as below. The same carveout can be specified when loading the *IPC ECHO TEST* remote core images
    though their requirements may be lesser. Note that below example includes additional carveout required for CnM codec. Please refer
    :ref:`qnx_sdk_components_|dev_platform|` for details.

    .. code:: bash

        [+keeplinked] startup-tda54-vdk -v -r0xA0000000,0x60000000,1 -r0x880000000,0x30000000,1 -r0x940000000,0x60000000,1

IPC VRING memory resource
--------------------------

The QNX IPC resource manager is used for communication between processors in a multi-processor environment.
The QNX IPC resource manager needs to be aware of the VRING memory to be used by remote cores. This is specified by the VRING_BASE_ADDRESS
define in the *tiipc_mgr_private.h* file of QNX IPC resource manager source code.

.. NOTE::
   See the file *${PSDK_QNX_PATH}/qnx/resmgr/ipc_qnx_rsmgr/resmgr/src/tiipc_mgr_private.h* for VRING_BASE_ADDRESS address used.

Shared Memory resource
------------------------

The Shared Memory Allocator resource manager (shmemallocator) make use of a shared memory region
that need to be in-sync with the remote core usage. This is specified by the SH_MEM_BLOCK1_START & SH_MEM_BLOCK1_SIZE,
define in the *SharedMemoryAllocator.c* file of Shared Memory Allocator resource manager source code.

.. NOTE::
   See the file *${PSDK_QNX_PATH}/qnx/sharedmemallocator/resmgr/SharedMemoryAllocator.c* for SH_MEM_BLOCK1_START address used.

