mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/9] reimplement memtest command
@ 2013-01-13 17:42 Alexander Aring
  2013-01-13 17:42 ` [PATCH 1/9] meminfo: fix missing include Alexander Aring
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

This patch series reimplement the memtest command.

Now it's support enable/disable caching on arm architecture
and skip barebox regions.

In part of this patch series are the following changes:
	- Fix missing include in meminfo.
	- Fix some memory adresses issues.
	- Make remap_range globally accessable.
	- Add function to get cache/uncache pte flags.
	- Add new section data which is between text and bss.
	- Add function to check if address is in iomem regions
	  of ram.

Alexander Aring (9):
  meminfo: fix missing include
  memory: fix size address calculation
  meminfo: fix display of allocated addresses
  arm-mmu: remove semicolon in arm mmu.c
  mmu: make remap_range global accessable
  memory: add function address_in_sdram_regions
  barebox-data: add barebox-data sections
  memtest: remove memtest command
  memtest: add rewritten memtest command

 arch/arm/cpu/mmu.c                               |  18 +-
 arch/arm/include/asm/mmu.h                       |  17 +
 arch/arm/lib/barebox.lds.S                       |   6 +-
 arch/blackfin/boards/ipe337/barebox.lds.S        |   6 +-
 arch/blackfin/include/asm/mmu.h                  |  19 +
 arch/mips/include/asm/mmu.h                      |  19 +
 arch/mips/lib/barebox.lds.S                      |   5 +-
 arch/nios2/cpu/barebox.lds.S                     |   5 +-
 arch/nios2/include/asm/mmu.h                     |  19 +
 arch/openrisc/include/asm/mmu.h                  |  19 +
 arch/ppc/boards/freescale-p2020rdb/barebox.lds.S |   6 +-
 arch/ppc/boards/pcm030/barebox.lds.S             |   5 +-
 arch/ppc/include/asm/mmu.h                       |  15 +
 arch/sandbox/include/asm/mmu.h                   |  19 +
 arch/x86/include/asm/mmu.h                       |  19 +
 arch/x86/lib/barebox.lds.S                       |   5 +-
 commands/Kconfig                                 |  16 +-
 commands/Makefile                                |   2 +-
 commands/memtest.c                               | 895 ++++++++++++++++-------
 common/meminfo.c                                 |   7 +-
 common/memory.c                                  |  21 +-
 include/asm-generic/sections.h                   |   1 +
 include/common.h                                 |   2 +
 include/memory.h                                 |   6 +
 24 files changed, 850 insertions(+), 302 deletions(-)
 create mode 100644 arch/blackfin/include/asm/mmu.h
 create mode 100644 arch/mips/include/asm/mmu.h
 create mode 100644 arch/nios2/include/asm/mmu.h
 create mode 100644 arch/openrisc/include/asm/mmu.h
 create mode 100644 arch/sandbox/include/asm/mmu.h
 create mode 100644 arch/x86/include/asm/mmu.h

-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/9] meminfo: fix missing include
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-13 17:42 ` [PATCH 2/9] memory: fix size address calculation Alexander Aring
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Fix include for linkerscript variables like _etext.
Otherwise build with #define DEBUG will fail.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 common/meminfo.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/meminfo.c b/common/meminfo.c
index 06fce5a..a7c515f 100644
--- a/common/meminfo.c
+++ b/common/meminfo.c
@@ -2,6 +2,7 @@
 #include <init.h>
 #include <memory.h>
 #include <asm-generic/memory_layout.h>
+#include <asm-generic/sections.h>
 
 static int display_meminfo(void)
 {
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/9] memory: fix size address calculation
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
  2013-01-13 17:42 ` [PATCH 1/9] meminfo: fix missing include Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-13 17:42 ` [PATCH 3/9] meminfo: fix display of allocated addresses Alexander Aring
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Fix size address calculation.

Global variables from <asm/sections.h> which are defined
in linker script *.lds files for end addresses has already
a +1 calculation.

For example:
stext = 0x100 with a size about 0x50 will result a etext = 0x150.
In this case a correct size calculation is (etext - stext) = 0x50.

In function 'request_sdram_region' the end address will be
calculated with (start + size - 1) which result a correct
end address of 0x149 in this example.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 common/memory.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/memory.c b/common/memory.c
index 2674002..7dd1384 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -74,11 +74,11 @@ static int mem_malloc_resource(void)
 	request_sdram_region("barebox",
 			(unsigned long)&_stext,
 			(unsigned long)&_etext -
-			(unsigned long)&_stext + 1);
+			(unsigned long)&_stext);
 	request_sdram_region("bss",
 			(unsigned long)&__bss_start,
 			(unsigned long)&__bss_stop -
-			(unsigned long)&__bss_start + 1);
+			(unsigned long)&__bss_start);
 #ifdef STACK_BASE
 	request_sdram_region("stack", STACK_BASE, STACK_SIZE);
 #endif
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/9] meminfo: fix display of allocated addresses
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
  2013-01-13 17:42 ` [PATCH 1/9] meminfo: fix missing include Alexander Aring
  2013-01-13 17:42 ` [PATCH 2/9] memory: fix size address calculation Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-13 17:42 ` [PATCH 4/9] arm-mmu: remove semicolon in arm mmu.c Alexander Aring
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Fix display to stdout of allocated addresses.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 common/meminfo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/meminfo.c b/common/meminfo.c
index a7c515f..a09b2d2 100644
--- a/common/meminfo.c
+++ b/common/meminfo.c
@@ -10,13 +10,13 @@ static int display_meminfo(void)
 	ulong mend   = mem_malloc_end();
 	ulong msize  = mend - mstart + 1;
 
-	debug("barebox code: 0x%p -> 0x%p\n", _stext, _etext);
-	debug("bss segment:  0x%p -> 0x%p\n", __bss_start, __bss_stop);
+	debug("barebox code: 0x%p -> 0x%p\n", _stext, _etext - 1);
+	debug("bss segment:  0x%p -> 0x%p\n", __bss_start, __bss_stop - 1);
 	printf("malloc space: 0x%08lx -> 0x%08lx (size %s)\n",
 		mstart, mend, size_human_readable(msize));
 #ifdef CONFIG_ARM
 	printf("stack space:  0x%08x -> 0x%08x (size %s)\n",
-		STACK_BASE, STACK_BASE + STACK_SIZE,
+		STACK_BASE, STACK_BASE + STACK_SIZE - 1,
 		size_human_readable(STACK_SIZE));
 #endif
 	return 0;
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/9] arm-mmu: remove semicolon in arm mmu.c
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
                   ` (2 preceding siblings ...)
  2013-01-13 17:42 ` [PATCH 3/9] meminfo: fix display of allocated addresses Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-13 17:42 ` [PATCH 5/9] mmu: make remap_range global accessable Alexander Aring
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Remove semicolon in PAGE_ALIGN macro.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/cpu/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 068e0ea..40b7ec4 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -294,7 +294,7 @@ void mmu_disable(void)
 	__mmu_cache_off();
 }
 
-#define PAGE_ALIGN(s) ((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+#define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
 
 void *dma_alloc_coherent(size_t size)
 {
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/9] mmu: make remap_range global accessable
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
                   ` (3 preceding siblings ...)
  2013-01-13 17:42 ` [PATCH 4/9] arm-mmu: remove semicolon in arm mmu.c Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-13 17:42 ` [PATCH 6/9] memory: add function address_in_sdram_regions Alexander Aring
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

There is only one implementation of 'remap_range' in
arm architecture. Added dummy function for others architectures.

Added new function 'mmu_get_pte_cached_flags' and
'mmu_get_pte_uncached_flags' to get pte flags for caching and
uncaching pages.

These flags are in arm architecture configured at runtime.
Others architectures will return 0, which don't have a mmu
implementation for this.

Also moved PAGE_ALIGN and add PAGE_ALIGN_DOWN macros to common.h.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/cpu/mmu.c              | 18 +++++++++++++++---
 arch/arm/include/asm/mmu.h      | 17 +++++++++++++++++
 arch/blackfin/include/asm/mmu.h | 19 +++++++++++++++++++
 arch/mips/include/asm/mmu.h     | 19 +++++++++++++++++++
 arch/nios2/include/asm/mmu.h    | 19 +++++++++++++++++++
 arch/openrisc/include/asm/mmu.h | 19 +++++++++++++++++++
 arch/ppc/include/asm/mmu.h      | 15 +++++++++++++++
 arch/sandbox/include/asm/mmu.h  | 19 +++++++++++++++++++
 arch/x86/include/asm/mmu.h      | 19 +++++++++++++++++++
 include/common.h                |  2 ++
 10 files changed, 163 insertions(+), 3 deletions(-)
 create mode 100644 arch/blackfin/include/asm/mmu.h
 create mode 100644 arch/mips/include/asm/mmu.h
 create mode 100644 arch/nios2/include/asm/mmu.h
 create mode 100644 arch/openrisc/include/asm/mmu.h
 create mode 100644 arch/sandbox/include/asm/mmu.h
 create mode 100644 arch/x86/include/asm/mmu.h

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 40b7ec4..50112d2 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -52,9 +52,23 @@ extern int arm_architecture;
 #define PTE_FLAGS_CACHED_V4 (PTE_SMALL_AP_UNO_SRW | PTE_BUFFERABLE | PTE_CACHEABLE)
 #define PTE_FLAGS_UNCACHED_V4 PTE_SMALL_AP_UNO_SRW
 
+/*
+ * PTE flags to set cached and uncached areas.
+ * This will be determined at runtime.
+ */
 static uint32_t PTE_FLAGS_CACHED;
 static uint32_t PTE_FLAGS_UNCACHED;
 
+uint32_t mmu_get_pte_cached_flags()
+{
+	return PTE_FLAGS_CACHED;
+}
+
+uint32_t mmu_get_pte_uncached_flags()
+{
+	return PTE_FLAGS_UNCACHED;
+}
+
 #define PTE_MASK ((1 << 12) - 1)
 
 /*
@@ -93,7 +107,7 @@ static u32 *find_pte(unsigned long adr)
 	return &table[(adr >> PAGE_SHIFT) & 0xff];
 }
 
-static void remap_range(void *_start, size_t size, uint32_t flags)
+void remap_range(void *_start, size_t size, uint32_t flags)
 {
 	unsigned long start = (unsigned long)_start;
 	u32 *p;
@@ -294,8 +308,6 @@ void mmu_disable(void)
 	__mmu_cache_off();
 }
 
-#define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
-
 void *dma_alloc_coherent(size_t size)
 {
 	void *ret;
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index a66da8c..f32cea6 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -41,7 +41,10 @@ void dma_flush_range(unsigned long, unsigned long);
 void dma_inv_range(unsigned long, unsigned long);
 unsigned long virt_to_phys(void *virt);
 void *phys_to_virt(unsigned long phys);
+void remap_range(void *_start, size_t size, uint32_t flags);
 void *map_io_sections(unsigned long physaddr, void *start, size_t size);
+uint32_t mmu_get_pte_cached_flags(void);
+uint32_t mmu_get_pte_uncached_flags(void);
 
 #else
 static inline void *dma_alloc_coherent(size_t size)
@@ -76,11 +79,25 @@ static inline void dma_inv_range(unsigned long s, unsigned long e)
 {
 }
 
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
 static inline void *map_io_sections(unsigned long phys, void *start, size_t size)
 {
 	return (void *)phys;
 }
 
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	return 0;
+}
+
 #endif
 
 #ifdef CONFIG_CACHE_L2X0
diff --git a/arch/blackfin/include/asm/mmu.h b/arch/blackfin/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/blackfin/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/mips/include/asm/mmu.h b/arch/mips/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/mips/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/nios2/include/asm/mmu.h b/arch/nios2/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/nios2/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/openrisc/include/asm/mmu.h b/arch/openrisc/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/openrisc/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/ppc/include/asm/mmu.h b/arch/ppc/include/asm/mmu.h
index b2dd0b7..799653a 100644
--- a/arch/ppc/include/asm/mmu.h
+++ b/arch/ppc/include/asm/mmu.h
@@ -540,4 +540,19 @@ extern int write_bat(ppc_bat_t bat, unsigned long upper, unsigned long lower);
 					(rt<<21)|(ra<<16)|(ws<<11)|(946<<1)
 
 #endif
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
 #endif /* _PPC_MMU_H_ */
diff --git a/arch/sandbox/include/asm/mmu.h b/arch/sandbox/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/sandbox/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
new file mode 100644
index 0000000..71f671f
--- /dev/null
+++ b/arch/x86/include/asm/mmu.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_MMU_H
+#define __ASM_MMU_H
+
+static inline void remap_range(void *_start, size_t size, uint32_t flags)
+{
+}
+
+static inline uint32_t mmu_get_pte_cached_flags(void)
+{
+	    return 0;
+}
+
+static inline uint32_t mmu_get_pte_uncached_flags(void)
+{
+	    return 0;
+}
+
+#endif /* __ASM_MMU_H */
+
diff --git a/include/common.h b/include/common.h
index b1c96de..3e67164 100644
--- a/include/common.h
+++ b/include/common.h
@@ -225,6 +225,8 @@ int run_shell(void);
 
 #define PAGE_SIZE	4096
 #define PAGE_SHIFT	12
+#define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
+#define PAGE_ALIGN_DOWN(x) ((x) & ~(PAGE_SIZE - 1))
 
 int memory_display(char *addr, loff_t offs, ulong nbytes, int size, int swab);
 
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 6/9] memory: add function address_in_sdram_regions
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
                   ` (4 preceding siblings ...)
  2013-01-13 17:42 ` [PATCH 5/9] mmu: make remap_range global accessable Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-13 17:42 ` [PATCH 7/9] barebox-data: add barebox-data sections Alexander Aring
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Add function address_in_sdram_regions to check if a address
is in any sdram region.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 common/memory.c  | 13 +++++++++++++
 include/memory.h |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/common/memory.c b/common/memory.c
index 7dd1384..24dd0dd 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -158,6 +158,19 @@ int release_sdram_region(struct resource *res)
 	return release_region(res);
 }
 
+int address_in_sdram_regions(resource_size_t address)
+{
+	struct memory_bank *bank = NULL;
+	struct resource *r = NULL;
+
+	for_each_memory_bank(bank)
+		list_for_each_entry(r, &bank->res->children, sibling)
+			if (ADDRESS_IN_REGIONS(address, r->start, r->end))
+				return 1;
+
+	return 0;
+}
+
 #ifdef CONFIG_OFTREE
 
 /*
diff --git a/include/memory.h b/include/memory.h
index 165d2dc..e12a28d 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -27,4 +27,10 @@ struct resource *request_sdram_region(const char *name, resource_size_t start,
 		resource_size_t size);
 int release_sdram_region(struct resource *res);
 
+#define ADDRESS_IN_REGIONS(address, region_start, region_end) \
+	((address >= region_start) && \
+	 (address <= region_end))
+
+int address_in_sdram_regions(resource_size_t address);
+
 #endif
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 7/9] barebox-data: add barebox-data sections
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
                   ` (5 preceding siblings ...)
  2013-01-13 17:42 ` [PATCH 6/9] memory: add function address_in_sdram_regions Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-14  9:51   ` Sascha Hauer
  2013-01-13 17:42 ` [PATCH 8/9] memtest: remove memtest command Alexander Aring
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Add barebox-data section in arm branch to get complete
barebox regions in sdram regions tree.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 arch/arm/lib/barebox.lds.S                       | 6 +++++-
 arch/blackfin/boards/ipe337/barebox.lds.S        | 6 +++++-
 arch/mips/lib/barebox.lds.S                      | 5 ++++-
 arch/nios2/cpu/barebox.lds.S                     | 5 +++--
 arch/ppc/boards/freescale-p2020rdb/barebox.lds.S | 6 ++++--
 arch/ppc/boards/pcm030/barebox.lds.S             | 5 +++--
 arch/x86/lib/barebox.lds.S                       | 5 ++++-
 common/memory.c                                  | 4 ++++
 include/asm-generic/sections.h                   | 1 +
 9 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index bac1a04..6cad804 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -65,7 +65,9 @@ SECTIONS
 		__stop_unwind_tab = .;
 	}
 #endif
-	_etext = .;			/* End of text and rodata section */
+	_etext = . - 1;			/* End of text and rodata section */
+
+	_sdata = .;
 
 	. = ALIGN(4);
 	.data : { *(.data*) }
@@ -87,6 +89,8 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	__usymtab_end = .;
 
+	_edata = . - 1;
+
 	. = ALIGN(4);
 	__bss_start = .;
 	.bss : { *(.bss*) }
diff --git a/arch/blackfin/boards/ipe337/barebox.lds.S b/arch/blackfin/boards/ipe337/barebox.lds.S
index 6a07b43..29f5d9e 100644
--- a/arch/blackfin/boards/ipe337/barebox.lds.S
+++ b/arch/blackfin/boards/ipe337/barebox.lds.S
@@ -54,7 +54,9 @@ SECTIONS
 	. = ALIGN(4);
 	.rodata : { *(.rodata) }
 
-	__etext = .;			/* End of text and rodata section */
+	__etext = . - 1;	/* End of text and rodata section */
+
+	_sdata = .;
 
 	. = ALIGN(4);
 	.data : { *(.data) }
@@ -79,6 +81,8 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	___usymtab_end = .;
 
+	_edata - . -1;
+
 	. = ALIGN(4);
 	___bss_start = .;
 	.bss : { *(.bss) }
diff --git a/arch/mips/lib/barebox.lds.S b/arch/mips/lib/barebox.lds.S
index 0cbf2d7..6f05513 100644
--- a/arch/mips/lib/barebox.lds.S
+++ b/arch/mips/lib/barebox.lds.S
@@ -43,7 +43,8 @@ SECTIONS
 	. = ALIGN(4);
 	.rodata : { *(.rodata*) }
 
-	_etext = .;			/* End of text and rodata section */
+	_etext = . - 1;			/* End of text and rodata section */
+	_sdata = .;
 
 	. = ALIGN(4);
 	.data : { *(.data*) }
@@ -68,6 +69,8 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	__usymtab_end = .;
 
+	_edata = . - 1;
+
 	. = ALIGN(4);
 	__bss_start = .;
 	.bss : { *(.bss*) }
diff --git a/arch/nios2/cpu/barebox.lds.S b/arch/nios2/cpu/barebox.lds.S
index af7be4d..ac4cc8a 100644
--- a/arch/nios2/cpu/barebox.lds.S
+++ b/arch/nios2/cpu/barebox.lds.S
@@ -67,13 +67,14 @@ SECTIONS
 	__usymtab : { BAREBOX_SYMS }
 	___usymtab_end = .;
 
-	_etext = .; /* End of text and rodata section */
+	_etext = . - 1; /* End of text and rodata section */
 
 	/* INIT DATA sections - "Small" data (see the gcc -G option)
 	 * is always gp-relative. Here we make all init data sections
 	 * adjacent to simplify the startup code -- and provide
 	 * the global pointer for gp-relative access.
 	 */
+	_sdata = .;
 	_data = .;
 	.data :
 	{
@@ -94,7 +95,7 @@ SECTIONS
 	}
 	. = ALIGN(4);
 
-	_edata = .;
+	_edata = . - 1;
 	PROVIDE (edata = .);
 
 	/* UNINIT DATA - Small uninitialized data is first so it's
diff --git a/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S b/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S
index 95033d4..e9b0679 100644
--- a/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S
+++ b/arch/ppc/boards/freescale-p2020rdb/barebox.lds.S
@@ -39,7 +39,9 @@ SECTIONS
     *(.text*)
   } :text
 
-  _etext = .;
+  _etext = . - 1;
+
+  _sdata = .;
   PROVIDE (etext = .);
 
   .rodata    :
@@ -74,7 +76,7 @@ SECTIONS
     *(.dynamic*)
     CONSTRUCTORS
   }
-  _edata  =  .;
+  _edata  =  . - 1;
   PROVIDE (edata = .);
 
   . = .;
diff --git a/arch/ppc/boards/pcm030/barebox.lds.S b/arch/ppc/boards/pcm030/barebox.lds.S
index cc86d82..bfc646b 100644
--- a/arch/ppc/boards/pcm030/barebox.lds.S
+++ b/arch/ppc/boards/pcm030/barebox.lds.S
@@ -67,7 +67,8 @@ SECTIONS
 
   /* Read-write section, merged into data segment: */
   . = (. + 0x0FFF) & 0xFFFFF000;
-  _etext = .;
+  _etext = . - 1;
+  _sdata = .;
   PROVIDE (erotext = .);
   .reloc   :
   {
@@ -90,7 +91,7 @@ SECTIONS
     *(.dynamic*)
     CONSTRUCTORS
   }
-  _edata  =  .;
+  _edata  =  . - 1;
   PROVIDE (edata = .);
 
   . = .;
diff --git a/arch/x86/lib/barebox.lds.S b/arch/x86/lib/barebox.lds.S
index 8bd2a7b..5826fb2 100644
--- a/arch/x86/lib/barebox.lds.S
+++ b/arch/x86/lib/barebox.lds.S
@@ -149,7 +149,8 @@ SECTIONS
 		. = ALIGN(4);
 		*(.rodata*)
 		. = ALIGN(4);
-		_etext = .;			/* End of text and rodata section */
+		_etext = . - 1;	/* End of text and rodata section */
+		_sdata = .;
 	} > barebox
 	BAREBOX_BARE_INIT_SIZE
 
@@ -191,6 +192,8 @@ SECTIONS
 		. = ALIGN(4);
 	} > barebox
 
+	_edata = . - 1;
+
 	.bss : {
 		__bss_start = .;
 		*(.bss*);
diff --git a/common/memory.c b/common/memory.c
index 24dd0dd..1748d78 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -75,6 +75,10 @@ static int mem_malloc_resource(void)
 			(unsigned long)&_stext,
 			(unsigned long)&_etext -
 			(unsigned long)&_stext);
+	request_sdram_region("barebox data",
+			(unsigned long)&_sdata,
+			(unsigned long)&_edata -
+			(unsigned long)&_sdata);
 	request_sdram_region("bss",
 			(unsigned long)&__bss_start,
 			(unsigned long)&__bss_stop -
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 17d5fd1..5492aa4 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -3,6 +3,7 @@
 
 extern char _text[], _stext[], _etext[];
 extern char __bss_start[], __bss_stop[];
+extern char _sdata[], _edata[];
 extern char __bare_init_start[], __bare_init_end[];
 extern char _end[];
 extern void *_barebox_image_size;
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 8/9] memtest: remove memtest command
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
                   ` (6 preceding siblings ...)
  2013-01-13 17:42 ` [PATCH 7/9] barebox-data: add barebox-data sections Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-13 17:42 ` [PATCH 9/9] memtest: add rewritten " Alexander Aring
  2013-01-14 13:11 ` [PATCH 0/9] reimplement " Sascha Hauer
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Remove memtest command.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 commands/Kconfig   |   9 --
 commands/Makefile  |   1 -
 commands/memtest.c | 351 -----------------------------------------------------
 3 files changed, 361 deletions(-)
 delete mode 100644 commands/memtest.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 53cee5c..fc0e448 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -496,15 +496,6 @@ config CMD_NANDTEST
 	select PARTITION_NEED_MTD
 	prompt "nandtest"
 
-config CMD_MTEST
-	tristate
-	prompt "mtest"
-
-config CMD_MTEST_ALTERNATIVE
-	bool
-	depends on CMD_MTEST
-	prompt "alternative mtest implementation"
-
 endmenu
 
 menu "video command"
diff --git a/commands/Makefile b/commands/Makefile
index 359f566..3145685 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -7,7 +7,6 @@ obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
-obj-$(CONFIG_CMD_MTEST)		+= memtest.o
 obj-$(CONFIG_CMD_EDIT)		+= edit.o
 obj-$(CONFIG_CMD_EXEC)		+= exec.o
 obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
diff --git a/commands/memtest.c b/commands/memtest.c
deleted file mode 100644
index 2d64d00..0000000
--- a/commands/memtest.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * mtest - Perform a memory test
- *
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- */
-
-#include <common.h>
-#include <command.h>
-#include <types.h>
-
-/*
- * Perform a memory test. A more complete alternative test can be
- * configured using CONFIG_CMD_MTEST_ALTERNATIVE. The complete test
- * loops until interrupted by ctrl-c or by a failure of one of the
- * sub-tests.
- */
-#ifdef CONFIG_CMD_MTEST_ALTERNATIVE
-static int mem_test(ulong _start, ulong _end, ulong pattern_unused)
-{
-	vu_long *start = (vu_long *)_start;
-	vu_long *end   = (vu_long *)_end;
-	vu_long *addr;
-	ulong	val;
-	ulong	readback;
-	vu_long	addr_mask;
-	vu_long	offset;
-	vu_long	test_offset;
-	vu_long	pattern;
-	vu_long	temp;
-	vu_long	anti_pattern;
-	vu_long	num_words;
-#ifdef CFG_MEMTEST_SCRATCH
-	vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH;
-#else
-	vu_long *dummy = start;
-#endif
-	int	j;
-	int iterations = 1;
-
-	static const ulong bitpattern[] = {
-		0x00000001,	/* single bit */
-		0x00000003,	/* two adjacent bits */
-		0x00000007,	/* three adjacent bits */
-		0x0000000F,	/* four adjacent bits */
-		0x00000005,	/* two non-adjacent bits */
-		0x00000015,	/* three non-adjacent bits */
-		0x00000055,	/* four non-adjacent bits */
-		0xaaaaaaaa,	/* alternating 1/0 */
-	};
-
-	/* XXX: enforce alignment of start and end? */
-	for (;;) {
-		if (ctrlc()) {
-			putchar ('\n');
-			return 1;
-		}
-
-		printf("Iteration: %6d\r", iterations);
-		iterations++;
-
-		/*
-		 * Data line test: write a pattern to the first
-		 * location, write the 1's complement to a 'parking'
-		 * address (changes the state of the data bus so a
-		 * floating bus doen't give a false OK), and then
-		 * read the value back. Note that we read it back
-		 * into a variable because the next time we read it,
-		 * it might be right (been there, tough to explain to
-		 * the quality guys why it prints a failure when the
-		 * "is" and "should be" are obviously the same in the
-		 * error message).
-		 *
-		 * Rather than exhaustively testing, we test some
-		 * patterns by shifting '1' bits through a field of
-		 * '0's and '0' bits through a field of '1's (i.e.
-		 * pattern and ~pattern).
-		 */
-		addr = start;
-		/* XXX */
-		if (addr == dummy) ++addr;
-		for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) {
-		    val = bitpattern[j];
-		    for(; val != 0; val <<= 1) {
-			*addr  = val;
-			*dummy  = ~val; /* clear the test data off of the bus */
-			readback = *addr;
-			if(readback != val) {
-			     printf ("FAILURE (data line): "
-				"expected 0x%08lx, actual 0x%08lx at address 0x%p\n",
-					  val, readback, addr);
-			}
-			*addr  = ~val;
-			*dummy  = val;
-			readback = *addr;
-			if(readback != ~val) {
-			    printf ("FAILURE (data line): "
-				"Is 0x%08lx, should be 0x%08lx at address 0x%p\n",
-					readback, ~val, addr);
-			}
-		    }
-		}
-
-		/*
-		 * Based on code whose Original Author and Copyright
-		 * information follows: Copyright (c) 1998 by Michael
-		 * Barr. This software is placed into the public
-		 * domain and may be used for any purpose. However,
-		 * this notice must not be changed or removed and no
-		 * warranty is either expressed or implied by its
-		 * publication or distribution.
-		 */
-
-		/*
-		 * Address line test
-		 *
-		 * Description: Test the address bus wiring in a
-		 *              memory region by performing a walking
-		 *              1's test on the relevant bits of the
-		 *              address and checking for aliasing.
-		 *              This test will find single-bit
-		 *              address failures such as stuck -high,
-		 *              stuck-low, and shorted pins. The base
-		 *              address and size of the region are
-		 *              selected by the caller.
-		 *
-		 * Notes:	For best results, the selected base
-		 *              address should have enough LSB 0's to
-		 *              guarantee single address bit changes.
-		 *              For example, to test a 64-Kbyte
-		 *              region, select a base address on a
-		 *              64-Kbyte boundary. Also, select the
-		 *              region size as a power-of-two if at
-		 *              all possible.
-		 *
-		 * Returns:     0 if the test succeeds, 1 if the test fails.
-		 *
-		 * ## NOTE ##	Be sure to specify start and end
-		 *              addresses such that addr_mask has
-		 *              lots of bits set. For example an
-		 *              address range of 01000000 02000000 is
-		 *              bad while a range of 01000000
-		 *              01ffffff is perfect.
-		 */
-		addr_mask = ((ulong)end - (ulong)start)/sizeof(vu_long);
-		pattern = (vu_long) 0xaaaaaaaa;
-		anti_pattern = (vu_long) 0x55555555;
-
-		debug("%s:%d: addr mask = 0x%.8lx\n",
-			__FUNCTION__, __LINE__,
-			addr_mask);
-		/*
-		 * Write the default pattern at each of the
-		 * power-of-two offsets.
-		 */
-		for (offset = 1; (offset & addr_mask) != 0; offset <<= 1)
-			start[offset] = pattern;
-
-		/*
-		 * Check for address bits stuck high.
-		 */
-		test_offset = 0;
-		start[test_offset] = anti_pattern;
-
-		for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
-		    temp = start[offset];
-		    if (temp != pattern) {
-			printf ("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
-				" expected 0x%.8lx, actual 0x%.8lx\n",
-				(ulong)&start[offset], pattern, temp);
-			return 1;
-		    }
-		}
-		start[test_offset] = pattern;
-
-		/*
-		 * Check for addr bits stuck low or shorted.
-		 */
-		for (test_offset = 1; (test_offset & addr_mask) != 0; test_offset <<= 1) {
-		    start[test_offset] = anti_pattern;
-
-		    for (offset = 1; (offset & addr_mask) != 0; offset <<= 1) {
-			temp = start[offset];
-			if ((temp != pattern) && (offset != test_offset)) {
-			    printf ("\nFAILURE: Address bit stuck low or shorted @"
-				" 0x%.8lx: expected 0x%.8lx, actual 0x%.8lx\n",
-				(ulong)&start[offset], pattern, temp);
-			    return 1;
-			}
-		    }
-		    start[test_offset] = pattern;
-		}
-
-		/*
-		 * Description: Test the integrity of a physical
-		 *		memory device by performing an
-		 *		increment/decrement test over the
-		 *		entire region. In the process every
-		 *		storage bit in the device is tested
-		 *		as a zero and a one. The base address
-		 *		and the size of the region are
-		 *		selected by the caller.
-		 *
-		 * Returns:     0 if the test succeeds, 1 if the test fails.
-		 */
-		num_words = ((ulong)end - (ulong)start)/sizeof(vu_long) + 1;
-
-		/*
-		 * Fill memory with a known pattern.
-		 */
-		for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-			start[offset] = pattern;
-		}
-
-		/*
-		 * Check each location and invert it for the second pass.
-		 */
-		for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-		    temp = start[offset];
-		    if (temp != pattern) {
-			printf ("\nFAILURE (read/write) @ 0x%.8lx:"
-				" expected 0x%.8lx, actual 0x%.8lx)\n",
-				(ulong)&start[offset], pattern, temp);
-			return 1;
-		    }
-
-		    anti_pattern = ~pattern;
-		    start[offset] = anti_pattern;
-		}
-
-		/*
-		 * Check each location for the inverted pattern and zero it.
-		 */
-		for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-		    anti_pattern = ~pattern;
-		    temp = start[offset];
-		    if (temp != anti_pattern) {
-			printf ("\nFAILURE (read/write): @ 0x%.8lx:"
-				" expected 0x%.8lx, actual 0x%.8lx)\n",
-				(ulong)&start[offset], anti_pattern, temp);
-			return 1;
-		    }
-		    start[offset] = 0;
-		}
-	}
-
-}
-#else
-static int mem_test(ulong _start, ulong _end, ulong pattern)
-{
-	vu_long	*addr;
-	vu_long *start = (vu_long *)_start;
-	vu_long *end   = (vu_long *)_end;
-	ulong	val;
-	ulong	readback;
-	ulong	incr;
-	int rcode;
-
-	incr = 1;
-	for (;;) {
-		if (ctrlc()) {
-			putchar('\n');
-			return 1;
-		}
-
-		printf ("\rPattern 0x%08lX  Writing..."
-			"%12s"
-			"\b\b\b\b\b\b\b\b\b\b",
-			pattern, "");
-
-		for (addr=start,val=pattern; addr<end; addr++) {
-			*addr = val;
-			val  += incr;
-		}
-
-		puts ("Reading...");
-
-		for (addr=start,val=pattern; addr<end; addr++) {
-			readback = *addr;
-			if (readback != val) {
-				printf ("\nMem error @ 0x%08X: "
-					"found 0x%08lX, expected 0x%08lX\n",
-					(uint)addr, readback, val);
-				rcode = 1;
-			}
-			val += incr;
-		}
-
-		/*
-		 * Flip the pattern each time to make lots of zeros and
-		 * then, the next time, lots of ones.  We decrement
-		 * the "negative" patterns and increment the "positive"
-		 * patterns to preserve this feature.
-		 */
-		if(pattern & 0x80000000) {
-			pattern = -pattern;	/* complement & increment */
-		}
-		else {
-			pattern = ~pattern;
-		}
-		incr = -incr;
-	}
-	return rcode;
-}
-#endif
-
-static int do_mem_mtest(int argc, char *argv[])
-{
-	ulong start, end, pattern = 0;
-
-	if (argc < 3)
-		return COMMAND_ERROR_USAGE;
-
-	start = simple_strtoul(argv[1], NULL, 0);
-	end = simple_strtoul(argv[2], NULL, 0);
-
-	if (argc > 3)
-		pattern = simple_strtoul(argv[3], NULL, 0);
-
-	printf ("Testing 0x%08x ... 0x%08x:\n", (uint)start, (uint)end);
-	
-	return mem_test(start, end, pattern);
-}
-
-static const __maybe_unused char cmd_mtest_help[] =
-"Usage: <start> <end> "
-#ifdef CONFIG_CMD_MTEST_ALTERNATIVE
-"[pattern]"
-#endif
-"\nsimple RAM read/write test\n";
-
-BAREBOX_CMD_START(mtest)
-	.cmd		= do_mem_mtest,
-	.usage		= "simple RAM test",
-	BAREBOX_CMD_HELP(cmd_mtest_help)
-BAREBOX_CMD_END
-
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 9/9] memtest: add rewritten memtest command
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
                   ` (7 preceding siblings ...)
  2013-01-13 17:42 ` [PATCH 8/9] memtest: remove memtest command Alexander Aring
@ 2013-01-13 17:42 ` Alexander Aring
  2013-01-14 13:11 ` [PATCH 0/9] reimplement " Sascha Hauer
  9 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-13 17:42 UTC (permalink / raw)
  To: barebox; +Cc: marc

Rewrite memtest command:
	- Skip barebox sdram regions.
	- Uncache unused mem regions while testing.
	- Add iteration parameter.
	- Add parameter to do only bus testing.
	- Check start and end addresses.
	- Testing all banks if no start and end
	  address are given.

	- Add sha changes (thanks):
	- fix calculation of regions to test. When we use PAGE_ALIGN on
	  size, size can be to high.
	  - start address has to be aligned up
	  - end address has to be aligned down
	  - then size can be calculated as end - start + 1
	- Add ctrlc() to the longer loops
	- Add a progress bar to give some visual feedback that something
	  issues
	  still going on.

	- Change to use end element instead of size in region struct.
	- Fix some newline issues.

	- Add '-c' parameter if CONFIG_MMU enabled
	  to test with enabled cache.
	- Fix some size calculation.
	- set start address to 0xffffffff

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 commands/Kconfig   |   9 +
 commands/Makefile  |   1 +
 commands/memtest.c | 696 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 706 insertions(+)
 create mode 100644 commands/memtest.c

diff --git a/commands/Kconfig b/commands/Kconfig
index fc0e448..f027a7e 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -496,6 +496,15 @@ config CMD_NANDTEST
 	select PARTITION_NEED_MTD
 	prompt "nandtest"
 
+config CMD_MEMTEST
+    tristate
+    prompt "memtest"
+	help
+	  This command enables a memtest to test installed memory.
+	  During this test allocated iomem regions will be skipped.
+	  If tested architecture has MMU with PTE flags support,
+	  caching can be set enabled or disabled.
+
 endmenu
 
 menu "video command"
diff --git a/commands/Makefile b/commands/Makefile
index 3145685..6b4d9cb 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_CMD_LOADY)		+= loadxy.o
 obj-$(CONFIG_CMD_LOADS)		+= loads.o
 obj-$(CONFIG_CMD_ECHO)		+= echo.o
 obj-$(CONFIG_CMD_MEMORY)	+= mem.o
+obj-$(CONFIG_CMD_MEMTEST)   += memtest.o
 obj-$(CONFIG_CMD_EDIT)		+= edit.o
 obj-$(CONFIG_CMD_EXEC)		+= exec.o
 obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
diff --git a/commands/memtest.c b/commands/memtest.c
new file mode 100644
index 0000000..33aa7e0
--- /dev/null
+++ b/commands/memtest.c
@@ -0,0 +1,696 @@
+/*
+ * memtest - Perform a memory test
+ *
+ * (C) Copyright 2013
+ * Alexander Aring <a.aring@gmail.com>
+ *
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <types.h>
+#include <getopt.h>
+#include <memory.h>
+#include <errno.h>
+#include <progress.h>
+#include <asm/mmu.h>
+
+/*
+ * PTE flags variables to set cached and
+ * uncached regions.
+ */
+static uint32_t PTE_FLAGS_CACHED;
+static uint32_t PTE_FLAGS_UNCACHED;
+
+static const vu_long bitpattern[] = {
+	0x00000001,	/* single bit */
+	0x00000003,	/* two adjacent bits */
+	0x00000007,	/* three adjacent bits */
+	0x0000000F,	/* four adjacent bits */
+	0x00000005,	/* two non-adjacent bits */
+	0x00000015,	/* three non-adjacent bits */
+	0x00000055,	/* four non-adjacent bits */
+	0xAAAAAAAA,	/* alternating 1/0 */
+};
+
+/*
+ * In CONFIG_MMU we have a special c flag.
+ */
+#ifdef CONFIG_MMU
+static char optstr[] = "s:e:i:cb";
+#else
+static char optstr[] = "s:e:i:b";
+#endif
+
+/*
+ * Perform a memory test. The complete test
+ * loops until interrupted by ctrl-c.
+ */
+static int mem_test(vu_long _start, vu_long _end,
+		int bus_only)
+{
+	vu_long *start = (vu_long *)_start;
+	/* Point the dummy to start[1] */
+	vu_long *dummy = start+1;
+
+	vu_long val;
+	vu_long readback;
+	vu_long offset;
+	vu_long pattern;
+	vu_long test_offset;
+	vu_long temp;
+	vu_long anti_pattern;
+	vu_long num_words;
+
+	int i;
+	int ret;
+
+	if (!IS_ALIGNED(_end - _start + 1, sizeof(vu_long))) {
+		printf("Testing memarea size (0x%08lx) not a multiple"
+				"of size 0x%x, please change start or end address.",
+				_end - _start + 1, sizeof(vu_long));
+		return -1;
+	}
+
+	num_words = (_end - _start + 1)/sizeof(vu_long);
+
+	printf("Starting data line test.\n");
+
+	/*
+	 * Data line test: write a pattern to the first
+	 * location, write the 1's complement to a 'parking'
+	 * address (changes the state of the data bus so a
+	 * floating bus doen't give a false OK), and then
+	 * read the value back. Note that we read it back
+	 * into a variable because the next time we read it,
+	 * it might be right (been there, tough to explain to
+	 * the quality guys why it prints a failure when the
+	 * "is" and "should be" are obviously the same in the
+	 * error message).
+	 *
+	 * Rather than exhaustively testing, we test some
+	 * patterns by shifting '1' bits through a field of
+	 * '0's and '0' bits through a field of '1's (i.e.
+	 * pattern and ~pattern).
+	 */
+	for (i = 0; i < sizeof(bitpattern)/
+			sizeof(bitpattern[0]); i++) {
+		ret = address_in_sdram_regions((vu_long)start);
+		if (ret) {
+			printf("WARNING (data line): "
+					"address 0x%08lx is in sdram regions.\n"
+					"Will skip this memory address.\n",
+					(vu_long)start);
+			break;
+		}
+
+		ret = address_in_sdram_regions((vu_long)dummy);
+		if (ret) {
+			printf("WARNING (data line): "
+					"address 0x%08lx is in sdram regions.\n"
+					"Will skip this memory address.\n",
+					(vu_long)dummy);
+			break;
+		}
+
+		val = bitpattern[i];
+
+		for (; val != 0; val <<= 1) {
+			*start = val;
+			/* clear the test data off of the bus */
+			*dummy = ~val;
+			readback = *start;
+
+			if (readback != val) {
+				printf("FAILURE (data line): "
+					"expected 0x%08lx, actual 0x%08lx at address 0x%08lx.\n",
+					val, readback, (vu_long)start);
+				return -1;
+			}
+
+			*start = ~val;
+			*dummy = val;
+			readback = *start;
+			if (readback != ~val) {
+				printf("FAILURE (data line): "
+					"Is 0x%08lx, should be 0x%08lx at address 0x%08lx.\n",
+					readback,
+					~val, (vu_long)start);
+				return -1;
+			}
+		}
+	}
+
+
+	/*
+	 * Based on code whose Original Author and Copyright
+	 * information follows: Copyright (c) 1998 by Michael
+	 * Barr. This software is placed into the public
+	 * domain and may be used for any purpose. However,
+	 * this notice must not be changed or removed and no
+	 * warranty is either expressed or implied by its
+	 * publication or distribution.
+	 */
+
+	/*
+	 * Address line test
+	 *
+	 * Description: Test the address bus wiring in a
+	 *              memory region by performing a walking
+	 *              1's test on the relevant bits of the
+	 *              address and checking for aliasing.
+	 *              This test will find single-bit
+	 *              address failures such as stuck -high,
+	 *              stuck-low, and shorted pins. The base
+	 *              address and size of the region are
+	 *              selected by the caller.
+	 *
+	 * Notes:	For best results, the selected base
+	 *              address should have enough LSB 0's to
+	 *              guarantee single address bit changes.
+	 *              For example, to test a 64-Kbyte
+	 *              region, select a base address on a
+	 *              64-Kbyte boundary. Also, select the
+	 *              region size as a power-of-two if at
+	 *              all possible.
+	 *
+	 * ## NOTE ##	Be sure to specify start and end
+	 *              addresses such that num_words has
+	 *              lots of bits set. For example an
+	 *              address range of 01000000 02000000 is
+	 *              bad while a range of 01000000
+	 *              01ffffff is perfect.
+	 */
+
+	pattern = 0xAAAAAAAA;
+	anti_pattern = 0x55555555;
+
+	/*
+	 * Write the default pattern at each of the
+	 * power-of-two offsets.
+	 */
+	for (offset = 1; (offset & num_words) != 0; offset <<= 1) {
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret) {
+			printf("WARNING (stuck high): "
+					"address 0x%08lx is in sdram regions.\n",
+					(vu_long)&start[offset]);
+			continue;
+		}
+
+		start[offset] = pattern;
+	}
+
+	printf("Check for address bits stuck high.\n");
+
+	/*
+	 * Check for address bits stuck high.
+	 */
+	test_offset = 0;
+
+	ret = address_in_sdram_regions((vu_long)&start[test_offset]);
+	if (ret)
+		printf("WARNING (stuck high): "
+				"address 0x%08lx is in sdram regions.\n",
+				(vu_long)&start[test_offset]);
+	else
+		start[test_offset] = anti_pattern;
+
+	for (offset = 1; (offset & num_words) != 0; offset <<= 1) {
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret) {
+			printf("WARNING (stuck high): "
+					"address 0x%08lx is in sdram regions.\n",
+					(vu_long)&start[offset]);
+			continue;
+		}
+
+		temp = start[offset];
+
+		if (temp != pattern) {
+			printf("FAILURE: Address bit "
+					"stuck high @ 0x%08lx:"
+					" expected 0x%08lx, actual 0x%08lx.\n",
+					(vu_long)&start[offset],
+					pattern, temp);
+			return -1;
+		}
+	}
+
+	ret = address_in_sdram_regions((vu_long)&start[test_offset]);
+	if (ret)
+		printf("WARNING (stuck high): "
+				"address 0x%08lx is in sdram regions.\n",
+				(vu_long)&start[test_offset]);
+	else
+		start[test_offset] = pattern;
+
+	printf("Check for address bits stuck "
+			"low or shorted.");
+
+	/*
+	 * Check for address bits stuck low or shorted.
+	 */
+	for (test_offset = 1;
+			(test_offset & num_words) != 0;
+			test_offset <<= 1) {
+		ret = address_in_sdram_regions(
+				(vu_long)&start[test_offset]);
+		if (ret) {
+			printf("\nWARNING (low high): "
+					"address 0x%08lx is in barebox regions.\n",
+					(vu_long)&start[test_offset]);
+			continue;
+		}
+
+		start[test_offset] = anti_pattern;
+
+		for (offset = 1; (offset & num_words) != 0; offset <<= 1) {
+			ret = address_in_sdram_regions(
+					(vu_long)&start[offset]);
+			if (ret) {
+				printf("\nWARNING (low high): "
+					"address 0x%08lx is in barebox regions.\n",
+					(vu_long)&start[test_offset]);
+				continue;
+			}
+
+			temp = start[offset];
+
+			if ((temp != pattern) &&
+					(offset != test_offset)) {
+				printf("\nFAILURE: Address bit stuck"
+						" low or shorted @"
+						" 0x%08lx: expected 0x%08lx, actual 0x%08lx.\n",
+						(vu_long)&start[offset],
+						pattern, temp);
+				return -1;
+			}
+		}
+		start[test_offset] = pattern;
+	}
+
+	/* We tested only the bus if != 0
+	 * leaving here */
+	if (bus_only)
+		return 0;
+
+	printf("\nStarting integrity check of physicaly ram.\n"
+			"Filling ram with patterns...\n");
+
+	/*
+	 * Description: Test the integrity of a physical
+	 *		memory device by performing an
+	 *		increment/decrement test over the
+	 *		entire region. In the process every
+	 *		storage bit in the device is tested
+	 *		as a zero and a one. The base address
+	 *		and the size of the region are
+	 *		selected by the caller.
+	 */
+
+	/*
+	 * Fill memory with a known pattern.
+	 */
+	init_progression_bar(num_words);
+	for (offset = 0; offset < num_words; offset++) {
+		if (!(offset & 0xfff)) {
+			if (ctrlc())
+				return -EINTR;
+			show_progress(offset);
+		}
+
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret)
+			continue;
+
+		start[offset] = offset + 1;
+	}
+
+	show_progress(offset);
+
+	printf("\nCompare written patterns...\n");
+
+	/*
+	 * Check each location and invert it for the second pass.
+	 */
+	init_progression_bar(num_words - 1);
+	for (offset = 0; offset < num_words; offset++) {
+		if (!(offset & 0xfff)) {
+			if (ctrlc())
+				return -EINTR;
+			show_progress(offset);
+		}
+
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		if (ret)
+			continue;
+
+		temp = start[offset];
+		if (temp != (offset + 1)) {
+			printf("\nFAILURE (read/write) @ 0x%08lx:"
+					" expected 0x%08lx, actual 0x%08lx.\n",
+					(vu_long)&start[offset],
+					(offset + 1), temp);
+			return -1;
+		}
+
+		anti_pattern = ~(offset + 1);
+		start[offset] = anti_pattern;
+	}
+
+	show_progress(offset);
+
+	printf("\nFilling ram with inverted pattern and compare it...\n");
+
+	/*
+	 * Check each location for the inverted pattern and zero it.
+	 */
+	init_progression_bar(num_words - 1);
+	for (offset = 0; offset < num_words; offset++) {
+		if (!(offset & 0xfff)) {
+			if (ctrlc())
+				return -EINTR;
+			show_progress(offset);
+		}
+
+		ret = address_in_sdram_regions((vu_long)&start[offset]);
+		/* Step over barebox mem usage */
+		if (ret)
+			continue;
+
+		anti_pattern = ~(offset + 1);
+		temp = start[offset];
+
+		if (temp != anti_pattern) {
+			printf("\nFAILURE (read/write): @ 0x%08lx:"
+					" expected 0x%08lx, actual 0x%08lx.\n",
+					(vu_long)&start[offset],
+					anti_pattern, temp);
+			return -1;
+		}
+
+		start[offset] = 0;
+	}
+
+	show_progress(offset);
+
+	return 0;
+}
+
+#ifdef CONFIG_MMU
+static void print_region(vu_long start, vu_long size, uint32_t flags)
+{
+	if (!size)
+		return;
+
+	if (flags == PTE_FLAGS_UNCACHED) {
+		printf("Set non caching region at 0x%08lx - "
+				"0x%08lx size 0x%08lx.\n",
+				start, start + size - 1, size);
+		return;
+	}
+
+	if (flags == PTE_FLAGS_CACHED)
+		printf("Set caching region at 0x%08lx - "
+				"0x%08lx size 0x%08lx.\n",
+				start, start + size - 1, size);
+}
+
+static void do_remap_range(struct memory_bank *bank, uint32_t flags)
+{
+	struct resource *r = NULL;
+	struct resource *r_prev = NULL;
+
+	vu_long size;
+	vu_long start;
+	vu_long end;
+
+	/* We assume that the regions are sorted in this list */
+	list_for_each_entry(r, &bank->res->children, sibling) {
+		/* Do on head element for bank boundary */
+		if (r->sibling.prev == &bank->res->children) {
+			/* remember last used element */
+			r_prev = r;
+
+			start = PAGE_ALIGN(bank->start);
+			end = PAGE_ALIGN_DOWN(r->start) - 1;
+			if (start >= end)
+				continue;
+			size = end - start + 1;
+
+			print_region(start, size, flags);
+			remap_range((void *)start, size, flags);
+
+			continue;
+		}
+		/* Between used regions */
+		start = PAGE_ALIGN(r_prev->end);
+		end = PAGE_ALIGN_DOWN(r->start) - 1;
+		if (start < end) {
+			size = end - start + 1;
+			print_region(start, size, flags);
+			remap_range((void *)start, size, flags);
+		}
+
+		r_prev = r;
+		/* Do on head element for bank boundary */
+		if (list_is_last(&r->sibling, &bank->res->children)) {
+			start = PAGE_ALIGN(r->end);
+			end = PAGE_ALIGN_DOWN(bank->start + bank->size) - 1;
+			if (start >= end)
+				continue;
+			size = end - start + 1;
+
+			print_region(start, size, flags);
+			remap_range((void *)start, size, flags);
+		}
+	}
+}
+#endif
+
+static int do_mem_memtest(int argc, char *argv[])
+{
+	/* Set start address to 0xffffffff which
+	 * can't be. */
+	vu_long start = 0xffffffff;
+	vu_long end = 0;
+
+	uint i;
+	uint max_i = 1;
+
+#ifdef CONFIG_MMU
+	int cache = 0;
+#endif
+	int bus_only = 0;
+	int err = 0;
+	int cnt = 0;
+	int opt;
+
+	struct memory_bank *bank = NULL;
+	struct resource *r = NULL;
+
+	while ((opt = getopt(argc, argv, optstr)) > 0) {
+		switch (opt) {
+		case 's':
+			start = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'e':
+			end = simple_strtoul(optarg, NULL, 0);
+			break;
+		case 'i':
+			max_i = simple_strtoul(optarg, NULL, 0);
+			break;
+#ifdef CONFIG_MMU
+		case 'c':
+			cache = 1;
+			break;
+#endif
+		case 'b':
+			bus_only = 1;
+			break;
+		default:
+			return COMMAND_ERROR_USAGE;
+		}
+	}
+
+	if (optind > argc)
+		return COMMAND_ERROR_USAGE;
+
+	/* Error if no end address */
+	if (start != 0xffffffff && !end) {
+		printf("Please add an end address.\n");
+		return 1;
+	}
+
+	/* Error if no start address */
+	if (end && start == 0xffffffff) {
+		printf("Please add a start address.\n");
+		return 1;
+	}
+
+	/* Check parameters */
+	if (end && start != 0xffffffff) {
+		if (end <= start) {
+			printf("End address less than or"
+					" equal start address.\n");
+			return 1;
+		}
+
+		/* Check if given start and end address are in any banks */
+		for_each_memory_bank(bank) {
+			if (ADDRESS_IN_REGIONS(start, bank->start,
+						bank->start + bank->size))
+				cnt++;
+
+			if (ADDRESS_IN_REGIONS(end, bank->start,
+						bank->start + bank->size))
+				cnt++;
+		}
+
+		if (cnt != 2) {
+			printf("Start or end addresses are"
+					" not in any ram bank.\n");
+			return 1;
+		}
+	}
+
+	/*
+	 * Get pte flags. Which are configured at
+	 * runtime at booting.
+	 */
+	PTE_FLAGS_CACHED = mmu_get_pte_cached_flags();
+	PTE_FLAGS_UNCACHED = mmu_get_pte_uncached_flags();
+
+	for_each_memory_bank(bank) {
+		list_for_each_entry(r, &bank->res->children, sibling)
+			printf("Skipping region at 0x%08x - "
+					"0x%08x, size 0x%08x (%s)\n",
+					r->start, r->end,
+					r->end - r->start + 1, r->name);
+#ifdef CONFIG_MMU
+		/* Disable or enable caching */
+		if (cache)
+			do_remap_range(bank, PTE_FLAGS_CACHED);
+		else
+			do_remap_range(bank, PTE_FLAGS_UNCACHED);
+#endif
+	}
+
+	/* Do test if we set a start or end address */
+	if (start != 0xffffffff && end) {
+		printf("Testing address range: 0x%08lx - 0x%08lx,"
+				" size 0x%08lx.\n",
+				start, end, end - start + 1);
+
+		for (i = 1; (i <= max_i) || !max_i; i++) {
+			printf("Iteration: %u\n", i);
+
+			/* Do the memtest */
+			err = mem_test(start, end, bus_only);
+			if (err == -EINTR) {
+				printf("\nTest interrupted.\n");
+				goto err;
+			}
+
+			if (err < 0) {
+				printf("\nTest failed.\n");
+				goto err;
+			}
+			printf("\nTested %u iteration(s) without errors.\n", i);
+		}
+#ifdef CONFIG_MMU
+		/* Renable caching */
+		if (!cache)
+			for_each_memory_bank(bank)
+				do_remap_range(bank, PTE_FLAGS_CACHED);
+#endif
+		printf("Memtest done.\n");
+
+		return 0;
+	}
+
+	/* If we set no start or end address
+	 * we do the test on all ram banks */
+	for (i = 1; (i <= max_i) || !max_i; i++) {
+		for_each_memory_bank(bank) {
+			start = bank->start;
+			end = bank->start + bank->size - 1;
+
+			printf("Testing address range: 0x%08lx - "
+					"0x%08lx, size 0x%08lx on bank /dev/%s.\n",
+					start, end, bank->size,
+					bank->res->name);
+
+			printf("Iteration: %u\n", i);
+
+			err = mem_test(start, end, bus_only);
+			if (err == -EINTR) {
+				printf("\nTest interrupted.\n");
+				goto err;
+			}
+
+			if (err < 0) {
+				printf("\nTest on bank /dev/%s failed.\n",
+						bank->res->name);
+				goto err;
+			}
+			printf("\nTested %u iteration(s) without errors.\n", i);
+		}
+	}
+#ifdef CONFIG_MMU
+		/* Renable caching */
+	if (!cache)
+		for_each_memory_bank(bank)
+			do_remap_range(bank, PTE_FLAGS_CACHED);
+#endif
+	printf("Memtest done.\n");
+
+	return 0;
+
+err:
+#ifdef CONFIG_MMU
+	/* Enable caching */
+	for_each_memory_bank(bank)
+		do_remap_range(bank, PTE_FLAGS_CACHED);
+#endif
+
+	return 1;
+}
+
+static const __maybe_unused char cmd_memtest_help[] =
+"Usage: memtest [OPTION]...\n"
+"memtest related commands\n"
+"	-s	<start>		start address to begin memtest.\n"
+"	-e	<end>		end address to stop memtest.\n"
+"	-i	<iterations>	iterations [default=1, endless=0].\n"
+#ifdef CONFIG_MMU
+"	-c			run test with enable cache.\n"
+#endif
+"	-b			only test bus datalines.";
+
+BAREBOX_CMD_START(memtest)
+	.cmd		= do_mem_memtest,
+	.usage		= "Memory Test",
+	BAREBOX_CMD_HELP(cmd_memtest_help)
+BAREBOX_CMD_END
-- 
1.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 7/9] barebox-data: add barebox-data sections
  2013-01-13 17:42 ` [PATCH 7/9] barebox-data: add barebox-data sections Alexander Aring
@ 2013-01-14  9:51   ` Sascha Hauer
  2013-01-14 10:39     ` Alexander Aring
  0 siblings, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2013-01-14  9:51 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox, marc

On Sun, Jan 13, 2013 at 06:42:21PM +0100, Alexander Aring wrote:
> Add barebox-data section in arm branch to get complete
> barebox regions in sdram regions tree.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>  arch/arm/lib/barebox.lds.S                       | 6 +++++-
>  arch/blackfin/boards/ipe337/barebox.lds.S        | 6 +++++-
>  arch/mips/lib/barebox.lds.S                      | 5 ++++-
>  arch/nios2/cpu/barebox.lds.S                     | 5 +++--
>  arch/ppc/boards/freescale-p2020rdb/barebox.lds.S | 6 ++++--
>  arch/ppc/boards/pcm030/barebox.lds.S             | 5 +++--
>  arch/x86/lib/barebox.lds.S                       | 5 ++++-
>  common/memory.c                                  | 4 ++++
>  include/asm-generic/sections.h                   | 1 +
>  9 files changed, 33 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
> index bac1a04..6cad804 100644
> --- a/arch/arm/lib/barebox.lds.S
> +++ b/arch/arm/lib/barebox.lds.S
> @@ -65,7 +65,9 @@ SECTIONS
>  		__stop_unwind_tab = .;
>  	}
>  #endif
> -	_etext = .;			/* End of text and rodata section */
> +	_etext = . - 1;			/* End of text and rodata section */

Is this correct? In 2/9 you explained that etext points to the next free
memory location rather than to the last byte in the text segment. 2/9
fixes the request_sdram_region call accordingly. Now it is changed to be
the last byte of the text segment?

> +
> +	_sdata = .;
>  
>  	. = ALIGN(4);
>  	.data : { *(.data*) }
> @@ -87,6 +89,8 @@ SECTIONS
>  	__usymtab : { BAREBOX_SYMS }
>  	__usymtab_end = .;
>  
> +	_edata = . - 1;

Should probably also be _edata = .;

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 7/9] barebox-data: add barebox-data sections
  2013-01-14  9:51   ` Sascha Hauer
@ 2013-01-14 10:39     ` Alexander Aring
  0 siblings, 0 replies; 13+ messages in thread
From: Alexander Aring @ 2013-01-14 10:39 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox, Marc Reilly


[-- Attachment #1.1: Type: text/plain, Size: 2658 bytes --]

Hi,

You are right! Sry, about that.
I checked both values for regions overlapping with iomem. Both doesn't
overlapped(because align) but etext = .; is right.
Otherwise (for example in arm) "barebox" region is placed a little bit
in "barebox-data" region.

I draw a little graphics(some time ago) to demonstrate which variable from
which managment structure calc with 'inclusive' or 'exclusive' byte for
end-address. I attach them to this mail.


2013/1/14 Sascha Hauer <s.hauer@pengutronix.de>

> On Sun, Jan 13, 2013 at 06:42:21PM +0100, Alexander Aring wrote:
> > Add barebox-data section in arm branch to get complete
> > barebox regions in sdram regions tree.
> >
> > Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > ---
> >  arch/arm/lib/barebox.lds.S                       | 6 +++++-
> >  arch/blackfin/boards/ipe337/barebox.lds.S        | 6 +++++-
> >  arch/mips/lib/barebox.lds.S                      | 5 ++++-
> >  arch/nios2/cpu/barebox.lds.S                     | 5 +++--
> >  arch/ppc/boards/freescale-p2020rdb/barebox.lds.S | 6 ++++--
> >  arch/ppc/boards/pcm030/barebox.lds.S             | 5 +++--
> >  arch/x86/lib/barebox.lds.S                       | 5 ++++-
> >  common/memory.c                                  | 4 ++++
> >  include/asm-generic/sections.h                   | 1 +
> >  9 files changed, 33 insertions(+), 10 deletions(-)
> >
> > diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
> > index bac1a04..6cad804 100644
> > --- a/arch/arm/lib/barebox.lds.S
> > +++ b/arch/arm/lib/barebox.lds.S
> > @@ -65,7 +65,9 @@ SECTIONS
> >               __stop_unwind_tab = .;
> >       }
> >  #endif
> > -     _etext = .;                     /* End of text and rodata section
> */
> > +     _etext = . - 1;                 /* End of text and rodata section
> */
>
> Is this correct? In 2/9 you explained that etext points to the next free
> memory location rather than to the last byte in the text segment. 2/9
> fixes the request_sdram_region call accordingly. Now it is changed to be
> the last byte of the text segment?
>
> > +
> > +     _sdata = .;
> >
> >       . = ALIGN(4);
> >       .data : { *(.data*) }
> > @@ -87,6 +89,8 @@ SECTIONS
> >       __usymtab : { BAREBOX_SYMS }
> >       __usymtab_end = .;
> >
> > +     _edata = . - 1;
>
> Should probably also be _edata = .;
>
> Sascha
>
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>

[-- Attachment #1.2: Type: text/html, Size: 3824 bytes --]

[-- Attachment #2: barebox_address.png --]
[-- Type: image/png, Size: 79356 bytes --]

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/9] reimplement memtest command
  2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
                   ` (8 preceding siblings ...)
  2013-01-13 17:42 ` [PATCH 9/9] memtest: add rewritten " Alexander Aring
@ 2013-01-14 13:11 ` Sascha Hauer
  9 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-14 13:11 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox, marc

Hi Alexander,

On Sun, Jan 13, 2013 at 06:42:14PM +0100, Alexander Aring wrote:
> This patch series reimplement the memtest command.
> 
> Now it's support enable/disable caching on arm architecture
> and skip barebox regions.
> 
> In part of this patch series are the following changes:
> 	- Fix missing include in meminfo.
> 	- Fix some memory adresses issues.
> 	- Make remap_range globally accessable.
> 	- Add function to get cache/uncache pte flags.
> 	- Add new section data which is between text and bss.
> 	- Add function to check if address is in iomem regions
> 	  of ram.
> 
> Alexander Aring (9):
>   meminfo: fix missing include
>   memory: fix size address calculation
>   meminfo: fix display of allocated addresses
>   arm-mmu: remove semicolon in arm mmu.c

I applied up to 4/9 to master for now.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-01-14 13:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-13 17:42 [PATCH 0/9] reimplement memtest command Alexander Aring
2013-01-13 17:42 ` [PATCH 1/9] meminfo: fix missing include Alexander Aring
2013-01-13 17:42 ` [PATCH 2/9] memory: fix size address calculation Alexander Aring
2013-01-13 17:42 ` [PATCH 3/9] meminfo: fix display of allocated addresses Alexander Aring
2013-01-13 17:42 ` [PATCH 4/9] arm-mmu: remove semicolon in arm mmu.c Alexander Aring
2013-01-13 17:42 ` [PATCH 5/9] mmu: make remap_range global accessable Alexander Aring
2013-01-13 17:42 ` [PATCH 6/9] memory: add function address_in_sdram_regions Alexander Aring
2013-01-13 17:42 ` [PATCH 7/9] barebox-data: add barebox-data sections Alexander Aring
2013-01-14  9:51   ` Sascha Hauer
2013-01-14 10:39     ` Alexander Aring
2013-01-13 17:42 ` [PATCH 8/9] memtest: remove memtest command Alexander Aring
2013-01-13 17:42 ` [PATCH 9/9] memtest: add rewritten " Alexander Aring
2013-01-14 13:11 ` [PATCH 0/9] reimplement " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox