Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JIpZP-0001wm-Er for mharc-grub-devel@gnu.org; Sat, 26 Jan 2008 13:15:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JIpZN-0001wF-IX for grub-devel@gnu.org; Sat, 26 Jan 2008 13:15:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JIpZK-0001vE-4A for grub-devel@gnu.org; Sat, 26 Jan 2008 13:15:57 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JIpZJ-0001vB-Vv for grub-devel@gnu.org; Sat, 26 Jan 2008 13:15:54 -0500 Received: from wa-out-1112.google.com ([209.85.146.181]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JIpZJ-0007Tu-Hm for grub-devel@gnu.org; Sat, 26 Jan 2008 13:15:53 -0500 Received: by wa-out-1112.google.com with SMTP id k34so2391195wah.10 for ; Sat, 26 Jan 2008 10:15:52 -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=FG1qrvWu8Mrz/A3uDWKBusKG5OrwcXt6zW3qkb/A0KQ=; b=wazCKAbdUcU7kVuGVQEbInxlM5UeIDU6XXpIN8Qj+lVfoi/eK2N4bAqt84yNmnXbPlbv7fvXsc2lC2hmbWqgSsmnjZBWZ1v1KpEkyyWFTVIHLOtgY2IoVCEPv87dhBGMIdAfrfwB7WmyINbXLkcGBw4Ol8ApdBFO+t+r+QX2ZSo= 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=wWtN+HLIabuijiQOG3So6bo1ouiB6BXS/xy974+WkNiaBGDZedMUVE22cifsNWoo/6Pa7ZUxYgli4SHq5goeQp0u2867cxzOGHHvJW1ZzP4Xc6kIfQqDaXHIL7jC1TAcV4UImv8J4vinAdsGSRuE9GqoaVERAgPX9+S7Q8LYP+g= Received: by 10.110.43.18 with SMTP id q18mr1702856tiq.24.1201371351107; Sat, 26 Jan 2008 10:15:51 -0800 (PST) Received: by 10.110.31.8 with HTTP; Sat, 26 Jan 2008 10:15:51 -0800 (PST) Message-ID: Date: Sun, 27 Jan 2008 02:15:51 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <20080126172120.GA4119@thorin> 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: Sat, 26 Jan 2008 18:15:57 -0000 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