2012-10-19 7 views
1

GRUB을 부트 로더로 사용하여 몇 주 동안 작업 한 후, 어떻게 작동하는지 이해할 수 있도록 자신을 롤업해야한다고 결정했습니다. Brokenthorn의 인터넷 자습서 (현재 http://www.brokenthorn.com/Resources/OSDev9.html에 있음)를 발견했습니다. 보호 모드로 전환하려고하면 멀리 떨어진 후에 CPU 하드웨어가 재설정됩니다. 나는 2.6 대 보츠를 달리고있다.보호 모드로 멀리 점프 한 후 GPF

(나는 그것을 내 문제를 해결할 것이라고 생각했기 때문에 튜토리얼의 거의 사본 - 그렇지 않은)이 내 두 번째 단계의 부트 로더

bits 16 

; Remember the memory map-- 0x500 through 0x7bff is unused above the BIOS data area. 
; We are loaded at 0x500 (0x50:0) 

org 0x50:0x0 

jmp main    ; go to start 

;******************************************************* 
; Preprocessor directives 
;******************************************************* 

%include "Gdt.inc"   ; Gdt routines 

;******************************************************* 
; Data Section 
;******************************************************* 


;******************************************************* 
; STAGE 2 ENTRY POINT 
; 
;  -Store BIOS information 
;  -Load Kernel 
;  -Install GDT; go into protected mode (pmode) 
;  -Jump to Stage 3 
;******************************************************* 

main: 

    ;-------------------------------; 
    ; Setup segments and stack ; 
    ;-------------------------------; 

    cli    ; clear interrupts 
    xor ax, ax   ; null segments 
    mov ds, ax 
    mov es, ax 
    mov ax, 0x9000  ; stack begins at 0x9000-0xffff 
    mov ss, ax 
    mov sp, 0xFFFF 
    sti    ; enable interrupts 



    call InstallGDT  ; install our GDT 
    ;activate gate a20 

    mov al,2 
    out 0x92,al 


    ;-------------------------------; 
    ; Go into pmode  ; 
    ;-------------------------------; 

    cli    ; clear interrupts 
    mov eax, cr0  ; set bit 0 in cr0--enter pmode 
    or eax, 1 
    mov cr0, eax 
    jmp 08h:Stage3  ; ############It restarts here############ 

    ; Note: Do NOT re-enable interrupts! Doing so will triple fault! 
    ; We will fix this in Stage 3. 
;****************************************************** 
; ENTRY POINT FOR STAGE 3 
;****************************************************** 

bits 32     ; Welcome to the 32 bit world! 

Stage3: 

    ;-------------------------------; 
    ; Set registers  ; 
    ;-------------------------------; 

    mov  ax, 0x10  ; set data segments to data selector (0x10) 
    mov  ds, ax 
    mov  ss, ax 
    mov  es, ax 
    mov  esp, 90000h  ; stack begins from 90000h 


;******************************************************* 
; Stop execution 
;******************************************************* 

STOP: 


    hlt 

내 GDT는 :

gdt_data: 
    dd 0    ; null descriptor 
    dd 0 

; gdt code:    ; code descriptor 
    dw 0FFFFh   ; limit low 
    dw 0    ; base low 
    db 0    ; base middle 
    db 10011010b   ; access 
    db 11001111b   ; granularity 
    db 0    ; base high 

; gdt data:    ; data descriptor 
    dw 0FFFFh   ; limit low (Same as code) 
    dw 0    ; base low 
    db 0    ; base middle 
    db 10010010b   ; access 
    db 11001111b   ; granularity 
    db 0    ; base high 

end_of_gdt: 
toc: 
    dw end_of_gdt - gdt_data - 1 ; limit (Size of GDT) 
    dd gdt_data    ; base of GDT 

입니다 오류 코드는 다음 코드를 시도 할 때 나타납니다.

00018047272e[CPU0 ] jump_protected: gate type 0 unsupported 
00018047272e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d) 
00018047272e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08) 
00018047272i[CPU0 ] CPU is in protected mode (active) 
00018047272i[CPU0 ] CS.mode = 16 bit 
00018047272i[CPU0 ] SS.mode = 16 bit 
00018047272i[CPU0 ] EFER = 0x00000000 
00018047272i[CPU0 ] | EAX=60000011 EBX=00000000 ECX=00090003 EDX=00000080 
00018047272i[CPU0 ] | ESP=0000ffff EBP=00000000 ESI=000e0000 EDI=0000ffac 
00018047272i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf 
00018047272i[CPU0 ] | SEG sltr(index|ti|rpl)  base limit G D 
00018047272i[CPU0 ] | CS:0050(0004| 0| 0) 00000500 0000ffff 0 0 
00018047272i[CPU0 ] | DS:0000(0005| 0| 0) 00000000 0000ffff 0 0 
00018047272i[CPU0 ] | SS:9000(0005| 0| 0) 00090000 0000ffff 0 0 
00018047272i[CPU0 ] | ES:0000(0005| 0| 0) 00000000 0000ffff 0 0 
00018047272i[CPU0 ] | FS:0000(0005| 0| 0) 00000000 0000ffff 0 0 
00018047272i[CPU0 ] | GS:0000(0005| 0| 0) 00000000 0000ffff 0 0 
00018047272i[CPU0 ] | EIP=0000004f (0000004f) 
00018047272i[CPU0 ] | CR0=0x60000011 CR2=0x00000000 
00018047272i[CPU0 ] | CR3=0x00000000 CR4=0x00000000 
00018047272i[CPU0 ] 0x000000000000004f>> jmp far 0008:00a4 : EAA4000800 
00018047272e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting 
00018047272i[SYS ] bx_pc_system_c::Reset(HARDWARE) called 
00018047272i[CPU0 ] cpu hardware reset 

이 문제를 해결하려면 어떻게해야합니까?

답변

4
0x000000000000004f>> jmp far 0008:00a4 : EAA4000800 

그것은 조직 0 × 50과 같습니다 멀리 점프보다 0008 같아야하기 때문에 0x0으로이 일을 엉망으로되어 05a4. org 0x50 대신 0x500을 사용해보십시오 : 0x0.

+0

나는 그렇게 많은 시간을 보냈다는 것을 그렇게 단순하다고 믿을 수 없다. 정말 고맙습니다. – user1133383