Exemplo n.º 1
0
/*
**  Name:	void dp_pio16_user2nic(dpeth_t *dep, int pageno, int pktsize)
**  Function:	Copies a packet from user area to board (Prog. I/O, 16bits).
*/
static void dp_pio16_user2nic(dpeth_t *dep, int pageno, int pktsize)
{
  u8_t two_bytes[2];
  phys_bytes phys_user, phys_2bytes = vir2phys(two_bytes);
  vir_bytes ecount = (pktsize + 1) & NOT(0x0001);
  int bytes, ix = 0, odd_byte = 0;
  iovec_dat_t *iovp = &dep->de_write_iovec;

  outb_reg0(dep, DP_ISR, ISR_RDC);
  dp_read_setup(dep, ecount, pageno * DP_PAGESIZE);

  do {
	bytes = iovp->iod_iovec[ix].iov_size;
	if (bytes > pktsize) bytes = pktsize;

	phys_user = numap(iovp->iod_proc_nr, iovp->iod_iovec[ix].iov_addr, bytes);
	if (!phys_user) panic(UmapErrMsg);

	if (odd_byte) {
		phys_copy(phys_user, phys_2bytes + 1, (phys_bytes) 1);
		out_word(dep->de_data_port, *(u16_t *)two_bytes);
		pktsize--;
		bytes--;
		phys_user++;
		odd_byte = 0;
		if (!bytes) continue;
	}
	ecount = bytes & NOT(0x0001);
	if (ecount != 0) {
		phys_outsw(dep->de_data_port, phys_user, ecount);
		pktsize -= ecount;
		bytes -= ecount;
		phys_user += ecount;
	}
	if (bytes) {
		phys_copy(phys_user, phys_2bytes, (phys_bytes) 1);
		pktsize--;
		bytes--;
		phys_user++;
		odd_byte = 1;
	}
	if (++ix >= IOVEC_NR) {	/* Next buffer of I/O vector */
		dp_next_iovec(iovp);
		ix = 0;
	}

  }  while (bytes > 0);

  if (odd_byte) out_word(dep->de_data_port, *(u16_t *) two_bytes);
  for (ix = 0; ix < 100; ix++) {
	if (inb_reg0(dep, DP_ISR) & ISR_RDC) break;
  }
  if (ix == 100) {
	panic(RdmaErrMsg);
  }
  return;
}
Exemplo n.º 2
0
/*
 * Stop ethernet board
 */
void
eth_stop()
{
    register long l;

    /* stop chip and disable DMA access */
    out_word(LA_RAP, RDP_CSR0);
    out_word(LA_CSR, CSR_STOP);
    for (l = 0; (in_word(LA_CSR) & CSR_STOP) == 0; l++) {
	if (l >= MAXLOOP) {
	    printf("Lance failed to stop\n");
	    break;
	}
    }
    dma_done(NE_DMACHANNEL);
}
Exemplo n.º 3
0
void pci_write_config_reg16(bdf_addr_t address,
                            unsigned offset,
                            const uint16_t value)
{
    pci_config_space_set_addr(address, offset);

    out_word(PCI_CONFIG_DATA +(offset & 2), value);
}
Exemplo n.º 4
0
void
ega_hwterm(void)
{
  setmode(MODE_SET);

  /* Copy character table from ROM back into bit plane 2 before turning
   * off graphics.
   */
  out_word(SEQREG, 0x0100);	/* syn reset */
  out_word(SEQREG, 0x0402);	/* cpu writes only to map 2 */
  out_word(SEQREG, 0x0704);	/* sequential addressing */
  out_word(SEQREG, 0x0300);	/* clear synchronous reset */

  out_word(GRREG, 0x0204);	/* select map 2 for CPU reads */
  out_word(GRREG, 0x0005);	/* disable odd-even addressing */

#if ROMFONT
  {
	  FARADDR	srcoffset;
	  FARADDR	destoffset;
	  int 		data;
	  int 		ch;
	  int 		row;

	  srcoffset = rom_char_addr;
	  destoffset = EGA_BASE;
	  for (ch = 0; ch < FONT_CHARS; ch++) {
		for(row = 0; row < ROM_CHAR_HEIGHT; row++) {
			data = GETBYTE_FP(srcoffset++);
			PUTBYTE_FP(destoffset++, data);
		}
		destoffset += (RAM_SCAN_LINES - ROM_CHAR_HEIGHT);
	  }
  }
#endif

  /* Finally set the registers back for text mode. */
  writeregs(graph_off);
}
Exemplo n.º 5
0
/*
 * Reset ethernet board (i.e. after a timeout)
 */
void
eth_reset()
{
    register long l;
    uint32 addr;
    int i;

    /* program DMA chip */
    dma_cascade(NE_DMACHANNEL);

    /* stop the chip, and make sure it did */
    out_word(LA_RAP, RDP_CSR0);
    out_word(LA_CSR, CSR_STOP);
    for (l = 0; (in_word(LA_CSR) & CSR_STOP) == 0; l++) {
	if (l >= MAXLOOP) {
	    printf("Lance failed to stop\n");
	    return;
	}
    }

    /* fill lance initialization block */
    bzero(initblock, sizeof(initblock_t));

    /* set my ethernet address */
    initblock->ib_padr[0] = eth_myaddr[0];
    initblock->ib_padr[1] = eth_myaddr[1];
    initblock->ib_padr[2] = eth_myaddr[2];
    initblock->ib_padr[3] = eth_myaddr[3];
    initblock->ib_padr[4] = eth_myaddr[4];
    initblock->ib_padr[5] = eth_myaddr[5];

    /* receive ring pointer */
    addr = (dsseg() << 4) + (uint32)rmd;
    initblock->ib_rdralow = (uint16)addr;
    initblock->ib_rdrahigh = (uint8)(addr >> 16);
    initblock->ib_rlen = LOG2NRCVRING << 5;

    /* transmit ring with one element */
    addr = (dsseg() << 4) + (uint32)tmd;
    initblock->ib_tdralow = (uint16)addr;
    initblock->ib_tdrahigh = (uint8)(addr >> 16);
    initblock->ib_tlen = 0 << 5;

    /* setup the receive ring entries */
    for (next_rmd = 0, i = 0; i < NRCVRING; i++) {
	addr = (dsseg() << 4) + (uint32)&rbuffer[i];
	rmd[i].rmd_ladr = (uint16)addr;
	rmd[i].rmd_hadr = (uint8)(addr >> 16);
	rmd[i].rmd_mcnt = 0;
	rmd[i].rmd_bcnt = -LANCEBUFSIZE;
	rmd[i].rmd_flags = RMD_OWN;
    }

    /* zero transmit ring */
    bzero(tmd, sizeof(tmde_t));

    /* give lance the init block */
    addr = (dsseg() << 4) + (uint32)initblock;
    out_word(LA_RAP, RDP_CSR1);
    out_word(LA_CSR1, (uint16)addr);
    out_word(LA_RAP, RDP_CSR2);
    out_word(LA_CSR2, (int8)(addr >> 16));
    out_word(LA_RAP, RDP_CSR3);
    out_word(LA_CSR3, 0);

    /* and initialize it */
    out_word(LA_RAP, RDP_CSR0);
    out_word(LA_CSR, CSR_INIT|CSR_STRT);

    /* wait for the lance to complete initialization and fire it up */
    for (l = 0; (in_word(LA_CSR) & CSR_IDON) == 0; l++) {
	if (l >= MAXLOOP) {
	    printf("Lance failed to initialize\n");
	    break;
	}
    }
    for (l=0; (in_word(LA_CSR)&(CSR_TXON|CSR_RXON))!=(CSR_TXON|CSR_RXON); l++) {
	if (l >= MAXLOOP) {
	    printf("Lance not started\n");
	    break;
	}
    }
}