Page 1 of 1

ne2000 send packet problem

Posted: Mon Oct 10, 2016 5:54 pm
by Raymond
I used the code on osdev.org for ne2000 which can send the packets,i run it on bochs,i get the mac address.
ioaddr---0xC040
irq---11
These are logs of bochs,i think they are right.Because i used '0xC040' ioaddr to get the mac addr successfully.
But when i send the data to the remote dma,it should have an interrupt after sending all the data,but my code
do not show the irq flag
code below:

Code: Select all

void init_net(struct BOOTINFO *binfo){
	sprintf(ns,"init net");
	putfonts8_asc(binfo->vram, binfo->scrnx, 0, 32, COL8_FFFFFF, ns);
	int addr,data;
	reg = 0x10;
	int i;
	short count = 42;
	
	ioaddr = 0xc040;
	addr = PCI_BUS_CONFIG(0,3,0,reg);
	io_out32(0xCF8,addr);
	io_out32(0xCFC,ioaddr);

	make_arp_pac();//here is make arp packet info
	io_out8(ioaddr+0x00,0x22);//COMMAND register set to "start" and "nodma"
	io_out8(ioaddr+0x0a,count&0xff);//low byte count
	io_out8(ioaddr+0x0b,(count>>8)&0xff);//high byte count
	io_out8(ioaddr+0x07,(1<<6));//Remote DMA complete?
	io_out8(ioaddr+0x08,0x00);//loaded with 0x00 (low)
	io_out8(ioaddr+0x09,0x40);//target page number (high)
	io_out8(ioaddr+0x0f,0x40);//IMR
	
	for(i=0;i<42;i++){
		io_out8(ioaddr+0x10,nic_data[i]);
	}
	
	sprintf(ns,"nic int %x",nic_flag);
	putfonts8_asc(binfo->vram, binfo->scrnx, 0, 48, COL8_FFFFFF, ns);
}
I finished all the function,i just need a help. :D
(There is a pic file to show the screen below. )

Re: ne2000 send packet problem

Posted: Mon Oct 10, 2016 9:11 pm
by Raymond
I know ne2000 sending maybe not need to fire on an interrup?Is this right?Or the irq 11 is wrong.

Re: ne2000 send packet problem

Posted: Tue Oct 11, 2016 2:28 am
by Raymond

Code: Select all

// keep s.remote_bytes from underflowing
    if (BX_NE2K_THIS s.remote_bytes > BX_NE2K_THIS s.DCR.wdsize)
      if (io_len == 4) {
        BX_NE2K_THIS s.remote_bytes -= io_len;
      } else {
        BX_NE2K_THIS s.remote_bytes -= (BX_NE2K_THIS s.DCR.wdsize + 1);
      }
    else
      BX_NE2K_THIS s.remote_bytes = 0;

    // If all bytes have been written, signal remote-DMA complete
    if (BX_NE2K_THIS s.remote_bytes == 0) {
      BX_NE2K_THIS s.ISR.rdma_done = 1;
      if (BX_NE2K_THIS s.IMR.rdma_inte) {
        set_irq_level(1);
      }
    }
The code above is from bochs 2.6.8 source code 'ne2k.cc' line 697.
'set_irq_level(1);' is firing on an interrupt ,i have set the rdma_inte of IMR and rdma_done bit is set
after delete the IMR,i just mean that my code must go to the code of interrupt ,but who can tell me what have happened? :?