Skip to contentSkip to conversation

arm cache fixes

PATCH New Uwe Kleine-König 1 participant 4 messages Jan 22, 2010 – Mar 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm cache fixes

Hi,

while digging around in Linux' early boot code for ARM I noticed that the mmu hasn't been disabled on iMX27 when giving control to Linux.

The other patch mostly cosmetic to print out when barebox.bin (and barebox.S) are updated.

I send the patches as reply to this mail. Shortlog and diffstat are below.

Best regards
Uwe

The following changes since commit 0dde20da20411bf4dcd5593601d2f36e9ba04f66:
Peter Korsgaard (1):
documentation: It's U-Boot that doesn't have getopt, not Barebox

are available in the git repository at:

git://git.pengutronix.de/git/ukl/barebox.git master

Uwe Kleine-König (2):
give nice output when generating barebox.bin and barebox.S
arm: make disabling the cache actually work

 Makefile           |   15 ++++++++++++---
 arch/arm/cpu/mmu.c |   29 ++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 4 deletions(-)
Signature · 7 lines
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/2 give nice output when generating barebox.bin and barebox.S

As a side effect don't build barebox.S when barebox.bin is updated. I didn't manage to keep the old behaviour and I consider it cleaner this way.

---
 Makefile |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
Makefile +12 -3
index 0c00829..5b5c2e8 100644
@@ -641,9 +641,18 @@ define rule_barebox-modpost
 	$(Q)echo 'cmd_$@ := $(cmd_barebox-modpost)' > $(dot-target).cmd
 endef
 
-barebox.bin: barebox
-	$(Q)$(OBJCOPY) -O binary barebox barebox.bin
-	$(Q)$(OBJDUMP) -d barebox > barebox.S
+quiet_cmd_objcopy = OBJCOPY $@
+      cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
+
+OBJCOPYFLAGS_barebox.bin = -O binary
+barebox.bin: barebox FORCE
+	$(call if_changed,objcopy)
+#$(Q)$(OBJCOPY) -O binary barebox barebox.bin
+
+quiet_cmd_disasm = DISASM  $@
+      cmd_disasm = $(OBJDUMP) -d $< > $@
+barebox.S: barebox FORCE
+	$(call if_changed,disasm)
 
 # barebox image
 barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE
Signature · 7 lines
1.6.6


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 1/1 give nice output when generating barebox.bin and barebox.S

As a side effect don't build barebox.S when barebox.bin is updated. I didn't manage to keep the old behaviour and I consider it cleaner this way.

---
Hello,

I rebased this to current master. The X86 stuff is untouched, probably it could be integrated, too, but I didn't want to spend the time trying, if the patch isn't welcome in principle. Sascha?

Grüßle
Uwe

 Makefile |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
Makefile +14 -3
index 01d2052..8b9b454 100644
@@ -641,9 +641,16 @@ define rule_barebox-modpost
 	$(Q)echo 'cmd_$@ := $(cmd_barebox-modpost)' > $(dot-target).cmd
 endef
 
-barebox.bin: barebox
-	$(Q)$(OBJCOPY) -O binary barebox barebox.bin
+quiet_cmd_objcopy = OBJCOPY $@
+      cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
+
+OBJCOPYFLAGS_barebox.bin = -O binary
+
+barebox.bin: barebox FORCE
+	$(call if_changed,objcopy)
+
 ifdef CONFIG_X86
+barebox.S: barebox
 ifdef CONFIG_X86_HDBOOT
 	@echo "-------------------------------------------------" > barebox.S
 	@echo " * MBR content" >> barebox.S
@@ -665,7 +672,11 @@ endif
 	@echo " * Init Calls content" >> barebox.S
 	$(Q)$(OBJDUMP) -j .barebox_initcalls -d barebox >> barebox.S
 else
-	$(Q)$(OBJDUMP) -d barebox > barebox.S
+quiet_cmd_disasm = DISASM  $@
+      cmd_disasm = $(OBJDUMP) -d $< > $@
+
+barebox.S: barebox FORCE
+	$(call if_changed,disasm)
 endif
 
 # barebox image
Signature · 7 lines
1.7.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 2/2 arm: make disabling the cache actually work

In reply to Uwe Kleine-König

The code before looks to me like work in progress. It only drained the write buffer and skipped disabling mmu and caches by an early return from inline assembler (which is broken in itself as it doesn't restore frame pointer, stack pointer and other saved registers).

---
 arch/arm/cpu/mmu.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
arch/arm/cpu/mmu.c +28 -1
index 9e00927..95b8302 100644
@@ -54,7 +54,7 @@ void mmu_enable(void)
 {
 	asm volatile (
 		"mrc p15, 0, r1, c1, c0, 0;"
-		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache */
+		"orr r1, r1, #0x0007;"  /* enable MMU + Dcache + alignment fault checking */
 		"mcr p15, 0, r1, c1, c0, 0"
 		:
 		:
@@ -67,6 +67,30 @@ void mmu_enable(void)
  */
 void mmu_disable(void)
 {
+#if defined(CONFIG_CPU_ARM926T)
+	unsigned int tmp = 0;
+	asm volatile (
+		/* test, clean and invalidate D cache */
+		"1:	mrc	p15, 0, r15, c7, c14, 3\n"
+		"	bne	1b\n"
+		/* invalidate I cache (Rd SBZ) */
+		"	mcr	p15, 0, %1, c7, c5, 0\n"
+		/* drain write buffer (Rd SBZ) */
+		"	mcr	p15, 0, %1, c7, c10, 4\n"
+
+		/* read control register */
+		"	mrc	p15, 0, %0, c1, c0\n"
+		/* clear C and M */
+		"	bic	%0, %0, #0x0005\n"
+		/* write back control register */
+		"	mcr	p15, 0, %0, c1, c0\n"
+
+		/* invalidate TLBs (Rd SBZ) */
+		"	mcr p15, 0, %1, c8, c7, 0;"
+		: "=&r" (tmp) : "r" (tmp) : "cc" );
+
+#else
+	/* ??? */
 	asm volatile (
 		"nop; "
 		"nop; "
@@ -75,9 +99,11 @@ void mmu_disable(void)
 		"nop; "
 		"nop; "
 		/* test, clean and invalidate cache */
+		/* mrc     p15, 0, $rd, c7, c14, 3; is armv5tej specific */
 		"1:	mrc	p15, 0, r15, c7, c14, 3;" 
 		"	bne	1b;"
 		"	mov	pc, lr;"
+		/* the following code is never reached */
 		"	mov r0, #0x0;"
 		"	mcr p15, 0, r0, c7, c10, 4;" /* drain the write buffer   */
 		"	mcr p15, 0, r1, c7, c6, 0;"  /* clear data cache         */
@@ -90,6 +116,7 @@ void mmu_disable(void)
 		:
 		: "r0" /* Clobber list */
 	);
+#endif
 }
 
 /*
Signature · 7 lines
1.6.6


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox