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

Submitted by:  Gandalf <f22_storm>
Submitted on:  Thu 12 Aug 2004 01:15:09 AM UTC  
 
Category: BootingSeverity: Major
Priority: 5 - NormalItem Group: None
Status: NonePrivacy: Public
Assigned to: NoneOriginator Name: 
Open/Closed: ClosedRelease: 0.95
Release: NoneReproducibility: 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>
Project 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>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 15 Dec 2007 04:37:40 PM UTCrobertmhOpen/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1