]>
Commit | Line | Data |
---|---|---|
e5d94488 | 1 | #include <io.h> |
85bc8ca6 | 2 | #include <smi.h> |
36ce375d | 3 | #include <pci.h> |
4fb81ad0 | 4 | #include <reg-82801b.h> |
ce91287c | 5 | #include <output.h> |
d71d9872 | 6 | #include "vga-overlay.h" |
f2b87dd6 JW |
7 | #include <smram.h> |
8 | ||
9 | extern int _bss, _bssend; | |
e5d94488 | 10 | |
07d1dd26 | 11 | extern void timer_handler(smi_event_t ev); |
8a677ebb | 12 | extern void kbc_handler(smi_event_t ev); |
73fb9b4c | 13 | extern void gbl_rls_handler(smi_event_t ev); |
07d1dd26 | 14 | |
ce91287c JW |
15 | int bother_3c905(pci_dev_t *dev) |
16 | { | |
17 | if (dev->vid == 0x10B7 || dev->did == 0x9200) | |
18 | { | |
19 | int bar; | |
20 | ||
21 | outputf("Found a 3c905 to bother"); | |
22 | pci_write16(dev->bus, dev->dev, dev->fn, 0x04, 0x00); | |
23 | ||
24 | for (bar = 0; bar < 6; bar++) | |
25 | if (dev->bars[bar].type != PCI_BAR_NONE) | |
26 | pci_write32(dev->bus, dev->dev, dev->fn, 0x10 + bar*4, 0); | |
27 | ||
28 | return 1; | |
29 | } | |
30 | return 0; | |
31 | } | |
32 | ||
e5d94488 | 33 | void __firstrun_start() { |
f2b87dd6 JW |
34 | unsigned char *bp; |
35 | smram_state_t smram; | |
36 | ||
37 | smram = smram_save_state(); | |
38 | smram_tseg_set_state(SMRAM_TSEG_OPEN); | |
39 | ||
40 | for (bp = (void *)&_bss; (void *)bp < (void *)&_bssend; bp++) | |
41 | *bp = 0; | |
42 | ||
ce91287c | 43 | outputf("NetWatch running"); |
e5d94488 JP |
44 | |
45 | /* Try really hard to shut up USB_LEGKEY. */ | |
46 | pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0)); | |
47 | pci_write16(0, 31, 2, 0xC0, 0); | |
48 | pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0)); | |
49 | pci_write16(0, 31, 4, 0xC0, 0); | |
50 | ||
51 | /* Turn on the SMIs we want */ | |
07d1dd26 | 52 | smi_disable(); |
8a677ebb | 53 | |
ce91287c JW |
54 | pci_probe(bother_3c905); |
55 | ||
07d1dd26 JW |
56 | smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler); |
57 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
8a677ebb JW |
58 | |
59 | smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler); | |
60 | smi_enable_event(SMI_EVENT_DEVTRAP_KBC); | |
73fb9b4c JW |
61 | |
62 | smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler); | |
63 | smi_enable_event(SMI_EVENT_GBL_RLS); | |
8a677ebb | 64 | |
85bc8ca6 | 65 | smi_enable(); |
f2b87dd6 JW |
66 | |
67 | smram_restore_state(smram); | |
e5d94488 JP |
68 | } |
69 |