]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/drivers/amd64/reset-amd64.cpp
9b075f683127fc227ba456c422b550258c0735d4
[l4.git] / kernel / fiasco / src / drivers / amd64 / reset-amd64.cpp
1 IMPLEMENTATION[amd64 && vmx]:
2
3 static void
4 virt_off()
5 {
6   asm volatile("vmxoff");
7 }
8
9 IMPLEMENTATION[amd64 && !vmx]:
10
11 static void
12 virt_off()
13 {}
14
15 IMPLEMENTATION[amd64]:
16
17 #include "io.h"
18 #include "processor.h"
19
20 // reset PC
21 void __attribute__ ((noreturn))
22 pc_reset()
23 {
24   virt_off();
25
26   // i8042: store the next byte at port 0x60 as command byte
27   while (Io::in8 (0x64) & 0x2)
28     ;
29   Io::out8_p (0x60, 0x64);
30
31   // i8042 command byte (PS/2-compatible mode):
32   //   b0=0 ... no IRQ 1 is generated when data available in input buffer
33   //   b1=0 ... no IRQ 1 is generated when mouse data available in input buffer
34   //   b2=1 ... set SYS flag in status register -- tells POST to perform
35   //            "warm boot" tests/initiailization
36   //   b3=0 ... reserved
37   //   b4=0 ... keyboard interface enabled
38   //   b5=0 ... auxillary PS/2 device (mouse) interface enabled
39   //   b6=0 ... translation disabled -- data appears at input buffer exactly
40   //            as read from keyboard
41   //   b7=0 ... reserved
42   while (Io::in8 (0x64) & 0x2)
43     ;
44   Io::out8_p (0x4, 0x60);
45
46   // i8042: pulse output port with 1110b
47   //   b0=0 ... reset computer
48   //   b1=1 ... set gate A20
49   //   b2=1 ... pull mouse data low
50   //   b3=1 ... pull mouse clock low
51   while (Io::in8 (0x64) & 0x2)
52     ;
53   Io::out8_p (0xfe,0x64);
54
55   for (;;)
56     Proc::pause();
57 }