grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Loading boot image retrieved from CD-ROM


From: Alex Roman
Subject: Loading boot image retrieved from CD-ROM
Date: Sun, 24 Jun 2007 00:31:14 -0400

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--


--
Alex Roman <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]