[lkml]   [2004]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectSwitch back to Real mode and then boot strap
    Hi All,

    I am new to this mailing list ... Need some help, PLEASE :)

    I am running redhat Linux with kernel 2.4.21-4.EL.

    Basically I have a requirement of re-booting ( Without really rebooting )
    the OS from the hard disk ( even if a floppy is present or a bootable CD-ROM
    is present). Update CMOS to change the boot sequence is not an option for
    my requirement.

    My idea is to read the MBR off the hard disk and then jump to the memory
    location of the MBR after switching to real mode. The thing I do not want to
    do is to jump to real address FFFF:0000 because it is going to select the
    boot device ( Where this selection, I do not have any control when I
    rebooted )

    I found a function in process.c ( arch/i386/kernel/ ) called
    machine_real_restart(code,length) where you could give the address of a real
    mode routine. If I call this function (ofcource from a kernel module) with
    address pointed to a piece of code which has ljmp $0xffff,$0x0, the system
    reboots fine. I WAS VERY EXCITED TO SEE THIS.

    Proceeding to my next step, I generated an array of machine code (.code16),
    where I use INT 13h to read the first sector off the hard drive to
    0000:7c00, and then ljmp to 0000:7c000. I used the above kernel function to
    call this. I am was so disappointed to see the SYSTEM JUST HANGS :( .

    Here is the routine I am using ...

    xorw %ax,%ax
    movw %ax,%ds
    movw %ax,%ss
    movw %ax,%es
    movw $0xffff, %sp
    movw $0x201,%ax
    movw $0x01,%cx
    movw $0x7c00, %bx
    movw $0x80,%dx
    int $0x13
    movb $0x0e,%ah
    movb $0x5A,%al
    int $0x10
    ljmp $0x0000,$0x7c00

    Here the code for device IOCTL for my character device.

    int device_ioctl( struct inode *inode, struct file *file, unsigned int i_n,
    unsigned long i_p )

    static unsigned char jbios [] = {

    0x31 ,0xc0 ,0x8e ,0xd8 ,0x8e ,0xd0 ,0x8e ,0xc0 ,0xbc ,0xff ,0xff ,0xb8
    ,0x01 ,0x02 ,0xb9 ,0x01 ,0x00 ,0xbb ,0x00 ,0x7c ,0xba ,0x80 ,0x00 ,0xcd
    ,0x13 ,0xb4 ,0x0e ,0xb0 ,0x5a ,0xcd ,0x10 ,0xea ,0x00 ,0x7c ,0x00 ,0x00 };

    if ( i_n == 999 ) {

    When I call the ioctl, it just hangs. If I replace the code with only a ljmp
    $0xffff,0x0 instruction it reboots the computer as it should.

    Any ideas, what I am doing wrong here ?



    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:06    [W:0.021 / U:30.260 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site