]> Joshua Wise's Git repositories - netwatch.git/blame - netwatch/firstrun.c
Merge nyus.joshuawise.com:/storage/git/netwatch
[netwatch.git] / netwatch / firstrun.c
CommitLineData
9e2a82e4
JP
1#include <io.h>
2#include <smi.h>
3#include <pci.h>
4#include <reg-82801b.h>
5#include <output.h>
6#include "vga-overlay.h"
7#include <smram.h>
cdde55f5 8#include <text.h>
9e2a82e4 9#include "../net/net.h"
74032dae 10#include <crc32.h>
9e2a82e4
JP
11
12extern int _bss, _bssend;
13
14extern void timer_handler(smi_event_t ev);
15extern void kbc_handler(smi_event_t ev);
16extern void gbl_rls_handler(smi_event_t ev);
17
34a7d0d2
JW
18extern pci_driver_t *drivers[];
19
722e5aea 20void smi_init() {
9e2a82e4 21 smram_state_t smram;
34a7d0d2 22 pci_driver_t **driver;
9e2a82e4
JP
23
24 smram = smram_save_state();
25 smram_tseg_set_state(SMRAM_TSEG_OPEN);
722e5aea 26
9e2a82e4
JP
27 outputf("NetWatch running");
28
29 /* Try really hard to shut up USB_LEGKEY. */
30 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
31 pci_write16(0, 31, 2, 0xC0, 0);
32 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
33 pci_write16(0, 31, 4, 0xC0, 0);
34
35 /* Turn on the SMIs we want */
36 smi_disable();
9e2a82e4
JP
37
38 eth_init();
34a7d0d2 39
74032dae
JW
40 crc32_init();
41
34a7d0d2
JW
42 /* After everything is initialized, load drivers. */
43 for (driver = drivers; *driver; driver++)
44 {
45 outputf("Probing driver: %s", (*driver)->name);
46 if (pci_probe_driver(*driver))
47 output("Found a card");
48 }
49 outputf("Driver probe complete");
cdde55f5
JW
50
51 /* Load in fonts. */
52 text_init();
722e5aea 53
9e2a82e4
JP
54 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
55 smi_enable_event(SMI_EVENT_FAST_TIMER);
722e5aea 56
9e2a82e4
JP
57 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
58 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
59
60 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
61 smi_enable_event(SMI_EVENT_GBL_RLS);
722e5aea 62
9e2a82e4
JP
63 smi_enable();
64
65 vga_flush_imm(1);
66
67 smram_restore_state(smram);
68}
69
This page took 0.031406 seconds and 4 git commands to generate.