diff options
author | H. Peter Anvin <hpa@zytor.com> | 2005-09-06 18:17:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:57:29 -0400 |
commit | f8eeaaf4180334a8e5c3582fe62a5f8176a8c124 (patch) | |
tree | f2db782c1a67c1d632942d43b68bd2c5c7c3981d | |
parent | 5e1efe4931bf7d95b2f3d48ca0b79ea0e8341cc2 (diff) |
[PATCH] Make the bzImage format self-terminating
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Frank Sorenson <frank@tuxrocks.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | Documentation/i386/boot.txt | 35 | ||||
-rw-r--r-- | arch/i386/boot/setup.S | 2 | ||||
-rw-r--r-- | arch/i386/boot/tools/build.c | 4 | ||||
-rw-r--r-- | arch/x86_64/boot/setup.S | 2 | ||||
-rw-r--r-- | arch/x86_64/boot/tools/build.c | 4 |
5 files changed, 30 insertions, 17 deletions
diff --git a/Documentation/i386/boot.txt b/Documentation/i386/boot.txt index 1c48f0eba6fb..10312bebe55d 100644 --- a/Documentation/i386/boot.txt +++ b/Documentation/i386/boot.txt | |||
@@ -2,7 +2,7 @@ | |||
2 | ---------------------------- | 2 | ---------------------------- |
3 | 3 | ||
4 | H. Peter Anvin <hpa@zytor.com> | 4 | H. Peter Anvin <hpa@zytor.com> |
5 | Last update 2002-01-01 | 5 | Last update 2005-09-02 |
6 | 6 | ||
7 | On the i386 platform, the Linux kernel uses a rather complicated boot | 7 | On the i386 platform, the Linux kernel uses a rather complicated boot |
8 | convention. This has evolved partially due to historical aspects, as | 8 | convention. This has evolved partially due to historical aspects, as |
@@ -34,6 +34,8 @@ Protocol 2.02: (Kernel 2.4.0-test3-pre3) New command line protocol. | |||
34 | Protocol 2.03: (Kernel 2.4.18-pre1) Explicitly makes the highest possible | 34 | Protocol 2.03: (Kernel 2.4.18-pre1) Explicitly makes the highest possible |
35 | initrd address available to the bootloader. | 35 | initrd address available to the bootloader. |
36 | 36 | ||
37 | Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes. | ||
38 | |||
37 | 39 | ||
38 | **** MEMORY LAYOUT | 40 | **** MEMORY LAYOUT |
39 | 41 | ||
@@ -103,10 +105,9 @@ The header looks like: | |||
103 | Offset Proto Name Meaning | 105 | Offset Proto Name Meaning |
104 | /Size | 106 | /Size |
105 | 107 | ||
106 | 01F1/1 ALL setup_sects The size of the setup in sectors | 108 | 01F1/1 ALL(1 setup_sects The size of the setup in sectors |
107 | 01F2/2 ALL root_flags If set, the root is mounted readonly | 109 | 01F2/2 ALL root_flags If set, the root is mounted readonly |
108 | 01F4/2 ALL syssize DO NOT USE - for bootsect.S use only | 110 | 01F4/4 2.04+(2 syssize The size of the 32-bit code in 16-byte paras |
109 | 01F6/2 ALL swap_dev DO NOT USE - obsolete | ||
110 | 01F8/2 ALL ram_size DO NOT USE - for bootsect.S use only | 111 | 01F8/2 ALL ram_size DO NOT USE - for bootsect.S use only |
111 | 01FA/2 ALL vid_mode Video mode control | 112 | 01FA/2 ALL vid_mode Video mode control |
112 | 01FC/2 ALL root_dev Default root device number | 113 | 01FC/2 ALL root_dev Default root device number |
@@ -129,8 +130,12 @@ Offset Proto Name Meaning | |||
129 | 0228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line | 130 | 0228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line |
130 | 022C/4 2.03+ initrd_addr_max Highest legal initrd address | 131 | 022C/4 2.03+ initrd_addr_max Highest legal initrd address |
131 | 132 | ||
132 | For backwards compatibility, if the setup_sects field contains 0, the | 133 | (1) For backwards compatibility, if the setup_sects field contains 0, the |
133 | real value is 4. | 134 | real value is 4. |
135 | |||
136 | (2) For boot protocol prior to 2.04, the upper two bytes of the syssize | ||
137 | field are unusable, which means the size of a bzImage kernel | ||
138 | cannot be determined. | ||
134 | 139 | ||
135 | If the "HdrS" (0x53726448) magic number is not found at offset 0x202, | 140 | If the "HdrS" (0x53726448) magic number is not found at offset 0x202, |
136 | the boot protocol version is "old". Loading an old kernel, the | 141 | the boot protocol version is "old". Loading an old kernel, the |
@@ -230,12 +235,16 @@ loader to communicate with the kernel. Some of its options are also | |||
230 | relevant to the boot loader itself, see "special command line options" | 235 | relevant to the boot loader itself, see "special command line options" |
231 | below. | 236 | below. |
232 | 237 | ||
233 | The kernel command line is a null-terminated string up to 255 | 238 | The kernel command line is a null-terminated string currently up to |
234 | characters long, plus the final null. | 239 | 255 characters long, plus the final null. A string that is too long |
240 | will be automatically truncated by the kernel, a boot loader may allow | ||
241 | a longer command line to be passed to permit future kernels to extend | ||
242 | this limit. | ||
235 | 243 | ||
236 | If the boot protocol version is 2.02 or later, the address of the | 244 | If the boot protocol version is 2.02 or later, the address of the |
237 | kernel command line is given by the header field cmd_line_ptr (see | 245 | kernel command line is given by the header field cmd_line_ptr (see |
238 | above.) | 246 | above.) This address can be anywhere between the end of the setup |
247 | heap and 0xA0000. | ||
239 | 248 | ||
240 | If the protocol version is *not* 2.02 or higher, the kernel | 249 | If the protocol version is *not* 2.02 or higher, the kernel |
241 | command line is entered using the following protocol: | 250 | command line is entered using the following protocol: |
@@ -255,7 +264,7 @@ command line is entered using the following protocol: | |||
255 | **** SAMPLE BOOT CONFIGURATION | 264 | **** SAMPLE BOOT CONFIGURATION |
256 | 265 | ||
257 | As a sample configuration, assume the following layout of the real | 266 | As a sample configuration, assume the following layout of the real |
258 | mode segment: | 267 | mode segment (this is a typical, and recommended layout): |
259 | 268 | ||
260 | 0x0000-0x7FFF Real mode kernel | 269 | 0x0000-0x7FFF Real mode kernel |
261 | 0x8000-0x8FFF Stack and heap | 270 | 0x8000-0x8FFF Stack and heap |
@@ -312,9 +321,9 @@ Such a boot loader should enter the following fields in the header: | |||
312 | 321 | ||
313 | **** LOADING THE REST OF THE KERNEL | 322 | **** LOADING THE REST OF THE KERNEL |
314 | 323 | ||
315 | The non-real-mode kernel starts at offset (setup_sects+1)*512 in the | 324 | The 32-bit (non-real-mode) kernel starts at offset (setup_sects+1)*512 |
316 | kernel file (again, if setup_sects == 0 the real value is 4.) It | 325 | in the kernel file (again, if setup_sects == 0 the real value is 4.) |
317 | should be loaded at address 0x10000 for Image/zImage kernels and | 326 | It should be loaded at address 0x10000 for Image/zImage kernels and |
318 | 0x100000 for bzImage kernels. | 327 | 0x100000 for bzImage kernels. |
319 | 328 | ||
320 | The kernel is a bzImage kernel if the protocol >= 2.00 and the 0x01 | 329 | The kernel is a bzImage kernel if the protocol >= 2.00 and the 0x01 |
diff --git a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S index 8cb420f40c58..ca668d9df164 100644 --- a/arch/i386/boot/setup.S +++ b/arch/i386/boot/setup.S | |||
@@ -82,7 +82,7 @@ start: | |||
82 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) | 82 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) |
83 | 83 | ||
84 | .ascii "HdrS" # header signature | 84 | .ascii "HdrS" # header signature |
85 | .word 0x0203 # header version number (>= 0x0105) | 85 | .word 0x0204 # header version number (>= 0x0105) |
86 | # or else old loadlin-1.5 will fail) | 86 | # or else old loadlin-1.5 will fail) |
87 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG | 87 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG |
88 | start_sys_seg: .word SYSSEG | 88 | start_sys_seg: .word SYSSEG |
diff --git a/arch/i386/boot/tools/build.c b/arch/i386/boot/tools/build.c index 6835f6d47c31..05798419a6a9 100644 --- a/arch/i386/boot/tools/build.c +++ b/arch/i386/boot/tools/build.c | |||
@@ -177,7 +177,9 @@ int main(int argc, char ** argv) | |||
177 | die("Output: seek failed"); | 177 | die("Output: seek failed"); |
178 | buf[0] = (sys_size & 0xff); | 178 | buf[0] = (sys_size & 0xff); |
179 | buf[1] = ((sys_size >> 8) & 0xff); | 179 | buf[1] = ((sys_size >> 8) & 0xff); |
180 | if (write(1, buf, 2) != 2) | 180 | buf[2] = ((sys_size >> 16) & 0xff); |
181 | buf[3] = ((sys_size >> 24) & 0xff); | ||
182 | if (write(1, buf, 4) != 4) | ||
181 | die("Write of image length failed"); | 183 | die("Write of image length failed"); |
182 | 184 | ||
183 | return 0; /* Everything is OK */ | 185 | return 0; /* Everything is OK */ |
diff --git a/arch/x86_64/boot/setup.S b/arch/x86_64/boot/setup.S index ff58b2832b75..12ea0b6c52e2 100644 --- a/arch/x86_64/boot/setup.S +++ b/arch/x86_64/boot/setup.S | |||
@@ -81,7 +81,7 @@ start: | |||
81 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) | 81 | # This is the setup header, and it must start at %cs:2 (old 0x9020:2) |
82 | 82 | ||
83 | .ascii "HdrS" # header signature | 83 | .ascii "HdrS" # header signature |
84 | .word 0x0203 # header version number (>= 0x0105) | 84 | .word 0x0204 # header version number (>= 0x0105) |
85 | # or else old loadlin-1.5 will fail) | 85 | # or else old loadlin-1.5 will fail) |
86 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG | 86 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG |
87 | start_sys_seg: .word SYSSEG | 87 | start_sys_seg: .word SYSSEG |
diff --git a/arch/x86_64/boot/tools/build.c b/arch/x86_64/boot/tools/build.c index 18b5bac1c428..c44f5e2ec100 100644 --- a/arch/x86_64/boot/tools/build.c +++ b/arch/x86_64/boot/tools/build.c | |||
@@ -178,7 +178,9 @@ int main(int argc, char ** argv) | |||
178 | die("Output: seek failed"); | 178 | die("Output: seek failed"); |
179 | buf[0] = (sys_size & 0xff); | 179 | buf[0] = (sys_size & 0xff); |
180 | buf[1] = ((sys_size >> 8) & 0xff); | 180 | buf[1] = ((sys_size >> 8) & 0xff); |
181 | if (write(1, buf, 2) != 2) | 181 | buf[2] = ((sys_size >> 16) & 0xff); |
182 | buf[3] = ((sys_size >> 24) & 0xff); | ||
183 | if (write(1, buf, 4) != 4) | ||
182 | die("Write of image length failed"); | 184 | die("Write of image length failed"); |
183 | 185 | ||
184 | return 0; /* Everything is OK */ | 186 | return 0; /* Everything is OK */ |