From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1I2K4w-0004Qm-Pk for mharc-grub-devel@gnu.org; Sun, 24 Jun 2007 00:52:02 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I2K4v-0004Qh-6Q for grub-devel@gnu.org; Sun, 24 Jun 2007 00:52:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I2K4u-0004QR-3w for grub-devel@gnu.org; Sun, 24 Jun 2007 00:52:00 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I2K4t-0004QO-Qb for grub-devel@gnu.org; Sun, 24 Jun 2007 00:51:59 -0400 Received: from m15-111.126.com ([220.181.15.111]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1I2K4s-00022t-EX for grub-devel@gnu.org; Sun, 24 Jun 2007 00:51:59 -0400 Received: from localhost (unknown [123.49.201.18]) by smtp1 (Coremail) with SMTP id wKjJCyVAVB5q+H1GPjLTAg==.55641S2; Sun, 24 Jun 2007 12:51:55 +0800 (CST) Date: Sun, 24 Jun 2007 12:51:35 +0800 From: Bean To: The development of GRUB 2 Message-ID: <20070624045135.GA8487@ws3.vdp.com> References: <8c0c43de0706232131t48e63e45jf99963529a2f2304@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8c0c43de0706232131t48e63e45jf99963529a2f2304@mail.gmail.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-Coremail-Antispam: 1U3Yxn0WfASr-VFAUDIcSsGvfJTRUUUjVkFxVCF77xC6IxKo4 kEV4ylIxAIcVC2z280aVAFwI0_Jr0_Gr1lnxkEFVAIw20F6cxK64vIFxWlx4CE17CEb7AF 67AKxVWUJVWUXwCjxxvEw4Wle4C267I2x7xF54xIwI1lYx0E2Ix0cI8IcVAFwI0_Jr0_Jr 4l4x8a6c8ajcxJMcIj6I8E87Iv67AKxVWUJVW8JwAFxVCaYxvI4VCIwcAKzIAtMxkI7II2 jI8vz4vEwIxGrwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UMxkIecxEwVAFwVW8XwAFF2 0E14v26r1j6r4UM2kK6IIF8VAqrcv_JFWUCry8M7kC6x804xWl1IIY67AEw4v_Jr0_Jr4l 5I8CrVACY4xI64kE6c02F40Ex7xfMxkFs20EY4vEwck0b40E8IxJMxkFs20EY4vE8sxKj4 xv1wCY1Ik26cxK6x8YrwAYjsxI4VW7JjkaLaAFLSUrUUUUUjvjm3AaLaJ3UjIFyTuYvjxU DhZ2DUUUUUAaLaJafrg_AFyxKF17ZryUAw4DZryDJw43p5X_Gw4xKoZYqF1rGa1xKry0gF y2kr18Ca4fCa4Fgr93Xw17Xr4FqF4DXr1j9343Wwn5Ja98KrWSg347Was3XayfJ34ktFn3 = X-detected-kernel: Linux 2.4-2.6 Subject: Re: Loading boot image retrieved from CD-ROM 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: Sun, 24 Jun 2007 04:52:01 -0000 On Sun, Jun 24, 2007 at 12:31:14AM -0400, Alex Roman wrote: > Hello, > > As you may recall, I'm working on the Google Summer of Code project to > enable GRUB2 to boot off CDs. > > I can now read boot images from CDs using int 13h BIOS calls :) And > I've confirmed I'm actually reading the ISOLINUX image because I can > perform some manual disassembly and it matches what I see in the > ISOLINUX source code :) > > The problem is now booting them. From what I've gathered from the > specs, I'm supposed to load the bootable image at address 0x7c00, > clear the segments (-code segment) and perform a long jump (to set the > code segment) at address 0x7c00 using segment 0x7c0 and offset 0x0. > > Now, I can't read the bootable image directly at 0x7c00, so what I do > is I read it in GRUB_MEMORY_MACHINE_SCRATCH_ADDR + a small offset I > use for some structures. Then I have a function in startup.S which > will copy from that address, into 0x7c00 and then start executing the > image. > > The problem is that QEMU freezes when I call the asm function. Was > wondering if anyone could take a quick look at the function to see if > I'm doing anything wrong, or if someone could suggest how to best > debug this issue... > > Thanks in advance! > > Here is the function: > > --start-- > /* > * void grub_eltorito_boot (int drive, void *buf, int size) > * > * This starts an eltorito boot image from 0:7c00h > */ > > FUNCTION(grub_eltorito_boot) > pushl %eax > pushl %edx > pushl %ecx > > call EXT_C(grub_dl_unload_all) > > /* set up to pass boot drive */ > popl %edx > > /* address in %ebx */ > popl %ebx > > /* count in %ecx */ > popl %ecx > > /* must move image to 0x07c0:0 */ > movw $0x07c0, %ax > movw %ax, %es > xorw %ax, %ax > movw %ax, %di > > pushl %ebx > > /* offset to move from in %si */ > andw $0xf, %bx > movw %bx, %si > > /* segment to move from in %ds */ > popl %ebx > shrl $4, %ebx > movw %bx, %ds > > /* move image */ > rep > movsb > > > /* Turn off Gate A20 */ > xorl %eax, %eax > call EXT_C(grub_gate_a20) > > call prot_to_real > .code16 > xorw %ax, %ax > movw %ax, %ds > movw %ax, %es > movw %ax, %fs > movw %ax, %gs > movw %ax, %ss > ljmp $0x07c0,$0 > .code32 > --end-- Maybe the image overwrites code in statrt.S after it's copied to 0x7c00. To verify, you can print the address of function like grub_eltorito_boot, grub_gate_a20 and prot_to_real, see if they're within range of 0x7c00 to 0x7c00 + image length. -- Bean