在我的MIT OS课程(686)中,我发现了一些我不理解的代码。我想了解指令inb $0x64, %al
的启动 / boot.S。我的理解是它正在从数据端口0x64读一个字节到AL,端口0x64是什么?正在测试哪个设备或机制忙?我对代码忙中的注释感到困惑吗?评论是什么意思,它指的是什么?
# Enable A20: # For fascinating historical reasons (related to the fact that # the earliest 8086-based PCs could only address 1MB of physical memory # and subsequent 80286-based PCs wanted to retain maximum compatibility), # physical address line 20 is tied to low when the machine boots. # Obviously this a bit of a drag for us, especially when trying to # address memory above 1MB. This code undoes this. seta20.1: inb $0x64,%al # Get status testb $0x2,%al # Busy? jnz seta20.1 # Yes movb $0xd1,%al # Command: Write outb %al,$0x64 # output port seta20.2: inb $0x64,%al # Get status testb $0x2,%al # Busy? jnz seta20.2 # Yes movb $0xdf,%al # Enable outb %al,$0x60 # A20
小智.. 5
什么是端口0x64?
端口0x64是键盘控制器的IO端口。
键盘控制器有两个端口0x64和0x60。
端口0x64(命令端口)用于向键盘控制器(PS / 2)发送命令。
端口0x60(数据端口)用于向PS / 2(键盘)控制器或PS / 2设备本身发送数据。
正在测试哪个设备或机制忙?我对代码忙中的注释感到困惑吗?评论是什么意思,它指的是什么?
此处的代码使CPU轮询PS / 2键盘控制器以查看其是否繁忙。
inb $0x64,%al # Get status
上面的指令读取PS / 2控制器的状态寄存器,该寄存器的长度为8位。具体来说,它正在尝试读取输入缓冲区的状态-位1。
testb $0x2,%al # Busy?
从前一个inb指令返回的字节在此处进行测试。在此检查输入缓冲区的状态,以查看其是否已满或为空-位1(0x2)。
Status Register - PS/2 Controller Bit Meaning 0 Output buffer status (0 = empty, 1 = full) (must be set before attempting to read data from IO port 0x60) 1 Input buffer status (0 = empty, 1 = full) (must be clear before attempting to write data to IO port 0x60 or IO port 0x64) 2 System Flag - Meant to be cleared on reset and set by firmware (via. PS/2 Controller Configuration Byte) if the system passes self tests (POST) 3 Command/data (0 = data written to input buffer is data for PS/2 device, 1 = data written to input buffer is data for PS/2 controller command) 4 Unknown (chipset specific) - May be "keyboard lock" (more likely unused on modern systems) 5 Unknown (chipset specific) - May be "receive time-out" or "second PS/2 port output buffer full" 6 Time-out error (0 = no error, 1 = time-out error) 7 Parity error (0 = no error, 1 = parity error)
x86汇编代码 的语法上面的线程详细说明了此处引用的端口0x64和0x60。
另外,下面的链接详细讨论了如何使用IO端口。 I / O端口地址和数据如何发送?
什么是端口0x64?
端口0x64是键盘控制器的IO端口。
键盘控制器有两个端口0x64和0x60。
端口0x64(命令端口)用于向键盘控制器(PS / 2)发送命令。
端口0x60(数据端口)用于向PS / 2(键盘)控制器或PS / 2设备本身发送数据。
正在测试哪个设备或机制忙?我对代码忙中的注释感到困惑吗?评论是什么意思,它指的是什么?
此处的代码使CPU轮询PS / 2键盘控制器以查看其是否繁忙。
inb $0x64,%al # Get status
上面的指令读取PS / 2控制器的状态寄存器,该寄存器的长度为8位。具体来说,它正在尝试读取输入缓冲区的状态-位1。
testb $0x2,%al # Busy?
从前一个inb指令返回的字节在此处进行测试。在此检查输入缓冲区的状态,以查看其是否已满或为空-位1(0x2)。
Status Register - PS/2 Controller Bit Meaning 0 Output buffer status (0 = empty, 1 = full) (must be set before attempting to read data from IO port 0x60) 1 Input buffer status (0 = empty, 1 = full) (must be clear before attempting to write data to IO port 0x60 or IO port 0x64) 2 System Flag - Meant to be cleared on reset and set by firmware (via. PS/2 Controller Configuration Byte) if the system passes self tests (POST) 3 Command/data (0 = data written to input buffer is data for PS/2 device, 1 = data written to input buffer is data for PS/2 controller command) 4 Unknown (chipset specific) - May be "keyboard lock" (more likely unused on modern systems) 5 Unknown (chipset specific) - May be "receive time-out" or "second PS/2 port output buffer full" 6 Time-out error (0 = no error, 1 = time-out error) 7 Parity error (0 = no error, 1 = parity error)
x86汇编代码 的语法上面的线程详细说明了此处引用的端口0x64和0x60。
另外,下面的链接详细讨论了如何使用IO端口。 I / O端口地址和数据如何发送?