]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - net/net.c
add watcher
[netwatch.git] / net / net.c
... / ...
CommitLineData
1#include <pci.h>
2#include <io.h>
3#include <video_defines.h>
4#include <smram.h>
5#include <pci-bother.h>
6#include <output.h>
7#include "net.h"
8
9static struct nic *_nic = 0x0;
10
11extern struct pci_driver a3c90x_driver;
12
13static char test[1024] = {0};
14
15static unsigned char vga_read(unsigned char idx)
16{
17 outb(CRTC_IDX_REG, idx);
18 return inb(CRTC_DATA_REG);
19}
20
21static unsigned int vga_base()
22{
23 return (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 9)
24 + (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 1);
25}
26
27void eth_poll()
28{
29 int i;
30// static int c;
31 static short pos = 0x0;
32 unsigned short base = vga_base();
33 unsigned char *p = (unsigned char *)0xB8000;
34 smram_state_t old_state;
35
36 if (!_nic)
37 return;
38
39 _nic->poll(_nic, 0);
40 smram_tseg_set_state(SMRAM_TSEG_OPEN);
41 old_state = smram_save_state();
42
43// if ((c++) % 2)
44// return;
45
46 test[0] = pos >> 8;
47 test[1] = pos & 0xFF;
48 test[2] = base >> 8;
49 test[3] = base & 0xFF;
50
51 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
52
53 for (i = 4; i < 1024; i++)
54 {
55 test[i] = p[pos++];
56 pos %= 0x8000;
57 }
58 smram_restore_state(old_state);
59 _nic->transmit("\x00\x03\x93\x87\x84\x8C", 0x1337, 1024, test);
60}
61
62int eth_register(struct nic *nic)
63{
64 if (_nic)
65 return -1;
66 _nic = nic;
67 return 0;
68}
69
70void eth_init()
71{
72 /* Required for DMA to work. :( */
73 smram_tseg_set_state(SMRAM_TSEG_OPEN);
74 pci_probe_driver(a3c90x_driver);
75}
This page took 0.018931 seconds and 4 git commands to generate.