Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Jul 2005 13:19:43 +0800 (CST)
From:      =?gb2312?q?Mr=20=BC=FC=20=CE=A4?= <weijian0204@yahoo.com.cn>
To:        freebsd-amd64@FreeBSD.org
Subject:   Please help me about enter long mode!
Message-ID:  <20050717051943.23822.qmail@web15309.mail.cnb.yahoo.com>

next in thread | raw e-mail | index | archive | help
Hi:
Please help me.I can't enter long mode.I'm no good
ideas!If you could give me your assembly code about
how to enter long mode correctly,I can give some
monney.Thank you,very much.
My assembly code:
 
;----------------------------------------------------------------------
; Processor Initialization
;----------------------------------------------------------------------
bits 16
org 0x7c00
;----------------------------------------------------------------------
GDT_CodeSegment_Selector    equ 0x08
 
;----------------------------------------------------------------------
 jmp Initializate_Processor
 
GDT_Tables:
   GDT_Null:
 Null_Discriptor1 dd 0x00
 Null_Discriptor2 dd 0x00
 
   GDT_CodeSegment_Address equ $-GDT_Tables
   GDT_CodeSegment:
  dw 0xffff
  dw 0x0000
  db 0x00
  db 10011010b 
  db 11001111b
  db 0x00
 
   GDT_DataSegment_Address equ $-GDT_Tables
   GDT_DataSegment:
  dw 0xffff
  dw 0x0000
  db 0x00
  db 10010010b
  db 11001111b
  db 0x00
 
   GDT64_CodeSegment_Address equ $-GDT_Tables
   GDT64_CodeSegment:
  dd 0x0000
  db 0x00
  db 10011000b
  db 00000000b
  db 0x00
 
 GDT_End:
 GDT_Address:
  dw GDT_End-GDT_Tables-1
  dd GDT_Tables
;----------------------------------------------------------------------
IDT_Address:
IDT_Address_Limit dw IDT_End-IDT_Tables-1
IDT_Address_Base  dd IDT_Tables
 
IDT_Tables:
 
IDT_Discriptor_00:
Target_Code_Segment_Offset1_00  dw 0x0000 ;Low bit
Target_Code_Segment_Selector_00 dw
GDT_CodeSegment_Selector
Attribute_00   dw 0x8e00
Target_Code_Segment_Offset2_00 dw 0x0100 ;High bit
 
 
 
IDT_End:
;
--------------------------------------------------------------------------------------
 
Initializate_Processor:
 
Mask_All_IRQ:
 mov al,255
 out 0xa1,al
 out 0x21,al
 
Enable_A20:
 
 Enable_A20_First:
  in al,0x64
  test al,2
  jnz Enable_A20_First
  mov al,0xd1
  out 0x64,al
 Enable_A20_Second:
  in al,0x64
  test al,2
  jnz Enable_A20_Second
  mov al,0xdf
  out 0x60,al
 
Disable_Interrupt:
 cli
 
Load_GDT:    
        lgdt [GDT_Address]
 lidt [IDT_Address]
 
Enable_ProtectedMode:
                                         
 mov eax,0x11                                         
                            
        mov cr0,eax    
 
        jmp GDT_CodeSegment_Address:Code_32  
 
Bits 32
Code_32:
 
 mov ax,GDT_DataSegment_Address
 mov ds,ax
 mov es,ax
 mov ss,ax 
 mov fs,ax 
 mov gs,ax
 mov esp,0xffff  
 
PAE:
  mov edi,0x100000
 mov eax,0x110000
 add eax,0x01
 stosd
 
 mov edi,0x110000
 mov eax,0x120000
 add eax,0x01
 stosd
 
 mov edi,0x120000
 mov eax,0x130000
 add eax,0x01
 stosd
 
 mov edi,0x130000
 mov eax,0x000001
 mov ecx,0x200
STOSE_PTE:
 stosd
 add eax,0x1000
 add edi,4
 loop STOSE_PTE
 
 mov eax,cr4
 bts eax,5
 mov cr4,eax
 
       mov   eax,0x100000         ; page directory
location
       mov   cr3,eax
       mov   eax,cr0
 
mov ecx,0xc0000080
rdmsr
bts eax,8
wrmsr
 
mov eax,cr0
bts eax,31
mov cr0,eax
 
 db 0x66
 db 0xea
 dd Start64
 dw 0x18
bits 64
Start64:
 

jmp $
 
 
                                    Jian.
                                07/16/2005


	

	
		
___________________________________________________________ 
雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱
http://cn.mail.yahoo.com/?id=77071




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050717051943.23822.qmail>