启用A20门时是否需要这么多键盘控制器等待呼叫 [英] Are so many keyboard controller wait calls needed when enabling the A20 gate

查看:95
本文介绍了启用A20门时是否需要这么多键盘控制器等待呼叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在A20行的 OSDev页面中,启用A20的代码为:

From the OSDev page on the A20 line, the code for enabling A20 is given as:

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
    sti
    ret

a20wait:
    in      al,0x64
    test    al,2
    jnz     a20wait
    ret


a20wait2:
    in      al,0x64
    test    al,1
    jz      a20wait2
    ret

a20wait等待输入缓冲区,而a20wait2等待输出缓冲区.

a20wait waits on the input buffer and a20wait2 on the output buffer.

据我了解,对0x64进行写入/读取操作是访问命令/状态寄存器,而不是缓冲区寄存器.

From what I understood, writing to/reading from 0x64 access the command/status register and not the buffer registers.

那么,为什么在输入/输出缓冲区上有那么多等待?在读取状态寄存器之前,输出缓冲区上应该没有一个,而在写入新的命令字节之后,输入缓冲区上是否应该有一个?

Then why are there are so many waits on the input/output buffers ? Shouldn't there be one on the output buffer before reading the status register, and one on the input buffer after writing the new command byte ?

我尝试禁用所有其他等待调用,除了上一段中提到的两个等待调用外,它工作正常.但是我很好奇他们为什么会在那里.还有其他原因吗?

I tried disabling all other wait calls except the two I mentioned in the previous paragraph and it worked fine. But I'm curious as to why they are there. Is there some other reason ?

推荐答案

A20门控制信号由另一个处理器提供.传统上是8042微控制器,其输出端口引脚之一驱动信号.该微控制器旨在处理键盘接口,它具有未使用的输出引脚,因此设计AT的IBM工程师决定削减硬件成本并使用它来控制A20门信号.

The A20 gate control signal is provided by another processor. Traditionally an 8042 micro-controller, one of its output port pins drives the signal. That micro-controller was intended to handle the keyboard interface, it had a unused output pin so the IBM engineers that designed the AT decided to cut hardware cost and control the A20 gate signal with it.

主处理器和该微控制器之间的接口非常简单,只有两个8位端口. I/O地址0x60是数据端口,0x64是命令/状态端口.

The interface between the main processor and that microcontroller is a very simplistic one, just two 8-bit ports. I/O address 0x60 is the data port, 0x64 is the command/status port.

8042执行自​​己的程序,完全独立于主处理器.因此需要与之交谈,握手必须在软件中完成.确保8042获得前一条命令并执行后,您才可以写一些东西.并且只有在确保8042写入数据端口后才能读取内容.因此,需要旋转输入和输出缓冲区状态位,以使8042赶上来.

The 8042 executes its own program, completely independent from the main processor. So some care is required to talk to it, the handshaking has to be done in software. You can only write something after you made sure that the 8042 obtained the previous command and executed it. And only read something after you made sure that the 8042 wrote to the data port. Spinning on the input and output buffer status bits is thus required to let the 8042 catch up.

取消旋转可能会在仿真器中进行的操作.在真正的硬件上正常工作的可能性很小,您可能会很幸运.完全没有必要冒险.

Removing that spinning may work in an emulator. Pretty unlikely to work correctly on real hardware, you could get lucky. There's completely no point in risking it.

这篇关于启用A20门时是否需要这么多键盘控制器等待呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆