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);
77 void __firstrun_stub() {
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);
85 /* Turn on the SMIs we want */
88 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
89 smi_enable_event(SMI_EVENT_FAST_TIMER);
91 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
92 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
94 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
95 smi_enable_event(SMI_EVENT_GBL_RLS);