All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify
@ 2009-07-15  1:00 Pavel Roskin
  2009-07-15  1:00 ` [PATCH 2/7] Remove unused version information from boot/i386/pc/boot.S Pavel Roskin
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15  1:00 UTC (permalink / raw)
  To: grub-devel

ChangeLog:

	* include/grub/i386/pc/boot.h: Sort all offsets.
	(GRUB_BOOT_MACHINE_KERNEL_ADDRESS): Remove, it's unused.
	(GRUB_BOOT_MACHINE_KERNEL_SEGMENT): Likewise.
	* boot/i386/pc/boot.S: Assert location of every offset listed in
	include/grub/i386/pc/boot.h.
---
 boot/i386/pc/boot.S         |    8 +++++++-
 include/grub/i386/pc/boot.h |   10 ++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index 8d8c27c..fb90947 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -65,6 +65,7 @@ start:
 	 * this area.
 	 */
 
+	. = _start + GRUB_BOOT_MACHINE_BPB_START
 	. = _start + 4
 
 	/* scratch space */
@@ -91,14 +92,19 @@ cylinder_start:
 	 * End of BIOS parameter block.
 	 */
 
+	. = _start + GRUB_BOOT_MACHINE_VER_MAJ
 boot_version:
 	.byte	GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
 kernel_address:
 	.word	GRUB_BOOT_MACHINE_KERNEL_ADDR
 kernel_segment:
 	.word	GRUB_BOOT_MACHINE_KERNEL_SEG
+
+	. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
 kernel_sector:
 	.long	1, 0
+
+	. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE
 boot_drive:
 	.byte 0xff	/* the disk to load kernel from */
 			/* 0xff means use the boot drive */
@@ -477,8 +483,8 @@ nt_magic:
 	 *  sneaky, huh?
 	 */
 
-part_start:
 	. = _start + GRUB_BOOT_MACHINE_PART_START
+part_start:
 
 probe_values:
 	.byte	36, 18, 15, 9, 0
diff --git a/include/grub/i386/pc/boot.h b/include/grub/i386/pc/boot.h
index f35cb3a..221ed38 100644
--- a/include/grub/i386/pc/boot.h
+++ b/include/grub/i386/pc/boot.h
@@ -31,17 +31,11 @@
 /* The offset of the major version.  */
 #define GRUB_BOOT_MACHINE_VER_MAJ	0x3e
 
-/* The offset of BOOT_DRIVE.  */
-#define GRUB_BOOT_MACHINE_BOOT_DRIVE	0x4c
-
-/* The offset of KERNEL_ADDRESS.  */
-#define GRUB_BOOT_MACHINE_KERNEL_ADDRESS	0x40
-
 /* The offset of KERNEL_SECTOR.  */
 #define GRUB_BOOT_MACHINE_KERNEL_SECTOR	0x44
 
-/* The offset of KERNEL_SEGMENT.  */
-#define GRUB_BOOT_MACHINE_KERNEL_SEGMENT	0x42
+/* The offset of BOOT_DRIVE.  */
+#define GRUB_BOOT_MACHINE_BOOT_DRIVE	0x4c
 
 /* The offset of BOOT_DRIVE_CHECK.  */
 #define GRUB_BOOT_MACHINE_DRIVE_CHECK	0x4e



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/7] Remove unused version information from boot/i386/pc/boot.S
  2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
@ 2009-07-15  1:00 ` Pavel Roskin
  2009-07-15  1:00 ` [PATCH 3/7] Eliminate kernel_segment Pavel Roskin
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15  1:00 UTC (permalink / raw)
  To: grub-devel

ChangeLog:

	* boot/i386/pc/boot.S (boot_version): Remove.
	* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_VER_MAJ):
	Remove.
---
 boot/i386/pc/boot.S         |    3 ---
 include/grub/i386/pc/boot.h |    3 ---
 2 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index fb90947..e5685dc 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -92,9 +92,6 @@ cylinder_start:
 	 * End of BIOS parameter block.
 	 */
 
-	. = _start + GRUB_BOOT_MACHINE_VER_MAJ
-boot_version:
-	.byte	GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
 kernel_address:
 	.word	GRUB_BOOT_MACHINE_KERNEL_ADDR
 kernel_segment:
diff --git a/include/grub/i386/pc/boot.h b/include/grub/i386/pc/boot.h
index 221ed38..a91f55a 100644
--- a/include/grub/i386/pc/boot.h
+++ b/include/grub/i386/pc/boot.h
@@ -28,9 +28,6 @@
 /* The offset of the end of BPB (BIOS Parameter Block).  */
 #define GRUB_BOOT_MACHINE_BPB_END	0x3e
 
-/* The offset of the major version.  */
-#define GRUB_BOOT_MACHINE_VER_MAJ	0x3e
-
 /* The offset of KERNEL_SECTOR.  */
 #define GRUB_BOOT_MACHINE_KERNEL_SECTOR	0x44
 



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/7] Eliminate kernel_segment
  2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
  2009-07-15  1:00 ` [PATCH 2/7] Remove unused version information from boot/i386/pc/boot.S Pavel Roskin
@ 2009-07-15  1:00 ` Pavel Roskin
  2009-07-16 15:45   ` Robert Millan
  2009-07-15  1:00 ` [PATCH 4/7] Eliminate kernel_address Pavel Roskin
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15  1:00 UTC (permalink / raw)
  To: grub-devel

ChangeLog:

	* boot/i386/pc/boot.S (kernel_segment): Remove.
	(copy_buffer): Copy to 0x0000:0x8000, not to 0x0800:0x0000.
---
 boot/i386/pc/boot.S |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index e5685dc..15d02e5 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -94,8 +94,6 @@ cylinder_start:
 
 kernel_address:
 	.word	GRUB_BOOT_MACHINE_KERNEL_ADDR
-kernel_segment:
-	.word	GRUB_BOOT_MACHINE_KERNEL_SEG
 
 	. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
 kernel_sector:
@@ -372,13 +370,6 @@ setup_sectors:
 	movw	%es, %bx
 
 copy_buffer:
-#ifdef APPLE_CC
-	kernel_segment_abs = ABS (kernel_segment)
-	movw	(kernel_segment_abs), %es
-#else
-	movw	ABS(kernel_segment), %es
-#endif
-
 	/*
 	 * We need to save %cx and %si because the startup code in
 	 * kernel uses them without initializing them.
@@ -389,7 +380,8 @@ copy_buffer:
 	movw	$0x100, %cx
 	movw	%bx, %ds
 	xorw	%si, %si
-	xorw	%di, %di
+	movw	$GRUB_BOOT_MACHINE_KERNEL_ADDR, %di
+	movw	%si, %es
 
 	cld
 



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/7] Eliminate kernel_address
  2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
  2009-07-15  1:00 ` [PATCH 2/7] Remove unused version information from boot/i386/pc/boot.S Pavel Roskin
  2009-07-15  1:00 ` [PATCH 3/7] Eliminate kernel_segment Pavel Roskin
@ 2009-07-15  1:00 ` Pavel Roskin
  2009-07-16 15:52   ` Robert Millan
  2009-07-15  1:00 ` [PATCH 5/7] Add newline after "Error" in bootsector Pavel Roskin
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15  1:00 UTC (permalink / raw)
  To: grub-devel

ChangeLog:

	* boot/i386/pc/boot.S: Eliminate kernel_address.  Add .bss
	section corresponding to the loader.  Use relative jump to the
	loader.
---
 boot/i386/pc/boot.S |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index 15d02e5..9323cb9 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -92,9 +92,6 @@ cylinder_start:
 	 * End of BIOS parameter block.
 	 */
 
-kernel_address:
-	.word	GRUB_BOOT_MACHINE_KERNEL_ADDR
-
 	. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
 kernel_sector:
 	.long	1, 0
@@ -392,12 +389,7 @@ copy_buffer:
 	popa
 
 	/* boot kernel */
-#ifdef APPLE_CC
-	kernel_address_abs = ABS (kernel_address)
-	jmp	*(kernel_address_abs)
-#else
-	jmp	*(kernel_address)
-#endif
+	jmp	kernel_entry
 
 /* END OF MAIN LOOP */
 
@@ -532,3 +524,7 @@ fd_probe_error_string:	.asciz "Floppy"
 
 /* the last 2 bytes in the sector 0 contain the signature */
 	.word	GRUB_BOOT_MACHINE_SIGNATURE
+
+	.bss
+	. = . + 0x200
+kernel_entry:



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/7] Add newline after "Error" in bootsector
  2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
                   ` (2 preceding siblings ...)
  2009-07-15  1:00 ` [PATCH 4/7] Eliminate kernel_address Pavel Roskin
@ 2009-07-15  1:00 ` Pavel Roskin
  2009-07-15  1:00 ` [PATCH 6/7] Increase BPB size to accommodate FAT32 Pavel Roskin
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15  1:00 UTC (permalink / raw)
  To: grub-devel

ChangeLog:

	* boot/i386/pc/boot.S (general_error_string): Add DOS newline at
	the end of "Error" to make the message more readable in qemu.
---
 boot/i386/pc/boot.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index 9323cb9..e3f5228 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -425,7 +425,7 @@ notification_string:	.asciz "GRUB "
 geometry_error_string:	.asciz "Geom"
 hd_probe_error_string:	.asciz "Hard Disk"
 read_error_string:	.asciz "Read"
-general_error_string:	.asciz " Error"
+general_error_string:	.asciz " Error\r\n"
 
 /*
  * message: write the string pointed to by %si



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/7] Increase BPB size to accommodate FAT32.
  2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
                   ` (3 preceding siblings ...)
  2009-07-15  1:00 ` [PATCH 5/7] Add newline after "Error" in bootsector Pavel Roskin
@ 2009-07-15  1:00 ` Pavel Roskin
  2009-07-15  1:00 ` [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations Pavel Roskin
  2009-07-16 15:43 ` [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Robert Millan
  6 siblings, 0 replies; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15  1:00 UTC (permalink / raw)
  To: grub-devel

ChangeLog:

	* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_BPB_END):
	Increase to 0x5a.  Adjust other offsets accordingly.
	Original patch by Yves Blusseau <yves.grub-devel@zetam.org>
---
 include/grub/i386/pc/boot.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/grub/i386/pc/boot.h b/include/grub/i386/pc/boot.h
index a91f55a..cf73c3a 100644
--- a/include/grub/i386/pc/boot.h
+++ b/include/grub/i386/pc/boot.h
@@ -26,16 +26,16 @@
 #define GRUB_BOOT_MACHINE_BPB_START	0x3
 
 /* The offset of the end of BPB (BIOS Parameter Block).  */
-#define GRUB_BOOT_MACHINE_BPB_END	0x3e
+#define GRUB_BOOT_MACHINE_BPB_END	0x5a
 
 /* The offset of KERNEL_SECTOR.  */
-#define GRUB_BOOT_MACHINE_KERNEL_SECTOR	0x44
+#define GRUB_BOOT_MACHINE_KERNEL_SECTOR	0x5a
 
 /* The offset of BOOT_DRIVE.  */
-#define GRUB_BOOT_MACHINE_BOOT_DRIVE	0x4c
+#define GRUB_BOOT_MACHINE_BOOT_DRIVE	0x62
 
 /* The offset of BOOT_DRIVE_CHECK.  */
-#define GRUB_BOOT_MACHINE_DRIVE_CHECK	0x4e
+#define GRUB_BOOT_MACHINE_DRIVE_CHECK	0x64
 
 /* The offset of a magic number used by Windows NT.  */
 #define GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC	0x1b8



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations
  2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
                   ` (4 preceding siblings ...)
  2009-07-15  1:00 ` [PATCH 6/7] Increase BPB size to accommodate FAT32 Pavel Roskin
@ 2009-07-15  1:00 ` Pavel Roskin
  2009-07-15 15:33   ` Pavel Roskin
  2009-07-16 15:43 ` [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Robert Millan
  6 siblings, 1 reply; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15  1:00 UTC (permalink / raw)
  To: grub-devel

ChangeLog:

	* boot/i386/pc/boot.S: Declare 0x0-0x7c00 as a discardable .bss
	segment.  Eliminate ABS, rely on the assembler knowing correct
	addresses.  Eliminate .bss segment for the kernel, use direct
	jump to the kernel address.
---
 boot/i386/pc/boot.S |   72 +++++++++------------------------------------------
 1 files changed, 12 insertions(+), 60 deletions(-)

diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index e3f5228..0002773 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -24,20 +24,13 @@
  *  defines for the code go here
  */
 
-	/* Absolute addresses
-	   This makes the assembler generate the address without support
-	   from the linker. (ELF can't relocate 16-bit addresses!) */
-#define ABS(x) (x-_start+0x7c00)
-
 	/* Print message string */
-#ifdef APPLE_CC
-#define MSG(x)	x ## _abs = ABS(x); movw $x ## _abs, %si; call message
-#else
-#define MSG(x)	movw $ABS(x), %si; call message
-#endif
+#define MSG(x)	movw $x, %si; call message
 
 	.file	"boot.S"
 
+	.bss
+	. = 0x7c00
 	.text
 
 	/* Tell GAS to generate 16-bit instructions so that this code works
@@ -126,12 +119,7 @@ boot_drive_check:
 	 * ljmp to the next instruction because some bogus BIOSes
 	 * jump to 07C0:0000 instead of 0000:7C00.
 	 */
-#ifdef APPLE_CC
-	real_start_abs = ABS(real_start)
-	ljmp	$0, $(real_start_abs)
-#else
-	ljmp	$0, $ABS(real_start)
-#endif
+	ljmp	$0, $real_start
 
 real_start:
 
@@ -148,12 +136,7 @@ real_start:
 	/*
 	 *  Check if we have a forced disk reference here
 	 */
-#ifdef APPLE_CC
-	boot_drive_abs = ABS (boot_drive)
-	movb    boot_drive_abs, %al
-#else
-	movb   ABS(boot_drive), %al
-#endif
+	movb	boot_drive, %al
 	cmpb	$0xff, %al
 	je	1f
 	movb	%al, %dl
@@ -165,12 +148,7 @@ real_start:
 	MSG(notification_string)
 
 	/* set %si to the disk address packet */
-#ifdef APPLE_CC
-	disk_address_packet_abs = ABS (disk_address_packet)
-	movw	$disk_address_packet_abs, %si
-#else
-	movw	$ABS(disk_address_packet), %si
-#endif
+	movw	$disk_address_packet, %si
 
 	/* do not probe LBA if the drive is a floppy */
 	testb	$GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl
@@ -211,18 +189,10 @@ lba_mode:
 	movw	$0x0010, (%si)
 
 	/* the absolute address */
-#ifdef APPLE_CC
-	kernel_sector_abs = ABS (kernel_sector)
-	movl	(kernel_sector_abs), %ebx
-	movl	%ebx, 8(%si)
-	movl	(kernel_sector_abs + 4), %ebx
-	movl	%ebx, 12(%si)
-#else
-	movl	ABS(kernel_sector), %ebx
+	movl	kernel_sector, %ebx
 	movl	%ebx, 8(%si)
-	movl	ABS(kernel_sector + 4), %ebx
+	movl	kernel_sector + 4, %ebx
 	movl	%ebx, 12(%si)
-#endif
 
 	/* the segment of buffer address */
 	movw	$GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si)
@@ -289,22 +259,13 @@ final_init:
 
 setup_sectors:
 	/* load logical sector start (top half) */
-#ifdef APPLE_CC
-	kernel_sector_abs = ABS (kernel_sector)
-	movl	(kernel_sector_abs + 4), %eax
-#else
-	movl	ABS(kernel_sector + 4), %eax
-#endif
+	movl	kernel_sector + 4, %eax
 
 	orl	%eax, %eax
 	jnz	geometry_error
 
 	/* load logical sector start (bottom half) */
-#ifdef APPLE_CC
-	movl	(kernel_sector_abs), %eax
-#else
-	movl	ABS(kernel_sector), %eax
-#endif
+	movl	kernel_sector, %eax
 
 	/* zero %edx */
 	xorl	%edx, %edx
@@ -389,7 +350,7 @@ copy_buffer:
 	popa
 
 	/* boot kernel */
-	jmp	kernel_entry
+	jmp	GRUB_BOOT_MACHINE_KERNEL_ADDR
 
 /* END OF MAIN LOOP */
 
@@ -475,12 +436,7 @@ floppy_probe:
  *  Perform floppy probe.
  */
 
-#ifdef APPLE_CC
-	probe_values_abs = ABS (probe_values)
-	movw	$(probe_values_abs-1), %si
-#else
-	movw	$ABS(probe_values-1), %si
-#endif
+	movw	$probe_values - 1, %si
 
 probe_loop:
 	/* reset floppy controller INT 13h AH=0 */
@@ -524,7 +480,3 @@ fd_probe_error_string:	.asciz "Floppy"
 
 /* the last 2 bytes in the sector 0 contain the signature */
 	.word	GRUB_BOOT_MACHINE_SIGNATURE
-
-	.bss
-	. = . + 0x200
-kernel_entry:



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations
  2009-07-15  1:00 ` [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations Pavel Roskin
@ 2009-07-15 15:33   ` Pavel Roskin
  2009-07-15 22:41     ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15 15:33 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, 2009-07-14 at 21:00 -0400, Pavel Roskin wrote:
> ChangeLog:
> 
> 	* boot/i386/pc/boot.S: Declare 0x0-0x7c00 as a discardable .bss
> 	segment.  Eliminate ABS, rely on the assembler knowing correct
> 	addresses.  Eliminate .bss segment for the kernel, use direct
> 	jump to the kernel address.

I managed to install a Darwin cross-compiler, and it turn out it won't
accept .bss in assembler files.  Using real addresses would be very,
very nice, but we'll need to find a portable way.  Maybe grub-macho2img
should be taught to cut away sections filled with zeroes.

So patches 5 and 7 are dropped for now.  Patches 1-4 and 6 have been
applied.  Installation on FAT32 is safe now.  The "Hard Disk" message
has been preserved, so it can be shortened later if the real need
arises.

That said, using direct jump to 0x8000 would save 3 bytes, and then we
can save 2 bytes by taking an unconditional jump from the "disk check"
code and reverting the logic.  And maybe we could save 1 byte by yanking
"cli" as writing to %ss disables interrupts until the next instruction.

While testing the patches in qemu, I've seen some error messages and
found that they should be followed by a new line, as qemu adds its own
error message.

-- 
Regards,
Pavel Roskin



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] RFC: Use correct addresses, eliminate manual  relocations
  2009-07-15 15:33   ` Pavel Roskin
@ 2009-07-15 22:41     ` Vladimir 'phcoder' Serbinenko
  2009-07-15 23:40       ` Pavel Roskin
  2009-07-16  3:44       ` Pavel Roskin
  0 siblings, 2 replies; 15+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-07-15 22:41 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, Jul 15, 2009 at 5:33 PM, Pavel Roskin<proski@gnu.org> wrote:
> On Tue, 2009-07-14 at 21:00 -0400, Pavel Roskin wrote:
>> ChangeLog:
>>
>>       * boot/i386/pc/boot.S: Declare 0x0-0x7c00 as a discardable .bss
>>       segment.  Eliminate ABS, rely on the assembler knowing correct
>>       addresses.  Eliminate .bss segment for the kernel, use direct
>>       jump to the kernel address.
>
> I managed to install a Darwin cross-compiler, and it turn out it won't
> accept .bss in assembler files.  Using real addresses would be very,
> very nice, but we'll need to find a portable way.  Maybe grub-macho2img
> should be taught to cut away sections filled with zeroes.
>
AFAIR during compilation process relocation entries are preserved and
resolved only in the last step. Now thinking it should work even
without .bss. Anyway don't care much about compiling bootsectors under
darwin. Apple's CC generates longer opcodes which breaks bootsectors.
Untill someone finds a fix darwin users will have to use bootsectors
compiled under linux. It's not a huge problem since very few
developpers need to modify boot sector
> So patches 5 and 7 are dropped for now.  Patches 1-4 and 6 have been
> applied.  Installation on FAT32 is safe now.  The "Hard Disk" message
> has been preserved, so it can be shortened later if the real need
> arises.
>
> That said, using direct jump to 0x8000 would save 3 bytes
Unfortunately BIOSes loading at 7c0:0 exist
> and then we
> can save 2 bytes by taking an unconditional jump from the "disk check"
> code and reverting the logic.
I don't understand what part of code you mean but as long if it's just
revertion of a logic to do the same then it's fine with me
> And maybe we could save 1 byte by yanking
> "cli" as writing to %ss disables interrupts until the next instruction.
I pefer to keep cli because alternative i386 implementations may have
bug with it
>
> While testing the patches in qemu, I've seen some error messages and
> found that they should be followed by a new line, as qemu adds its own
> error message.
>
> --
> Regards,
> Pavel Roskin
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] RFC: Use correct addresses, eliminate manual  relocations
  2009-07-15 22:41     ` Vladimir 'phcoder' Serbinenko
@ 2009-07-15 23:40       ` Pavel Roskin
  2009-07-16  3:44       ` Pavel Roskin
  1 sibling, 0 replies; 15+ messages in thread
From: Pavel Roskin @ 2009-07-15 23:40 UTC (permalink / raw)
  To: The development of GRUB 2

On Thu, 2009-07-16 at 00:41 +0200, Vladimir 'phcoder' Serbinenko wrote:

> AFAIR during compilation process relocation entries are preserved and
> resolved only in the last step. Now thinking it should work even
> without .bss. Anyway don't care much about compiling bootsectors under
> darwin. Apple's CC generates longer opcodes which breaks bootsectors.
> Untill someone finds a fix darwin users will have to use bootsectors
> compiled under linux. It's not a huge problem since very few
> developpers need to modify boot sector

OK, good to know.  I'll try to preserve Darwin compatibility though.  At
least I can test it now.

> > So patches 5 and 7 are dropped for now.

I meant patches 4 (removal of kernel_address) and 7 (elimination of
manual relocations).

>   Patches 1-4 and 6 have been
> > applied.  Installation on FAT32 is safe now.  The "Hard Disk" message
> > has been preserved, so it can be shortened later if the real need
> > arises.
> >
> > That said, using direct jump to 0x8000 would save 3 bytes
> Unfortunately BIOSes loading at 7c0:0 exist

I mean we can remove kernel_address (minus 2 bytes) and use "jmp 0x8000"
instead of "jmp *(kernel_address)" (3 bytes instead of 4).  We are in
the correct segment already at that point.

> > and then we
> > can save 2 bytes by taking an unconditional jump from the "disk check"
> > code and reverting the logic.
> I don't understand what part of code you mean but as long if it's just
> revertion of a logic to do the same then it's fine with me

Well, we cannot "revert the logic", as we don't use grub-setup in
grub-mkrescue (perhaps it should be fixed).  As it stands now, the
bootsector should default to "no drive check".

I have a solution for that, but it turns out that grub-setup is buggy,
specifically this code:

if (dest_dev->disk->id & 0x80)

dest_dev->disk->id is just a position of the entry in device.map.
Moreover, util/hostdisk.c sets disk->has_partitions to 1
indiscriminately, even for floppies, so we cannot rely on it.  I suspect
that installation on floppies is broken, as copying the partition table
would overwrite the floppy code in the bootsector.

Before this is fixed, it's better to keep the drive check as is.

> > And maybe we could save 1 byte by yanking
> > "cli" as writing to %ss disables interrupts until the next instruction.
> I pefer to keep cli because alternative i386 implementations may have
> bug with it

OK.

-- 
Regards,
Pavel Roskin



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations
  2009-07-15 22:41     ` Vladimir 'phcoder' Serbinenko
  2009-07-15 23:40       ` Pavel Roskin
@ 2009-07-16  3:44       ` Pavel Roskin
  2009-07-16 15:36         ` Vladimir 'phcoder' Serbinenko
  1 sibling, 1 reply; 15+ messages in thread
From: Pavel Roskin @ 2009-07-16  3:44 UTC (permalink / raw)
  To: grub-devel

Quoting Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>:

Sorry for the second reply.  I have some new data now.

> AFAIR during compilation process relocation entries are preserved and
> resolved only in the last step. Now thinking it should work even
> without .bss.

I wrongly assumed that I need it to eliminate the ABS macro, which is  
quite intrusive.  It turns out ABS can be eliminated without any .bss  
sections.  I have no idea why ABS appeared originally.  Maybe some  
really old tools couldn't deal with the relocations.

> Anyway don't care much about compiling bootsectors under
> darwin.

We have to care, as we have a lot of preprocessor directives in the  
bootsector sources, and they stand in the way of other changes.  We  
should either maintain that code or discard it.

> Apple's CC generates longer opcodes which breaks bootsectors.

You mean Apple assembler.  And I know why it happens.  The Apple  
assembler assumes unknown labels to be global and generates long  
jumps.  I looked at the source and it looks like only labels starting  
with "L" are considered local.

I prepended "L_" to all labels that are used for jumps, and now the  
Apple assembler creates exactly the same boot.img as the native Linux  
assembler.

> Untill someone finds a fix darwin users will have to use bootsectors
> compiled under linux. It's not a huge problem since very few
> developpers need to modify boot sector

I think I have a fix.  I'll post both patches for boot.S - one to  
remove Apple preprocessor directives and the other to remove ABS.  If  
both work for everyone (I'm worried about Cygwin), we can go ahead  
with other files.

By the way, Apple cpp defines __APPLE__ and __APPLE_CC__, so we don't  
need to define APPLE_CC.  But I hope to get rid of APPLE_CC in most  
places before the rest is converted to __APPLE__.

-- 
Regards,
Pavel Roskin



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] RFC: Use correct addresses, eliminate manual  relocations
  2009-07-16  3:44       ` Pavel Roskin
@ 2009-07-16 15:36         ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 15+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-07-16 15:36 UTC (permalink / raw)
  To: The development of GRUB 2

On Thu, Jul 16, 2009 at 5:44 AM, Pavel Roskin<proski@gnu.org> wrote:
> Quoting Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>:
>
> Sorry for the second reply.  I have some new data now.
>
>> AFAIR during compilation process relocation entries are preserved and
>> resolved only in the last step. Now thinking it should work even
>> without .bss.
>
> I wrongly assumed that I need it to eliminate the ABS macro, which is quite
> intrusive.  It turns out ABS can be eliminated without any .bss sections.  I
> have no idea why ABS appeared originally.  Maybe some really old tools
> couldn't deal with the relocations.
>
I'm not sure whether supporting old tools is desirable. On one hand
some OSes may have kept old tools for binary compatibility (I think
especially about haiku which has plans to add multiboot support) but
on the other hand since nobody checks a compilation with old tools is
probably broken anyway. What do others think?
>> Anyway don't care much about compiling bootsectors under
>> darwin.
>
> We have to care, as we have a lot of preprocessor directives in the
> bootsector sources, and they stand in the way of other changes.  We should
> either maintain that code or discard it.
>
No that you found a way to compile them I do care. Just after having
done all the workarounds and fixes to compile core and modules I
recieved an allergy to this toolchain but I will continue to support
it even if I won't spend a lot of time on it.
>> Apple's CC generates longer opcodes which breaks bootsectors.
>
> You mean Apple assembler.  And I know why it happens.  The Apple assembler
> assumes unknown labels to be global and generates long jumps.  I looked at
> the source and it looks like only labels starting with "L" are considered
> local.
>
> I prepended "L_" to all labels that are used for jumps, and now the Apple
> assembler creates exactly the same boot.img as the native Linux assembler.
>
Nice. Now afaik the last barrier to grub-on-darwin to be functional
are trampolines.
>> Untill someone finds a fix darwin users will have to use bootsectors
>> compiled under linux. It's not a huge problem since very few
>> developpers need to modify boot sector
>
> I think I have a fix.  I'll post both patches for boot.S - one to remove
> Apple preprocessor directives and the other to remove ABS.  If both work for
> everyone (I'm worried about Cygwin), we can go ahead with other files.
>
I'll check them on my OSes
> By the way, Apple cpp defines __APPLE__ and __APPLE_CC__,
Yves Blusseau told me about that just before I went to vacation and so
I haven't made use of this info and Yves submitted no patch despite me
encouraging him to do so
> so we don't need
> to define APPLE_CC.  But I hope to get rid of APPLE_CC in most places before
> the rest is converted to __APPLE__.
Perhaps in some cases we need something more fine-grained like test if
resulting image is Mach-O since mixed toolchains with some Apple and
some non-Apple components are possible
>
> --
> Regards,
> Pavel Roskin
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify
  2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
                   ` (5 preceding siblings ...)
  2009-07-15  1:00 ` [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations Pavel Roskin
@ 2009-07-16 15:43 ` Robert Millan
  6 siblings, 0 replies; 15+ messages in thread
From: Robert Millan @ 2009-07-16 15:43 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Jul 14, 2009 at 09:00:17PM -0400, Pavel Roskin wrote:
> ChangeLog:
> 
> 	* include/grub/i386/pc/boot.h: Sort all offsets.
> 	(GRUB_BOOT_MACHINE_KERNEL_ADDRESS): Remove, it's unused.
> 	(GRUB_BOOT_MACHINE_KERNEL_SEGMENT): Likewise.
> 	* boot/i386/pc/boot.S: Assert location of every offset listed in
> 	include/grub/i386/pc/boot.h.
> ---
>  boot/i386/pc/boot.S         |    8 +++++++-
>  include/grub/i386/pc/boot.h |   10 ++--------
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
> index 8d8c27c..fb90947 100644
> --- a/boot/i386/pc/boot.S
> +++ b/boot/i386/pc/boot.S
> @@ -65,6 +65,7 @@ start:
>  	 * this area.
>  	 */
>  
> +	. = _start + GRUB_BOOT_MACHINE_BPB_START
>  	. = _start + 4

Why is this +4 still needed?  If it's alignment, I'd make it explicit.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/7] Eliminate kernel_segment
  2009-07-15  1:00 ` [PATCH 3/7] Eliminate kernel_segment Pavel Roskin
@ 2009-07-16 15:45   ` Robert Millan
  0 siblings, 0 replies; 15+ messages in thread
From: Robert Millan @ 2009-07-16 15:45 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Jul 14, 2009 at 09:00:30PM -0400, Pavel Roskin wrote:
> ChangeLog:
> 
> 	* boot/i386/pc/boot.S (kernel_segment): Remove.
> 	(copy_buffer): Copy to 0x0000:0x8000, not to 0x0800:0x0000.

This looks like it would set an higher limit to the kernel link address.  Are
we certain we want this?

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/7] Eliminate kernel_address
  2009-07-15  1:00 ` [PATCH 4/7] Eliminate kernel_address Pavel Roskin
@ 2009-07-16 15:52   ` Robert Millan
  0 siblings, 0 replies; 15+ messages in thread
From: Robert Millan @ 2009-07-16 15:52 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Jul 14, 2009 at 09:00:36PM -0400, Pavel Roskin wrote:
> ChangeLog:
> 
> 	* boot/i386/pc/boot.S: Eliminate kernel_address.  Add .bss
> 	section corresponding to the loader.  Use relative jump to the
> 	loader.

Nice simplification.  But what's this .bss needed for?  It doesn't look
like a BSS.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-07-16 15:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-15  1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
2009-07-15  1:00 ` [PATCH 2/7] Remove unused version information from boot/i386/pc/boot.S Pavel Roskin
2009-07-15  1:00 ` [PATCH 3/7] Eliminate kernel_segment Pavel Roskin
2009-07-16 15:45   ` Robert Millan
2009-07-15  1:00 ` [PATCH 4/7] Eliminate kernel_address Pavel Roskin
2009-07-16 15:52   ` Robert Millan
2009-07-15  1:00 ` [PATCH 5/7] Add newline after "Error" in bootsector Pavel Roskin
2009-07-15  1:00 ` [PATCH 6/7] Increase BPB size to accommodate FAT32 Pavel Roskin
2009-07-15  1:00 ` [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations Pavel Roskin
2009-07-15 15:33   ` Pavel Roskin
2009-07-15 22:41     ` Vladimir 'phcoder' Serbinenko
2009-07-15 23:40       ` Pavel Roskin
2009-07-16  3:44       ` Pavel Roskin
2009-07-16 15:36         ` Vladimir 'phcoder' Serbinenko
2009-07-16 15:43 ` [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.