فهرست منبع

[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>
H. Peter Anvin 20 سال پیش
والد
کامیت
f8eeaaf418
5فایلهای تغییر یافته به همراه30 افزوده شده و 17 حذف شده
  1. 22 13
      Documentation/i386/boot.txt
  2. 1 1
      arch/i386/boot/setup.S
  3. 3 1
      arch/i386/boot/tools/build.c
  4. 1 1
      arch/x86_64/boot/setup.S
  5. 3 1
      arch/x86_64/boot/tools/build.c

+ 22 - 13
Documentation/i386/boot.txt

@@ -2,7 +2,7 @@
 		     ----------------------------
 		     ----------------------------
 
 
 		    H. Peter Anvin <hpa@zytor.com>
 		    H. Peter Anvin <hpa@zytor.com>
-			Last update 2002-01-01
+			Last update 2005-09-02
 
 
 On the i386 platform, the Linux kernel uses a rather complicated boot
 On the i386 platform, the Linux kernel uses a rather complicated boot
 convention.  This has evolved partially due to historical aspects, as
 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.
 Protocol 2.03:	(Kernel 2.4.18-pre1) Explicitly makes the highest possible
 Protocol 2.03:	(Kernel 2.4.18-pre1) Explicitly makes the highest possible
 		initrd address available to the bootloader.
 		initrd address available to the bootloader.
 
 
+Protocol 2.04:	(Kernel 2.6.14) Extend the syssize field to four bytes.
+
 
 
 **** MEMORY LAYOUT
 **** MEMORY LAYOUT
 
 
@@ -103,10 +105,9 @@ The header looks like:
 Offset	Proto	Name		Meaning
 Offset	Proto	Name		Meaning
 /Size
 /Size
 
 
-01F1/1	ALL	setup_sects	The size of the setup in sectors
+01F1/1	ALL(1	setup_sects	The size of the setup in sectors
 01F2/2	ALL	root_flags	If set, the root is mounted readonly
 01F2/2	ALL	root_flags	If set, the root is mounted readonly
-01F4/2	ALL	syssize		DO NOT USE - for bootsect.S use only
-01F6/2	ALL	swap_dev	DO NOT USE - obsolete
+01F4/4	2.04+(2	syssize		The size of the 32-bit code in 16-byte paras
 01F8/2	ALL	ram_size	DO NOT USE - for bootsect.S use only
 01F8/2	ALL	ram_size	DO NOT USE - for bootsect.S use only
 01FA/2	ALL	vid_mode	Video mode control
 01FA/2	ALL	vid_mode	Video mode control
 01FC/2	ALL	root_dev	Default root device number
 01FC/2	ALL	root_dev	Default root device number
@@ -129,8 +130,12 @@ Offset	Proto	Name		Meaning
 0228/4	2.02+	cmd_line_ptr	32-bit pointer to the kernel command line
 0228/4	2.02+	cmd_line_ptr	32-bit pointer to the kernel command line
 022C/4	2.03+	initrd_addr_max	Highest legal initrd address
 022C/4	2.03+	initrd_addr_max	Highest legal initrd address
 
 
-For backwards compatibility, if the setup_sects field contains 0, the
-real value is 4.
+(1) For backwards compatibility, if the setup_sects field contains 0, the
+    real value is 4.
+
+(2) For boot protocol prior to 2.04, the upper two bytes of the syssize
+    field are unusable, which means the size of a bzImage kernel
+    cannot be determined.
 
 
 If the "HdrS" (0x53726448) magic number is not found at offset 0x202,
 If the "HdrS" (0x53726448) magic number is not found at offset 0x202,
 the boot protocol version is "old".  Loading an old kernel, the
 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
 relevant to the boot loader itself, see "special command line options"
 relevant to the boot loader itself, see "special command line options"
 below.
 below.
 
 
-The kernel command line is a null-terminated string up to 255
-characters long, plus the final null.
+The kernel command line is a null-terminated string currently up to
+255 characters long, plus the final null.  A string that is too long
+will be automatically truncated by the kernel, a boot loader may allow
+a longer command line to be passed to permit future kernels to extend
+this limit.
 
 
 If the boot protocol version is 2.02 or later, the address of the
 If the boot protocol version is 2.02 or later, the address of the
 kernel command line is given by the header field cmd_line_ptr (see
 kernel command line is given by the header field cmd_line_ptr (see
-above.)
+above.)  This address can be anywhere between the end of the setup
+heap and 0xA0000.
 
 
 If the protocol version is *not* 2.02 or higher, the kernel
 If the protocol version is *not* 2.02 or higher, the kernel
 command line is entered using the following protocol:
 command line is entered using the following protocol:
@@ -255,7 +264,7 @@ command line is entered using the following protocol:
 **** SAMPLE BOOT CONFIGURATION
 **** SAMPLE BOOT CONFIGURATION
 
 
 As a sample configuration, assume the following layout of the real
 As a sample configuration, assume the following layout of the real
-mode segment:
+mode segment (this is a typical, and recommended layout):
 
 
 	0x0000-0x7FFF	Real mode kernel
 	0x0000-0x7FFF	Real mode kernel
 	0x8000-0x8FFF	Stack and heap
 	0x8000-0x8FFF	Stack and heap
@@ -312,9 +321,9 @@ Such a boot loader should enter the following fields in the header:
 
 
 **** LOADING THE REST OF THE KERNEL
 **** LOADING THE REST OF THE KERNEL
 
 
-The non-real-mode kernel starts at offset (setup_sects+1)*512 in the
-kernel file (again, if setup_sects == 0 the real value is 4.)  It
-should be loaded at address 0x10000 for Image/zImage kernels and
+The 32-bit (non-real-mode) kernel starts at offset (setup_sects+1)*512
+in the kernel file (again, if setup_sects == 0 the real value is 4.)
+It should be loaded at address 0x10000 for Image/zImage kernels and
 0x100000 for bzImage kernels.
 0x100000 for bzImage kernels.
 
 
 The kernel is a bzImage kernel if the protocol >= 2.00 and the 0x01
 The kernel is a bzImage kernel if the protocol >= 2.00 and the 0x01

+ 1 - 1
arch/i386/boot/setup.S

@@ -82,7 +82,7 @@ start:
 # This is the setup header, and it must start at %cs:2 (old 0x9020:2)
 # This is the setup header, and it must start at %cs:2 (old 0x9020:2)
 
 
 		.ascii	"HdrS"		# header signature
 		.ascii	"HdrS"		# header signature
-		.word	0x0203		# header version number (>= 0x0105)
+		.word	0x0204		# header version number (>= 0x0105)
 					# or else old loadlin-1.5 will fail)
 					# or else old loadlin-1.5 will fail)
 realmode_swtch:	.word	0, 0		# default_switch, SETUPSEG
 realmode_swtch:	.word	0, 0		# default_switch, SETUPSEG
 start_sys_seg:	.word	SYSSEG
 start_sys_seg:	.word	SYSSEG

+ 3 - 1
arch/i386/boot/tools/build.c

@@ -177,7 +177,9 @@ int main(int argc, char ** argv)
 		die("Output: seek failed");
 		die("Output: seek failed");
 	buf[0] = (sys_size & 0xff);
 	buf[0] = (sys_size & 0xff);
 	buf[1] = ((sys_size >> 8) & 0xff);
 	buf[1] = ((sys_size >> 8) & 0xff);
-	if (write(1, buf, 2) != 2)
+	buf[2] = ((sys_size >> 16) & 0xff);
+	buf[3] = ((sys_size >> 24) & 0xff);
+	if (write(1, buf, 4) != 4)
 		die("Write of image length failed");
 		die("Write of image length failed");
 
 
 	return 0;					    /* Everything is OK */
 	return 0;					    /* Everything is OK */

+ 1 - 1
arch/x86_64/boot/setup.S

@@ -81,7 +81,7 @@ start:
 # This is the setup header, and it must start at %cs:2 (old 0x9020:2)
 # This is the setup header, and it must start at %cs:2 (old 0x9020:2)
 
 
 		.ascii	"HdrS"		# header signature
 		.ascii	"HdrS"		# header signature
-		.word	0x0203		# header version number (>= 0x0105)
+		.word	0x0204		# header version number (>= 0x0105)
 					# or else old loadlin-1.5 will fail)
 					# or else old loadlin-1.5 will fail)
 realmode_swtch:	.word	0, 0		# default_switch, SETUPSEG
 realmode_swtch:	.word	0, 0		# default_switch, SETUPSEG
 start_sys_seg:	.word	SYSSEG
 start_sys_seg:	.word	SYSSEG

+ 3 - 1
arch/x86_64/boot/tools/build.c

@@ -178,7 +178,9 @@ int main(int argc, char ** argv)
 		die("Output: seek failed");
 		die("Output: seek failed");
 	buf[0] = (sys_size & 0xff);
 	buf[0] = (sys_size & 0xff);
 	buf[1] = ((sys_size >> 8) & 0xff);
 	buf[1] = ((sys_size >> 8) & 0xff);
-	if (write(1, buf, 2) != 2)
+	buf[2] = ((sys_size >> 16) & 0xff);
+	buf[3] = ((sys_size >> 24) & 0xff);
+	if (write(1, buf, 4) != 4)
 		die("Write of image length failed");
 		die("Write of image length failed");
 
 
 	return 0;					    /* Everything is OK */
 	return 0;					    /* Everything is OK */