[SCSI] scsi-driver ultrastore replace Scsi_Cmnd with struct scsi_cmnd
[linux-2.6/verdex.git] / drivers / usb / mon / mon_dma.c
blobddcfc01e77a022918940d725986ff0061591f6cb
1 /*
2 * The USB Monitor, inspired by Dave Harding's USBMon.
4 * mon_dma.c: Library which snoops on DMA areas.
6 * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
7 */
8 #include <linux/kernel.h>
9 #include <linux/list.h>
10 #include <linux/highmem.h>
11 #include <asm/page.h>
13 #include <linux/usb.h> /* Only needed for declarations in usb_mon.h */
14 #include "usb_mon.h"
17 * PC-compatibles, are, fortunately, sufficiently cache-coherent for this.
19 #if defined(__i386__) || defined(__x86_64__) /* CONFIG_ARCH_I386 doesn't exit */
20 #define MON_HAS_UNMAP 1
22 #define phys_to_page(phys) pfn_to_page((phys) >> PAGE_SHIFT)
24 char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len)
26 struct page *pg;
27 unsigned long flags;
28 unsigned char *map;
29 unsigned char *ptr;
32 * On i386, a DMA handle is the "physical" address of a page.
33 * In other words, the bus address is equal to physical address.
34 * There is no IOMMU.
36 pg = phys_to_page(dma_addr);
39 * We are called from hardware IRQs in case of callbacks.
40 * But we can be called from softirq or process context in case
41 * of submissions. In such case, we need to protect KM_IRQ0.
43 local_irq_save(flags);
44 map = kmap_atomic(pg, KM_IRQ0);
45 ptr = map + (dma_addr & (PAGE_SIZE-1));
46 memcpy(dst, ptr, len);
47 kunmap_atomic(map, KM_IRQ0);
48 local_irq_restore(flags);
49 return 0;
51 #endif /* __i386__ */
53 #ifndef MON_HAS_UNMAP
54 char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len)
56 return 'D';
58 #endif