blob: 4bca8a28546c2474e6300d041e117186175dc0ea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_SCATTERLIST_H
2#define _ASM_SCATTERLIST_H
3
Jean Delvarea9dfd282007-03-06 02:45:12 -08004#include <asm/types.h>
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*
Jens Axboed09d2762007-10-23 12:39:41 +02007 * Drivers must set either ->address or (preferred) page and ->offset
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * to indicate where data must be transferred to/from.
9 *
Jens Axboed09d2762007-10-23 12:39:41 +020010 * Using page is recommended since it handles highmem data as well as
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * low mem. ->address is restricted to data which has a virtual mapping, and
Jens Axboed09d2762007-10-23 12:39:41 +020012 * it will go away in the future. Updating to page can be automated very
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 * easily -- something like
14 *
15 * sg->address = some_ptr;
16 *
17 * can be rewritten as
18 *
Jens Axboe642f1492007-10-24 11:20:47 +020019 * sg_set_buf(sg, some_ptr, length);
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 *
21 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
22 */
23struct scatterlist {
Jens Axboed6ec0842007-10-22 20:01:06 +020024#ifdef CONFIG_DEBUG_SG
25 unsigned long sg_magic;
26#endif
Jens Axboe18dabf42007-10-22 19:57:20 +020027 unsigned long page_link;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 unsigned int offset; /* for highmem, page offset */
29
30 dma_addr_t dma_address;
31 unsigned int length;
32};
33
Robert P. J. Day82b12e22008-02-04 22:29:54 -080034/*
35 * These macros should be used after a pci_map_sg call has been done
36 * to get bus addresses of each of the SG entries and their lengths.
37 * You should only work with the number of sg entries pci_map_sg
38 * returns, or alternatively stop on the first sg_dma_len(sg) which
39 * is 0.
40 */
41#define sg_dma_address(sg) ((sg)->dma_address)
42#define sg_dma_len(sg) ((sg)->length)
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#define ISA_DMA_THRESHOLD (0xffffffffUL)
45
46#endif /* !_ASM_SCATTERLIST_H */