[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compiling grub2 on *BSD?
From: |
Bean |
Subject: |
Re: Compiling grub2 on *BSD? |
Date: |
Mon, 28 Jan 2008 18:14:28 +0800 |
On Jan 27, 2008 2:15 AM, Bean <address@hidden> wrote:
> On Jan 27, 2008 1:21 AM, Robert Millan <address@hidden> wrote:
> > > FreeBSD:
> > >
> > > lnxboot.S: Assembler messages:
> > > lnxboot.S:49: Error: `0x200+data_start - data_next(%ebx,%eax)' is not a
> > > valid 16 bit base/index expression
> > > lnxboot.S:264: Error: `(%esi,%eax)' is not a valid 16 bit base/index
> > > expression
> > > lnxboot.S:265: Error: `(%edi,%eax)' is not a valid 16 bit base/index
> > > expression
> >
> > I recall having seen this before. Please, can you check the list archives?
> > I think we solved it for other files, but it might have been respawned in
> > lnxboot.S.
>
> yes, this is caused by a trick to use 32-bit address mode for fast
> arithmetic. here is the patch, along with some code cleanup for
> lnxboot.S.
>
> diff --git a/boot/i386/pc/lnxboot.S b/boot/i386/pc/lnxboot.S
> index f1a4ded..81d8e40 100644
> --- a/boot/i386/pc/lnxboot.S
> +++ b/boot/i386/pc/lnxboot.S
> @@ -36,22 +36,7 @@
> .globl start, _start
>
> data_start:
> - pushw %cs
> - popw %ds
> - xorl %eax, %eax
> - xorl %ebx, %ebx
> - call data_next
> -
> -data_next:
> - popw %bx
> - movw %cs, %ax
> - shll $4, %eax
> - leal 0x200 + data_start - data_next(%ebx,%eax), %eax
> - movzbl setup_sects - data_next(%bx), %ecx
> - shll $9, %ecx
> - addl %ecx, %eax
> - movl %eax, code32_start - data_next(%bx)
> -
> + xorl %ebp, %ebp
> jmp linux_next
>
> . = data_start + 0x1F1
> @@ -76,7 +61,7 @@ boot_flag:
> start:
> _start:
>
> - jmp linux_code
> + jmp linux_init
>
> .ascii "HdrS" // Header signature
> .word 0x0203 // Header version number
> @@ -134,9 +119,10 @@ reg_edx:
> data_leng:
> .long 0
>
> -linux_code:
> +linux_init:
>
> movw %cs:(reg_edx - start), %dx
> + movl %cs:(code32_start - start), %ebp
>
> linux_next:
>
> @@ -164,9 +150,6 @@ real_code:
> movw %si, %ss
> movw $(CODE_ADDR), %sp
>
> - pushl %esi
> - pushl %edi
> -
> // Move itself to 0:CODE_ADDR
>
> cld
> @@ -183,34 +166,45 @@ real_code:
>
> real_code_2:
>
> - pushw %es
> - popw %ds
> -
> - movl (ramdisk_image - start), %esi
> - or %esi, %esi
> + xchgl %ebp, %esi
> + orl %esi, %esi
> jnz 1f
> - movl (code32_start - start), %esi
> + movw %ds, %si
> + shll $4, %esi
> + addl %ebp, %esi
> 1:
>
> + pushw %es
> + popw %ds
> +
> movl $0x200, %ecx
> addl %ecx, %esi
> movl $DATA_ADDR, %edi
>
> call move_memory
>
> - movsbl %dh, %eax
> - movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART)
> + // Check for the multiboot signature
> + cmpl $0x1badb002, %ss:(DATA_ADDR + 0x50)
> + jz 1f
>
> - movsbl (reg_edx + 2 - start), %eax
> - movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
> + movl (ramdisk_image - start), %esi
> + movl (ramdisk_size - start), %ecx
> + movl $(DATA_ADDR - 0x200), %edi
> + jmp 2f
> +
> +1:
>
> movl %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx
> addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx
>
> +2:
> call move_memory
>
> - popl %edi
> - popl %esi
> + movsbl %dh, %eax
> + movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART)
> +
> + movsbl (reg_edx + 2 - start), %eax
> + movl %eax, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART)
>
> ljmp $(DATA_ADDR >> 4), $0
>
> @@ -261,8 +255,8 @@ move_memory:
>
> 2:
>
> - leal (%esi, %eax), %esi
> - leal (%edi, %eax), %edi
> + addl %eax, %esi
> + addl %eax, %edi
> subl %eax, %ecx
> jnz 1b
>
>
>
>
> --
> Bean
>
if there is no objection, I'd like to check in this patch.
--
Bean
Re: Compiling grub2 on *BSD?, walt, 2008/01/26
- Re: Compiling grub2 on *BSD?, Robert Millan, 2008/01/27
- Re: Compiling grub2 on *BSD?, jakllsch, 2008/01/29
- Re: Compiling grub2 on *BSD?, Robert Millan, 2008/01/29
- Re: Compiling grub2 on *BSD?, jakllsch, 2008/01/29
- Re: Compiling grub2 on *BSD?, Marco Gerards, 2008/01/30