]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/firstrun.c
second arg of memcpy should be const
[netwatch.git] / aseg / firstrun.c
CommitLineData
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
9extern int _bss, _bssend;
e5d94488 10
07d1dd26 11extern void timer_handler(smi_event_t ev);
8a677ebb 12extern void kbc_handler(smi_event_t ev);
73fb9b4c 13extern void gbl_rls_handler(smi_event_t ev);
07d1dd26 14
e8351f1a
JW
15static int found = 0, _bus, _dev, _fn;
16
17void do_bother()
18{
19 int bar;
20
21 if (!found)
22 return;
23
24 pci_write16(_bus, _dev, _fn, 0x04, 0x00);
25 for (bar = 0; bar < 6; bar++)
26 pci_write32(_bus, _dev, _fn, 0x10 + bar*4, 0x1FFFFFFF);
27}
28
ce91287c
JW
29int bother_3c905(pci_dev_t *dev)
30{
31 if (dev->vid == 0x10B7 || dev->did == 0x9200)
32 {
ce91287c 33 outputf("Found a 3c905 to bother");
ce91287c 34
e8351f1a
JW
35 _bus = dev->bus;
36 _dev = dev->dev;
37 _fn = dev->fn;
38 found = 1;
39
40 do_bother();
ce91287c
JW
41
42 return 1;
43 }
44 return 0;
45}
46
e5d94488 47void __firstrun_start() {
f2b87dd6
JW
48 unsigned char *bp;
49 smram_state_t smram;
50
51 smram = smram_save_state();
52 smram_tseg_set_state(SMRAM_TSEG_OPEN);
53
54 for (bp = (void *)&_bss; (void *)bp < (void *)&_bssend; bp++)
55 *bp = 0;
56
ce91287c 57 outputf("NetWatch running");
e5d94488
JP
58
59 /* Try really hard to shut up USB_LEGKEY. */
60 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
61 pci_write16(0, 31, 2, 0xC0, 0);
62 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
63 pci_write16(0, 31, 4, 0xC0, 0);
64
65 /* Turn on the SMIs we want */
07d1dd26 66 smi_disable();
8a677ebb 67
ce91287c
JW
68 pci_probe(bother_3c905);
69
07d1dd26
JW
70 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
71 smi_enable_event(SMI_EVENT_FAST_TIMER);
8a677ebb
JW
72
73 smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler);
74 smi_enable_event(SMI_EVENT_DEVTRAP_KBC);
73fb9b4c
JW
75
76 smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler);
77 smi_enable_event(SMI_EVENT_GBL_RLS);
8a677ebb 78
85bc8ca6 79 smi_enable();
f2b87dd6
JW
80
81 smram_restore_state(smram);
e5d94488
JP
82}
83
This page took 0.035508 seconds and 4 git commands to generate.