OSDev.org

The Place to Start for Operating System Developers
It is currently Sat May 18, 2024 3:15 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: difficulty activating A20
PostPosted: Sun Feb 03, 2008 1:33 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
Can any body tell me why this code doesn't work, it attempts to activate A20, i've been trying to run it on vmware but it doesn't do any output and it just seems to loop (vmware normally tell you when it reaches a hlt instruction which it doesn't)

Code:
bits 16
org 0x7c00
start:
mov ax, cs
mov ds, ax
mov es, ax
mov fs, ax
mov ax, 0x1D0
mov ss, ax
mov sp, 0x200
mov si, init
call PutStr
cli
call waitkeyclear
mov al, 0xd1
out 0x64, al
call waitkeyclear
mov al, 0xdf
out 0x60, al
call waitkeyclear
mov cx, 0x10
.waisttime
nop
nop
xor ax, ax
loop .waisttime
mov al, 0xd0
out 0x64, al
call waitkeyfull
in al, 0x60
test al, 2
jnz .A20_on
mov al, 'A'
call halt
.A20_on
sti
mov si, A20_success
call PutStr
hlt


waitkeyclear:
xor al, al
mov al, 0x64
test al, 2
jnz waitkeyclear
ret

waitkeyfull:
xor cx, cx
mov al, 0x64
test al, 1
jz waitkeyfull
ret



halt:
cli
hlt

PutStr:      
mov ah,0x0E   
mov bh,0x00   
mov bl,0x07   
.nextchar   
lodsb      
or al,al         
jz .return         
int 0x10   
jmp .nextchar   
.return      
ret      


drive dw ''
A20_success db 'A20 Enabled', 13, 10, 0
init db 'initiation started', 13, 10, 0

times 510-($-$$) db 0
dw 0xAA55

I assembled it with nasm

Thanks in advance,

Jules


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 2:43 pm 
Offline

Joined: Fri Nov 02, 2007 8:28 pm
Posts: 19
its "in al, 0x64" not "mov al, 0x64"

waitkeyfull:
xor cx, cx
mov al, 0x64 <---------------------- here
test al, 1
jz waitkeyfull
ret


same thing in waitkeyclear


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 2:46 pm 
Offline

Joined: Fri Nov 02, 2007 8:28 pm
Posts: 19
also, I think you're supposed to disable the keyboard and auxiliary device (ps/2 mouse) when doing this in the off-chance that a key is pressed between the time you check if the key buffer is empty and the time you reprogram the A20 line.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 2:51 pm 
Offline

Joined: Fri Nov 02, 2007 8:28 pm
Posts: 19
if you want an easy way to debug this kind of stuff next time, you can use the VGA palette color 0 to show where the program jams

make a macro of:

push dx
push ax
mov dx, 0x3C8
xor al, al
out dx, al
inc dx
mov al, 63 ; red 0-63
out dx, al
mov al, 0 ; green 0-63
out dx, al
mov al, 0 ; blue 0-63
out dx, al
pop ax
pop dx

it will change color 0 (usually the background color that's all over the screen in text mode) to red in this case

use different colors in different places in the code to find out where in the code it crashes.

good luck


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 3:02 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 20, 2007 3:00 pm
Posts: 672
Location: London UK
Thanks I did the changes that you sudjested, but this time all it did is make the pc beep, any ideas why that is?, any ideas why did the output function not work? and also how do i disable the keyboard?
(sorry for all the newbie questions)
Thanks,

Jules


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 6:01 pm 
Offline

Joined: Wed Nov 07, 2007 12:09 am
Posts: 19
There is a bios function to Enable the A20 for you.
Code:
A20:   ;Attempt to enable the A20 using the bios
   mov   ax, 0x2401
   int   0x15


If it fails, it sets the Carry flag, and if it's not supported it'll return 0x86 in ah.

Of course, if this call isn't supported, it won't enable the A20 gate, but I use it regardless, because my computer supports it. (And that's all I really care about, since I don't plan to use my OS on other computers.)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 8:43 am 
Offline
Member
Member

Joined: Wed Oct 31, 2007 9:09 am
Posts: 1385
Or, one reads the Wiki.


JAL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 10:30 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 07, 2007 1:45 pm
Posts: 1401
Location: Eugene, OR, US
There are several ways of setting A20, besides the methods that have been mentioned. (BTW, since you did the CLI, you don't need to worry about keystrokes.)

The Standard way. Do like you are doing -- send the 0xD0 command to port 0x64, read the byte at port 0x60, if bit with value=2 is not set, then set it, then send 0xD1 to port 0x64, and send the updated byte (with that "2" bit turned on) back to port 0x60.

The Compaq way (that should work on all machines). Do the same as the standard way, except send 0x20 to 0x64, read 0x60, check bit with value=1, set the bit, send value 0x60 to port 0x64, send updated byte to port 0x60.

Start with those two. If your machine is an HP Vectra, then you need to use still another way.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group