]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - netwatch/smi.c
Add cross-compile support (for fools like me who build on OS X) to the Makefiles.
[netwatch.git] / netwatch / smi.c
... / ...
CommitLineData
1/* smi.c
2 * First-run SMI C entry point
3 * NetWatch system management mode administration console
4 *
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
8 *
9 */
10
11#include <io.h>
12#include <smram.h>
13#include <video_defines.h>
14#include <minilib.h>
15#include <smi.h>
16#include <pci-bother.h>
17#include <serial.h>
18#include <fb.h>
19#include <output.h>
20#include <msr.h>
21#include "../net/net.h"
22#include "vga-overlay.h"
23
24unsigned int counter = 0;
25unsigned long pcisave = 0;
26unsigned char vgasave = 0;
27
28void smi_entry(void)
29{
30 char statstr[512];
31
32 /* Reenable caching on SMRAM. */
33 WRMSR(0x202, (RDMSR(0x202) & ~(0xFFULL)) | 0x06ULL);
34
35 pcisave = inl(0xCF8);
36 vgasave = inb(0x3D4);
37 pci_unbother_all();
38
39 serial_init();
40
41 if (fb)
42 fb->getvmode(fb->priv);
43
44 counter++;
45 if (!fb || fb->curmode.text)
46 {
47 sprintf(statstr, "NetWatch! %08x %08x", smi_status(), counter);
48 strblit(statstr, 0, 0, 0);
49 }
50
51 eth_poll();
52
53 if (inl(0x840) & 0x1000)
54 {
55 /*
56 pci_dump();
57 */
58 outl(0x840, 0x1100);
59 outl(0x840, 0x0100);
60 }
61
62
63 smi_poll();
64
65 pci_bother_all();
66 outl(0xCF8, pcisave);
67 outb(0x3D4, vgasave);
68
69 /* Disable caching on SMRAM again, to prevent the user from whacking us. */
70 WRMSR(0x202, RDMSR(0x202) & ~(0xFFULL));
71}
72
73extern void timer_handler(smi_event_t ev);
74extern void kbc_handler(smi_event_t ev);
75extern void gbl_rls_handler(smi_event_t ev);
76
77void __firstrun_stub() {
78
79 /* Try really hard to shut up USB_LEGKEY. */
80 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
81 pci_write16(0, 31, 2, 0xC0, 0);
82 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
83 pci_write16(0, 31, 4, 0xC0, 0);
84
85 /* Turn on the SMIs we want */
86 smi_disable();
87
88 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
89 smi_enable_event(SMI_EVENT_FAST_TIMER);
90
91 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
92 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
93
94 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
95 smi_enable_event(SMI_EVENT_GBL_RLS);
96
97 smi_enable();
98}
This page took 0.027734 seconds and 4 git commands to generate.