dma.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <linux/types.h>
  2. #include <linux/kernel.h>
  3. #include <linux/mm.h>
  4. #include <linux/kd.h>
  5. #include <linux/tty.h>
  6. #include <linux/console.h>
  7. #include <asm/setup.h>
  8. #include <asm/bootinfo.h>
  9. #include <asm/system.h>
  10. #include <asm/pgtable.h>
  11. #include <asm/apollodma.h>
  12. #include <asm/io.h>
  13. /* note only works for 16 Bit 1 page DMA's */
  14. static unsigned short next_free_xlat_entry=0;
  15. unsigned short dma_map_page(unsigned long phys_addr,int count,int type) {
  16. unsigned long page_aligned_addr=phys_addr & (~((1<<12)-1));
  17. unsigned short start_map_addr=page_aligned_addr >> 10;
  18. unsigned short free_xlat_entry, *xlat_map_entry;
  19. int i;
  20. free_xlat_entry=next_free_xlat_entry;
  21. for(i=0,xlat_map_entry=addr_xlat_map+(free_xlat_entry<<2);i<8;i++,xlat_map_entry++) {
  22. #if 0
  23. printk("phys_addr: %x, page_aligned_addr: %x, start_map_addr: %x\n",phys_addr,page_aligned_addr,start_map_addr+i);
  24. #endif
  25. out_be16(xlat_map_entry, start_map_addr+i);
  26. }
  27. next_free_xlat_entry+=2;
  28. if(next_free_xlat_entry>125)
  29. next_free_xlat_entry=0;
  30. #if 0
  31. printk("next_free_xlat_entry: %d\n",next_free_xlat_entry);
  32. #endif
  33. return free_xlat_entry<<10;
  34. }
  35. void dma_unmap_page(unsigned short dma_addr) {
  36. return ;
  37. }