Skip to contentSkip to conversation

sparc: use piggyback_32 for sparc64

PATCH In review Sam Ravnborg 2 participants 7 messages Jan 1, 2011 – Jan 2, 2011 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 7/9 sparc: use piggyback_32 for sparc64

piggyback_32 adapted to support sparc64:
- locating "HdrS" differs for sparc and sparc64
- sparc64 updates a_text, a_data + a_bss in the final a.out header

Updated Makefile to use piggyback_32 for sparc64.
Deleted the now unused piggyback_64.c

---
 arch/sparc/boot/Makefile       |    6 +-
 arch/sparc/boot/piggyback_32.c |   86 +++++++++++++++++++++++++------
 arch/sparc/boot/piggyback_64.c |  110 ----------------------------------------
 3 files changed, 72 insertions(+), 130 deletions(-)
 delete mode 100644 arch/sparc/boot/piggyback_64.c
arch/sparc/boot/Makefile +3 -3
index 4c81fe5..06a79a2 100644
@@ -6,7 +6,7 @@
 ROOT_IMG	:= /usr/src/root.img
 ELFTOAOUT	:= elftoaout
 
-hostprogs-y	:= piggyback_32 piggyback_64 btfixupprep
+hostprogs-y	:= piggyback_32 btfixupprep
 targets		:= tftpboot.img btfix.o btfix.S image zImage vmlinux.aout
 clean-files	:= System.map
 
@@ -69,7 +69,7 @@ endif
 
 ifeq ($(CONFIG_SPARC64),y)
 quiet_cmd_piggy     = PIGGY   $@
-      cmd_piggy     = $(obj)/piggyback_64 $@ System.map $(ROOT_IMG)
+      cmd_piggy     = $(obj)/piggyback_32 $(BITS) $@ System.map $(ROOT_IMG)
 quiet_cmd_strip     = STRIP   $@
       cmd_strip     = $(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start vmlinux -o $@
 
@@ -82,7 +82,7 @@ $(obj)/image: vmlinux FORCE
 $(obj)/zImage: $(obj)/image
 	$(call if_changed,gzip)
 
-$(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_64 System.map $(ROOT_IMG) FORCE
+$(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback_32 System.map $(ROOT_IMG) FORCE
 	$(call if_changed,elftoaout)
 	$(call if_changed,piggy)
 	@echo '  kernel: $@ is ready'
arch/sparc/boot/piggyback_32.c +69 -17

107 lines not on this page · raw message

arch/sparc/boot/piggyback_64.c deleted +0 -110

110 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#1 lore raw

arch/sparc/boot/piggyback_64.c line 5

Quoted 11 lines · Sam Ravnborg
arch/sparc/boot/piggyback_64.c deleted +0 -5
deleted file mode 100644
index a26a686..0000000
@@ -1,110 +0,0 @@
-/*
-   Simple utility to make a single-image install kernel with initial ramdisk
-   for Sparc64 tftpbooting without need to set up nfs.
-   
-   Copyright (C) 1997 Jakub Jelinek ([email protected])

Presumably you copied all that code from this file, so you should also move over the copyright statement (the year in the other one differs).

Signature · 1 line
     2. That which causes joy or happiness.
#2 lore raw
In reply to Sam Ravnborg

Hi Josip.

Quoted 15 lines · Josip Rodin

arch/sparc/boot/piggyback_64.c line 5

Quoted 11 lines · Sam Ravnborg
arch/sparc/boot/piggyback_64.c deleted +0 -5
deleted file mode 100644
index a26a686..0000000
@@ -1,110 +0,0 @@
-/*
-   Simple utility to make a single-image install kernel with initial ramdisk
-   for Sparc64 tftpbooting without need to set up nfs.
-   
-   Copyright (C) 1997 Jakub Jelinek ([email protected])

Presumably you copied all that code from this file, so you should also move over the copyright statement (the year in the other one differs).

Thanks for looking through the patches.

I have based all the work on the _32.c variant.

From the _64.c variant I used only small bits to redo the same functionality.

If this warrant to update the copyright or not I am not sure. But as you brougth it to my attention I will do so and add my own copyright in the process.

Jakub - you can see the original thread here:
http://marc.info/?l=linux-sparc&m9391542615466&w=2

Sam

#3 lore raw
In reply to Sam Ravnborg

arch/sparc/boot/piggyback_32.c static int get_start_end(const char *filename, unsigned int *start, unsigned int

Quoted 11 lines · Sam Ravnborg
arch/sparc/boot/piggyback_32.c +6 -4
+		for (i = 0; i < LOOKBACK; ++i) {
+			if (buffer[i + 0] = 'H' && buffer[i + 1] = 'd' &&
+			    buffer[i + 2] = 'r' && buffer[i + 3] = 'S') {
+				return offset + i;
+			}
+		}
 
-	for (q = buffer, r = q + 512; q < r; q += 4) {
-		if (*q = 'H' && q[1] = 'd' && q[2] = 'r' && q[3] = 'S')
-			break;
-	}

BTW, while the new code is eminently more readable in general, is there a reason to slow down that search by using increments of 1 instead of 4? Did the old one ever miss?

Signature · 1 line
     2. That which causes joy or happiness.
#4 lore raw
In reply to Sam Ravnborg
Quoted 8 lines · Josip Rodin
Quoted 6 lines · Sam Ravnborg
arch/sparc/boot/piggyback_32.c +6 -0
+		for (i = 0; i < LOOKBACK; ++i) {
+			if (buffer[i + 0] = 'H' && buffer[i + 1] = 'd' &&
+			    buffer[i + 2] = 'r' && buffer[i + 3] = 'S') {
+				return offset + i;
+			}
+		}
Quoted 8 lines

arch/sparc/boot/piggyback_32.c int main(int argc,char **argv) · line 177

Quoted 4 lines
arch/sparc/boot/piggyback_32.c +0 -4
-	for (q = buffer, r = q + 512; q < r; q += 4) {
-		if (*q = 'H' && q[1] = 'd' && q[2] = 'r' && q[3] = 'S')
-			break;
-	}

BTW, while the new code is eminently more readable in general, is there a reason to slow down that search by using increments of 1 instead of 4? Did the old one ever miss?

I used increment by 1 because there was nothing in head_32/_64 comments that guaranteed that "HdrS" would be on a 4-byte aligned address. [The actual implmentation guarantees this today].

I had two options:
- use increment by one
- use increment by 4 and explain why it was safe to do so

And I just picked the simpler variant.

So I do not fix any know issue - just playing safe. And speed does not matter here....

Sam

#5 lore raw
In reply to Sam Ravnborg
Quoted 22 lines · Sam Ravnborg
Quoted 8 lines · Josip Rodin
Quoted 6 lines · Sam Ravnborg
arch/sparc/boot/piggyback_32.c +6 -0
+		for (i = 0; i < LOOKBACK; ++i) {
+			if (buffer[i + 0] = 'H' && buffer[i + 1] = 'd' &&
+			    buffer[i + 2] = 'r' && buffer[i + 3] = 'S') {
+				return offset + i;
+			}
+		}
Quoted 8 lines

arch/sparc/boot/piggyback_32.c int main(int argc,char **argv) · line 177

Quoted 4 lines
arch/sparc/boot/piggyback_32.c +0 -4
-	for (q = buffer, r = q + 512; q < r; q += 4) {
-		if (*q = 'H' && q[1] = 'd' && q[2] = 'r' && q[3] = 'S')
-			break;
-	}

BTW, while the new code is eminently more readable in general, is there a reason to slow down that search by using increments of 1 instead of 4? Did the old one ever miss?

I used increment by 1 because there was nothing in head_32/_64 comments that guaranteed that "HdrS" would be on a 4-byte aligned address. [The actual implmentation guarantees this today].

Quoted 8 lines

I had two options:
- use increment by one
- use increment by 4 and explain why it was safe to do so

And I just picked the simpler variant.

So I do not fix any know issue - just playing safe. And speed does not matter here....

OK, just thought you might want to document that, given all the discussion about arcane code. (Thanks.) I would actually hesitate from calling this one the simpler variant, because making as few changes as possible compared to the old code usually makes a refactoring simpler to debug if the need arises :)

Signature · 1 line
     2. That which causes joy or happiness.
#6 lore raw
In reply to Sam Ravnborg
Quoted 29 lines · Josip Rodin
Quoted 28 lines · Sam Ravnborg
Quoted 8 lines · Josip Rodin
Quoted 6 lines · Sam Ravnborg
arch/sparc/boot/piggyback_32.c +6 -0
+		for (i = 0; i < LOOKBACK; ++i) {
+			if (buffer[i + 0] = 'H' && buffer[i + 1] = 'd' &&
+			    buffer[i + 2] = 'r' && buffer[i + 3] = 'S') {
+				return offset + i;
+			}
+		}
Quoted 8 lines

arch/sparc/boot/piggyback_32.c int main(int argc,char **argv) · line 177

Quoted 4 lines
arch/sparc/boot/piggyback_32.c +0 -4
-	for (q = buffer, r = q + 512; q < r; q += 4) {
-		if (*q = 'H' && q[1] = 'd' && q[2] = 'r' && q[3] = 'S')
-			break;
-	}

BTW, while the new code is eminently more readable in general, is there a reason to slow down that search by using increments of 1 instead of 4? Did the old one ever miss?

I used increment by 1 because there was nothing in head_32/_64 comments that guaranteed that "HdrS" would be on a 4-byte aligned address. [The actual implmentation guarantees this today].

I had two options:
- use increment by one
- use increment by 4 and explain why it was safe to do so

And I just picked the simpler variant.

Quoted 7 lines
Quoted 2 lines

So I do not fix any know issue - just playing safe. And speed does not matter here....

OK, just thought you might want to document that, given all the discussion about arcane code. (Thanks.) I would actually hesitate from calling this one the simpler variant, because making as few changes as possible compared to the old code usually makes a refactoring simpler to debug if the need arises :)

Good points!
I will aredo this to use increment-by-four and document this in v3 of the patchset.

Sam