]> Joshua Wise's Git repositories - netwatch.git/blob - ich2/smi.c
92607c42e0da3de3466da1d7bee70f5aef71dd42
[netwatch.git] / ich2 / smi.c
1 #include <smi.h>
2 #include <pci.h>
3 #include <io.h>
4 #include <stdint.h>
5 #include <vga-overlay.h>
6 #include <reg-82801b.h>
7
8 uint16_t _get_PMBASE()
9 {
10         return pci_read32(ICH2_LPC_BUS, ICH2_LPC_DEV, ICH2_LPC_FN, ICH2_LPC_PCI_PMBASE) & ICH2_PMBASE_MASK;
11 }
12
13 void smi_disable()
14 {
15         unsigned short smi_en = _get_PMBASE() + ICH2_PMBASE_SMI_EN;
16         outl(smi_en, inl(smi_en) & ~ICH2_SMI_EN_GBL_SMI_EN);
17 }
18
19 void smi_enable()
20 {
21         unsigned short smi_en = _get_PMBASE() + ICH2_PMBASE_SMI_EN;
22         outl(smi_en, inl(smi_en) | ICH2_SMI_EN_GBL_SMI_EN);
23 }
24
25 unsigned long smi_status()
26 {
27         unsigned short smi_sts = _get_PMBASE() + ICH2_PMBASE_SMI_STS;
28         return inl(smi_sts);
29 }
30
31 void smi_poll()
32 {
33         unsigned long sts = smi_status();
34         
35         if (sts & ICH2_SMI_STS_BIOS_STS)
36         {
37                 dolog("Unhandled: BIOS_STS");
38                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_BIOS_STS);
39         }
40         
41         if (sts & ICH2_SMI_STS_LEGACY_USB_STS)
42         {
43                 dolog("Unhandled: LEGACY_USB_STS");
44                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_LEGACY_USB_STS);
45         }
46         
47         if (sts & ICH2_SMI_STS_SLP_SMI_STS)
48         {
49                 dolog("Unhandled: SLP_SMI_STS");
50                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SLP_SMI_STS);
51         }
52         
53         if (sts & ICH2_SMI_STS_APM_STS)
54         {
55                 dolog("Unhandled: APM_STS");
56                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SLP_SMI_STS);
57         }
58         
59         if (sts & ICH2_SMI_STS_SWSMI_TMR_STS)   // Ack it, then request another.
60         {
61                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SLP_SMI_STS);
62                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
63                         inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) & ~ICH2_SMI_EN_SWSMI_TMR_EN);
64                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
65                         inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) | ICH2_SMI_EN_SWSMI_TMR_EN);
66         }
67         
68         if (sts & ICH2_SMI_STS_PM1_STS_REG)
69         {
70                 /* XXX -- trawl through PMBASE+00h to see what happened */
71         }
72         
73         if (sts & ICH2_SMI_STS_GPE0_STS)
74         {
75                 /* XXX -- trawl through GPE0_STS to see what happened */
76         }
77         
78         if (sts & ICH2_SMI_STS_MCSMI_STS)
79         {
80                 dolog("Unhandled: MCSMI_STS");
81                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_MCSMI_STS);
82         }
83         
84         if (sts & ICH2_SMI_STS_DEVMON_STS)
85         {
86                 /* XXX -- trawl through DEVx_TRAP_STS to see what happened */
87                 /* XXX -- trawl through DEVTRAP_STS to see what happened */
88         }
89         
90         if (sts & ICH2_SMI_STS_TCO_STS)
91         {
92                 dolog("Unhandled: TCO_STS");
93                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_TCO_STS);
94         }
95         
96         if (sts & ICH2_SMI_STS_PERIODIC_STS)
97         {
98                 dolog("Unhandled: PERIODIC_STS");
99                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_PERIODIC_STS);
100         }
101         
102         if (sts & ICH2_SMI_STS_SERIRQ_SMI_STS)
103         {
104                 dolog("Unhandled: SERIRQ_SMI_STS");
105                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SERIRQ_SMI_STS);
106         }
107         
108         if (sts & ICH2_SMI_STS_SMBUS_SMI_STS)
109         {
110                 dolog("Unhandled: SMBUS_SMI_STS");
111                 outl(_get_PMBASE() + ICH2_PMBASE_SMI_STS, ICH2_SMI_STS_SMBUS_SMI_STS);
112         }
113         
114         if (smi_status())
115                 dolog("WARNING: failed to clear SMI_STS!");
116         
117         outl(_get_PMBASE() + ICH2_PMBASE_SMI_EN,
118                 inl(_get_PMBASE() + ICH2_PMBASE_SMI_EN) |
119                         ICH2_SMI_EN_EOS |
120                         ICH2_SMI_EN_GBL_SMI_EN);
121 }
This page took 0.023083 seconds and 2 git commands to generate.