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