]>
Commit | Line | Data |
---|---|---|
3c4e084d JP |
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 | ||
9e2a82e4 JP |
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> | |
113df320 | 17 | #include <serial.h> |
c77a83d6 JW |
18 | #include <fb.h> |
19 | #include <output.h> | |
eda689ee | 20 | #include <msr.h> |
9e2a82e4 JP |
21 | #include "../net/net.h" |
22 | #include "vga-overlay.h" | |
23 | ||
9e2a82e4 | 24 | unsigned int counter = 0; |
9e2a82e4 JP |
25 | unsigned long pcisave = 0; |
26 | unsigned char vgasave = 0; | |
27 | ||
9e2a82e4 JP |
28 | void smi_entry(void) |
29 | { | |
30 | char statstr[512]; | |
68beefa8 | 31 | |
eda689ee JW |
32 | /* Reenable caching on SMRAM. */ |
33 | WRMSR(0x202, (RDMSR(0x202) & ~(0xFFULL)) | 0x06ULL); | |
34 | ||
9e2a82e4 JP |
35 | pcisave = inl(0xCF8); |
36 | vgasave = inb(0x3D4); | |
9e2a82e4 | 37 | pci_unbother_all(); |
c77a83d6 JW |
38 | |
39 | serial_init(); | |
40 | ||
41 | if (fb) | |
42 | fb->getvmode(fb->priv); | |
68beefa8 | 43 | |
9e2a82e4 | 44 | counter++; |
5cb80fe1 JW |
45 | if (!fb || fb->curmode.text) |
46 | { | |
47 | sprintf(statstr, "NetWatch! %08x %08x", smi_status(), counter); | |
48 | strblit(statstr, 0, 0, 0); | |
49 | } | |
9e2a82e4 | 50 | |
9e2a82e4 | 51 | eth_poll(); |
9e2a82e4 JP |
52 | |
53 | if (inl(0x840) & 0x1000) | |
54 | { | |
55 | /* | |
56 | pci_dump(); | |
57 | */ | |
58 | outl(0x840, 0x1100); | |
59 | outl(0x840, 0x0100); | |
60 | } | |
61 | ||
113df320 | 62 | |
9e2a82e4 | 63 | smi_poll(); |
68beefa8 | 64 | |
9e2a82e4 | 65 | pci_bother_all(); |
9e2a82e4 JP |
66 | outl(0xCF8, pcisave); |
67 | outb(0x3D4, vgasave); | |
eda689ee JW |
68 | |
69 | /* Disable caching on SMRAM again, to prevent the user from whacking us. */ | |
70 | WRMSR(0x202, RDMSR(0x202) & ~(0xFFULL)); | |
9e2a82e4 JP |
71 | } |
72 | ||
722e5aea JP |
73 | extern void timer_handler(smi_event_t ev); |
74 | extern void kbc_handler(smi_event_t ev); | |
75 | extern void gbl_rls_handler(smi_event_t ev); | |
9e2a82e4 | 76 | |
2768393f JW |
77 | void __firstrun_stub() |
78 | { | |
722e5aea JP |
79 | /* Turn on the SMIs we want */ |
80 | smi_disable(); | |
9e2a82e4 JP |
81 | |
82 | smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler); | |
83 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
84 | ||
722e5aea JP |
85 | smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler); |
86 | smi_enable_event(SMI_EVENT_DEVTRAP_KBC); | |
87 | ||
88 | smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler); | |
89 | smi_enable_event(SMI_EVENT_GBL_RLS); | |
90 | ||
9e2a82e4 JP |
91 | smi_enable(); |
92 | } |