Skip to contentSkip to conversation

x86 boot enhancements, boot bean counting 8/11

PATCH In review Eric W. Biederman 2 participants 4 messages Apr 17, 2002 – Apr 18, 2002 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86 boot enhancements, boot bean counting 8/11

Linus please apply,

Rework the actual build/link step for kernel images.
- remove the need for objcopy
- Kill the ROOT_DEV Makefile variable, the implementation was only half correct and there are much better ways to specify your root device than modifying the kernel Makefile.
- Don't loose information when the executable is built

Except for a few extra fields in setup.S the binary image is unchanged.

Eric

Makefile +0 -9
diff -uNr linux-2.5.8.boot.footprint/Makefile linux-2.5.8.boot.build/Makefile
@@ -93,15 +93,6 @@
 AFLAGS := -D__ASSEMBLY__ $(CPPFLAGS)
 
 #
-# ROOT_DEV specifies the default root-device when making the image.
-# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
-# the default of FLOPPY is used by 'build'.
-# This is i386 specific.
-#
-
-export ROOT_DEV = CURRENT
-
-#
 # If you want to preset the SVGA mode, uncomment the next line and
 # set SVGA_MODE to whatever number you want.
 # Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
arch/i386/boot/Makefile +14 -22
diff -uNr linux-2.5.8.boot.footprint/arch/i386/boot/Makefile linux-2.5.8.boot.build/arch/i386/boot/Makefile
@@ -12,13 +12,11 @@
 		$(TOPDIR)/include/linux/autoconf.h \
 		$(TOPDIR)/include/asm/boot.h
 
-zImage: $(CONFIGURE) bootsect setup compressed/vmlinux tools/build
-	$(OBJCOPY) compressed/vmlinux compressed/vmlinux.out
-	tools/build bootsect setup compressed/vmlinux.out $(ROOT_DEV) > zImage
-
-bzImage: $(CONFIGURE) bbootsect bsetup compressed/bvmlinux tools/build
-	$(OBJCOPY) compressed/bvmlinux compressed/bvmlinux.out
-	tools/build -b bbootsect bsetup compressed/bvmlinux.out $(ROOT_DEV) > bzImage
+zImage: $(CONFIGURE) tools/build $(TOPDIR)/vmlinux realmode compressed/vmlinux 
+	tools/build $(TOPDIR)/vmlinux realmode compressed/vmlinux zImage
+
+bzImage: $(CONFIGURE) tools/build $(TOPDIR)/vmlinux brealmode compressed/bvmlinux 
+	tools/build -b $(TOPDIR)/vmlinux brealmode compressed/bvmlinux bzImage
 
 compressed/vmlinux: $(TOPDIR)/vmlinux
 	@$(MAKE) -C compressed vmlinux
@@ -39,49 +37,43 @@
 install: $(CONFIGURE) $(BOOTIMAGE)
 	sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map "$(INSTALL_PATH)"
 
-tools/build: tools/build.c
+tools/build: tools/build.c $(TOPDIR)/include/linux/version.h $(TOPDIR)/include/linux/compile.h $(TOPDIR)/include/asm-i386/boot.h
 	$(HOSTCC) $(HOSTCFLAGS) -o $@ $< -I$(TOPDIR)/include
 
-bootsect: bootsect.o
-	$(LD) -Ttext 0x0 -s --oformat binary -o $@ $<
-
 bootsect.o: bootsect.s
 	$(AS) -o $@ $<
 
 bootsect.s: bootsect.S Makefile $(BOOT_INCL)
 	$(CPP) $(CPPFLAGS) -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@
 
-bbootsect: bbootsect.o
-	$(LD) -Ttext 0x0 -s --oformat binary $< -o $@
-
 bbootsect.o: bbootsect.s
 	$(AS) -o $@ $<
 
 bbootsect.s: bootsect.S Makefile $(BOOT_INCL)
 	$(CPP) $(CPPFLAGS) -D__BIG_KERNEL__ -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@
 
-setup: setup.o
-	$(LD) -Ttext 0x0 -s --oformat binary -e begtext -o $@ $<
-
 setup.o: setup.s
 	$(AS) -o $@ $<
 
 setup.s: setup.S video.S Makefile $(BOOT_INCL) $(TOPDIR)/include/linux/version.h $(TOPDIR)/include/linux/compile.h
 	$(CPP) $(CPPFLAGS) -D__ASSEMBLY__ -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@
 
-bsetup: bsetup.o
-	$(LD) -Ttext 0x0 -s --oformat binary -e begtext -o $@ $<
-
 bsetup.o: bsetup.s
 	$(AS) -o $@ $<
 
 bsetup.s: setup.S video.S Makefile $(BOOT_INCL) $(TOPDIR)/include/linux/version.h $(TOPDIR)/include/linux/compile.h
 	$(CPP) $(CPPFLAGS) -D__BIG_KERNEL__ -D__ASSEMBLY__ -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@
 
+realmode: bootsect.o setup.o
+	$(LD) -T realmode.lds -o $@ $^
+
+brealmode: bbootsect.o bsetup.o
+	$(LD) -T realmode.lds -o $@ $^
+
 dep:
 
 clean:
 	rm -f tools/build
-	rm -f setup bootsect zImage compressed/vmlinux.out
-	rm -f bsetup bbootsect bzImage compressed/bvmlinux.out
+	rm -f realmode zImage
+	rm -f brealmode bzImage
 	@$(MAKE) -C compressed clean
arch/i386/boot/bootsect.S +1 -1
diff -uNr linux-2.5.8.boot.footprint/arch/i386/boot/bootsect.S linux-2.5.8.boot.build/arch/i386/boot/bootsect.S
@@ -54,7 +54,7 @@
 #endif
 
 .code16
-.text
+.section ".bootsect", "ax", @progbits
 
 .global _start
 _start:
arch/i386/boot/realmode.lds +18 -0
diff -uNr linux-2.5.8.boot.footprint/arch/i386/boot/realmode.lds linux-2.5.8.boot.build/arch/i386/boot/realmode.lds
@@ -0,0 +1,18 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+ENTRY(_start)
+OUTPUT_ARCH(i386)
+SECTIONS
+{
+	.bootsect 0 : AT(0x10000) {
+		*(.bootsect)
+	}
+	.setup 0 : AT(LOADADDR(.bootsect) + SIZEOF(.bootsect)) {
+		*(.setup)
+	}
+	.setup.heap SIZEOF(.setup) : AT(LOADADDR(.setup) + SIZEOF(.setup)) {
+		*(.setup.heap)
+	}
+	/DISCARD/ : {
+		*(*)
+	}
+}
arch/i386/boot/setup.S +4 -1
diff -uNr linux-2.5.8.boot.footprint/arch/i386/boot/setup.S linux-2.5.8.boot.build/arch/i386/boot/setup.S
@@ -80,7 +80,7 @@
 .code16
 .globl _setup, _esetup
 
-.text
+.section ".setup", "ax", @progbits
 _setup:	
 
 start:
@@ -171,6 +171,9 @@
 		.long	(_esetup_heap - _setup) + DELTA_BOOTSECT
 real_filesz:				# Datasize of the real mode kernel
 		.long (_esetup - _setup) + DELTA_BOOTSECT
+kern_base:	.long	KERNEL_START	# Kernel load address
+kern_memsz:	.long	0x00000000	# Kernel memory usage
+kern_filesz:	.long	0x00000000	# Kernel datasize
 trampoline:	call	start_of_setup
 		# Don't let the E820 map overlap code
 		. = (E820MAP - DELTA_BOOTSECT) + (E820MAX * E820ENTRY_SIZE)
arch/i386/boot/tools/build.c +513 -147

759 lines not on this page · raw message

arch/x86_64/boot/Makefile +2 -2
diff -uNr linux-2.5.8.boot.footprint/arch/x86_64/boot/Makefile linux-2.5.8.boot.build/arch/x86_64/boot/Makefile
@@ -14,11 +14,11 @@
 
 zImage: $(CONFIGURE) bootsect setup compressed/vmlinux tools/build
 	$(OBJCOPY) compressed/vmlinux compressed/vmlinux.out
-	tools/build bootsect setup compressed/vmlinux.out $(ROOT_DEV) > zImage
+	tools/build bootsect setup compressed/vmlinux.out CURRENT > zImage
 
 bzImage: $(CONFIGURE) bbootsect bsetup compressed/bvmlinux tools/build
 	$(OBJCOPY) compressed/bvmlinux compressed/bvmlinux.out
-	tools/build -b bbootsect bsetup compressed/bvmlinux.out $(ROOT_DEV) > bzImage
+	tools/build -b bbootsect bsetup compressed/bvmlinux.out CURRENT > bzImage
 
 bzImage-padded: bzImage
 	dd if=/dev/zero bs=1k count=70 >> bzImage
include/asm-i386/boot_param.h +4 -1
diff -uNr linux-2.5.8.boot.footprint/include/asm-i386/boot_param.h linux-2.5.8.boot.build/include/asm-i386/boot_param.h
@@ -88,7 +88,10 @@
 	__u32 real_base;			/* 0x234 */
 	__u32 real_memsz;			/* 0x238 */
 	__u32 real_filesz;			/* 0x23c */
-	__u8  reserved15[0x2d0 - 0x240];	/* 0x240 */
+ 	__u32 kern_base;			/* 0x240 */
+ 	__u32 kern_memsz;			/* 0x244 */
+ 	__u32 kern_filesz;			/* 0x248 */
+ 	__u8  reserved15[0x2d0 - 0x24c];	/* 0x24c */
 	struct e820entry e820_map[E820MAX];	/* 0x2d0 */
 						/* 0x550 */
 } __attribute__((packed));
#1 lore raw
Quoted 8 lines · Eric W. Biederman

Linus please apply,

Rework the actual build/link step for kernel images.
- remove the need for objcopy
- Kill the ROOT_DEV Makefile variable, the implementation was only half correct and there are much better ways to specify your root device than modifying the kernel Makefile.
- Don't loose information when the executable is built

Coudl you please use sufficiently large fields for kdev_t variables? This way if we once have bigger device id spaces one will not have to mess with the boot code again.
Thank you.

arch/i386/boot/tools/build.c line 104

Quoted 7 lines
arch/i386/boot/tools/build.c +7 -0
+
+struct boot_params {
+	uint8_t  reserved1[0x1f1];		/* 0x000 */
+	uint8_t  setup_sects;			/* 0x1f1 */
+	uint16_t mount_root_rdonly;		/* 0x1f2 */
+	uint16_t syssize;			/* 0x1f4 */
+	uint16_t swapdev;			/* 0x1f6 */

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this should be uint32_t

arch/i386/boot/tools/build.c line 110

Quoted 6 lines
arch/i386/boot/tools/build.c +6 -0
+	uint16_t ramdisk_flags;			/* 0x1f8 */
+#define RAMDISK_IMAGE_START_MASK  	0x07FF
+#define RAMDISK_PROMPT_FLAG		0x8000
+#define RAMDISK_LOAD_FLAG		0x4000	
+	uint16_t vid_mode;			/* 0x1fa */
+	uint16_t root_dev;			/* 0x1fc */

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this should be uint32_t

#2 lore raw
In reply to Eric W. Biederman
Quoted 9 lines · Martin Dalecki
Quoted 7 lines · Eric W. Biederman

Linus please apply,
Rework the actual build/link step for kernel images. - remove the need for objcopy
- Kill the ROOT_DEV Makefile variable, the implementation
was only half correct and there are much better ways
to specify your root device than modifying the kernel Makefile.
- Don't loose information when the executable is built

Quoted 4 lines

Coudl you please use sufficiently large fields for kdev_t variables? This way if we once have bigger device id spaces one will not have to mess with the boot code again.
Thank you.

1) This patch doesn't change anything except to document which fields are present, and how big they are, and no there isn't enough room to trivially expand these fields.
2) Exporting kdev_t from the kernel would be very bad.
3) swapdev is long dead, and root_dev while it works is unnecessary, you can specify it on the command line just fine.

So we already are future proofed, and the change you suggest would be a bad one. The compiled in command line fully supports the ability to set your root device, so no functionality is lost.

Like I said in my intro a lot of this code simply makes what the boot processes is currently doing more visible.

Eric

#3 lore raw
In reply to Eric W. Biederman
Quoted 26 lines · Eric W. Biederman
Quoted 10 lines · Martin Dalecki
Quoted 7 lines · Eric W. Biederman

Linus please apply,
Rework the actual build/link step for kernel images. - remove the need for objcopy
- Kill the ROOT_DEV Makefile variable, the implementation
was only half correct and there are much better ways
to specify your root device than modifying the kernel Makefile.
- Don't loose information when the executable is built

Quoted 4 lines

Coudl you please use sufficiently large fields for kdev_t variables? This way if we once have bigger device id spaces one will not have to mess with the boot code again.
Thank you.

1) This patch doesn't change anything except to document which fields are present, and how big they are, and no there isn't enough room to trivially expand these fields.
2) Exporting kdev_t from the kernel would be very bad.
3) swapdev is long dead, and root_dev while it works is unnecessary, you can specify it on the command line just fine.

Quoted 7 lines

So we already are future proofed, and the change you suggest would be a bad one. The compiled in command line fully supports the ability to set your root device, so no functionality is lost.

Like I said in my intro a lot of this code simply makes what the boot processes is currently doing more visible.

Fine that explains it. Sorry for bogging you about it.