/*===========================================================================* * sef_cb_init_fresh * *===========================================================================*/ PRIVATE int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) { /* Initialize the rtl8169 driver. */ unsigned left; /* Select a buffer that can safely be used for dma transfers. * Its absolute address is 'DmaPhys', the normal address is 'DmaPtr'. */ #if (CHIP == INTEL) DmaPtr = DmaBuffer; sys_umap(SELF, D, (vir_bytes)DmaBuffer, sizeof(DmaBuffer), &DmaPhys); if((left = dma_bytes_left(DmaPhys)) < DMA_SIZE) { /* First half of buffer crosses a 64K boundary, can't DMA into that */ DmaPtr += left; DmaPhys += left; } #else /* CHIP != INTEL */ panic("initialization failed: CHIP != INTEL: %d", 0); #endif /* CHIP == INTEL */ /* Announce we are up! */ driver_announce(); return(OK); }
PRIVATE int init_buffers(sub_dev_t *sub_dev_ptr) { #if (CHIP == INTEL) char *base; size_t size, off; unsigned left; u32_t i; phys_bytes ph; /* allocate dma buffer space */ size= sub_dev_ptr->DmaSize + 64 * 1024; off = base= alloc_contig(size, AC_ALIGN4K, &ph); if (!base) { error("%s: failed to allocate dma buffer for channel %d\n", drv.DriverName,i); return EIO; } sub_dev_ptr->DmaBuf= base; tell_dev((vir_bytes)base, size, 0, 0, 0); /* allocate extra buffer space */ if (!(sub_dev_ptr->ExtraBuf = malloc(sub_dev_ptr->NrOfExtraBuffers * sub_dev_ptr->DmaSize / sub_dev_ptr->NrOfDmaFragments))) { error("%s failed to allocate extra buffer for channel %d\n", drv.DriverName,i); return EIO; } sub_dev_ptr->DmaPtr = sub_dev_ptr->DmaBuf; i = sys_umap(SELF, D, (vir_bytes) sub_dev_ptr->DmaBuf, (phys_bytes) sizeof(sub_dev_ptr->DmaBuf), &(sub_dev_ptr->DmaPhys)); if (i != OK) { return EIO; } if ((left = dma_bytes_left(sub_dev_ptr->DmaPhys)) < sub_dev_ptr->DmaSize) { /* First half of buffer crosses a 64K boundary, * can't DMA into that */ sub_dev_ptr->DmaPtr += left; sub_dev_ptr->DmaPhys += left; } /* write the physical dma address and size to the device */ drv_set_dma(sub_dev_ptr->DmaPhys, sub_dev_ptr->DmaSize, sub_dev_ptr->Nr); return OK; #else /* CHIP != INTEL */ error("%s: init_buffer() failed, CHIP != INTEL", drv.DriverName); return EIO; #endif /* CHIP == INTEL */ }