i386: Switching to protected mode?

i386: Switching to protected mode?

Post by Nicolas Weidman » Wed, 05 Nov 1997 04:00:00



I have some problems switching to protected mode.

This code is loaded at segment 0x1000 and starts execution at start

GDT:
        .word   0, 0, 0, 0

        .word   0xffff
        .word   0x0000    /* boot segment 0x1000 */
        .word   0x9a01
        .word   0x0040

        .word   0xffff
        .word   0x0000
        .word   0x9c01
        .word   0x0040

GDTR:
        .word   19, 0, 0

start:
        .byte   0x66
        mov     $GDT, %eax
        .byte   0x67             /* address prefix */
        .byte   0x66             /* data prefix */
        movl    %eax, GDTR + 2

        cli

        .byte   0x67, 0x66
        lgdt    GDTR

        mov     %cr0, %eax
        .byte   0x66
        or      $1, %eax
        mov     %eax, %cr0

        .byte   0x66
        ljmp    $0x08, $prot

prot:
        movw    $0x10, %ax
        mov     %ax, %ds
        mov     %ax, %ss
        mov     %ax, %es

This (nicely ?) reboots my machine.

What is wrong. Thank you for your help.

Nicolas

 
 
 

i386: Switching to protected mode?

Post by Benjamin Redelings » Wed, 05 Nov 1997 04:00:00


I thought Linux was ALWAYS in protected mode... I can't imagine a user
process being allowed to change that setting!  Are you writing a kernel
or something?

Good luck,
-BenRI

 
 
 

i386: Switching to protected mode?

Post by Stefan Monnie » Wed, 05 Nov 1997 04:00:00



> This (nicely ?) reboots my machine.

Have you tried renaming it "reboot" ?

Quote:> What is wrong. Thank you for your help.

The problem is that it might not always reboot your machine with
other versions of the kernel. Better stick to the standard commands
like "reboot", "shutdown" or whatever is your favorite variant.

        Stefan "hope it helps"

 
 
 

i386: Switching to protected mode?

Post by Martynas Kunigeli » Sat, 08 Nov 1997 04:00:00



> I have some problems switching to protected mode.

> This code is loaded at segment 0x1000 and starts execution at start

> GDT:
>         .word   0, 0, 0, 0

>         .word   0xffff
>         .word   0x0000    /* boot segment 0x1000 */
>         .word   0x9a01
>         .word   0x0040

>         .word   0xffff
>         .word   0x0000
>         .word   0x9c01
>         .word   0x0040

> GDTR:
>         .word   19, 0, 0

> start:
>         .byte   0x66
>         mov     $GDT, %eax
>         .byte   0x67             /* address prefix */
>         .byte   0x66             /* data prefix */
>         movl    %eax, GDTR + 2

>         cli

>         .byte   0x67, 0x66
>         lgdt    GDTR

>         mov     %cr0, %eax
>         .byte   0x66
>         or      $1, %eax
>         mov     %eax, %cr0

>         .byte   0x66
>         ljmp    $0x08, $prot

> prot:
>         movw    $0x10, %ax
>         mov     %ax, %ds
>         mov     %ax, %ss
>         mov     %ax, %es

> This (nicely ?) reboots my machine.

> What is wrong. Thank you for your help.

I have no idea what is wrong, but the first thing to try
is to use the .code16 directive of GAS. It will eliminate the
.byte 0x66 prefixes and you'll be able to use the real names
of instructions (movw instead of movl etc.)

My $0.0002

Martynas

 
 
 

1. i386: Switching to protected mode

I have some problems when switching to protected mode: it fails.

GDT:
        .word   0, 0, 0, 0

        .word   0xffff
        .word   0x0000
        .word   0x9a01
        .word   0x0040

        .word   0xffff
        .word   0x0000
        .word   0x9201
        .word   0x0040

GDTR:
        .word   23, 0, 0

start:
        .byte   0x66
        movl    $GDT, %eax
        .byte   0x67, 0x66
        movl    %eax, GDTR + 2

        cli

        .byte   0x67, 0x66
        lgdt    GDTR

        mov     %cr0, %eax
        .byte   0x66
        or      $1, %eax
        mov     %eax, %cr0

        .byte   0x66
        ljmp    $0x08, $prot
prot:
        movw    $0x10, %ax
        mov     %ax, %ds
        mov     %ax, %ss
        mov     %ax, %es

halt:
        hlt
        jmp     halt

This completely fails and reboots the machine.

Thank you for your help.

Nicolas

2. Please help me to get into my account!

3. switch from protected mode to real mode in kernel

4. SunPCI - somewhat OT?

5. Video RAM in protected mode (i386)

6. Redhat 3.0.3; kernel 1.2.13 how to install a new viedeo card ??

7. A confusion about IA32 protected mode protecting kernel data.

8. convert decimal to octal

9. linux->real mode-> boot other OS in protected mode

10. How to enter VGA 12H mode from protected mode?

11. Switching from an Xwin graphics mode to a terminal mode

12. Switching btw Xwin graphical mode and terminal mode

13. Problems switching between X Mode and Login Prompt Mode