flat assembler
Message board for the users of flat assembler.

Index > OS Construction > enabling the a20 gate

Author
Thread Post new topic Reply to topic
Gmakermaniac!!!



Joined: 20 Mar 2005
Posts: 6
Location: usa
Gmakermaniac!!! 22 Mar 2005, 02:56
I'm lost...... how do you do it? can someone give me a link to an example? thanks in advance
Post 22 Mar 2005, 02:56
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 22 Mar 2005, 04:56
Gmakermaniac!!! wrote:
I'm lost...... how do you do it? can someone give me a link to an example? thanks in advance


Check out this well documented example.
Post 22 Mar 2005, 04:56
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 22 Mar 2005, 17:23
I use this code:
Code:
;=========================================================;; A20                                            11/12/03 ;;---------------------------------------------------------;; DOS EXTREME OS V0.01                                    ;; by ASHLEY4.                                             ;;                                                         ;; Enable the A20 line.                                    ;;=========================================================;enable_A20:        pusha        cli  ; Disable all irqs        cld        mov   al,255  ; Mask all irqs        out   0xa1,al        out   0x21,all.5:    in    al,0x64  ; Enable A20        test  al,2  ; Test the buffer full flag        jnz   l.5  ; Loop until buffer is empty        mov   al,0xD1  ; Keyboard: write to output port        out   0x64,al  ; Output command to keyboardl.6:    in    al,0x64        test  al,2        jnz   l.6  ; Wait 'till buffer is empty again        mov   al,0xDF  ; keyboard: set A20        out   0x60,al  ; Send it to the keyboard controller        mov   cx,14hl.7:   ; this is approx. a 25uS delay to wait        out   0edh,ax  ; for the kb controler to execute our        loop  l.7  ; command.        sti        popa        ret    


NOTE: this is called in realmode and the cli is done before moving to pmode.
Post 22 Mar 2005, 17:23
View user's profile Send private message Reply with quote
Gmakermaniac!!!



Joined: 20 Mar 2005
Posts: 6
Location: usa
Gmakermaniac!!! 22 Mar 2005, 22:19
thanks Smile All I know was my first line was right, otherwise, I was going compleatly the wrong way. It dosn't represent yours at all. Thanks. I'll look through the code
Post 22 Mar 2005, 22:19
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 23 Mar 2005, 02:33
I use the following in RetroForth/Native:

Code:
; Enable A20 gate
a20enable:
        mov     al,0xd1
        out     0x64,al
        call    a20wait
        mov     al,0xdf
        out     0x60,al
        call    a20wait
        mov     al,0xff
        out     0x64,al
a20wait:
        in      al,0x64
        jmp     .l0
.l0:    and     al,2
        jnz     a20wait
        ret    

_________________
Charles Childers, Programmer
Post 23 Mar 2005, 02:33
View user's profile Send private message Visit poster's website Reply with quote
Gmakermaniac!!!



Joined: 20 Mar 2005
Posts: 6
Location: usa
Gmakermaniac!!! 24 Mar 2005, 00:32
0.o.... mine came out so long Smile..... it works though Rolling Eyes

Code:
enable_a20:                     ; enable_a20 function: enable the A20 gate
        pusha           ; push all general purpose registers
        mov SI, .msg
        call strout     ; display the message
        cli             ; disable hardware interrupts
        mov CX, 5       ; 5 attempts to enable it

.1:
.1.1:   ; wait for port to open, and send the command to read the output port
        xor AX, AX      ; nullify AX
        in AL, 0x64     ; read port status
        bt AX, 1        ; see if the port is busy
        jc .1.1         ; if it is, check again
        mov AL, 0xD0    ; D0h is the command to read port output
        out 0x64, AL    ; send the command to the port
.1.2:   ; wait for data to be ready
        xor AX, AX      ; nullify AX
        in AL, 0x64     ; read data status
        bt AX, 0        ;
        jnc .1.2        ; if it's not ready, keep waiting
        xor AX, AX      ; nullify AX
        in AL, 0x60     ; read data from keyboard
        push AX         ; store AX for later
.1.3:   ; wait for port to open to write the status byte
        in AL, 0x64     ; read port status
        bt AX, 1        ; check to see if the port is ready
        jc .1.3         ; keep checking untill it's ready
        mov AL, 0xD1    ;
        out 0x64, AL    ; tell the kbd controller I want to change the status byte
.1.4:   ; wait for the controller to be ready
        xor AX, AX     ; nullify AX
        in AL, 0x64    ; read status byte
        bt AX, 1       ; see if it's busy
        jc .1.4        ; and if it is, repeat
        pop AX         ; get the value we stored earlier
        or AL, 00000010b ; turn on the A20 enable bit
        out 60h, AL    ; send the byte to the controller
.1.5:   ; send command to read output port
        xor AX, AX     ; nullify AX
        in AL, 0x64    ; check the kbd status
        bt AX, 1       ; .....
        jc .1.5        ; if it's not, check again
        mov AL, 0xD0   ; command to read port output
        out 0x64, AL   ; send the command
.1.6:   ; get the info
        xor AX, AX     ; nullify AX
        in AL, 0x64    ; get port status
        bt AX, 0       ;
        jnc .1.6       ; keep going till it's ready
        xor AX, AX     ; nullify AX
        in AL, 0x60    ; get the data from the port
        bt AX, 1       ; is the A20 bit set??
        jc .success    ; success!!! w00t!!!
        loop .1        ; try 5 times
; failure code here
        sti            ; enable interrupts
        mov SI, .failmsg
        call strout    ; display the failure message
        popa           ; return the registers back to the way they were
        hlt            ; halt cpu operation
        ret
.success:
        sti            ; enable interrupts
        mov SI, .successmsg
        call strout    ; display the success message
        popa           ; return the registers back to the way they were
        ret

.msg db "Enableing A20 gate:  ",0
.failmsg db "Failed enabeling the A20 gate, halting cpu operations.  you may turn off your pc.",13,10,0
.successmsg db "A20 gate enabled successfully.",13,10,0
;-------    

_________________
____________________
my computer lags so much, that when I move the volume dial on my speakers, it takes several seconds for me to hear the difference
Post 24 Mar 2005, 00:32
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 24 Mar 2005, 04:26
The most important thing, is that you got it to work Smile .
Post 24 Mar 2005, 04:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.