]> Joshua Wise's Git repositories - netwatch.git/blob - aseg-paging/smi.c
Merge branch 'master' of /storage/git/netwatch
[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         /* wee! */
35         if (fb && !fb->curmode.text)
36         {
37                 output("not text! nope nope nope");
38                 int ass[][2] = {
39                               {1,0},       {4,0},{5,0},{6,0}, {8,0},{9,0},{10,0},
40                         {0,1},      {2,1}, {4,1},             {8,1},
41                         {0,2},{1,2},{2,2}, {4,2},{5,2},{6,2}, {8,2},{9,2},{10,2},
42                         {0,3},      {2,3},             {6,3},             {10,3},
43                         {0,4},      {2,4}, {4,4},{5,4},{6,4}, {8,4},{9,4},{10,4},
44                         {-1,-1}
45                 };
46                 int p;
47                 for (p = 0; ass[p][0] != -1; p++)
48                 {
49                         int x, y;
50                         for (y = 0; y < 8; y++)
51                                 for (x = 0; x < 8; x++)
52                                 {
53                                         unsigned long a =
54                                                 (unsigned long) fb->fbaddr +
55                                                 ((y+ass[p][1]*8) * fb->curmode.xres + ass[p][0]*8 + x) * 4;
56                                         *(unsigned long *)p2v(a) = 0xFF0000FF;
57                                 }
58                 }
59         }
60         
61         eth_poll();
62         
63         if (inl(0x840) & 0x1000)
64         {
65         /*
66                 pci_dump();
67         */
68                 outl(0x840, 0x1100);
69                 outl(0x840, 0x0100);
70         }
71
72
73         smi_poll();
74         
75         pci_bother_all();
76         outl(0xCF8, pcisave);
77         outb(0x3D4, vgasave);
78 }
79
80 extern void timer_handler(smi_event_t ev);
81 extern void kbc_handler(smi_event_t ev);
82 extern void gbl_rls_handler(smi_event_t ev);
83
84 void __firstrun_stub() {
85
86         /* Try really hard to shut up USB_LEGKEY. */
87         pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
88         pci_write16(0, 31, 2, 0xC0, 0);
89         pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
90         pci_write16(0, 31, 4, 0xC0, 0);
91
92         /* Turn on the SMIs we want */
93         smi_disable();
94
95         smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
96         smi_enable_event(SMI_EVENT_FAST_TIMER);
97
98         smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
99         smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
100
101         smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
102         smi_enable_event(SMI_EVENT_GBL_RLS);
103
104         smi_enable();
105 }
This page took 0.033553 seconds and 4 git commands to generate.