]> Joshua Wise's Git repositories - netwatch.git/blob - aseg-paging/smi.c
031797d28efe7d5299d1aee94753b40a58406529
[netwatch.git] / aseg-paging / smi.c
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>
7 #include <serial.h>
8 #include <fb.h>
9 #include <output.h>
10 #include "../net/net.h"
11 #include "vga-overlay.h"
12
13 unsigned int counter = 0;
14 unsigned long pcisave = 0;
15 unsigned char vgasave = 0;
16
17 void smi_entry(void)
18 {
19         char statstr[512];
20
21         pcisave = inl(0xCF8);
22         vgasave = inb(0x3D4);
23         pci_unbother_all();
24         
25         serial_init();
26         
27         if (fb)
28                 fb->getvmode(fb->priv);
29
30         counter++;
31         sprintf(statstr, "NetWatch! %08x %08x", smi_status(), counter);
32         strblit(statstr, 0, 0, 0);
33         
34         eth_poll();
35         
36         if (inl(0x840) & 0x1000)
37         {
38         /*
39                 pci_dump();
40         */
41                 outl(0x840, 0x1100);
42                 outl(0x840, 0x0100);
43         }
44
45
46         smi_poll();
47         
48         pci_bother_all();
49         outl(0xCF8, pcisave);
50         outb(0x3D4, vgasave);
51 }
52
53 extern void timer_handler(smi_event_t ev);
54 extern void kbc_handler(smi_event_t ev);
55 extern void gbl_rls_handler(smi_event_t ev);
56
57 void __firstrun_stub() {
58
59         /* Try really hard to shut up USB_LEGKEY. */
60         pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
61         pci_write16(0, 31, 2, 0xC0, 0);
62         pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
63         pci_write16(0, 31, 4, 0xC0, 0);
64
65         /* Turn on the SMIs we want */
66         smi_disable();
67
68         smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
69         smi_enable_event(SMI_EVENT_FAST_TIMER);
70
71         smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
72         smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
73
74         smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
75         smi_enable_event(SMI_EVENT_GBL_RLS);
76
77         smi_enable();
78 }
This page took 0.019825 seconds and 2 git commands to generate.