# SPDX-License-Identifier:      GPL-2.0+
#
# Copyright 2016 Freescale Semiconductor
# Copyright 2017,2020-2021 NXP
#

SRAM Layout
============
SRAM is from 0x34000000 to 0x34800000 (8 MB)

===================================================================================================================
|                 |             U-boot            |              U-boot           |             Linux             |
|  Reserved for   |        before relocation      |         after relocation      |   after all 4 cores started   |
|=================|================|==============|================|==============|================|==============|
|                 |Starting address|Ending address|Starting address|Ending address|Starting address|Ending address|
|=================|================|==============|================|==============|================|==============|
|Stack            |   0x34000000   |  0x34004000  |      -         |      -       |       -        |     -        |
|-----------------|----------------|--------------|----------------|--------------|----------------|--------------|
|MMU Tables       |   0x34004000   |  0x3408ffff  |      -         |      -       |       -        |     -        |
|-----------------|----------------|--------------|----------------|--------------|----------------|--------------|
|DTB              |   0x34090000   |  variable**  |   0x34090000   |  variable**  |       -        |      -       |
|-----------------|----------------|--------------|----------------|--------------|----------------|--------------|
|u-boot           |   0x340a0000   |  variable**  |   0x340a0000   |  variable**  |       -        |      -       |
===================================================================================================================

** u-boot size is variable (depends on configuration).

DDR Layout
============

The maximum addressable DDR regions from each type of core are:

=========================================================================
|      Core      | Region | Starting address | Ending address |   Size  |
|----------------|--------|------------------|----------------|---------|
|       M4       |  DDR0  |    0x80000000    |  0xBFFFFFFF    |  1024 MB|
|                |  DDR1  |    0xC0000000    |  0xDFFFFFFF    |  512 MB |
|----------------|--------|------------------|----------------|---------|
|       A53      |  DDR0  |    0x80000000    |  0xBFFFFFFF    |  1024 MB|
|                |  DDR1  |    0xC0000000    |  0xEFFFFFFF    |  1024 MB|
=========================================================================

Entire DDR region splits into two regions:

=========================================================================
|     Board      | Region | Starting address | Ending address |   Size  |
|----------------|--------|------------------|----------------|---------|
| EVB, PCIE,     |  DDR0  |    0x80000000    |  0x8FFFFFFF    |  256 MB |
| FVB_REVB, TMDP |  DDR1  |    0xC0000000    |  0xCFFFFFFF    |  256 MB |
|----------------|--------|------------------|----------------|---------|
|  FVB           |  DDR0  |    0x80000000    |  0xBFFFFFFF    |  1024 MB|
|                |  DDR1  |    0xC0000000    |  0xEFFFFFFF    |  1024 MB|
=========================================================================

DDR0 memory region is marked as non-cacheable.
DDR1 memory region is marked as non-cacheable.

Reserved regions:

=========================================================================================================================
|                 |             U-boot            |                U-boot               |             Linux             |
|  Reserved for   |        before relocation      |           after relocation          |   after all 4 cores started   |
|=================|================|==============|==================|==================|================|==============|
|                 |Starting address|Ending address| Starting address |  Ending address  |Starting address|Ending address|
|=================|================|==============|===============  =|==================|================|==============|
|MMU tables       |       -        |      -       |   0x80000000     |    0x80010000    |   0x80000000   |  0x80010000  |
|-----------------|----------------|--------------|------------------|------------------|----------------|--------------|
|u-boot           |       -        |      -       | DDR0, variable***| DDR0, variable***|       -        |      -       |
|-----------------|----------------|--------------|------------------|------------------|----------------|--------------|
|linux            |       -        |      -       |       -          |      -           |   DDR0 + DDR1, See System.map |
=========================================================================================================================

*** u-boot address and size, after relocation, is variable (depends on configuration).


Flash Layout
============

Flash memory is used for storage (u-boot image, for example).

Environment Variables
=====================

boot_mtd:       Select the booting method: bootm/booti. If CONFIG_USE_BOOTI is not defined
                in the S32 gen1 SOC configuration bootm will be used by default.

image:          It is the name of kernel image. Please note that the image has to be synchronised with
                the used boot method.


MMU Translation Tables
======================

(1) Early MMU Tables:

     Level 0                   Level 1                   Level 2
------------------        ------------------
| 0x00_0000_0000 | -----> | 0x00_0000_0000 | -------|           ...
------------------        ------------------        |   ------------------
| 0x80_0000_0000 | --|    | 0x00_4000_0000 | -----| |-> | 0x00_2000_0000 |
------------------   |    ------------------      | |   ------------------
|    invalid     |   |    | 0x00_8000_0000 | ---| | |   | 0x00_2020_0000 |
------------------   |    ------------------    | | |   ------------------
                     |    | 0x00_c000_0000 | -| | | |   |       ...      |
                     |    ------------------  | | | |   ------------------
                     |    | 0x01_0000_0000 |  | | | |-> | 0x00_3800_0000 |
                     |    ------------------  | | |     ------------------
                     |            ...         | | |     | 0x00_3820_0000 |
                     |                        | | |     ------------------
                     |                        | | |             ...
                     |                        | | |
                     |                        | | |     ------------------
                     |                        | | |---> | 0x00_4000_0000 |
                     |                        | |       ------------------
                     |            ...         | |       | 0x00_4020_0000 |
                     |    ------------------  | |       ------------------
                     |--> | 0x80_0000_0000 |  | |               ...
                          ------------------  | |
                          | 0x80_4000_0000 |  | |       ------------------
                          ------------------  | |-----> | 0x00_8000_0000 |
                          | 0x80_8000_0000 |  |         ------------------
                          ------------------  |         | 0x00_8020_0000 |
                          | 0x80_c000_0000 |  |         ------------------
                          ------------------  |         |       ...      |
                          | 0x81_0000_0000 |  |         ------------------
                          ------------------  |-------> | 0x00_C000_0000 |
                                 ...                    ------------------
                                                        | 0x00_C020_0000 |
                                                        ------------------
                                                                ...

(2) Final MMU Tables:

     Level 0                   Level 1                   Level 2
------------------        ------------------
| 0x00_0000_0000 | -----> | 0x00_0000_0000 | -------|           ...
------------------        ------------------        |   ------------------
| 0x80_0000_0000 | --|    | 0x00_4000_0000 | -----| |-> | 0x00_2000_0000 |
------------------   |    ------------------      | |   ------------------
|    invalid     |   |    | 0x00_8000_0000 | ---| | |   | 0x00_2020_0000 |
------------------   |    ------------------    | | |   ------------------
                     |    | 0x00_c000_0000 | -| | | |   |       ...      |
                     |    ------------------  | | | |   ------------------
                     |    | 0x01_0000_0000 |  | | | |-> | 0x00_3800_0000 |
                     |    ------------------  | | |     ------------------
                     |            ...         | | |     | 0x00_3820_0000 |
                     |                        | | |     ------------------
                     |                        | | |             ...
                     |                        | | |
                     |                        | | |     ------------------
                     |                        | | |---> | 0x00_4000_0000 |
                     |                        | |       ------------------
                     |            ...         | |       | 0x00_4020_0000 |
                     |    ------------------  | |       ------------------
                     |--> | 0x80_0000_0000 |  | |               ...
                          ------------------  | |
                          | 0x80_4000_0000 |  | |       ------------------
                          ------------------  | |-----> | 0x00_8000_0000 |
                          | 0x80_8000_0000 |  |         ------------------
                          ------------------  |         | 0x00_8020_0000 |
                          | 0x80_c000_0000 |  |         ------------------
                          ------------------  |         |       ...      |
                          | 0x81_0000_0000 |  |         ------------------
                          ------------------  |-------> | 0x00_C000_0000 |
                                 ...                    ------------------
                                                        | 0x00_C020_0000 |
                                                        ------------------
                                                                ...

