]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - aseg/firstrun.c
Add the 3c905 bother routine.
[netwatch.git] / aseg / firstrun.c
... / ...
CommitLineData
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>
8
9extern int _bss, _bssend;
10
11extern void timer_handler(smi_event_t ev);
12extern void kbc_handler(smi_event_t ev);
13extern void gbl_rls_handler(smi_event_t ev);
14
15int 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
33void __firstrun_start() {
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
43 outputf("NetWatch running");
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 */
52 smi_disable();
53
54 pci_probe(bother_3c905);
55
56 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
57 smi_enable_event(SMI_EVENT_FAST_TIMER);
58
59 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
60 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
61
62 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
63 smi_enable_event(SMI_EVENT_GBL_RLS);
64
65 smi_enable();
66
67 smram_restore_state(smram);
68}
69
This page took 0.02552 seconds and 4 git commands to generate.