pcidma.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
  3. *
  4. * May be copied or modified under the terms of the GNU General Public
  5. * License. See linux/COPYING for more information.
  6. *
  7. * Dynamic DMA mapping support.
  8. *
  9. * On the overdrive, we can only DMA from memory behind the PCI bus!
  10. * this means that all DMA'able memory must come from there.
  11. * this restriction will not apply to later boards.
  12. */
  13. #include <linux/types.h>
  14. #include <linux/mm.h>
  15. #include <linux/string.h>
  16. #include <linux/pci.h>
  17. #include <asm/io.h>
  18. void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
  19. dma_addr_t * dma_handle)
  20. {
  21. void *ret;
  22. int gfp = GFP_ATOMIC;
  23. printk("BUG: pci_alloc_consistent() called - not yet supported\n");
  24. /* We ALWAYS need DMA memory on the overdrive hardware,
  25. * due to it's extreme weirdness
  26. * Need to flush the cache here as well, since the memory
  27. * can still be seen through the cache!
  28. */
  29. gfp |= GFP_DMA;
  30. ret = (void *) __get_free_pages(gfp, get_order(size));
  31. if (ret != NULL) {
  32. memset(ret, 0, size);
  33. *dma_handle = virt_to_bus(ret);
  34. }
  35. return ret;
  36. }
  37. void pci_free_consistent(struct pci_dev *hwdev, size_t size,
  38. void *vaddr, dma_addr_t dma_handle)
  39. {
  40. free_pages((unsigned long) vaddr, get_order(size));
  41. }