]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - netwatch/firstrun.c
Apply patches from jdpotter@google.com, as submitted to NetWatch Maintainer Team...
[netwatch.git] / netwatch / firstrun.c
... / ...
CommitLineData
1/* firstrun.c
2 * First-run handler
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 <smi.h>
13#include <pci.h>
14#include <reg-82801b.h>
15#include <output.h>
16#include "vga-overlay.h"
17#include <smram.h>
18#include <text.h>
19#include "../net/net.h"
20#include <crc32.h>
21
22extern int _bss, _bssend;
23
24extern void timer_handler(smi_event_t ev);
25extern void kbc_handler(smi_event_t ev);
26extern void gbl_rls_handler(smi_event_t ev);
27
28extern pci_driver_t *drivers[];
29
30void smi_init() {
31 smram_state_t smram;
32 pci_driver_t **driver;
33
34 smram = smram_save_state();
35 smram_tseg_set_state(SMRAM_TSEG_OPEN);
36
37 outputf("NetWatch running");
38
39 /* Try really hard to shut up USB_LEGKEY. */
40 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
41 pci_write16(0, 31, 2, 0xC0, 0);
42 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
43 pci_write16(0, 31, 4, 0xC0, 0);
44
45 /* Turn on the SMIs we want */
46 smi_disable();
47
48 eth_init();
49
50 crc32_init();
51
52 /* After everything is initialized, load drivers. */
53 for (driver = drivers; *driver; driver++)
54 {
55 outputf("Probing driver: %s", (*driver)->name);
56 if (pci_probe_driver(*driver))
57 output("Found a card");
58 }
59 outputf("Driver probe complete");
60
61 /* Load in fonts. */
62 text_init();
63
64 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
65 smi_enable_event(SMI_EVENT_FAST_TIMER);
66
67 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
68 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
69
70 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
71 smi_enable_event(SMI_EVENT_GBL_RLS);
72
73 smi_enable();
74
75 vga_flush_imm(1);
76
77 smram_restore_state(smram);
78}
79
This page took 0.022604 seconds and 4 git commands to generate.