This is unexpected poweroff.
I just translated next stuff from /grub-sources/stage2/asm.S:

ENTRY(real_to_prot)
    .code16
    cli

    /* load the GDT register */
    DATA32    ADDR32    lgdt    gdtdesc

    /* turn on protected mode */
    movl    %cr0, %eax
    orl    $CR0_PE_ON, %eax
    movl    %eax, %cr0

    /* jump to relocation, flush prefetch queue, and reload %cs */
    DATA32    ljmp    $PROT_MODE_CSEG, $protcseg

    /*
     *  The ".code32" directive only works in GAS, the GNU assembler!
     *  This gets out of "16-bit" mode.
     */
    .code32

protcseg:
    /* reload other segment registers */
    movw    $PROT_MODE_DSEG, %ax
    movw    %ax, %ds
    movw    %ax, %es
    movw    %ax, %fs
    movw    %ax, %gs
    movw    %ax, %ss

    /* put the return address in a known safe location */
    movl    (%esp), %eax
    movl    %eax, STACKOFF

    /* get protected mode stack */
    movl    protstack, %eax
    movl    %eax, %esp
    movl    %eax, %ebp

    /* get return address onto the right stack */
    movl    STACKOFF, %eax
    movl    %eax, (%esp)

    /* zero %eax */
    xorl    %eax, %eax

    /* return on the old (or initialized) stack! */
    ret


ENTRY(prot_to_real)
    /* just in case, set GDT */
    lgdt    gdtdesc

    /* save the protected mode stack */
    movl    %esp, %eax
    movl    %eax, protstack

    /* get the return address */
    movl    (%esp), %eax
    movl    %eax, STACKOFF

    /* set up new stack */
    movl    $STACKOFF, %eax
    movl    %eax, %esp
    movl    %eax, %ebp

    /* set up segment limits */
    movw    $PSEUDO_RM_DSEG, %ax
    movw    %ax, %ds
    movw    %ax, %es
    movw    %ax, %fs
    movw    %ax, %gs
    movw    %ax, %ss

    /* this might be an extra step */
    ljmp    $PSEUDO_RM_CSEG, $tmpcseg    /* jump to a 16 bit segment */

tmpcseg:
    .code16

    /* clear the PE bit of CR0 */
    movl    %cr0, %eax
    andl     $CR0_PE_OFF, %eax
    movl    %eax, %cr0

    /* flush prefetch queue, reload %cs */
    DATA32    ljmp    $0, $realcseg

realcseg:
    /* we are in real mode now
     * set up the real mode segment registers : DS, SS, ES
     */
    /* zero %eax */
    xorl    %eax, %eax

    movw    %ax, %ds
    movw    %ax, %es
    movw    %ax, %fs
    movw    %ax, %gs
    movw    %ax, %ss

    /* restore interrupts */
    sti

    /* return on new stack! */
    DATA32    ret

    .code32

Now need to understand what realy happened.

Best regards from airstep.

Attachment: poweroff.patch
Description: Binary data

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SharpOS-Developers mailing list
SharpOS-Developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sharpos-developers

Reply via email to