Skip to contentSkip to conversation

test/cmd/mem_copy.c: Use CONFIG_SYS_LOAD_ADDR for base

PATCH In review Tom Rini 2 participants 5 messages Oct 30, 2024 – Nov 2, 2024

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 test/cmd/mem_copy.c: Use CONFIG_SYS_LOAD_ADDR for base

When reading/writing to memory we cannot assume that a base address of 0x0 is correct and functional. So use CONFIG_SYS_LOAD_ADDR as the base from which we add a bit more padding and being our tests.

---
 test/cmd/mem_copy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/cmd/mem_copy.c +1 -1
index 1ba0cebbbe04..67eca328777a 100644
@@ -21,7 +21,7 @@ struct param {
 static int do_test(struct unit_test_state *uts,
 		   const char *suffix, int d, int s, int count)
 {
-	const long addr = 0x1000;
+	const long addr = CONFIG_SYS_LOAD_ADDR + 0x1000;
 	u8 shadow[BUF_SIZE];
 	u8 *buf;
 	int i, w, bytes;
Signature · 1 line
2.43.0
#1 lore raw

Hi Tom,

Quoted 15 lines · Tom Rini

When reading/writing to memory we cannot assume that a base address of 0x0 is correct and functional. So use CONFIG_SYS_LOAD_ADDR as the base from which we add a bit more padding and being our tests.

---
 test/cmd/mem_copy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/cmd/mem_copy.c +0 -0
index 1ba0cebbbe04..67eca328777a 100644

test/cmd/mem_copy.c struct param { · line 24

Quoted 5 lines
test/cmd/mem_copy.c +1 -1
@@ -21,7 +21,7 @@ struct param {
 static int do_test(struct unit_test_state *uts,
                   const char *suffix, int d, int s, int count)
 {
-       const long addr = 0x1000;
+       const long addr = CONFIG_SYS_LOAD_ADDR + 0x1000;

CFG_SYS_SDRAM_BASE would be better here, since it is the start of memory (0 on sandbox and most boards).

Quoted 6 lines
test/cmd/mem_copy.c +0 -1
        u8 shadow[BUF_SIZE];
        u8 *buf;
        int i, w, bytes;
--

2.43.0

Regards,
Simon

author
#2 lore raw
Quoted 13 lines · Simon Glass

Hi Tom,

Quoted 10 lines · Tom Rini

When reading/writing to memory we cannot assume that a base address of 0x0 is correct and functional. So use CONFIG_SYS_LOAD_ADDR as the base from which we add a bit more padding and being our tests.

---
 test/cmd/mem_copy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

test/cmd/mem_copy.c struct param { · line 24

Quoted 10 lines
test/cmd/mem_copy.c +1 -1
index 1ba0cebbbe04..67eca328777a 100644
@@ -21,7 +21,7 @@ struct param {
 static int do_test(struct unit_test_state *uts,
                   const char *suffix, int d, int s, int count)
 {
-       const long addr = 0x1000;
+       const long addr = CONFIG_SYS_LOAD_ADDR + 0x1000;

CFG_SYS_SDRAM_BASE would be better here, since it is the start of memory (0 on sandbox and most boards).

Why do we want start of memory? CONFIG_SYS_LOAD_ADDR is the address for where it's safe to load things to memory and fiddle with them.

Signature · 1 line
Tom
#3 lore raw

Hi Tom,

Quoted 29 lines · Tom Rini
Quoted 13 lines · Simon Glass

Hi Tom,

Quoted 10 lines · Tom Rini

When reading/writing to memory we cannot assume that a base address of 0x0 is correct and functional. So use CONFIG_SYS_LOAD_ADDR as the base from which we add a bit more padding and being our tests.

---
 test/cmd/mem_copy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

test/cmd/mem_copy.c struct param { · line 24

Quoted 10 lines
test/cmd/mem_copy.c +1 -1
index 1ba0cebbbe04..67eca328777a 100644
@@ -21,7 +21,7 @@ struct param {
 static int do_test(struct unit_test_state *uts,
                   const char *suffix, int d, int s, int count)
 {
-       const long addr = 0x1000;
+       const long addr = CONFIG_SYS_LOAD_ADDR + 0x1000;

CFG_SYS_SDRAM_BASE would be better here, since it is the start of memory (0 on sandbox and most boards).

Quoted 2 lines

Why do we want start of memory? CONFIG_SYS_LOAD_ADDR is the address for where it's safe to load things to memory and fiddle with them.

Well the load address is for loading images. It doesn't have anything to do with this test, so far as I can see. Not a big deal though.

I'm pleased you are finding all the issues I had with my lab...once I get it running I won't have to send so many patches :-)

Regards,
Imon

author
#4 lore raw
In reply to Tom Rini
Quoted 5 lines · Tom Rini

When reading/writing to memory we cannot assume that a base address of 0x0 is correct and functional. So use CONFIG_SYS_LOAD_ADDR as the base from which we add a bit more padding and being our tests.

Applied to local tree/v2-tidy-test-dir, thanks!

Signature · 1 line
Tom