]> Joshua Wise's Git repositories - netwatch.git/blame - netwatch/smi.c
Merge nyus.joshuawise.com:/storage/git/netwatch
[netwatch.git] / netwatch / smi.c
CommitLineData
9e2a82e4
JP
1#include <io.h>
2#include <smram.h>
3#include <video_defines.h>
4#include <minilib.h>
5#include <smi.h>
6#include <pci-bother.h>
113df320 7#include <serial.h>
c77a83d6
JW
8#include <fb.h>
9#include <output.h>
eda689ee 10#include <msr.h>
9e2a82e4
JP
11#include "../net/net.h"
12#include "vga-overlay.h"
13
9e2a82e4 14unsigned int counter = 0;
9e2a82e4
JP
15unsigned long pcisave = 0;
16unsigned char vgasave = 0;
17
9e2a82e4
JP
18void smi_entry(void)
19{
20 char statstr[512];
68beefa8 21
eda689ee
JW
22 /* Reenable caching on SMRAM. */
23 WRMSR(0x202, (RDMSR(0x202) & ~(0xFFULL)) | 0x06ULL);
24
9e2a82e4
JP
25 pcisave = inl(0xCF8);
26 vgasave = inb(0x3D4);
9e2a82e4 27 pci_unbother_all();
c77a83d6
JW
28
29 serial_init();
30
31 if (fb)
32 fb->getvmode(fb->priv);
68beefa8 33
9e2a82e4 34 counter++;
5cb80fe1
JW
35 if (!fb || fb->curmode.text)
36 {
37 sprintf(statstr, "NetWatch! %08x %08x", smi_status(), counter);
38 strblit(statstr, 0, 0, 0);
39 }
9e2a82e4 40
9e2a82e4 41 eth_poll();
9e2a82e4
JP
42
43 if (inl(0x840) & 0x1000)
44 {
45 /*
46 pci_dump();
47 */
48 outl(0x840, 0x1100);
49 outl(0x840, 0x0100);
50 }
51
113df320 52
9e2a82e4 53 smi_poll();
68beefa8 54
9e2a82e4 55 pci_bother_all();
9e2a82e4
JP
56 outl(0xCF8, pcisave);
57 outb(0x3D4, vgasave);
eda689ee
JW
58
59 /* Disable caching on SMRAM again, to prevent the user from whacking us. */
60 WRMSR(0x202, RDMSR(0x202) & ~(0xFFULL));
9e2a82e4
JP
61}
62
722e5aea
JP
63extern void timer_handler(smi_event_t ev);
64extern void kbc_handler(smi_event_t ev);
65extern void gbl_rls_handler(smi_event_t ev);
9e2a82e4 66
722e5aea 67void __firstrun_stub() {
9e2a82e4 68
722e5aea
JP
69 /* Try really hard to shut up USB_LEGKEY. */
70 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
71 pci_write16(0, 31, 2, 0xC0, 0);
72 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
73 pci_write16(0, 31, 4, 0xC0, 0);
9e2a82e4 74
722e5aea
JP
75 /* Turn on the SMIs we want */
76 smi_disable();
9e2a82e4
JP
77
78 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
79 smi_enable_event(SMI_EVENT_FAST_TIMER);
80
722e5aea
JP
81 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
82 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
83
84 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
85 smi_enable_event(SMI_EVENT_GBL_RLS);
86
9e2a82e4
JP
87 smi_enable();
88}
This page took 0.032099 seconds and 4 git commands to generate.