Page 2 of 2
Posted: Sat Mar 31, 2007 9:12 pm
by ~
XCHG wrote:Oh you can also restart the PC by setting Bit#0 in keyboard’s microcontroller output port. First you have to poll Port 0x64 and see if Bit#0 is zero and then go on if yes. Then send the command 0xD1 to Port 0x64 and poll the same port and wait until Bit#0 is zero again just like you did at the first step. Now send the command 0x01 to Port 0x60 and the PC will be restarted. Here is the code that I wrote:
Code: Select all
@@__WaitInputEmpty:
IN AL , 0x64
TEST AL , 0x01
JNE @@__WaitInputEmpty
MOV AL , 0xD1
OUT 0x64 , AL
@@__WaitAgain:
IN AL , 0x64
TEST AL , 0x01
JNE @@__WaitAgain
MOV AL , 0x01
OUT 0x60 , AL
Hope that it helps.
Would that work in a multicore/multiprocessor system (i.e., would it leave the machine in a predictable state)?
Posted: Wed Mar 26, 2008 9:12 am
by Kieran
What a great piece of code, this should be placed into the Wiki
Posted: Wed Mar 26, 2008 3:06 pm
by Zenith
It is on the wiki, though pretty hidden...
http://www.osdev.org/wiki/Keyboard_Controller
You didn't have to resurrect a year-old thread if you had looked harder...
Posted: Mon Apr 28, 2008 12:38 pm
by CmpXchg
Well, talking about shutdown, things ain't so sad.
Using the datasheet, I figured out how to shutdown my own PC via motherboard registers:
Code: Select all
%define pcidev(dev,func) (dev<<3)+func
...
;get I/O base
call pci_read_config_dword,pcidev(17,0),88h
;if pci_read returned, say, 4001h, adding 3 gives 4004h,
;which corresponds to I/O offset 4.
add ax,3
;do the magic;)
mov dx,ax
in ax,dx
or ah,00101000b
and ah,11111110b
out dx,ax
;the system should now go down ;) the next instruction is never executed, put hlt just in case
hlt
If you also happen to have a VIA VT82x chipset, you could test it on your machine. PS: I wonder if there's a universal way, is it possible to shutdown from within Protected Mode?