i entering pmode is err,who can help me?
i use following code by nasm[some code download from net],but when enter pmode it has reboot:
;nasmw -o boot.com boot.asm
;copyboot boot.com 0 1
;i in real mode,it is right
bit 16
org 0
.....
a20msg db 'Setting A20 address line',13,10,0
pmodemsg db 'Setting CR0 -> Entering PMode',13,10,0
; Here's the locations of my IDT and GDT. Remember, Intel's are
; little endian processors, therefore, these are in reversed order.
; Also note that lidt and lgdt accept a 32-bit address and 16-bit
; limit, therefore, these are 48-bit variables.
pIDT dw 7FFh ; limit of 256 IDT slots
dd 0000h ; starting at 0000
pGDT dw 17FFh ; limit of 768 GDT slots
dd 0800h ; starting at 0800h (after IDT)
....
;reading kernel file
read_me:
xor ax, ax
int 0x13
mov eax,0x9000 ;
mov es,eax
xor bx,bx
mov ax,0x0204 ;
mov ch,0 ;
mov cl,2 ;
mov dh,0 ;
mov dl,[bootdrv] ;
int 0x13 ;
jc read_me ;
;seting a20
mov si, a20msg ;
call message
call enable_A20
; the A20 line is on now. Let's load in our ITD and GDT tables...
; Ideally, there will actually be data in their locations (by loading
; the kernel)
lidt [pIDT]
lgdt [pGDT]
; now let's enter pmode...
mov si, pmodemsg
call message
call getkey
mov eax, cr0 ; load the control register in
or al, 1 ; set bit 1: pmode bit
mov cr0, eax ; copy it back to the control register
jmp $+2 ; and clear the prefetch queue
nop
nop
;!!!!!!!!!!!!!!!now go here,the machine is reboot?why??????????
mov si, pmodemsg
call message
call getkey
enable_A20:
cli
call a20wait
mov al,0xAD
out 0x64,al
call a20wait
mov al,0xD0
out 0x64,al
call a20wait2
in al,0x60
push eax
call a20wait
mov al,0xD1
out 0x64,al
call a20wait
pop eax
or al,2
out 0x60,al
call a20wait
mov al,0xAE
out 0x64,al
call a20wait
ret
a20wait:
.l0: mov ecx,65536
.l1: in al,0x64
test al,2
jz .l2
loop .l1
jmp .l0
.l2: ret
a20wait2:
.l0: mov ecx,65536
.l1: in al,0x64
test al,1
jnz .l2
loop .l1
jmp .l0
.l2: ret
times 510-($-$$) db 0
dw 0xAA55
a pmode boot loader problem,
Re:a pmode boot loader problem,
i have found out that if you post a whole page of code on this meesage baord people will usually not respond to you because they dont feel like analyzing it. try testing pieces of your code to see which exact part of it doesnt work and you'll get a lot more responses...
Re:a pmode boot loader problem,
i suggest, you find the website where you downloaded it from, and see if it has an authors name against it, the guy who wrote it originally.
ask them to find the error, since its their code.
they might even know about it already.
ask them to find the error, since its their code.
they might even know about it already.
-- Stu --
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:a pmode boot loader problem,
the way the proposed code switches to pmode sounds like a joke ...
Code: Select all
mov eax, cr0 ; load the control register in
or al, 1 ; set bit 1: pmode bit
mov cr0, eax ; copy it back to the control register
jmp $+2 ; and clear the prefetch queue
nop
nop
;!!!!!!!!!!!!!!!now go here,the machine is reboot?why??????????
mov si, pmodemsg
call message
call getkey
- just using jmp $+2 indeed clears the prefetch queue, but it doesn't provide a valid code descriptor to the CPU. a far jump like jmp code_selector:offset would be more appropriated
- there's nothing like a "now encode 32bits instructions" command to the assembler -- i'm not sure if it would have been better with it though, as the absence of the far jmp will probably leave the cpu in 16 bits decoding.
- there are calls without the set up of a valid task segment
- interrupts aren't even disabled during the switch.
Re:a pmode boot loader problem,
Take pypes advice. When I started writing a bootsector, I used that same tutorial. But I soon realized it wouldn't work for entering pmode and so I gave up on it.
Take a look at chris greese's code. Or look at prevous posts on this forum for help.
Take a look at chris greese's code. Or look at prevous posts on this forum for help.