Entering protected mode reboots -


for understanding working of operating system have made simpel bootloader loads small test application testing protected mode etc. after bootsector has been loaded @ 0x7c00 bootloader loads test code @ segment 0x2000 , starts first instruction. when try enter protected mode systems reboots. can me problem?

this code @ section 0x2000

    bits 16  ; entering_protectedmode:         cli                                                  mov ax, 2000h     mov ss, ax                                           mov sp, 0ffffh     sti                                                  cld                                                   mov ax, 2000h                                        mov ds, ax                                           mov es, ax                                           mov fs, ax                                           mov gs, ax      ;xor ax, ax     ;mov ds, ax              ; update data segment      cli                     ; clear interrupts      lgdt [gdtr]             ; load gdt gdtr (see gdt_32.inc)      call opena20gate        ; open a20 gate      call enablepmode        ; jumps protectedmode  opena20gate:     in al, 0x93         ; switch a20 gate via fast a20 port 92     or al, 2            ; set a20 gate bit 1     , al, ~1          ; clear init_now bit     out 0x92, al     ret  enablepmode:     mov eax, cr0     or eax, 1     mov cr0, eax     jmp code_seg : protectedmode  ;********************************* ;* global descriptor table (gdt) * ;********************************* null_desc:     dd 0            ; null descriptor     dd 0  code_desc:     dw 0xffff       ; limit low     dw 0            ; base low     db 0            ; base middle     db 10011010b    ; access     db 11001111b    ; granularity     db 0            ; base high  data_desc:     dw 0xffff       ; limit low     dw 0            ; base low     db 0            ; base middle     db 10010010b    ; access     db 11001111b    ; granularity     db 0            ; base high  gdtr:     dw gdtr - null_desc - 1 ; length of gdt     dd null_desc   ; base of gdt  code_seg equ code_desc - null_desc data_seg equ data_desc - null_desc    ;****************** ;* protected mode * ;******************     bits 32  protectedmode:      .halt:         jmp .halt      ;mov     ax, 10h     ;mov     ds, ax ; update data segment 

try one:

opena20gate: in al, 0x92; instead of 0x93; switch a20 gate via fast a20 port 92 or al, 2            ; set a20 gate bit 1 , al, ~1          ; clear init_now bit out 0x92, al ret  enablepmode: mov eax, cr0 or eax, 1 mov cr0, eax 

......

;code_seg must equal 8 "8:protectedmode". 8 points @ first descriptor of gdt. 16 bit: 15-3 - index in gdt (0 0 descriptor, 1 first descriptor - code, 2 second descriptor - data), 2 - table indicator (0 gdt, 1 ldt), 1-0 - rpl (the request privilege level).

jmp code_seg:protectedmode 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -