硬件遗留问题描述
- 8086的地址线有20根,可以访问 1MB (2^20)的内存空间
- 80286的地址线有24根
- 80386的地址线有32根,可以访问 4GB (2^32)的内存空间
为了保持兼容性Intel在地址线的第20位上制造了一个逻辑OR门,以便可以开启或关闭超过20位的地址总线 。
这样,为了兼容旧的处理器,在机器开启进入实模式时A20被禁止的。进入保护模式时,将其打开。
开启A20 gate
开启A20的常用的方法是通过键盘微控制器
/*代码来自ucore 2020课程实验lab1*/
# Enable A20:
# For backwards compatibility with the earliest PCs, physical
# address line 20 is tied low, so that addresses higher than
# 1MB wrap around to zero by default. This code undoes this.
seta20.1:
inb $0x64, %al # Wait for not busy(8042 input buffer empty).
testb $0x2, %al
jnz seta20.1
movb $0xd1, %al # 0xd1 -> port 0x64
outb %al, $0x64 # 0xd1 means: write data to 8042's P2 port
seta20.2:
inb $0x64, %al