Page 1 of 1

receive config register of rtl8139 card is reseting to 0

Posted: Wed Oct 31, 2012 10:40 am
by rajnesh
I am writing a rtl8139 network driver.
However I am not able to receive packets. On debugging I found that the receive config register (0x44) is reseting its value to 0.

Code: Select all

outl((BaseAddress + 0x44), 0x000002FF);  // For receiving all type of packets.
 uint32 reg2 = inl(BaseAddress + 0x44);   // reading if changes get reflected
  reg2 is 0.   // no change.

I am testing it in qemu.

Code: Select all

#  qemu script to run kernel
brctl addbr br0
tunctl -t tap0 -u root2
brctl addif br0 eth0
brctl addif br0 tap0
ifconfig eth0 up
ifconfig tap0 up
ifconfig br0 10.0.2.21/24
ifconfig eth0 0.0.0.0 promisc
[b]qemu -m 1G -kernel kernel -net nic,macaddr=05:aa:10:60:21:01,model=rtl8139 -net tap,ifname=tap0,script=no[/b]
ifconfig br0 down
brctl delbr br0
--thanks

Re: receive config register of rtl8139 card is reseting to 0

Posted: Wed Oct 31, 2012 2:24 pm
by kosmisk
Hi, i dont see all of your code but,
have you reset the interrupts by writing 1 to the bits of offset 003Eh register?
have you set the CAPR read pointer which keeps the address of data that driver had read?
if not, i think you must.

Re: receive config register of rtl8139 card is reseting to 0

Posted: Wed Oct 31, 2012 11:32 pm
by rajnesh

Code: Select all

uint32 rtl8139_rx_buffer = imalloc(1000);
    //power on 
    outb( (uint16) (BaseAddress + 0x52), 0x00);
   //reset 
   outb( (uint16) (BaseAddress + RTL8139_COMMAND), 0x10);
    while ( (inb( (uint16) (BaseAddress + RTL8139_COMMAND)) & 0x10) != 0 ) {
      printf("In Reset\n");
    }
    // Setup receive buffer location
    outl( (uint16) (BaseAddress + 0x30), (uint32)rtl8139_rx_buffer );
    // IRQ
    outw( (uint16) (BaseAddress + 0x3c), 0xe1ff);    
    // Enable receive
    outb( (uint16) (BaseAddress + RTL8139_COMMAND), 0x0C );

   // revision id
   uint32 reg = inb(BaseAddress + 0x05E);
   printf("Reg is %x\n", reg);

   outw((BaseAddress + 0x03e), 0xe1ff);    // setting as what you said
   outw((BaseAddress + 0x0038), rtl8139_rx_buffer);

      outl((BaseAddress + 0x44), 0x2FF);
      uint32 reg2 = inl(BaseAddress + 0x44);

   printf("Reg2r  is %x\n", reg2);  //this is still coming 0

Re: receive config register of rtl8139 card is reseting to 0

Posted: Sat Dec 29, 2012 6:10 pm
by jammmie999
Hey, I've got a similar problem, did you ever come up with a solution?

Thanks