Forum Discussion
Altera_Forum
Honored Contributor
15 years agoI've not run Linux nor used the ethernet on the fpga, but ....
The memory addresses give to the dma controller must be physical addresses, the linux virt_to_phys() function should give you this for memory malloced requesting 'DMA' (for other addresses it will return garbage!) To get a virtual address for the dma controller itself (and other io) the driver needs to call io_remap() with the physical address. On the ppc I was last writing linux drivers for, it was difficult to just allocate uncached memory (the calls wanted a dev_t which I didn't have). But the ring structures that describe the ethernet buffers (I think the altera MAC uses them - most do) will need to be in uncached memory (thinks - it might be worth using an M9K block that linux treats as io). You'll probably need to allocate the transmit and receive buffers themselves from cached memory (although using uncached might help you get started!). That will mean you need to force the cache writes before transmits and invalidates before processing receive buffer. There are probably standard Linux functions to do this - and the driver might be doing them already - but it might be quicker (and teh code will run faster) if you write nios specific functions. After all, you probably don't need the code to be that portable!