禁用尝试后,A20门已启用
我遇到了禁用(出于学习目的)A20门的问题。
这是我的引导加载程序代码:
onboot:
xorw %ax, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
movw $0x7c00, %ax
movw %ax, %bp
movw %ax, %sp
/* reading disk */
xorw %bx, %bx
movw %bx, %es
movw $0x7e00, %bx
movw $0x0201, %ax
movw $0x0002, %cx
movb $0x00, %dh
int $0x13
/* Disable a20 through bios */
movw $0x2400, %ax
int $0x15
/* clear through keyboard controller */
call clear_8042
movb $0xd1, %al
outb %al, $0x64
call clear_8042
movb $0b11011101, %al /* bit 0 = reset, must be 1,
bit 1 = a20 gate */
outb %al, $0x60
call clear_8042
movb $0xff, %al
outb %al, $0x64
call clear_8042
/* 0xffff0 + 0x7e0e = 0x107dfe*/
movw $0xffff, %bx
movw %bx, %es
movw %es:0x7e0e, %dx
pushw %dx
call printhex
addw $0x2, %sp
loop:
jmp %cs:loop
clear_8042:
pushw %ax
in $0x64, %al
test $2, %al
jnz clear_8042
popw %ax
ret
.= onboot+510
.word 0xaa55 /* little endian will reverse */
printhex:
pusha
movw %sp, %bp
movw 18(%bp), %dx
movw $0x0404, %cx /* ch = nibbles count, cl = iterator */
printhex_loop:
movw $0x0e0f, %ax
rol $4, %dx /* dl = nibble to show */
andb %dl, %al /* take a copy of dl in lowwer al nibble */
addb $0x90, %al /* if al is decimal nibble = 0x90 - 0x99
else = 0x9A - 0x9F */
daa /* if decimal = 0x90 - 0x99
else 0x0 - 0x5 w/ CF */
adc $0x40, %al /* if decimal = 0xD0 - 0xD9
else 0x41 - 0x46 */
daa /*if decimal = 0x30 = 0x39
else 0x41 - 0x46 */
int $0x10
dec %cl
jnz printhex_loop
popa
ret
以下指令的输出
movw%es:0x7e0e,%dx
必须为0xAA55(如果禁用A20门),但是由于某些原因,它启用了A20 Gate(输出)(输出)是0x0000)。
我在做什么错?如您所见,我一直在尝试使用BIOS中断和KBC控制器禁用它。
使用Manjaro和Qemu,如果有所不同。
I've encountered a problem with disabling (for learning purpose) a20 gate.
Here is my bootloader code:
onboot:
xorw %ax, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %ss
movw $0x7c00, %ax
movw %ax, %bp
movw %ax, %sp
/* reading disk */
xorw %bx, %bx
movw %bx, %es
movw $0x7e00, %bx
movw $0x0201, %ax
movw $0x0002, %cx
movb $0x00, %dh
int $0x13
/* Disable a20 through bios */
movw $0x2400, %ax
int $0x15
/* clear through keyboard controller */
call clear_8042
movb $0xd1, %al
outb %al, $0x64
call clear_8042
movb $0b11011101, %al /* bit 0 = reset, must be 1,
bit 1 = a20 gate */
outb %al, $0x60
call clear_8042
movb $0xff, %al
outb %al, $0x64
call clear_8042
/* 0xffff0 + 0x7e0e = 0x107dfe*/
movw $0xffff, %bx
movw %bx, %es
movw %es:0x7e0e, %dx
pushw %dx
call printhex
addw $0x2, %sp
loop:
jmp %cs:loop
clear_8042:
pushw %ax
in $0x64, %al
test $2, %al
jnz clear_8042
popw %ax
ret
.= onboot+510
.word 0xaa55 /* little endian will reverse */
printhex:
pusha
movw %sp, %bp
movw 18(%bp), %dx
movw $0x0404, %cx /* ch = nibbles count, cl = iterator */
printhex_loop:
movw $0x0e0f, %ax
rol $4, %dx /* dl = nibble to show */
andb %dl, %al /* take a copy of dl in lowwer al nibble */
addb $0x90, %al /* if al is decimal nibble = 0x90 - 0x99
else = 0x9A - 0x9F */
daa /* if decimal = 0x90 - 0x99
else 0x0 - 0x5 w/ CF */
adc $0x40, %al /* if decimal = 0xD0 - 0xD9
else 0x41 - 0x46 */
daa /*if decimal = 0x30 = 0x39
else 0x41 - 0x46 */
int $0x10
dec %cl
jnz printhex_loop
popa
ret
The output from following instruction
movw %es:0x7e0e, %dx
must be 0xaa55 (if a20 gate is DISABLED), but for some reason it acts like a20 gate is enabled (output is 0x0000).
What am i doing wrong? I've been trying disabling it with bios interrupts, and kbc controller as you see.
Using manjaro and qemu, if makes difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论