Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JJR0e-0002a6-1H for mharc-grub-devel@gnu.org; Mon, 28 Jan 2008 05:14:36 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJR0b-0002ZN-E3 for grub-devel@gnu.org; Mon, 28 Jan 2008 05:14:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJR0Z-0002Yl-Rn for grub-devel@gnu.org; Mon, 28 Jan 2008 05:14:32 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJR0Z-0002Ya-Br for grub-devel@gnu.org; Mon, 28 Jan 2008 05:14:31 -0500 Received: from rv-out-0910.google.com ([209.85.198.186]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JJR0Y-0005VY-RC for grub-devel@gnu.org; Mon, 28 Jan 2008 05:14:31 -0500 Received: by rv-out-0910.google.com with SMTP id c27so2507029rvf.6 for ; Mon, 28 Jan 2008 02:14:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=PjrOR+bioUSEFzJO58zXHruhzlRv3ql0sQd+zbsIQyw=; b=Gd/RsLIWzWQjNuvdsIfvpyGmKFXWvux4VnSZJImdS8/ZI4CD9AlexsLEaoQ1UkE7o4+wdieAbfROLReownAZCJGYLplSEolcqu8yPFtuXPenF2Wl7EtN5GzYgJD5ZrwZINqcMS9s//vgnXgIisAEee8qAwBDaZbmJs3+iqyIy0c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=adeCzBy/pD1qh2p7QPkIV3gF40h9/ZD315NVqqOn8akQSEdxNxxbmOD72AILia401PMdW3mE+sMS+jnFJ3VkpC/f3hwHjntKmyliVgnJhiQ5vteCj8QVkJyqbR51aEFwcJ7zxo2Ytc8wUWjQ2igXPz1ctcRIv+gtJfe6FVqrNFY= Received: by 10.140.203.9 with SMTP id a9mr3290688rvg.203.1201515268757; Mon, 28 Jan 2008 02:14:28 -0800 (PST) Received: by 10.141.82.5 with HTTP; Mon, 28 Jan 2008 02:14:28 -0800 (PST) Message-ID: Date: Mon, 28 Jan 2008 18:14:28 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080126172120.GA4119@thorin> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: Compiling grub2 on *BSD? X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jan 2008 10:14:34 -0000 On Jan 27, 2008 2:15 AM, Bean wrote: > On Jan 27, 2008 1:21 AM, Robert Millan 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