Thread: [chaos-svn] SF.net SVN: chaos: [1228] trunk/chaos-old/servers/network/ne2000
Status: Pre-Alpha
Brought to you by:
sf_hal
|
From: <per...@us...> - 2007-03-13 23:03:08
|
Revision: 1228
http://chaos.svn.sourceforge.net/chaos/?rev=1228&view=rev
Author: perlundberg
Date: 2007-03-13 16:03:05 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Worked more on the ne2000 server. Receiving seems to work now and the packets are forwarded to the ipv4 server but the ICMP ECHO message (a.k.a. ping) I am sending seems to be garbled somehow. The ipv4 server detects and acknowledges arp who-has packets being sent on the network though, so kind of a weird bug.
Modified Paths:
--------------
trunk/chaos-old/servers/network/ne2000/ne2000.c
trunk/chaos-old/servers/network/ne2000/ne2000.h
Modified: trunk/chaos-old/servers/network/ne2000/ne2000.c
===================================================================
--- trunk/chaos-old/servers/network/ne2000/ne2000.c 2007-03-12 20:30:09 UTC (rev 1227)
+++ trunk/chaos-old/servers/network/ne2000/ne2000.c 2007-03-13 23:03:05 UTC (rev 1228)
@@ -36,7 +36,6 @@
log_structure_type log_structure;
-u8 ne_detect(device_type *);
u8 ne_reset_chip(device_type *);
void ne_init_chip(device_type *, u8);
void ne_int_handler(device_type *);
@@ -48,117 +47,11 @@
//device_type card;
u32 message[1024];
-u32 data_buffer[1024]; /* xxx - was 400 before.. */
+u32 data_buffer[1518]; /* xxx - was 400 before.. */
struct ne_user_t users[MAX_USERS];
u8 num_users = 0;
-u8 ne_detect (device_type *n)
-{
- u8 chk = 0, x;
- u32 i;
-
- if (!n || !n->io || !n->irq)
- {
- log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "-- Invalid io(0x%x) address or irq(%d)", n->io, n->irq);
- return ERROR;
- }
-
- if (system_call_port_range_register (n->io, 0x1F, PACKAGE_NAME))
- {
- log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "-- Cannot allocate 0x%x => 0x%x", n->io, n->io+0x1f);
- return ERROR;
- }
-
- chk = system_port_in_u8 (n->io);
- if (chk == 0xff) /* No card found */
- {
- log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "-- Nothing found on 0x%x", n->io);
-
- /* FIXME: deallocate I/O space */
- return ERROR;
- }
-
- /* Check if it really is a NE2k card */
- outb (NE_NODMA + NE_PAGE1 + NE_STOP, n->io); /* Stop the card */
- x = inb (n->io + NE_R0_CNTR0);
- outb (0xff, n->io + NE_R0_CNTR0);
- outb (NE_NODMA + NE_PAGE0, n->io);
- inb (n->io + NE_R0_CNTR0); /* Clear the counter by reading */
-
- if (inb (n->io + NE_R0_CNTR0) != 0) /* Ooops ;) */
- {
- outb (chk, n->io);
- outb (chk, n->io + NE_R0_CNTR0);
- log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "Something, but not a NE2k card, found. Aborting");
- return ERROR;
- }
-
- ne_reset_chip (n);
-
- /* We don't ack _all_ interrupts in ne_reset_chip(),
- so we do it here instead */
- outb (0xff, n->io + NE_R0_ISR);
-
-
- /* Init registers and shit */
- for (i = 0;i < sizeof (ne_preinit_program)/sizeof (ne_program);i++)
- {
- outb (ne_preinit_program[i].value, n->io + ne_preinit_program[i].offset);
- }
-
- /* It's time to read the station address prom now */
- for (i = 0, x = 0;i < 32;i += 2)
- {
- n->prom[i] = inb (n->io + NE_DATAPORT);
- n->prom[i+1] = inb (n->io + NE_DATAPORT);
- if (n->prom[i] != n->prom[i+1])
- x = 1;
- }
-
- if (x) /* This isn't a 16 bit card */
- {
- log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "Haha! Your card isn't supported. Get a 16 bit card");
- return ERROR;
- }
-
- for (i = 0;i < 16;i++)
- n->prom[i] = n->prom[i+i];
-
- for (i = 0; i < 6; i++)
- n->ethernet_address[i] = n->prom[i];
-
- log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, "MAC address is %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x"
- " and signature [0x%x 0x%x]",
- n->prom[0], n->prom[1], n->prom[2],
- n->prom[3], n->prom[4], n->prom[5],
- n->prom[14], n->prom[15]);
-
- outb (0x49, n->io + NE_R0_DCR); /* Set the card in word-wide mode */
-
- /* Create a thread for the IRQ handler and set up an IRQ handler loop. */
- if (system_call_thread_create () == SYSTEM_RETURN_THREAD_NEW) {
- if (system_call_irq_register (n->irq, PACKAGE_NAME) != SYSTEM_RETURN_SUCCESS)
- {
- log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, "$@!# Couldn't register irq %d :(", n->irq);
- /* FIXME: Deallocate I/O space. */
-
- return ERROR;
- }
-
- while (TRUE) {
- system_call_irq_wait (n->irq);
- ne_int_handler (n);
- }
- }
-
- /* this code should probably wait here until the IRQ handler etc has
- been setup... */
-
- ne_init_chip (n, 0);
- return 0;
-}
-
u8 ne_reset_chip (device_type *n)
{
u16 i;
@@ -234,144 +127,134 @@
outb (NE_DEF_RXCFG, n->io + NE_R0_RCR); /* ..and receive. */
n->status |= NIC_UP;
}
- else
+ else {
n->status |= NIC_DOWN;
+ }
-
n->status &= ~NIC_INIT;
}
/* FIXME: rewrite this! */
void ne_int_handler (device_type *card __attribute__ ((unused)))
{
- return;
-
-#if 0
int sreg;
u8 num_handled;
- for (card->num_interrupts = 1;; card->num_interrupts++)
+ card->num_interrupts++;
+
+ if (debug >= 2)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Entering interrupt again");
+
+ if (card->status & NIC_INT)
+ log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- What, entering interrupt again???");
+
+ card->status |= NIC_INT;
+
+ /* Switch to page 0 */
+ outb (NE_NODMA + NE_PAGE0, card->io);
+
+ num_handled = 0;
+ while (!(card->status & NIC_BUSY) &&
+ (sreg = inb (card->io + NE_R0_ISR)) != 0 &&
+ num_handled++ < MAX_INT_WORK)
{
- if (debug >= 2)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Entering interrupt again");
-
- if (card->status & NIC_INT)
- log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- What, entering interrupt again???");
-
- card->status |= NIC_INT;
-
- /* Switch to page 0 */
- outb (NE_NODMA + NE_PAGE0, card->io);
-
- num_handled = 0;
- while (!(card->status & NIC_BUSY) &&
- (sreg = inb (card->io + NE_R0_ISR)) != 0 &&
- num_handled++ < MAX_INT_WORK)
+ // sreg = inb (card->io+NE_R0_ISR);
+ if (debug == 2)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** ISR:%2.2x ISM:%2.2x", sreg, inb(card->io + NE_R0_IMR));
+
+ if (!(card->status & NIC_UP))
+ log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- Weird, this nic should be stopped!");
+
+ if (sreg & BIT_ISR_OVERFLW)
{
-// sreg = inb (card->io+NE_R0_ISR);
- if (debug == 2)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** ISR:%2.2x ISM:%2.2x", sreg, inb(card->io + NE_R0_IMR));
-
- if (!(card->status & NIC_UP))
- log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- Weird, this nic should be stopped!");
-
- if (sreg & BIT_ISR_OVERFLW)
- {
- if (debug >= 1)
- log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- Overflow in rx buffer");
-
- /* This a little more than 10ms. */
+ if (debug >= 1)
+ log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- Overflow in rx buffer");
+
+ /* This a little more than 10ms. */
#ifdef CAN_WAIT_10_MS
- ne_handle_overflow (card);
-
+ ne_handle_overflow (card);
+
#else /* XXX - this code probably DONT work */
#error "Tomtevarning; DEN H\xC4R KODEN FUNKAR INTE"
- {
- u32 tomte;
-
- if (debug >= 1)
- log_print_formatted ("** resetting card->.");
-
- tomte = NE_RST_OVERRUN;
- card->status |= NIC_BUSY;
- syscall_message_send (syscall_process_get_pid_by_name ("ne"), &tomte, 4);
- break;
- /* Maybe we should ack. some interrupts.. */
- }
-#endif
- }
-
- if (sreg & (BIT_ISR_RX+BIT_ISR_RX_ERR))
{
- if (debug >= 2)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Packet received");
-
- ne_recv (card);
+ u32 tomte;
+
+ if (debug >= 1)
+ log_print_formatted ("** resetting card->.");
+
+ tomte = NE_RST_OVERRUN;
+ card->status |= NIC_BUSY;
+ syscall_message_send (syscall_process_get_pid_by_name ("ne"), &tomte, 4);
+ break;
+ /* Maybe we should ack. some interrupts.. */
}
+#endif
+ }
- if (sreg & BIT_ISR_TX)
- if (debug >= 1)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Transmit");
+ if (sreg & (BIT_ISR_RX+BIT_ISR_RX_ERR))
+ {
+ if (debug >= 2)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Packet received");
+
+ ne_recv (card);
+ }
- if (sreg & BIT_ISR_TX_ERR)
- if (debug >= 1)
- log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- Transmit error");
+ if (sreg & BIT_ISR_TX)
+ if (debug >= 1)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Transmit");
+
+ if (sreg & BIT_ISR_TX_ERR)
+ if (debug >= 1)
+ log_print_formatted (&log_structure, LOG_URGENCY_WARNING, "-- Transmit error");
- if (sreg & BIT_ISR_CNTRS)
- {
- u8 x,y,z;
- x = inb (card->io+NE_R0_CNTR0);
- y = inb (card->io+NE_R0_CNTR1);
- z = inb (card->io+NE_R0_CNTR2);
- outb (BIT_ISR_CNTRS, card->io+NE_R0_ISR);
- if (debug >= 2)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- COUNTERS: frame:%d crc:%d missed:%d", x,y,z);
- }
+ if (sreg & BIT_ISR_CNTRS)
+ {
+ u8 x,y,z;
+ x = inb (card->io+NE_R0_CNTR0);
+ y = inb (card->io+NE_R0_CNTR1);
+ z = inb (card->io+NE_R0_CNTR2);
+ outb (BIT_ISR_CNTRS, card->io+NE_R0_ISR);
+ if (debug >= 2)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- COUNTERS: frame:%d crc:%d missed:%d", x,y,z);
+ }
- if (sreg & BIT_ISR_RDC)
- {
- if (debug >= 2)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- Ignoring RDC interrupt");
+ if (sreg & BIT_ISR_RDC)
+ {
+ if (debug >= 2)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- Ignoring RDC interrupt");
- outb (BIT_ISR_RDC, card->io + NE_R0_ISR);
+ outb (BIT_ISR_RDC, card->io + NE_R0_ISR);
- /* XXX - lock here for debugging purposes */
-// for(;;);
- }
+ /* XXX - lock here for debugging purposes */
+ // for(;;);
+ }
- /* XXX - varf\xF6r i helvete sitter det en // h\xE4r? */
- /* Ack. all interrupts */
-// outb (0xff, card->io + NE_R0_ISR);
+ /* XXX - varf\xF6r i helvete sitter det en // h\xE4r? */
+ /* Ack. all interrupts */
+ // outb (0xff, card->io + NE_R0_ISR);
- /* XXX - does this enable the card again?
- does it make the card generate intr.:s. again? */
+ /* XXX - does this enable the card again?
+ does it make the card generate intr.:s. again? */
- outb (NE_NODMA + NE_PAGE0 + NE_START, card->io);
- }
+ outb (NE_NODMA + NE_PAGE0 + NE_START, card->io);
+ }
- if (num_handled == MAX_INT_WORK)
- if (debug >= 1)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- ** -- Max interrupt work done!!");
+ if (num_handled == MAX_INT_WORK)
+ if (debug >= 1)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- ** -- Max interrupt work done!!");
- card->status &= ~NIC_INT;
- if (debug >= 2)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** ISR:%2.2x ISM:%2.2x device_type status:%.2x (Leaving interrupt handler)", inb(card->io+NE_R0_ISR),
- inb (card->io+NE_R0_IMR), card->status);
-
- // FIXME: should we acknowledge each interrupt if we have multiple
- // interrupts waiting in queue? Probably.
- system_call_irq_acknowledge (card->irq);
- }
-#endif
+ card->status &= ~NIC_INT;
+ if (debug >= 2)
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** ISR:%2.2x ISM:%2.2x device_type status:%.2x (Leaving interrupt handler)", inb(card->io+NE_R0_ISR),
+ inb (card->io+NE_R0_IMR), card->status);
}
-
void ne_recv (device_type *card)
{
-/* xxx - moved data_buffer to global .. */
- u8 *data = ((u8 *)data_buffer) + ((u8) 8);
+ /* xxx - moved data_buffer to global .. */
+ u8 *data = ((u8 *) data_buffer) + ((u8) 8);
u8 rx_packets = 0;
u8 rx_page;
u8 frame, next_frame, pkt_status;
@@ -407,7 +290,7 @@
if (frame == rx_page) /* D0h, we're done */
{
- if (debug >= 1)
+ if (debug >= 2)
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** wow, we're done recv!");
break;
@@ -479,7 +362,7 @@
/* Do something useful */
if ((pkt_status & 0x0f) == BIT_RSR_RXOK)
{
- /* Wheee.. We recv. a good packet */
+ /* Wheee.. We received a good packet */
#define PROTO ((data[12]*256)+data[13])
if (debug >= 1)
@@ -523,34 +406,38 @@
if (i->protocol == 0x1)
{
- p += sizeof (struct iphdr);
+ p += sizeof (ipv4_ethernet_header_type);
log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "ICMP type is [%.2x : %.2x]", p[0], p[1]);
}
}
-
- for (n = 0; n < num_users; n++)
- {
- if (users[n].proto != e->h_proto)
+
+ /* Check if this packet should be delivered somewhere. */
+
+ for (n = 0; n < card->number_of_targets; n++)
+ {
+ if (card->target[n].protocol_type ==
+ ((ipv4_ethernet_header_type *) data)->protocol_type)
{
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** User proto: %d eth: %d\n", users[n].proto, (e->h_proto));
- continue;
+ message_parameter_type message_parameter;
+
+ message_parameter.protocol = IPC_PROTOCOL_ETHERNET;
+ message_parameter.message_class = IPC_ETHERNET_PACKET_RECEIVED;
+ message_parameter.length = pkt_len + 8; /* probably 8 bytes of header. */
+ message_parameter.block = FALSE;
+ message_parameter.data = data;
+
+ if (debug >= 1)
+ {
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
+ "Sending to mailbox ID %u",
+ card->target[n].mailbox_id);
+ }
+
+ system_call_mailbox_send (card->target[n].mailbox_id,
+ &message_parameter);
+ break;
}
-
- // Send the packet to the destination
-#if 0
- message_parameter_type message_parameter;
-
- message_parameter.protocol = IPC_PROTOCOL_ETHERNET;
- message_parameter.message_class = IPC_ETHERNET_PACKET_RECEIVED;
- message_parameter.length = pkt_len;
- message_parameter.block = FALSE;
- message_parameter.data = data_buffer;
-
- log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "Sending data to pid %ld: ETHERNET_PACKET_RECEIVED, len %d 0x%x\n", users[n].pid, pkt_len + 8, pkt_len + 8);
- system_call_mailbox_send (device->target[n].mailbox_id,
- &message_parameter);
-#endif
}
} /* End of IP code */
} /* End of RX ok code */
@@ -630,16 +517,16 @@
-void ne_handle_overflow (device_type *n)
+void ne_handle_overflow (device_type *device)
{
u8 txing, resend = 0;
u16 x;
- txing = inb (n->io) & NE_TRANS;
+ txing = inb (device->io) & NE_TRANS;
/* stop the card->. */
- outb (NE_NODMA + NE_PAGE0 + NE_STOP, n->io);
+ outb (NE_NODMA + NE_PAGE0 + NE_STOP, device->io);
if (debug >= 1)
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- Huh.. Overflow.. Sleeping one second!");
@@ -649,36 +536,36 @@
#endif
for(x = 1;x != 0;x++); /* XXX - Hmm, this is probably ok for now :) */
- outb (0, n->io + NE_R0_RBCR0);
- outb (0, n->io + NE_R0_RBCR1);
+ outb (0, device->io + NE_R0_RBCR0);
+ outb (0, device->io + NE_R0_RBCR1);
if (txing)
{
- if (!(inb (n->io+NE_R0_ISR) & (BIT_ISR_TX+BIT_ISR_TX_ERR)))
+ if (!(inb (device->io+NE_R0_ISR) & (BIT_ISR_TX+BIT_ISR_TX_ERR)))
resend++;
}
- outb (BIT_TCR_LB, n->io + NE_R0_TCR); /* Enter loopback mode */
- outb (NE_NODMA + NE_PAGE0+NE_START, n->io);
+ outb (BIT_TCR_LB, device->io + NE_R0_TCR); /* Enter loopback mode */
+ outb (NE_NODMA + NE_PAGE0+NE_START, device->io);
if (debug >= 1)
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** - Clearing rx buffer ring");
/* Clear RX ring buffer */
- ne_recv (n);
+ ne_recv (device);
/* Ack. overflow interrupt */
- outb (BIT_ISR_OVERFLW, n->io+NE_R0_ISR);
+ outb (BIT_ISR_OVERFLW, device->io+NE_R0_ISR);
/* Leave loopback mode & resend any stopped packets */
- outb (0, n->io + NE_R0_TCR);
+ outb (0, device->io + NE_R0_TCR);
if (resend)
- outb (NE_NODMA + NE_PAGE0 + NE_START + NE_TRANS, n->io);
+ outb (NE_NODMA + NE_PAGE0 + NE_START + NE_TRANS, device->io);
/* We're finnished */
log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, "** overflow reset done!");
- n->status &= ~NIC_BUSY;
+ device->status &= ~NIC_BUSY;
}
u16 hex2dec (u8 *s)
@@ -709,17 +596,126 @@
/* Open the ne2000 device. */
-static bool ne2000_open (device_type *device __attribute__ ((unused)))
+static bool ne2000_open (device_type *device)
{
- // FIXME
+ /* Create a thread for the IRQ handler and set up an IRQ handler loop. */
+ if (system_thread_create () == SYSTEM_RETURN_THREAD_NEW) {
+ log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, "in IRQ thread");
+
+ if (system_call_irq_register (device->irq, PACKAGE_NAME) != SYSTEM_RETURN_SUCCESS)
+ {
+ log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, "$@!# Couldn't register irq %d :(", device->irq);
+ /* FIXME: Deallocate I/O space. */
+
+ return FALSE;
+ }
+
+ system_call_thread_name_set ("IRQ handler");
+
+ while (TRUE) {
+ system_call_irq_wait (device->irq);
+ ne_int_handler (device);
+ system_call_irq_acknowledge (device->irq);
+ }
+ }
+
+ ne_init_chip (device, 1);
return TRUE;
}
+// FIXME: should have an accompanying ne2000_close ()...
+
/* Probe for an ne2000 compatible device. */
-static bool ne2000_probe (device_type *device __attribute__ ((unused)))
+static bool ne2000_probe (device_type *device)
{
- // FIXME
+ u8 chk = 0, x;
+ u32 i;
+
+ if (!device || !device->io || !device->irq)
+ {
+ log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "-- Invalid io(0x%x) address or irq(%d)", device->io, device->irq);
+ return FALSE;
+ }
+
+ if (system_call_port_range_register (device->io, 0x1F, PACKAGE_NAME))
+ {
+ log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "-- Cannot allocate 0x%x => 0x%x", device->io, device->io + 0x1f);
+ return FALSE;
+ }
+
+ chk = system_port_in_u8 (device->io);
+ if (chk == 0xff) /* No card found */
+ {
+ log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "-- Nothing found on 0x%x", device->io);
+
+ /* FIXME: deallocate I/O space */
+ return FALSE;
+ }
+
+ /* Check if it really is a NE2k card */
+ outb (NE_NODMA + NE_PAGE1 + NE_STOP, device->io); /* Stop the card */
+ x = inb (device->io + NE_R0_CNTR0);
+ outb (0xff, device->io + NE_R0_CNTR0);
+ outb (NE_NODMA + NE_PAGE0, device->io);
+ inb (device->io + NE_R0_CNTR0); /* Clear the counter by reading */
+
+ if (inb (device->io + NE_R0_CNTR0) != 0) /* Ooops ;) */
+ {
+ outb (chk, device->io);
+ outb (chk, device->io + NE_R0_CNTR0);
+ log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "Something, but not a NE2k card, found. Aborting");
+ return FALSE;
+ }
+
+ ne_reset_chip (device);
+
+ /* We don't ack _all_ interrupts in ne_reset_chip(),
+ so we do it here instead */
+ outb (0xff, device->io + NE_R0_ISR);
+
+
+ /* Init registers and shit */
+ for (i = 0;i < sizeof (ne_preinit_program)/sizeof (ne_program);i++)
+ {
+ outb (ne_preinit_program[i].value, device->io + ne_preinit_program[i].offset);
+ }
+
+ /* It's time to read the station address prom now */
+ for (i = 0, x = 0;i < 32;i += 2)
+ {
+ device->prom[i] = inb (device->io + NE_DATAPORT);
+ device->prom[i+1] = inb (device->io + NE_DATAPORT);
+ if (device->prom[i] != device->prom[i+1])
+ x = 1;
+ }
+
+ if (x) /* This isn't a 16 bit card */
+ {
+ log_print_formatted (&log_structure, LOG_URGENCY_EMERGENCY, "Haha! Your card isn't supported. Get a 16 bit card");
+ return FALSE;
+ }
+
+ for (i = 0;i < 16;i++) {
+ device->prom[i] = device->prom[i + i];
+ }
+
+ for (i = 0; i < 6; i++) {
+ device->ethernet_address[i] = device->prom[i];
+ }
+
+ log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, "MAC address is %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x"
+ " and signature [0x%x 0x%x]",
+ device->prom[0], device->prom[1], device->prom[2],
+ device->prom[3], device->prom[4], device->prom[5],
+ device->prom[14], device->prom[15]);
+
+ outb (0x49, device->io + NE_R0_DCR); /* Set the card in word-wide mode */
+
+ /* this code should probably wait here until the IRQ handler etc has
+ been setup... */
+
+ ne_init_chip (device, 0);
return TRUE;
}
@@ -835,7 +831,7 @@
while (TRUE)
{
mailbox_id_type reply_mailbox_id;
-
+
ipc_service_connection_wait (&ipc_structure);
reply_mailbox_id = ipc_structure.output_mailbox_id;
@@ -851,6 +847,7 @@
int main (void)
{
+ device_type *device;
bool found;
/* Set up our name. */
@@ -867,26 +864,31 @@
log_print_formatted (&log_structure, LOG_URGENCY_INFORMATIVE, "NE2000 server by noah williamsson");
- do
- {
- device_type *device;
+ memory_allocate ((void **) &device, sizeof (device_type));
+
+ // FIXME: Hardwired for now. These are the values that Bochs use
+ // by default, that's why I'm choosing them.
+ device->io = 0x300;
+ device->irq = 3;
- memory_allocate ((void **) &device, sizeof (device_type));
- found = ne2000_probe (device);
-
- if (!found)
+ device->num_dropped = 0;
+ device->num_interrupts = 0;
+
+ found = ne2000_probe (device);
+
+ if (!found)
+ {
+ log_print_formatted(&log_structure, LOG_URGENCY_INFORMATIVE, "!found");
+ memory_deallocate ((void **) &device);
+ }
+ else
+ {
+ if (system_thread_create () == SYSTEM_RETURN_THREAD_NEW)
{
- memory_deallocate ((void **) &device);
+ handle_device (device);
+ return 0;
}
- else
- {
- if (system_thread_create () == SYSTEM_RETURN_THREAD_NEW)
- {
- handle_device (device);
- return 0;
- }
- }
- } while (found);
+ }
system_call_process_parent_unblock ();
@@ -994,11 +996,6 @@
switch (message[0])
{
- case NE_START_CARD:
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "Starting card->. (pid %ld wants this..)", from);
- ne_init_chip (&card, 1);
- break;
-
case NE_STOP_CARD:
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "Stopping card->. (pid %ld wants this..)", from);
ne_init_chip (&card, 0);
Modified: trunk/chaos-old/servers/network/ne2000/ne2000.h
===================================================================
--- trunk/chaos-old/servers/network/ne2000/ne2000.h 2007-03-12 20:30:09 UTC (rev 1227)
+++ trunk/chaos-old/servers/network/ne2000/ne2000.h 2007-03-13 23:03:05 UTC (rev 1228)
@@ -95,7 +95,7 @@
u16 check;
u32 saddr;
u32 daddr;
-};
+} __attribute__ ((packed));
struct tcphdr {
@@ -115,7 +115,7 @@
u16 window;
u16 check;
u16 urg_ptr;
-};
+} __attribute__ ((packed));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <per...@us...> - 2007-03-14 21:14:26
|
Revision: 1229
http://chaos.svn.sourceforge.net/chaos/?rev=1229&view=rev
Author: perlundberg
Date: 2007-03-14 14:14:20 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Transmitting now ALMOST works as well. ;) The ARP reply from ipv4 comes through almost properly to my Linux box, but with the remark 'oui Unknown'. I have no clue what that means but probably, something with the packet is not 100% correct. It seems bigger in my tcpdump than what it should be. Also, the ne2000 server stops working whenever the first packet has been sent, so obviously, I seem to be doing something wrong. :-)
Modified Paths:
--------------
trunk/chaos-old/servers/network/ne2000/autochaos.rules
trunk/chaos-old/servers/network/ne2000/config.h
trunk/chaos-old/servers/network/ne2000/configure
trunk/chaos-old/servers/network/ne2000/ne2000.c
trunk/chaos-old/servers/network/ne2000/ne2000.h
Modified: trunk/chaos-old/servers/network/ne2000/autochaos.rules
===================================================================
--- trunk/chaos-old/servers/network/ne2000/autochaos.rules 2007-03-13 23:03:05 UTC (rev 1228)
+++ trunk/chaos-old/servers/network/ne2000/autochaos.rules 2007-03-14 21:14:20 UTC (rev 1229)
@@ -10,6 +10,7 @@
<library type="depend">system</library>
<library type="depend">memory</library>
<library type="depend">ipv4</library>
+ <library type="depend">time</library>
<makefile>makefile</makefile>
<source>ne2000.c</source>
</package>
Modified: trunk/chaos-old/servers/network/ne2000/config.h
===================================================================
--- trunk/chaos-old/servers/network/ne2000/config.h 2007-03-13 23:03:05 UTC (rev 1228)
+++ trunk/chaos-old/servers/network/ne2000/config.h 2007-03-14 21:14:20 UTC (rev 1229)
@@ -13,5 +13,6 @@
#include <system/system.h>
#include <memory/memory.h>
#include <ipv4/ipv4.h>
+#include <time/time.h>
#endif /* !__CONFIG_H__ */
Modified: trunk/chaos-old/servers/network/ne2000/configure
===================================================================
--- trunk/chaos-old/servers/network/ne2000/configure 2007-03-13 23:03:05 UTC (rev 1228)
+++ trunk/chaos-old/servers/network/ne2000/configure 2007-03-14 21:14:20 UTC (rev 1229)
@@ -169,7 +169,21 @@
exit 1;
}
+print ("Checking for time library... ");
+if (-f "$chaos_root/data/programming/libraries/static/library_time.a")
+{
+ print ("found.\n");
+ push (@libraries, "time");
+}
+else
+{
+ print ("not found.\n");
+ print ("\nError: time is a required library. Please check your configuration.\n\n");
+ exit 1;
+}
+
+
my $all_arguments = "";
foreach my $argument (@ARGV)
{
Modified: trunk/chaos-old/servers/network/ne2000/ne2000.c
===================================================================
--- trunk/chaos-old/servers/network/ne2000/ne2000.c 2007-03-13 23:03:05 UTC (rev 1228)
+++ trunk/chaos-old/servers/network/ne2000/ne2000.c 2007-03-14 21:14:20 UTC (rev 1229)
@@ -40,7 +40,7 @@
void ne_init_chip(device_type *, u8);
void ne_int_handler(device_type *);
void ne_recv(device_type *);
-void ne_xmit(device_type *);
+bool ne2000_start_transmit (void *data, u32 length, device_type *device);
void ne_download_buf(device_type *, u16, u8 *, u16);
void ne_handle_overflow(device_type *);
u16 hex2dec(u8 *);
@@ -191,7 +191,7 @@
#endif
}
- if (sreg & (BIT_ISR_RX+BIT_ISR_RX_ERR))
+ if (sreg & (BIT_ISR_RX + BIT_ISR_RX_ERR))
{
if (debug >= 2)
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Packet received");
@@ -241,45 +241,51 @@
outb (NE_NODMA + NE_PAGE0 + NE_START, card->io);
}
- if (num_handled == MAX_INT_WORK)
- if (debug >= 1)
+ if (num_handled == MAX_INT_WORK) {
+ if (debug >= 1) {
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- ** -- Max interrupt work done!!");
+ }
+ }
card->status &= ~NIC_INT;
- if (debug >= 2)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** ISR:%2.2x ISM:%2.2x device_type status:%.2x (Leaving interrupt handler)", inb(card->io+NE_R0_ISR),
- inb (card->io+NE_R0_IMR), card->status);
+ if (debug >= 2) {
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** ISR:%2.2x ISM:%2.2x device_type status:%.2x (Leaving interrupt handler)", inb(card->io + NE_R0_ISR),
+ inb (card->io + NE_R0_IMR), card->status);
+ }
}
void ne_recv (device_type *card)
{
/* xxx - moved data_buffer to global .. */
- u8 *data = ((u8 *) data_buffer) + ((u8) 8);
- u8 rx_packets = 0;
- u8 rx_page;
- u8 frame, next_frame, pkt_status;
- u16 current_offset, pkt_len;
- struct ne_pkt_hdr pkt_hdr;
+ u8 *data = ((u8 *) data_buffer) + ((u8) 8);
+ u8 rx_packets = 0;
+ u8 rx_page;
+ u8 frame, next_frame, pkt_status;
+ u16 current_offset, pkt_len;
+ struct ne_pkt_hdr pkt_hdr;
+ int n;
frame = 0;
current_offset = 0;
for (rx_packets = 0;rx_packets < 10;rx_packets++)
{
/* Switch to page 1 */
- outb (NE_NODMA+NE_PAGE1, card->io);
+ outb (NE_NODMA + NE_PAGE1, card->io);
/* Get the packet ptr from current page */
- rx_page = inb (card->io+NE_PG_CURRENT);
+ rx_page = inb (card->io + NE_PG_CURRENT);
/* Switch back to page 0 */
- outb (NE_NODMA+NE_PAGE0, card->io);
+ outb (NE_NODMA + NE_PAGE0, card->io);
- frame = inb (card->io+NE_BOUNDARY) + 1;
+ frame = inb (card->io + NE_BOUNDARY) + 1;
if (frame >= NE_PG_STOP)
{
- if (debug >= 2)
+ if (debug >= 2) {
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "-- hmm? weirdo. fixing frame: %x => %x", frame, NE_PG_RX_START);
+ }
+
frame = NE_PG_RX_START;
}
@@ -373,73 +379,33 @@
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** Download done!");
- { /* XXX - This code doesn't belong here, heh. */
- struct ethhdr *e;
- struct iphdr *i;
- struct tcphdr *t;
- u8 *p = data;
- u8 n;
-
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** proto is [%.4x] ==> %s", PROTO,
- PROTO == 0x800? "IP/ETH":
- PROTO == 0x806? "ARP/ETH": "unknown");
-
- e = (struct ethhdr *) p;
- p += sizeof(struct ethhdr);
- i = (struct iphdr *) p;
- p += sizeof(struct iphdr);
- t = (struct tcphdr *) p;
-
- if (host_to_network_u16 (e->h_proto) == 0x800)
+ /* Check if this packet should be delivered somewhere. */
+
+ for (n = 0; n < card->number_of_targets; n++)
+ {
+ if (card->target[n].protocol_type ==
+ ((ipv4_ethernet_header_type *) data)->protocol_type)
{
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
- "** IP: ver:0x%x prot:0x%x len:0x%x",
- i->version, i->protocol,
- host_to_network_u16(i->tot_len)-sizeof(struct ethhdr)-sizeof(struct iphdr));
- p = (u8 *)&i->saddr;
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
- "++ %s/IP Packet received [%u.%u.%u.%u ==> %u.%u.%u.%u]",
- i->protocol == 0x11? "UDP": i->protocol == 0x6? "TCP":
- i->protocol == 0x1? "ICMP": "Unknown",
- p[0], p[1], p[2], p[3],
- p[4], p[5], p[6], p[7]);
-
- if (i->protocol == 0x1)
+ message_parameter_type message_parameter;
+
+ message_parameter.protocol = IPC_PROTOCOL_ETHERNET;
+ message_parameter.message_class = IPC_ETHERNET_PACKET_RECEIVED;
+ message_parameter.length = pkt_len + 8; /* probably 8 bytes of header. */
+ message_parameter.block = FALSE;
+ message_parameter.data = data;
+
+ if (debug >= 1)
{
- p += sizeof (ipv4_ethernet_header_type);
- log_print_formatted(&log_structure, LOG_URGENCY_DEBUG, "ICMP type is [%.2x : %.2x]", p[0], p[1]);
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
+ "Sending to mailbox ID %u",
+ card->target[n].mailbox_id);
}
-
+
+ system_call_mailbox_send (card->target[n].mailbox_id,
+ &message_parameter);
+ break;
}
-
- /* Check if this packet should be delivered somewhere. */
-
- for (n = 0; n < card->number_of_targets; n++)
- {
- if (card->target[n].protocol_type ==
- ((ipv4_ethernet_header_type *) data)->protocol_type)
- {
- message_parameter_type message_parameter;
-
- message_parameter.protocol = IPC_PROTOCOL_ETHERNET;
- message_parameter.message_class = IPC_ETHERNET_PACKET_RECEIVED;
- message_parameter.length = pkt_len + 8; /* probably 8 bytes of header. */
- message_parameter.block = FALSE;
- message_parameter.data = data;
-
- if (debug >= 1)
- {
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG,
- "Sending to mailbox ID %u",
- card->target[n].mailbox_id);
- }
-
- system_call_mailbox_send (card->target[n].mailbox_id,
- &message_parameter);
- break;
- }
- }
- } /* End of IP code */
+ }
} /* End of RX ok code */
else
{
@@ -447,11 +413,13 @@
card->num_dropped++;
}
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x => %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x]",
- data[6], data[7], data[8],
- data[9], data[10], data[11],
- data[0], data[1], data[2],
- data[3], data[4], data[5]);
+ if (debug >= 2) {
+ log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x => %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x]",
+ data[6], data[7], data[8],
+ data[9], data[10], data[11],
+ data[0], data[1], data[2],
+ data[3], data[4], data[5]);
+ }
next_frame = pkt_hdr.next;
outb (next_frame-1, card->io+NE_BOUNDARY);
@@ -460,32 +428,136 @@
outb (BIT_ISR_RX + BIT_ISR_RX_ERR, card->io + NE_R0_ISR);
}
-void ne_xmit (device_type *card)
+#define NE_SANITY_CHECK
+bool ne2000_start_transmit (void *data, u32 length, device_type *device)
{
- u8 status;
+ int nic_base = device->io;
+ time_type dma_start;
- status = inb (card->io + NE_R0_TSR);
- if (debug >= 1)
- log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** TSR status is 0x%x", status);
+ int destination = 64 << 8;
+#ifdef NE_SANITY_CHECK
+ int retries = 0;
+#endif
- /* Acknowledge interrupt */
- outb (BIT_ISR_TX, card->io+NE_R0_ISR);
+ log_print(&log_structure, LOG_URGENCY_DEBUG, "in ne2000_start_transmit");
+
+ /* Round the count up for word writes. Do we need to do this?
+ What effect will an odd byte count have on the 8390?
+ I should check someday. */
+
+ if (length & 0x01) {
+ length++;
+ }
+
+ /* This *shouldn't* happen. If it does, it's the last thing you'll see */
+ if ((device->status & NIC_DMA) == NIC_DMA)
+ {
+ log_print_formatted(&log_structure, LOG_URGENCY_EMERGENCY,
+ "DMAing conflict in ne_block_output."
+ "[DMAstat:%d][irqlock:%d]\n",
+ device->status & NIC_DMA, device->status & NIC_INT);
+ return FALSE;
+ }
+ device->status |= NIC_DMA;
+ /* We should already be in page 0, but to be safe... */
+ outb_p(NE_PAGE0 + NE_START + NE_NODMA, nic_base + NE_R0_CMD);
+
+#ifdef NE_SANITY_CHECK
+retry:
+#endif
+
+#ifdef NE8390_RW_BUGFIX
+ /* Handle the read-before-write bug the same way as the
+ Crynwr packet driver -- the NatSemi method doesn't work.
+ Actually this doesn't always work either, but if you have
+ problems with your NEx000 this is better than nothing! */
+
+ outb_p(0x42, nic_base + NE_R0_RCNT0);
+ outb_p(0x00, nic_base + NE_R0_RCNT1);
+ outb_p(0x42, nic_base + NE_R0_RSAR0);
+ outb_p(0x00, nic_base + NE_R0_RSAR1);
+ outb_p(E8390_RREAD + E8390_START, nic_base + NE_R0_CMD);
+ /* Make certain that the dummy read has occurred. */
+ system_sleep(1);
+#endif
+
+ outb_p(BIT_ISR_RDC, nic_base + NE_R0_ISR);
+
+ /* Now the normal output. */
+ outb_p(length & 0xFF, nic_base + NE_R0_RBCR0);
+ outb_p(length >> 8, nic_base + NE_R0_RBCR1);
+
+ outb_p(destination & 0xFF, nic_base + NE_R0_RSAR0);
+ outb_p(destination >> 8, nic_base + NE_R0_RSAR1);
+
+ outb_p(NE_RWRITE + NE_START, nic_base + NE_R0_CMD);
+ log_print_formatted(&log_structure, LOG_URGENCY_INFORMATIVE,
+ "Sending %ld bytes...", length);
+ outsw(nic_base + NE_DATAPORT, data, length >> 1);
+
+ dma_start = time_get ();
+
+#ifdef NE_SANITY_CHECK
+ /* This was for the ALPHA version only, but enough people have
+ been encountering problems so it is still here. */
+
+ if (debug > 1)
+ {
+ /* DMA termination address check... */
+ unsigned int addr, tries = 20;
+ do {
+ int high = inb_p(nic_base + NE_R0_RSAR1);
+ int low = inb_p(nic_base + NE_R0_RSAR0);
+ addr = (high << 8) + low;
+ if (destination + length == addr) {
+ break;
+ }
+ } while (--tries > 0);
+
+ if (tries <= 0)
+ {
+ log_print_formatted(&log_structure, LOG_URGENCY_WARNING, "Tx packet transfer address mismatch,"
+ "%#4.4lx (expected) vs. %#4.4x (actual).\n",
+ destination + length, addr);
+ if (retries++ == 0)
+ goto retry;
+ }
+ }
+#endif
+
+ while ((inb_p(nic_base + NE_R0_ISR) & BIT_ISR_RDC) == 0)
+ /* Wait for up to 1 second. This is obviously far too long, the
+ Linux code uses 20ms but this is much easier to
+ implement. :-) */
+ if (time_get () - dma_start > 0) {
+ log_print(&log_structure, LOG_URGENCY_WARNING, "timeout waiting for Tx RDC.");
+ ne_reset_chip(device);
+ ne_init_chip(device, 1);
+ return FALSE;
+ }
+
+ outb_p(BIT_ISR_RDC, nic_base + NE_R0_ISR); /* Ack intr. */
+ device->status &= ~NIC_DMA;
+ /* Okay, let's send this frame. */
+ outb_p(NE_NODMA + NE_PAGE0, nic_base + NE_R0_CMD);
- /* XXX - hehe... */
+ if (inb_p(nic_base) & NE_TRANS)
+ {
+ log_print(&log_structure, LOG_URGENCY_WARNING, "ne2000_start_transmit() called with the transmitter busy");
+ return FALSE;
+ }
+ outb_p(length & 0xFF, nic_base + NE_R0_TBCR0);
+ outb_p(length >> 8, nic_base + NE_R0_TBCR1);
+ outb_p(destination >> 8, nic_base + NE_R0_TPSR);
+ outb_p(NE_NODMA + NE_TRANS + NE_START, nic_base + NE_R0_CMD);
-
-
+ return TRUE;
}
-
-
-
-
-
void ne_download_buf (device_type *n, u16 len, u8 *data, u16 offset)
{
if (debug >= 2)
@@ -497,7 +569,7 @@
outb (len >> 8, n->io + NE_R0_RBCR1);
outb (offset & 0xFF, n->io + NE_R0_RSAR0);
outb (offset >> 8, n->io + NE_R0_RSAR1);
- outb (NE_RREAD+NE_START, n->io);
+ outb (NE_RREAD + NE_START, n->io);
if (debug >= 2)
log_print_formatted (&log_structure, LOG_URGENCY_DEBUG, "** ne_download_buf(): now we're about to read..");
@@ -676,13 +748,13 @@
/* Init registers and shit */
- for (i = 0;i < sizeof (ne_preinit_program)/sizeof (ne_program);i++)
+ for (i = 0; i < sizeof (ne_preinit_program)/ sizeof (ne_program); i++)
{
outb (ne_preinit_program[i].value, device->io + ne_preinit_program[i].offset);
}
/* It's time to read the station address prom now */
- for (i = 0, x = 0;i < 32;i += 2)
+ for (i = 0, x = 0; i < 32; i += 2)
{
device->prom[i] = inb (device->io + NE_DATAPORT);
device->prom[i+1] = inb (device->io + NE_DATAPORT);
@@ -767,20 +839,20 @@
break;
}
-#if FALSE
case IPC_ETHERNET_PACKET_SEND:
{
- if (!etherlink3_start_transmit (data, message_parameter.length, device))
+ if (!ne2000_start_transmit (data, message_parameter.length, device))
{
log_print (&log_structure, LOG_URGENCY_ERROR,
"Failed to send an ethernet packet.");
- /* FIXME: Do something. */
+ /* FIXME: Do something useful. We should probably send an
+ IPC message back to the sender regardless, to notify that
+ the package was sent/not sent. */
}
break;
}
-#endif
case IPC_ETHERNET_ADDRESS_GET:
{
@@ -895,6 +967,7 @@
return 0;
}
+/* Can probably be removed soon... */
#if 0
int main(int argc, char *argv[])
{
Modified: trunk/chaos-old/servers/network/ne2000/ne2000.h
===================================================================
--- trunk/chaos-old/servers/network/ne2000/ne2000.h 2007-03-13 23:03:05 UTC (rev 1228)
+++ trunk/chaos-old/servers/network/ne2000/ne2000.h 2007-03-14 21:14:20 UTC (rev 1229)
@@ -19,7 +19,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA. */
-const int debug = 1;
+// FIXME: this should be a define, not a variable. That way we will
+// not even compile in debugging code if not debugging = greater
+// performance.
+const int debug = 0;
/* 0: no debug at all
1: normal debug
@@ -127,11 +130,19 @@
/* To avoid rewriting a lot of code... */
#define outb(a,b) system_port_out_u8 (b, a)
#define inb(a) system_port_in_u8 (a)
+#define outb_p(a,b) system_port_out_u8_pause (b,a)
+static inline u8 inb_p(u16 a) {
+ u8 value = system_port_in_u8 (a);
+ system_sleep (1);
+ return value;
+}
+
+#define outsw(a,b,c) system_port_out_u16_string(a,b,c)
+
/* FIXME: this should be placed in the ipv4 library or similar. */
#define host_to_network_u16(a) system_byte_swap_u16(a)
-
/* Message stuff */
#define NE_START_CARD 0x02
#define NE_STOP_CARD 0x04
@@ -186,9 +197,9 @@
#define NE_R0_TSR 0x04 /* Transmit status register [read] */
#define NE_R0_TPSR 0x04 /* Transmit page start address [write] */
#define NE_R0_NCR 0x05 /* Number of collision register [read] */
-#define NE_R0_TBCR0 0x06 /* Transmit byte count register 0 [write] */
-#define NE_R0_TBCR1 0x07 /* Transmit byte count register 1 [write] */
-#define NE_R0_FIFO 0x06 /* Fifo [read] */
+#define NE_R0_TBCR0 0x05 /* Transmit byte count register 0 [write] */
+#define NE_R0_FIFO 0x06 /* FIFO [read] */
+#define NE_R0_TBCR1 0x06 /* Transmit byte count register 1 [write] */
#define NE_R0_ISR 0x07 /* Interrupt status register [read/write] */
#define NE_R0_CRDA0 0x08 /* Current remote DMA address register 0 [read] */
#define NE_R0_RSAR0 0x08 /* Remote start address register 0 [write] */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|