]> Joshua Wise's Git repositories - netwatch.git/blame - net/net.c
Hacky network transmitter.
[netwatch.git] / net / net.c
CommitLineData
3b3161a1 1#include <pci.h>
6c744a5a
JW
2#include <io.h>
3#include <video_defines.h>
4#include <smram.h>
4d898e0b 5#include <pci-bother.h>
3b3161a1 6#include <output.h>
4d898e0b 7#include "net.h"
3b3161a1 8
7a914840 9static struct nic *_nic = 0x0;
3e6d6106 10
7a914840
JW
11extern struct pci_driver a3c90x_driver;
12
99182958
JW
13static char test[1024] = {0};
14
6c744a5a
JW
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
7a914840 27void eth_poll()
3b3161a1 28{
99182958 29 int i;
6c744a5a
JW
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;
99182958
JW
35
36 if (!_nic)
37 return;
38
39 _nic->poll(_nic, 0);
6c744a5a
JW
40 smram_tseg_set_state(SMRAM_TSEG_OPEN);
41 old_state = smram_save_state();
99182958 42
6c744a5a
JW
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);
99182958 52
6c744a5a 53 for (i = 4; i < 1024; i++)
99182958 54 {
6c744a5a
JW
55 test[i] = p[pos++];
56 pos %= 0x8000;
99182958 57 }
6c744a5a 58 smram_restore_state(old_state);
99182958 59 _nic->transmit("\x00\x03\x93\x87\x84\x8C", 0x1337, 1024, test);
3b3161a1
JW
60}
61
7a914840 62int eth_register(struct nic *nic)
3b3161a1 63{
7a914840
JW
64 if (_nic)
65 return -1;
66 _nic = nic;
67 return 0;
3b3161a1
JW
68}
69
70void eth_init()
71{
c25f3f39
JW
72 /* Required for DMA to work. :( */
73 smram_tseg_set_state(SMRAM_TSEG_OPEN);
74 pci_probe_driver(a3c90x_driver);
3b3161a1 75}
This page took 0.029073 seconds and 4 git commands to generate.