bugGNU GRUB - Bugs: bug #9984, Run DiskEMU1x.bin from Grub

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #9984: Run DiskEMU1x.bin from Grub

Submitter:  Gandalf <f22_storm>
Submitted:  Thu 12 Aug 2004 01:15:09 AM UTC
   
 
Category:  Booting Severity:  Major
Priority:  5 - Normal Item Group:  None
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Closed Release:  None
Release:  0.95 Reproducibility:  Every Time
Planned Release:  None

Sat 15 Dec 2007 04:37:40 PM UTC, comment #4: 

We've moved to GRUB 2 as a development platform. Please can you check if this bug still applies there, and if it does, reopen it?

Thanks

Robert Millan <robertmh>
Group administrator
Thu 12 Aug 2004 01:26:20 AM UTC, comment #3: 

something comments for codes in asm.S
====================================

Because Grub's stage2 lays on 0000:8000, we have to read file to 6000:0000;

In asm.S, we have 2 thing to do, one is move boot codes from 6000:0000 to 7c0:0000;  and another one is move the 1st one from Grub's body to 0000:6000, and run it. ;-)

Gandalf <f22_storm>
Thu 12 Aug 2004 01:21:30 AM UTC, comment #2: 

4). asm.S

/* void run_jump (segment, offset, drv_num)

  •  Jump to 0:7c00.  by Gandalf

 */

ENTRY(run_jump)
movl 0xc(%esp), %eax
mov %ax, drv_num

pushw %es
pushw %ds
pusha
call EXT_C(prot_to_real)
.code16

/* copy stub to 0:6000*/
movw $0x6000, %di
xorw %ax, %ax
push %ax
pop %es
movw $(RUN_MAIN), %si
movw $(END_OF_RUN_MAIN - RUN_MAIN), %cx
cld
rep movsb /* OK, transfer Done! */

movw drv_num, %dx
mov $(run_address_off), %di
lcall (%di) / run 0:6000 */

RUN_MAIN:
/* copy stub to 07c0:0000*/
pushw %dx /* Boot Drv Num */
movw $0x0, %di
movw $0x7c0, %ax
pushw %ax
popw %es
movw $0x0, %si

movw $0x6000, %ax
pushw %ax
popw %ds
movw $0x8000, %cx /* only support 32kb */
cld
rep movsb /* OK, transfer Done! */


xorw %ax, %ax
pushw %ax
popw %ds

popw %dx /* Boot Drv Num */

movw $0x7c0, %ax
movw %ax, (0x5002)

xorw %bx, %bx
movw %bx, (0x5000) /* 0x07c0:0 */

movw $0x5000, %di

lcall *(%di)
END_OF_RUN_MAIN:

DATA32 call EXT_C(real_to_prot)
.code32
popa
popw %ds
popw %es
ret

ENTRY(RUN_DATA)
.code16
run_address_off: .word 0x6000
run_address_seg: .word 0x0000
drv_num: .word   0x0000

Gandalf <f22_storm>
Thu 12 Aug 2004 01:19:51 AM UTC, comment #1: 

2). shared.h

void run_jump (unsigned long segment, unsigned long offset,
      int drv_num)
     _attribute_ ((noreturn));


3). asmstub.c

void
run_jump (unsigned long segment, unsigned long offset,
      int drv_num)
{
   stop();
}

Gandalf <f22_storm>
Thu 12 Aug 2004 01:15:09 AM UTC, original submission:  
  • For MultiBoot Support *


Since Grub can be loaded from CD, we may want it load some binary boot file from system, such as DiskEMU.bin, xpboot.bin, or bootsect.dat, and so on.

Yes, here are functions for this:
1). builtins.c
static int run_func(char *arg, int flags) {
 int ret;
 unsigned long run_drv;
 struct term_entry *prev_term = current_term;

 run_drv = saved_drive;
 if(run_drv == cdrom_drive)
 {
  if (cdrom_drive != 0xe0)
  {
   grub_printf("\n Please init CD-ROM 1st. \n");
   return 1;
  }
 }
 if (! grub_open (arg))
 {
   grub_printf("\n incorect parameter. \n");
   return 1;
  }
 
 /* Read whole file.  */
 ret = grub_read ((char *) RAW_ADDR (0x60000), -1);

 grub_close();

 if (current_term->shutdown)
 {
  (*current_term->shutdown)();
   current_term = term_table; /* assumption: console is first */
 }

 gateA20 (0);
 run_jump(0x7c0, 0, run_drv);

 /* if we get back here, we should go back to what our term was before */
 current_term = prev_term;
 if (current_term->startup)
      /* if our terminal fails to initialize, fall back to console since
       it should always work /

  if ((*current_term->startup)() == 0)
 current_term = term_table; /* we know that console is first */
 return 0;
}

static struct builtin builtin_run=
{
"run",
run_func,
BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST,
"run FILE",
"Run a NO-Emul Boot Sector file for CD-ROM Boot",
};


struct builtin *builtin_table[] =
{
   ... ...

  &builtin_run,

   ... ...
}

Gandalf <f22_storm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by robertmh (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-12-15 robertmh Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code