Skip to contentSkip to conversation

doc: Move the generic memory-documentation to doc/

PATCH Superseded Simon Glass 4 participants 6 messages Sep 19, 2024 – Sep 25, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 doc: Move the generic memory-documentation to doc/

Move this section of the README into doc/ with some minor updates to mention SPL and user lower-case hex.

---

 README                 | 45 ------------------------------------------
 doc/develop/index.rst  |  1 +
 doc/develop/memory.rst | 45 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 45 deletions(-)
 create mode 100644 doc/develop/memory.rst
README +0 -45
index 4be1e8c22a0..d73042406b6 100644
@@ -2516,51 +2516,6 @@ On RISC-V, the following registers are used:
 
     ==> U-Boot will use gp to hold a pointer to the global data
 
-Memory Management:
-------------------
-
-U-Boot runs in system state and uses physical addresses, i.e. the
-MMU is not used either for address mapping nor for memory protection.
-
-The available memory is mapped to fixed addresses using the memory
-controller. In this process, a contiguous block is formed for each
-memory type (Flash, SDRAM, SRAM), even when it consists of several
-physical memory banks.
-
-U-Boot is installed in the first 128 kB of the first Flash bank (on
-TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After
-booting and sizing and initializing DRAM, the code relocates itself
-to the upper end of DRAM. Immediately below the U-Boot code some
-memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
-configuration setting]. Below that, a structure with global Board
-Info data is placed, followed by the stack (growing downward).
-
-Additionally, some exception handler code is copied to the low 8 kB
-of DRAM (0x00000000 ... 0x00001FFF).
-
-So a typical memory configuration with 16 MB of DRAM could look like
-this:
-
-	0x0000 0000	Exception Vector code
-	      :
-	0x0000 1FFF
-	0x0000 2000	Free for Application Use
-	      :
-	      :
-
-	      :
-	      :
-	0x00FB FF20	Monitor Stack (Growing downward)
-	0x00FB FFAC	Board Info Data and permanent copy of global data
-	0x00FC 0000	Malloc Arena
-	      :
-	0x00FD FFFF
-	0x00FE 0000	RAM Copy of Monitor Code
-	...		eventually: LCD or video framebuffer
-	...		eventually: pRAM (Protected RAM - unchanged by reset)
-	0x00FF FFFF	[End of RAM]
-
-
 System Initialization:
 ----------------------
 
doc/develop/index.rst +1 -0
index 0d0e60ab56c..cbea38d4323 100644
@@ -13,6 +13,7 @@ General
    codingstyle
    designprinciples
    docstyle
+   memory
    patman
    process
    release_cycle
doc/develop/memory.rst new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw

Hello Simon,

Am Thu, Sep 19, 2024 at 05:14:22PM +0200 schrieb Simon Glass:

Quoted 2 lines

Move this section of the README into doc/ with some minor updates to mention SPL and user lower-case hex.

Maybe try not to rewrap unchanged paragraphs,
so git show --color-moved can detect those as just moved?

Quoted 112 lines

---

 README                 | 45 ------------------------------------------
 doc/develop/index.rst  |  1 +
 doc/develop/memory.rst | 45 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 45 deletions(-)
 create mode 100644 doc/develop/memory.rst
README +0 -45
index 4be1e8c22a0..d73042406b6 100644
@@ -2516,51 +2516,6 @@ On RISC-V, the following registers are used:
 
     ==> U-Boot will use gp to hold a pointer to the global data
 
-Memory Management:
-------------------
-
-U-Boot runs in system state and uses physical addresses, i.e. the
-MMU is not used either for address mapping nor for memory protection.
-
-The available memory is mapped to fixed addresses using the memory
-controller. In this process, a contiguous block is formed for each
-memory type (Flash, SDRAM, SRAM), even when it consists of several
-physical memory banks.
-
-U-Boot is installed in the first 128 kB of the first Flash bank (on
-TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After
-booting and sizing and initializing DRAM, the code relocates itself
-to the upper end of DRAM. Immediately below the U-Boot code some
-memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
-configuration setting]. Below that, a structure with global Board
-Info data is placed, followed by the stack (growing downward).
-
-Additionally, some exception handler code is copied to the low 8 kB
-of DRAM (0x00000000 ... 0x00001FFF).
-
-So a typical memory configuration with 16 MB of DRAM could look like
-this:
-
-	0x0000 0000	Exception Vector code
-	      :
-	0x0000 1FFF
-	0x0000 2000	Free for Application Use
-	      :
-	      :
-
-	      :
-	      :
-	0x00FB FF20	Monitor Stack (Growing downward)
-	0x00FB FFAC	Board Info Data and permanent copy of global data
-	0x00FC 0000	Malloc Arena
-	      :
-	0x00FD FFFF
-	0x00FE 0000	RAM Copy of Monitor Code
-	...		eventually: LCD or video framebuffer
-	...		eventually: pRAM (Protected RAM - unchanged by reset)
-	0x00FF FFFF	[End of RAM]
-
-
 System Initialization:
 ----------------------
 
doc/develop/index.rst +1 -0
index 0d0e60ab56c..cbea38d4323 100644
@@ -13,6 +13,7 @@ General
    codingstyle
    designprinciples
    docstyle
+   memory
    patman
    process
    release_cycle
doc/develop/memory.rst new file +29 -0
new file mode 100644
index 00000000000..fa1ae5e97ed
@@ -0,0 +1,45 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+Memory Management
+-----------------
+
+U-Boot runs in system state and uses physical addresses, i.e. the
+MMU is not used either for address mapping nor for memory protection.
+
+The available memory is mapped to fixed addresses using the
+memory-controller. In this process, a contiguous block is formed for each
+memory type (Flash, SDRAM, SRAM), even when it consists of several
+physical-memory banks.
+
+U-Boot is installed in XIP flash memory, or may be loaded into a lower region of
+RAM by a secondary program loader (SPL). After
+booting and sizing and initialising DRAM, the code relocates itself
+to the upper end of DRAM. Immediately below the U-Boot code some
+memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
+configuration setting]. Below that, a structure with global Board-Info
+data is placed, followed by the stack (growing downward).
+
+Additionally, some exception handler code may be copied to the low 8 kB
+of DRAM (0x00000000 ... 0x00001fff).
+
+So a typical memory configuration with 16 MB of DRAM could look like
+this::
+
+	0x0000 0000	Exception Vector code
+	      :

doc/develop/memory.rst line 39

Quoted 10 lines
doc/develop/memory.rst new file +10 -0
+	0x0000 1fff
+	0x0000 2000	Free for Application Use
+	      :
+	      :
+
+	      :
+	      :
+	0x00fb ff20	Monitor Stack (Growing downward)
+	0x00fb ffac	Board Info Data and permanent copy of global data
+	0x00fc 0000	Malloc Arena

Arena?

make htmldocs runs fine, page looks okay, thus:

Greets
Alex

Quoted 9 lines
doc/develop/memory.rst new file +6 -0
+	      :
+	0x00fd ffff
+	0x00fe 0000	RAM Copy of Monitor Code
+	...		eventually: LCD or video framebuffer
+	...		eventually: pRAM (Protected RAM - unchanged by reset)
+	0x00ff ffff	[End of RAM]
Signature · 1 line
2.43.0
#2 lore raw

Hi Alex,

Quoted 9 lines · Alexander Dahl

Hello Simon,

Am Thu, Sep 19, 2024 at 05:14:22PM +0200 schrieb Simon Glass:

Quoted 2 lines

Move this section of the README into doc/ with some minor updates to mention SPL and user lower-case hex.

Maybe try not to rewrap unchanged paragraphs,
so git show --color-moved can detect those as just moved?

I did try to do that, but perhaps did a line wrong?

Quoted 117 lines
Quoted 117 lines

---

 README                 | 45 ------------------------------------------
 doc/develop/index.rst  |  1 +
 doc/develop/memory.rst | 45 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 45 deletions(-)
 create mode 100644 doc/develop/memory.rst
README +0 -45
index 4be1e8c22a0..d73042406b6 100644
@@ -2516,51 +2516,6 @@ On RISC-V, the following registers are used:
 
     ==> U-Boot will use gp to hold a pointer to the global data
 
-Memory Management:
-------------------
-
-U-Boot runs in system state and uses physical addresses, i.e. the
-MMU is not used either for address mapping nor for memory protection.
-
-The available memory is mapped to fixed addresses using the memory
-controller. In this process, a contiguous block is formed for each
-memory type (Flash, SDRAM, SRAM), even when it consists of several
-physical memory banks.
-
-U-Boot is installed in the first 128 kB of the first Flash bank (on
-TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After
-booting and sizing and initializing DRAM, the code relocates itself
-to the upper end of DRAM. Immediately below the U-Boot code some
-memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
-configuration setting]. Below that, a structure with global Board
-Info data is placed, followed by the stack (growing downward).
-
-Additionally, some exception handler code is copied to the low 8 kB
-of DRAM (0x00000000 ... 0x00001FFF).
-
-So a typical memory configuration with 16 MB of DRAM could look like
-this:
-
-     0x0000 0000     Exception Vector code
-           :
-     0x0000 1FFF
-     0x0000 2000     Free for Application Use
-           :
-           :
-
-           :
-           :
-     0x00FB FF20     Monitor Stack (Growing downward)
-     0x00FB FFAC     Board Info Data and permanent copy of global data
-     0x00FC 0000     Malloc Arena
-           :
-     0x00FD FFFF
-     0x00FE 0000     RAM Copy of Monitor Code
-     ...             eventually: LCD or video framebuffer
-     ...             eventually: pRAM (Protected RAM - unchanged by reset)
-     0x00FF FFFF     [End of RAM]
-
-
 System Initialization:
 ----------------------
 
doc/develop/index.rst +1 -0
index 0d0e60ab56c..cbea38d4323 100644
@@ -13,6 +13,7 @@ General
    codingstyle
    designprinciples
    docstyle
+   memory
    patman
    process
    release_cycle
doc/develop/memory.rst new file +33 -0
new file mode 100644
index 00000000000..fa1ae5e97ed
@@ -0,0 +1,45 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+Memory Management
+-----------------
+
+U-Boot runs in system state and uses physical addresses, i.e. the
+MMU is not used either for address mapping nor for memory protection.
+
+The available memory is mapped to fixed addresses using the
+memory-controller. In this process, a contiguous block is formed for each
+memory type (Flash, SDRAM, SRAM), even when it consists of several
+physical-memory banks.
+
+U-Boot is installed in XIP flash memory, or may be loaded into a lower region of
+RAM by a secondary program loader (SPL). After
+booting and sizing and initialising DRAM, the code relocates itself
+to the upper end of DRAM. Immediately below the U-Boot code some
+memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
+configuration setting]. Below that, a structure with global Board-Info
+data is placed, followed by the stack (growing downward).
+
+Additionally, some exception handler code may be copied to the low 8 kB
+of DRAM (0x00000000 ... 0x00001fff).
+
+So a typical memory configuration with 16 MB of DRAM could look like
+this::
+
+     0x0000 0000     Exception Vector code
+           :
+     0x0000 1fff
+     0x0000 2000     Free for Application Use
+           :
+           :
Quoted 8 lines

doc/develop/memory.rst line 39

Quoted 6 lines
doc/develop/memory.rst new file +6 -0
+
+           :
+           :
+     0x00fb ff20     Monitor Stack (Growing downward)
+     0x00fb ffac     Board Info Data and permanent copy of global data
+     0x00fc 0000     Malloc Arena

Arena?

Yes, a strange choice of words perhaps, but fair enough.

Quoted 4 lines

make htmldocs runs fine, page looks okay, thus:

Thanks.

Quoted 13 lines

Greets
Alex

Quoted 9 lines
doc/develop/memory.rst new file +6 -1
+           :
+     0x00fd ffff
+     0x00fe 0000     RAM Copy of Monitor Code
+     ...             eventually: LCD or video framebuffer
+     ...             eventually: pRAM (Protected RAM - unchanged by reset)
+     0x00ff ffff     [End of RAM]
--

2.43.0

Regards,
Simon

#3 lore raw
In reply to Simon Glass
Quoted 86 lines · Simon Glass

Move this section of the README into doc/ with some minor updates to mention SPL and user lower-case hex.

---

  README                 | 45 ------------------------------------------
  doc/develop/index.rst  |  1 +
  doc/develop/memory.rst | 45 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 46 insertions(+), 45 deletions(-)

create mode 100644 doc/develop/memory.rst

README +0 -45
index 4be1e8c22a0..d73042406b6 100644
@@ -2516,51 +2516,6 @@ On RISC-V, the following registers are used:
 
      ==> U-Boot will use gp to hold a pointer to the global data
 
-Memory Management:
-------------------
-
-U-Boot runs in system state and uses physical addresses, i.e. the
-MMU is not used either for address mapping nor for memory protection.
-
-The available memory is mapped to fixed addresses using the memory
-controller. In this process, a contiguous block is formed for each
-memory type (Flash, SDRAM, SRAM), even when it consists of several
-physical memory banks.
-
-U-Boot is installed in the first 128 kB of the first Flash bank (on
-TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After
-booting and sizing and initializing DRAM, the code relocates itself
-to the upper end of DRAM. Immediately below the U-Boot code some
-memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
-configuration setting]. Below that, a structure with global Board
-Info data is placed, followed by the stack (growing downward).
-
-Additionally, some exception handler code is copied to the low 8 kB
-of DRAM (0x00000000 ... 0x00001FFF).
-
-So a typical memory configuration with 16 MB of DRAM could look like
-this:
-
-	0x0000 0000	Exception Vector code
-	      :
-	0x0000 1FFF
-	0x0000 2000	Free for Application Use
-	      :
-	      :
-
-	      :
-	      :
-	0x00FB FF20	Monitor Stack (Growing downward)
-	0x00FB FFAC	Board Info Data and permanent copy of global data
-	0x00FC 0000	Malloc Arena
-	      :
-	0x00FD FFFF
-	0x00FE 0000	RAM Copy of Monitor Code
-	...		eventually: LCD or video framebuffer
-	...		eventually: pRAM (Protected RAM - unchanged by reset)
-	0x00FF FFFF	[End of RAM]
-
-
  System Initialization:
  ----------------------
 
doc/develop/index.rst +1 -0
index 0d0e60ab56c..cbea38d4323 100644
@@ -13,6 +13,7 @@ General
     codingstyle
     designprinciples
     docstyle
+   memory
     patman
     process
     release_cycle
doc/develop/memory.rst new file +0 -0
new file mode 100644
index 00000000000..fa1ae5e97ed

doc/develop/memory.rst line 7

Quoted 7 lines
doc/develop/memory.rst new file +7 -0
@@ -0,0 +1,45 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+Memory Management
+-----------------
+
+U-Boot runs in system state and uses physical addresses, i.e. the
+MMU is not used either for address mapping nor for memory protection.

Hello Simon,

Thanks for getting the description moved.

The text that you are copying dates back to 2004 when U-Boot was focusing on the Power architecture. It needs some rework.

On RISC-V there is a physical memory protection (PMP) which is typically set up to guard against overwriting OpenSBI sitting at the lower end of RAM.

There is some ongoing work to implement NX protection via the MMU for ARM.

doc/develop/memory.rst line 12

Quoted 5 lines
doc/develop/memory.rst new file +5 -0
+
+The available memory is mapped to fixed addresses using the
+memory-controller. In this process, a contiguous block is formed for each
+memory type (Flash, SDRAM, SRAM), even when it consists of several
+physical-memory banks.

Can we simply say DRAM instead of SDRAM. We always refer to DRAM below. Whether the RAM frequency is synchronous or not is irrelevant here.

doc/develop/memory.rst line 15

Quoted 3 lines
doc/develop/memory.rst new file +3 -0
+
+U-Boot is installed in XIP flash memory, or may be loaded into a lower region of
+RAM by a secondary program loader (SPL). After

This does not describe U-Boot SPL as being a part of U-Boot.

doc/develop/memory.rst line 16

Quoted 1 line
doc/develop/memory.rst new file +1 -0
+booting and sizing and initialising DRAM, the code relocates itself

Initialization of DRAM can be done in code running before U-Boot.

doc/develop/memory.rst line 18

Quoted 2 lines
doc/develop/memory.rst new file +2 -0
+to the upper end of DRAM. Immediately below the U-Boot code some
+memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN>

+configuration setting]. Below that, a structure with global Board-Info

doc/develop/memory.rst line 23

Quoted 4 lines
doc/develop/memory.rst new file +4 -0
+data is placed, followed by the stack (growing downward).
+
+Additionally, some exception handler code may be copied to the low 8 kB
+of DRAM (0x00000000 ... 0x00001fff).

The exception handler code for RISC-V and ARMv8 is typically not located at 0x0.

On RISC-V stvec, the Supervisor Trap Vector Base Address Register, defines where the exception vectors are located in S-Mode.

On ARMv8 VBAR_EL2, the Vector Base Address Register (EL2), sets the location of the EL2 vector base.

doc/develop/memory.rst line 24

Quoted 2 lines
doc/develop/memory.rst new file +2 -0
+
+So a typical memory configuration with 16 MB of DRAM could look like

%s/MB/MiB/

doc/develop/memory.rst line 28

Quoted 3 lines
doc/develop/memory.rst new file +3 -0
+this::
+
+	0x0000 0000	Exception Vector code

On RISC-V the lowest memory addresses in RAM are typically used by OpenSBI. On ARM you may have TF-A sitting there.

Quoted 7 lines
doc/develop/memory.rst new file +7 -0
+	      :
+	0x0000 1fff
+	0x0000 2000	Free for Application Use
+	      :
+	      :
+
+	      :

doc/develop/memory.rst line 45

Quoted 10 lines
doc/develop/memory.rst new file +10 -0
+	      :
+	0x00fb ff20	Monitor Stack (Growing downward)
+	0x00fb ffac	Board Info Data and permanent copy of global data
+	0x00fc 0000	Malloc Arena
+	      :
+	0x00fd ffff
+	0x00fe 0000	RAM Copy of Monitor Code
+	...		eventually: LCD or video framebuffer
+	...		eventually: pRAM (Protected RAM - unchanged by reset)
+	0x00ff ffff	[End of RAM]

A description of the LMB and EFI should be added in a future patch.

Best regards

Heinrich

#4 lore raw

Hi Heinrich,

Quoted 138 lines · Heinrich Schuchardt
Quoted 86 lines · Simon Glass

Move this section of the README into doc/ with some minor updates to mention SPL and user lower-case hex.

---

  README                 | 45 ------------------------------------------
  doc/develop/index.rst  |  1 +
  doc/develop/memory.rst | 45 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 46 insertions(+), 45 deletions(-)

create mode 100644 doc/develop/memory.rst

README +0 -45
index 4be1e8c22a0..d73042406b6 100644
@@ -2516,51 +2516,6 @@ On RISC-V, the following registers are used:
 
      ==> U-Boot will use gp to hold a pointer to the global data
 
-Memory Management:
-------------------
-
-U-Boot runs in system state and uses physical addresses, i.e. the
-MMU is not used either for address mapping nor for memory protection.
-
-The available memory is mapped to fixed addresses using the memory
-controller. In this process, a contiguous block is formed for each
-memory type (Flash, SDRAM, SRAM), even when it consists of several
-physical memory banks.
-
-U-Boot is installed in the first 128 kB of the first Flash bank (on
-TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After
-booting and sizing and initializing DRAM, the code relocates itself
-to the upper end of DRAM. Immediately below the U-Boot code some
-memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
-configuration setting]. Below that, a structure with global Board
-Info data is placed, followed by the stack (growing downward).
-
-Additionally, some exception handler code is copied to the low 8 kB
-of DRAM (0x00000000 ... 0x00001FFF).
-
-So a typical memory configuration with 16 MB of DRAM could look like
-this:
-
-     0x0000 0000     Exception Vector code
-           :
-     0x0000 1FFF
-     0x0000 2000     Free for Application Use
-           :
-           :
-
-           :
-           :
-     0x00FB FF20     Monitor Stack (Growing downward)
-     0x00FB FFAC     Board Info Data and permanent copy of global data
-     0x00FC 0000     Malloc Arena
-           :
-     0x00FD FFFF
-     0x00FE 0000     RAM Copy of Monitor Code
-     ...             eventually: LCD or video framebuffer
-     ...             eventually: pRAM (Protected RAM - unchanged by reset)
-     0x00FF FFFF     [End of RAM]
-
-
  System Initialization:
  ----------------------
 
doc/develop/index.rst +1 -0
index 0d0e60ab56c..cbea38d4323 100644
@@ -13,6 +13,7 @@ General
     codingstyle
     designprinciples
     docstyle
+   memory
     patman
     process
     release_cycle
doc/develop/memory.rst new file +0 -0
new file mode 100644
index 00000000000..fa1ae5e97ed

doc/develop/memory.rst line 7

Quoted 7 lines
doc/develop/memory.rst new file +7 -0
@@ -0,0 +1,45 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+Memory Management
+-----------------
+
+U-Boot runs in system state and uses physical addresses, i.e. the
+MMU is not used either for address mapping nor for memory protection.

Hello Simon,

Thanks for getting the description moved.

The text that you are copying dates back to 2004 when U-Boot was focusing on the Power architecture. It needs some rework.

On RISC-V there is a physical memory protection (PMP) which is typically set up to guard against overwriting OpenSBI sitting at the lower end of RAM.

There is some ongoing work to implement NX protection via the MMU for ARM.

doc/develop/memory.rst line 12

Quoted 5 lines
doc/develop/memory.rst new file +5 -0
+
+The available memory is mapped to fixed addresses using the
+memory-controller. In this process, a contiguous block is formed for each
+memory type (Flash, SDRAM, SRAM), even when it consists of several
+physical-memory banks.

Can we simply say DRAM instead of SDRAM. We always refer to DRAM below. Whether the RAM frequency is synchronous or not is irrelevant here.

doc/develop/memory.rst line 15

Quoted 3 lines
doc/develop/memory.rst new file +3 -0
+
+U-Boot is installed in XIP flash memory, or may be loaded into a lower region of
+RAM by a secondary program loader (SPL). After

This does not describe U-Boot SPL as being a part of U-Boot.

doc/develop/memory.rst line 16

Quoted 1 line
doc/develop/memory.rst new file +1 -0
+booting and sizing and initialising DRAM, the code relocates itself

Initialization of DRAM can be done in code running before U-Boot.

doc/develop/memory.rst line 18

Quoted 2 lines
doc/develop/memory.rst new file +2 -0
+to the upper end of DRAM. Immediately below the U-Boot code some
+memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN>

+configuration setting]. Below that, a structure with global Board-Info

doc/develop/memory.rst line 23

Quoted 4 lines
doc/develop/memory.rst new file +4 -0
+data is placed, followed by the stack (growing downward).
+
+Additionally, some exception handler code may be copied to the low 8 kB
+of DRAM (0x00000000 ... 0x00001fff).

The exception handler code for RISC-V and ARMv8 is typically not located at 0x0.

Quoted 5 lines

On RISC-V stvec, the Supervisor Trap Vector Base Address Register, defines where the exception vectors are located in S-Mode.

On ARMv8 VBAR_EL2, the Vector Base Address Register (EL2), sets the location of the EL2 vector base.

I don't believe we need to get into the weeds on this description. It is just setting some guiding principles. Yes, every architecture is different, but people can see the general idea.

Perhaps we should add details about each architecture at the end, i.e. provide a link to an arch-specific page which provides more information?

Quoted 31 lines

doc/develop/memory.rst line 24

Quoted 3 lines
doc/develop/memory.rst new file +2 -0
+
+So a typical memory configuration with 16 MB of DRAM could look like

%s/MB/MiB/

doc/develop/memory.rst line 28

Quoted 3 lines
doc/develop/memory.rst new file +3 -0
+this::
+
+     0x0000 0000     Exception Vector code

On RISC-V the lowest memory addresses in RAM are typically used by OpenSBI. On ARM you may have TF-A sitting there.

Quoted 7 lines
doc/develop/memory.rst new file +7 -0
+           :
+     0x0000 1fff
+     0x0000 2000     Free for Application Use
+           :
+           :
+
+           :

doc/develop/memory.rst line 45

Quoted 10 lines
doc/develop/memory.rst new file +10 -0
+           :
+     0x00fb ff20     Monitor Stack (Growing downward)
+     0x00fb ffac     Board Info Data and permanent copy of global data
+     0x00fc 0000     Malloc Arena
+           :
+     0x00fd ffff
+     0x00fe 0000     RAM Copy of Monitor Code
+     ...             eventually: LCD or video framebuffer
+     ...             eventually: pRAM (Protected RAM - unchanged by reset)
+     0x00ff ffff     [End of RAM]
Quoted 1 line

A description of the LMB and EFI should be added in a future patch.

With my two series we can clean up EFI so that it works within the above.

Regards,
Simon

#5 lore raw
Quoted 147 lines · Simon Glass

Hi Heinrich,

Quoted 138 lines · Heinrich Schuchardt
Quoted 86 lines · Simon Glass

Move this section of the README into doc/ with some minor updates to mention SPL and user lower-case hex.

---

  README                 | 45 ------------------------------------------
  doc/develop/index.rst  |  1 +
  doc/develop/memory.rst | 45 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 46 insertions(+), 45 deletions(-)

create mode 100644 doc/develop/memory.rst

README +0 -45
index 4be1e8c22a0..d73042406b6 100644
@@ -2516,51 +2516,6 @@ On RISC-V, the following registers are used:
 
      ==> U-Boot will use gp to hold a pointer to the global data
 
-Memory Management:
-------------------
-
-U-Boot runs in system state and uses physical addresses, i.e. the
-MMU is not used either for address mapping nor for memory protection.
-
-The available memory is mapped to fixed addresses using the memory
-controller. In this process, a contiguous block is formed for each
-memory type (Flash, SDRAM, SRAM), even when it consists of several
-physical memory banks.
-
-U-Boot is installed in the first 128 kB of the first Flash bank (on
-TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After
-booting and sizing and initializing DRAM, the code relocates itself
-to the upper end of DRAM. Immediately below the U-Boot code some
-memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN
-configuration setting]. Below that, a structure with global Board
-Info data is placed, followed by the stack (growing downward).
-
-Additionally, some exception handler code is copied to the low 8 kB
-of DRAM (0x00000000 ... 0x00001FFF).
-
-So a typical memory configuration with 16 MB of DRAM could look like
-this:
-
-     0x0000 0000     Exception Vector code
-           :
-     0x0000 1FFF
-     0x0000 2000     Free for Application Use
-           :
-           :
-
-           :
-           :
-     0x00FB FF20     Monitor Stack (Growing downward)
-     0x00FB FFAC     Board Info Data and permanent copy of global data
-     0x00FC 0000     Malloc Arena
-           :
-     0x00FD FFFF
-     0x00FE 0000     RAM Copy of Monitor Code
-     ...             eventually: LCD or video framebuffer
-     ...             eventually: pRAM (Protected RAM - unchanged by reset)
-     0x00FF FFFF     [End of RAM]
-
-
  System Initialization:
  ----------------------
 
doc/develop/index.rst +1 -0
index 0d0e60ab56c..cbea38d4323 100644
@@ -13,6 +13,7 @@ General
     codingstyle
     designprinciples
     docstyle
+   memory
     patman
     process
     release_cycle
doc/develop/memory.rst new file +0 -0
new file mode 100644
index 00000000000..fa1ae5e97ed

doc/develop/memory.rst line 7

Quoted 7 lines
doc/develop/memory.rst new file +7 -0
@@ -0,0 +1,45 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+Memory Management
+-----------------
+
+U-Boot runs in system state and uses physical addresses, i.e. the
+MMU is not used either for address mapping nor for memory protection.

Hello Simon,

Thanks for getting the description moved.

The text that you are copying dates back to 2004 when U-Boot was focusing on the Power architecture. It needs some rework.

On RISC-V there is a physical memory protection (PMP) which is typically set up to guard against overwriting OpenSBI sitting at the lower end of RAM.

There is some ongoing work to implement NX protection via the MMU for ARM.

doc/develop/memory.rst line 12

Quoted 5 lines
doc/develop/memory.rst new file +5 -0
+
+The available memory is mapped to fixed addresses using the
+memory-controller. In this process, a contiguous block is formed for each
+memory type (Flash, SDRAM, SRAM), even when it consists of several
+physical-memory banks.

Can we simply say DRAM instead of SDRAM. We always refer to DRAM below. Whether the RAM frequency is synchronous or not is irrelevant here.

doc/develop/memory.rst line 15

Quoted 3 lines
doc/develop/memory.rst new file +3 -0
+
+U-Boot is installed in XIP flash memory, or may be loaded into a lower region of
+RAM by a secondary program loader (SPL). After

This does not describe U-Boot SPL as being a part of U-Boot.

doc/develop/memory.rst line 16

Quoted 1 line
doc/develop/memory.rst new file +1 -0
+booting and sizing and initialising DRAM, the code relocates itself

Initialization of DRAM can be done in code running before U-Boot.

doc/develop/memory.rst line 18

Quoted 2 lines
doc/develop/memory.rst new file +2 -0
+to the upper end of DRAM. Immediately below the U-Boot code some
+memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN>

+configuration setting]. Below that, a structure with global Board-Info

doc/develop/memory.rst line 23

Quoted 4 lines
doc/develop/memory.rst new file +4 -0
+data is placed, followed by the stack (growing downward).
+
+Additionally, some exception handler code may be copied to the low 8 kB
+of DRAM (0x00000000 ... 0x00001fff).

The exception handler code for RISC-V and ARMv8 is typically not located at 0x0.

Quoted 5 lines

On RISC-V stvec, the Supervisor Trap Vector Base Address Register, defines where the exception vectors are located in S-Mode.

On ARMv8 VBAR_EL2, the Vector Base Address Register (EL2), sets the location of the EL2 vector base.

Quoted 7 lines

I don't believe we need to get into the weeds on this description. It is just setting some guiding principles. Yes, every architecture is different, but people can see the general idea.

Perhaps we should add details about each architecture at the end, i.e. provide a link to an arch-specific page which provides more information?

Perhaps we should start by moving this content out of the top-level README and note at the start in the new document that the information is outdated and needs to be updated.

Signature · 1 line
Tom