]> Joshua Wise's Git repositories - netwatch.git/blame - net/net.c
correct scan codes
[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
50d89a31
JP
15static char packet[4096] = {0};
16
17typedef struct packet_t {
18 char from[6];
19 char to[6];
20 unsigned short ethertype;
21 char data[];
22} packet_t;
23
6c744a5a
JW
24static unsigned char vga_read(unsigned char idx)
25{
26 outb(CRTC_IDX_REG, idx);
27 return inb(CRTC_DATA_REG);
28}
29
30static unsigned int vga_base()
31{
32 return (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 9)
33 + (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 1);
34}
35
7a914840 36void eth_poll()
3b3161a1 37{
99182958 38 int i;
6c744a5a
JW
39// static int c;
40 static short pos = 0x0;
41 unsigned short base = vga_base();
42 unsigned char *p = (unsigned char *)0xB8000;
43 smram_state_t old_state;
99182958
JW
44
45 if (!_nic)
46 return;
47
50d89a31
JP
48 if (_nic->poll(_nic, 0)) {
49 _nic->packet = packet;
50 _nic->poll(_nic, 1);
51
52 packet_t * p = (packet_t *) packet;
53
54 outputf("NIC: Packet: %d 0x%x", _nic->packetlen, p->ethertype);
55 if (p->ethertype == 0x3813) {
56 outputf("NIC: Command: 0x%x", *((uint16_t *)p->data));
57 }
58 }
6c744a5a
JW
59 smram_tseg_set_state(SMRAM_TSEG_OPEN);
60 old_state = smram_save_state();
99182958 61
6c744a5a
JW
62// if ((c++) % 2)
63// return;
64
65 test[0] = pos >> 8;
66 test[1] = pos & 0xFF;
67 test[2] = base >> 8;
68 test[3] = base & 0xFF;
69
70 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
99182958 71
6c744a5a 72 for (i = 4; i < 1024; i++)
99182958 73 {
6c744a5a
JW
74 test[i] = p[pos++];
75 pos %= 0x8000;
99182958 76 }
6c744a5a 77 smram_restore_state(old_state);
99182958 78 _nic->transmit("\x00\x03\x93\x87\x84\x8C", 0x1337, 1024, test);
3b3161a1
JW
79}
80
7a914840 81int eth_register(struct nic *nic)
3b3161a1 82{
7a914840
JW
83 if (_nic)
84 return -1;
85 _nic = nic;
86 return 0;
3b3161a1
JW
87}
88
89void eth_init()
90{
c25f3f39
JW
91 /* Required for DMA to work. :( */
92 smram_tseg_set_state(SMRAM_TSEG_OPEN);
93 pci_probe_driver(a3c90x_driver);
3b3161a1 94}
This page took 0.036221 seconds and 4 git commands to generate.