I'm just learning kernel programming from this tutorial, which is in Polish - https://pl.wikibooks.org/wiki/Pisanie_OS It says there that the keyboard driver have many uses including rebooting the computer. It's a code for that:
reset:
call kbd
mov al,0xfe
out 0x64,al
kbd0:
jmp short $+2
in al,60h
kbd: jmp short $+2
in al,64h
test al,1
jnz kbd0
test al,2
jnz kbd
ret
I don't understand this code. Could someone explain it to me?
The 8086 processer has a reset pin. When asserted, this resets the processor to its initial state. This pin is connected to the keyboard controller; if you ask the keyboard controller to pull the reset pin up and then back down (which is what the code you posted does), the processor is reset.
Modern x86 processors work a bit different from that and the keyboard controller is no longer a separate chip. But still, the same method causes the southbridge to generate a reset signal, rebooting the computer.