]> Joshua Wise's Git repositories - netwatch.git/blame - aseg-paging/smi.c
cache p2v for painting ass
[netwatch.git] / aseg-paging / 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>
9e2a82e4
JP
10#include "../net/net.h"
11#include "vga-overlay.h"
12
9e2a82e4 13unsigned int counter = 0;
9e2a82e4
JP
14unsigned long pcisave = 0;
15unsigned char vgasave = 0;
16
9e2a82e4
JP
17void smi_entry(void)
18{
19 char statstr[512];
68beefa8 20
9e2a82e4
JP
21 pcisave = inl(0xCF8);
22 vgasave = inb(0x3D4);
9e2a82e4 23 pci_unbother_all();
c77a83d6
JW
24
25 serial_init();
26
27 if (fb)
28 fb->getvmode(fb->priv);
68beefa8 29
9e2a82e4 30 counter++;
722e5aea 31 sprintf(statstr, "NetWatch! %08x %08x", smi_status(), counter);
a02e8abd 32 strblit(statstr, 0, 0, 0);
9e2a82e4 33
c77a83d6
JW
34 /* wee! */
35 if (fb && !fb->curmode.text)
36 {
c77a83d6
JW
37 int ass[][2] = {
38 {1,0}, {4,0},{5,0},{6,0}, {8,0},{9,0},{10,0},
39 {0,1}, {2,1}, {4,1}, {8,1},
40 {0,2},{1,2},{2,2}, {4,2},{5,2},{6,2}, {8,2},{9,2},{10,2},
41 {0,3}, {2,3}, {6,3}, {10,3},
42 {0,4}, {2,4}, {4,4},{5,4},{6,4}, {8,4},{9,4},{10,4},
43 {-1,-1}
44 };
45 int p;
46 for (p = 0; ass[p][0] != -1; p++)
47 {
48 int x, y;
307d9f0e
JW
49 unsigned long lasta = 0;
50 unsigned long *lastmap;
c77a83d6
JW
51 for (y = 0; y < 8; y++)
52 for (x = 0; x < 8; x++)
53 {
54 unsigned long a =
55 (unsigned long) fb->fbaddr +
56 ((y+ass[p][1]*8) * fb->curmode.xres + ass[p][0]*8 + x) * 4;
307d9f0e
JW
57 if ((a & ~4095) != (lasta & ~4095))
58 {
59 lastmap = (unsigned long *)((unsigned long)p2v(a) & ~4095);
60 lasta = a;
61 }
62 lastmap[(a & 4095) / 4] = 0xFF0000FF;
c77a83d6
JW
63 }
64 }
65 }
66
9e2a82e4 67 eth_poll();
9e2a82e4
JP
68
69 if (inl(0x840) & 0x1000)
70 {
71 /*
72 pci_dump();
73 */
74 outl(0x840, 0x1100);
75 outl(0x840, 0x0100);
76 }
77
113df320 78
9e2a82e4 79 smi_poll();
68beefa8 80
9e2a82e4 81 pci_bother_all();
9e2a82e4
JP
82 outl(0xCF8, pcisave);
83 outb(0x3D4, vgasave);
84}
85
722e5aea
JP
86extern void timer_handler(smi_event_t ev);
87extern void kbc_handler(smi_event_t ev);
88extern void gbl_rls_handler(smi_event_t ev);
9e2a82e4 89
722e5aea 90void __firstrun_stub() {
9e2a82e4 91
722e5aea
JP
92 /* Try really hard to shut up USB_LEGKEY. */
93 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
94 pci_write16(0, 31, 2, 0xC0, 0);
95 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
96 pci_write16(0, 31, 4, 0xC0, 0);
9e2a82e4 97
722e5aea
JP
98 /* Turn on the SMIs we want */
99 smi_disable();
9e2a82e4
JP
100
101 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
102 smi_enable_event(SMI_EVENT_FAST_TIMER);
103
722e5aea
JP
104 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
105 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
106
107 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
108 smi_enable_event(SMI_EVENT_GBL_RLS);
109
9e2a82e4
JP
110 smi_enable();
111}
This page took 0.033204 seconds and 4 git commands to generate.