aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2005-09-06 18:17:24 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:29 -0400
commitf8eeaaf4180334a8e5c3582fe62a5f8176a8c124 (patch)
treef2db782c1a67c1d632942d43b68bd2c5c7c3981d
parent5e1efe4931bf7d95b2f3d48ca0b79ea0e8341cc2 (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.txt35
-rw-r--r--arch/i386/boot/setup.S2
-rw-r--r--arch/i386/boot/tools/build.c4
-rw-r--r--arch/x86_64/boot/setup.S2
-rw-r--r--arch/x86_64/boot/tools/build.c4
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
7On the i386 platform, the Linux kernel uses a rather complicated boot 7On the i386 platform, the Linux kernel uses a rather complicated boot
8convention. This has evolved partially due to historical aspects, as 8convention. 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.
34Protocol 2.03: (Kernel 2.4.18-pre1) Explicitly makes the highest possible 34Protocol 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
37Protocol 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:
103Offset Proto Name Meaning 105Offset Proto Name Meaning
104/Size 106/Size
105 107
10601F1/1 ALL setup_sects The size of the setup in sectors 10801F1/1 ALL(1 setup_sects The size of the setup in sectors
10701F2/2 ALL root_flags If set, the root is mounted readonly 10901F2/2 ALL root_flags If set, the root is mounted readonly
10801F4/2 ALL syssize DO NOT USE - for bootsect.S use only 11001F4/4 2.04+(2 syssize The size of the 32-bit code in 16-byte paras
10901F6/2 ALL swap_dev DO NOT USE - obsolete
11001F8/2 ALL ram_size DO NOT USE - for bootsect.S use only 11101F8/2 ALL ram_size DO NOT USE - for bootsect.S use only
11101FA/2 ALL vid_mode Video mode control 11201FA/2 ALL vid_mode Video mode control
11201FC/2 ALL root_dev Default root device number 11301FC/2 ALL root_dev Default root device number
@@ -129,8 +130,12 @@ Offset Proto Name Meaning
1290228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line 1300228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line
130022C/4 2.03+ initrd_addr_max Highest legal initrd address 131022C/4 2.03+ initrd_addr_max Highest legal initrd address
131 132
132For backwards compatibility, if the setup_sects field contains 0, the 133(1) For backwards compatibility, if the setup_sects field contains 0, the
133real 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
135If the "HdrS" (0x53726448) magic number is not found at offset 0x202, 140If the "HdrS" (0x53726448) magic number is not found at offset 0x202,
136the boot protocol version is "old". Loading an old kernel, the 141the 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
230relevant to the boot loader itself, see "special command line options" 235relevant to the boot loader itself, see "special command line options"
231below. 236below.
232 237
233The kernel command line is a null-terminated string up to 255 238The kernel command line is a null-terminated string currently up to
234characters long, plus the final null. 239255 characters long, plus the final null. A string that is too long
240will be automatically truncated by the kernel, a boot loader may allow
241a longer command line to be passed to permit future kernels to extend
242this limit.
235 243
236If the boot protocol version is 2.02 or later, the address of the 244If the boot protocol version is 2.02 or later, the address of the
237kernel command line is given by the header field cmd_line_ptr (see 245kernel command line is given by the header field cmd_line_ptr (see
238above.) 246above.) This address can be anywhere between the end of the setup
247heap and 0xA0000.
239 248
240If the protocol version is *not* 2.02 or higher, the kernel 249If the protocol version is *not* 2.02 or higher, the kernel
241command line is entered using the following protocol: 250command 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
257As a sample configuration, assume the following layout of the real 266As a sample configuration, assume the following layout of the real
258mode segment: 267mode 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
315The non-real-mode kernel starts at offset (setup_sects+1)*512 in the 324The 32-bit (non-real-mode) kernel starts at offset (setup_sects+1)*512
316kernel file (again, if setup_sects == 0 the real value is 4.) It 325in the kernel file (again, if setup_sects == 0 the real value is 4.)
317should be loaded at address 0x10000 for Image/zImage kernels and 326It should be loaded at address 0x10000 for Image/zImage kernels and
3180x100000 for bzImage kernels. 3270x100000 for bzImage kernels.
319 328
320The kernel is a bzImage kernel if the protocol >= 2.00 and the 0x01 329The 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)
87realmode_swtch: .word 0, 0 # default_switch, SETUPSEG 87realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
88start_sys_seg: .word SYSSEG 88start_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)
86realmode_swtch: .word 0, 0 # default_switch, SETUPSEG 86realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
87start_sys_seg: .word SYSSEG 87start_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 */