]>
Commit | Line | Data |
---|---|---|
3c4e084d JP |
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 | ||
9e2a82e4 JP |
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> | |
cdde55f5 | 18 | #include <text.h> |
9e2a82e4 | 19 | #include "../net/net.h" |
74032dae | 20 | #include <crc32.h> |
9e2a82e4 JP |
21 | |
22 | extern int _bss, _bssend; | |
23 | ||
24 | extern void timer_handler(smi_event_t ev); | |
25 | extern void kbc_handler(smi_event_t ev); | |
26 | extern void gbl_rls_handler(smi_event_t ev); | |
6093edb5 | 27 | extern void cs410_pwrbtn_handler(smi_event_t ev); |
9e2a82e4 | 28 | |
34a7d0d2 JW |
29 | extern pci_driver_t *drivers[]; |
30 | ||
722e5aea | 31 | void smi_init() { |
9e2a82e4 | 32 | smram_state_t smram; |
34a7d0d2 | 33 | pci_driver_t **driver; |
9e2a82e4 JP |
34 | |
35 | smram = smram_save_state(); | |
36 | smram_tseg_set_state(SMRAM_TSEG_OPEN); | |
722e5aea | 37 | |
9e2a82e4 JP |
38 | outputf("NetWatch running"); |
39 | ||
40 | /* Try really hard to shut up USB_LEGKEY. */ | |
41 | pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0)); | |
42 | pci_write16(0, 31, 2, 0xC0, 0); | |
43 | pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0)); | |
44 | pci_write16(0, 31, 4, 0xC0, 0); | |
45 | ||
46 | /* Turn on the SMIs we want */ | |
47 | smi_disable(); | |
9e2a82e4 JP |
48 | |
49 | eth_init(); | |
34a7d0d2 | 50 | |
74032dae JW |
51 | crc32_init(); |
52 | ||
34a7d0d2 JW |
53 | /* After everything is initialized, load drivers. */ |
54 | for (driver = drivers; *driver; driver++) | |
55 | { | |
56 | outputf("Probing driver: %s", (*driver)->name); | |
57 | if (pci_probe_driver(*driver)) | |
58 | output("Found a card"); | |
59 | } | |
60 | outputf("Driver probe complete"); | |
cdde55f5 JW |
61 | |
62 | /* Load in fonts. */ | |
63 | text_init(); | |
722e5aea | 64 | |
9e2a82e4 JP |
65 | smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler); |
66 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
722e5aea | 67 | |
9e2a82e4 JP |
68 | smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler); |
69 | smi_enable_event(SMI_EVENT_DEVTRAP_KBC); | |
70 | ||
71 | smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler); | |
72 | smi_enable_event(SMI_EVENT_GBL_RLS); | |
6093edb5 JW |
73 | |
74 | smi_register_handler(SMI_EVENT_PWRBTN, cs410_pwrbtn_handler); | |
75 | smi_enable_event(SMI_EVENT_PWRBTN); | |
722e5aea | 76 | |
9e2a82e4 JP |
77 | smi_enable(); |
78 | ||
79 | vga_flush_imm(1); | |
80 | ||
81 | smram_restore_state(smram); | |
82 | } | |
83 |