2 * First-run SMI C entry point
3 * NetWatch system management mode administration console
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.
13 #include <video_defines.h>
16 #include <pci-bother.h>
21 #include "../net/net.h"
22 #include "vga-overlay.h"
24 unsigned int counter = 0;
25 unsigned long pcisave = 0;
26 unsigned char vgasave = 0;
32 /* Reenable caching on SMRAM. */
33 WRMSR(0x202, (RDMSR(0x202) & ~(0xFFULL)) | 0x06ULL);
42 fb->getvmode(fb->priv);
45 if (!fb || fb->curmode.text)
47 sprintf(statstr, "NetWatch! %08x %08x", smi_status(), counter);
48 strblit(statstr, 0, 0, 0);
53 if (inl(0x840) & 0x1000)
69 /* Disable caching on SMRAM again, to prevent the user from whacking us. */
70 WRMSR(0x202, RDMSR(0x202) & ~(0xFFULL));
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);
76 extern void cs410_pwrbtn_handler(smi_event_t ev);
78 void __firstrun_stub() {
80 /* Try really hard to shut up USB_LEGKEY. */
81 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
82 pci_write16(0, 31, 2, 0xC0, 0);
83 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
84 pci_write16(0, 31, 4, 0xC0, 0);
86 /* Turn on the SMIs we want */
89 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
90 smi_enable_event(SMI_EVENT_FAST_TIMER);
92 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
93 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
95 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
96 smi_enable_event(SMI_EVENT_GBL_RLS);
98 smi_register_handler(SMI_EVENT_PWRBTN, cs410_pwrbtn_handler);
99 smi_enable_event(SMI_EVENT_PWRBTN);