diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2011-01-04 06:39:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-04 22:25:04 -0500 |
commit | 9c239053045568abf960b01e4eb2c7205e3cd7d6 (patch) | |
tree | 18ff36b9a58c0c4dded3d7a4097ea4e5ca1fa8fc /arch/sparc | |
parent | b2a39b0d8ec2ce2bdcff4e01572b4e885220254d (diff) |
sparc: additional comments to piggyback_32.c
While reverse engineering the functionality of piggyback
I missed that the code was actually commented.
So I added a few comments.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/boot/piggyback_32.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/arch/sparc/boot/piggyback_32.c b/arch/sparc/boot/piggyback_32.c index 5c86a7d03b6f..5e856f2e9e0f 100644 --- a/arch/sparc/boot/piggyback_32.c +++ b/arch/sparc/boot/piggyback_32.c | |||
@@ -36,6 +36,8 @@ | |||
36 | * as PROM looks for a.out image only. | 36 | * as PROM looks for a.out image only. |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #define AOUT_TEXT_OFFSET 32 | ||
40 | |||
39 | /* read two bytes as big endian */ | 41 | /* read two bytes as big endian */ |
40 | static unsigned short ld2(char *p) | 42 | static unsigned short ld2(char *p) |
41 | { | 43 | { |
@@ -154,12 +156,20 @@ int main(int argc,char **argv) | |||
154 | die(argv[1]); | 156 | die(argv[1]); |
155 | j = 0; | 157 | j = 0; |
156 | } else if (memcmp(buffer, aout_magic, 4) == 0) { | 158 | } else if (memcmp(buffer, aout_magic, 4) == 0) { |
157 | i = j = 32; | 159 | i = j = AOUT_TEXT_OFFSET; |
158 | } else { | 160 | } else { |
159 | fprintf (stderr, "Not ELF nor a.out. Don't blame me.\n"); | 161 | fprintf (stderr, "Not ELF nor a.out. Don't blame me.\n"); |
160 | exit(1); | 162 | exit(1); |
161 | } | 163 | } |
162 | k = i; | 164 | k = i; |
165 | /* | ||
166 | * We need to fill in values for sparc_ramdisk_image + sparc_ramdisk_size | ||
167 | * To locate these symbols search for the "HdrS" text which appear | ||
168 | * in the image a little before the gokernel symbol. | ||
169 | * See definition of these in init_32.S | ||
170 | */ | ||
171 | |||
172 | /* Find the gokernel label */ | ||
163 | i += (ld2(buffer + j + 2) << 2) - 512; | 173 | i += (ld2(buffer + j + 2) << 2) - 512; |
164 | if (lseek(image, i, 0) < 0) | 174 | if (lseek(image, i, 0) < 0) |
165 | die("lseek"); | 175 | die("lseek"); |
@@ -177,6 +187,13 @@ int main(int argc,char **argv) | |||
177 | if (lseek(image, offset, 0) < 0) | 187 | if (lseek(image, offset, 0) < 0) |
178 | die("lseek"); | 188 | die("lseek"); |
179 | 189 | ||
190 | /* | ||
191 | * root_flags = 0 | ||
192 | * root_dev = 1 (RAMDISK_MAJOR) | ||
193 | * ram_flags = 0 | ||
194 | * sparc_ramdisk_image = "PAGE aligned address after _end") | ||
195 | * sparc_ramdisk_size = size of image | ||
196 | */ | ||
180 | st4(buffer, 0); | 197 | st4(buffer, 0); |
181 | st4(buffer + 4, 0x01000000); | 198 | st4(buffer + 4, 0x01000000); |
182 | st4(buffer + 8, (end + 32 + 4095) & ~4095); | 199 | st4(buffer + 8, (end + 32 + 4095) & ~4095); |
@@ -184,11 +201,13 @@ int main(int argc,char **argv) | |||
184 | 201 | ||
185 | if (write(image, buffer + 2, 14) != 14) | 202 | if (write(image, buffer + 2, 14) != 14) |
186 | die(argv[1]); | 203 | die(argv[1]); |
204 | |||
205 | /* seek page aligned boundary in the image file and add boot image */ | ||
187 | if (lseek(image, k - start + ((end + 32 + 4095) & ~4095), 0) < 0) | 206 | if (lseek(image, k - start + ((end + 32 + 4095) & ~4095), 0) < 0) |
188 | die("lseek"); | 207 | die("lseek"); |
189 | if ((tail = open(argv[3],O_RDONLY)) < 0) | 208 | if ((tail = open(argv[3],O_RDONLY)) < 0) |
190 | die(argv[3]); | 209 | die(argv[3]); |
191 | while ((i = read (tail, buffer, 1024)) > 0) | 210 | while ((i = read(tail, buffer, 1024)) > 0) |
192 | if (write(image, buffer, i) != i) | 211 | if (write(image, buffer, i) != i) |
193 | die(argv[1]); | 212 | die(argv[1]); |
194 | if (close(image) < 0) | 213 | if (close(image) < 0) |