Subversion Repositories Kolibri OS

Rev

Rev 3297 | Rev 4568 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3297 Rev 3747
Line 170... Line 170...
170
	sg->page_link |= 0x02;
170
	sg->page_link |= 0x02;
171
	sg->page_link &= ~0x01;
171
	sg->page_link &= ~0x01;
172
}
172
}
Line 173... Line 173...
173
 
173
 
-
 
174
/**
-
 
175
 * sg_unmark_end - Undo setting the end of the scatterlist
-
 
176
 * @sg:		 SG entryScatterlist
-
 
177
 *
-
 
178
 * Description:
-
 
179
 *   Removes the termination marker from the given entry of the scatterlist.
-
 
180
 *
-
 
181
 **/
-
 
182
static inline void sg_unmark_end(struct scatterlist *sg)
-
 
183
{
-
 
184
#ifdef CONFIG_DEBUG_SG
-
 
185
	BUG_ON(sg->sg_magic != SG_MAGIC);
-
 
186
#endif
-
 
187
	sg->page_link &= ~0x02;
-
 
188
}
-
 
189
 
174
/**
190
/**
175
 * sg_phys - Return physical address of an sg entry
191
 * sg_phys - Return physical address of an sg entry
176
 * @sg:	     SG entry
192
 * @sg:	     SG entry
177
 *
193
 *
178
 * Description:
194
 * Description:
Line 229... Line 245...
229
 * Maximum number of entries that will be allocated in one piece, if
245
 * Maximum number of entries that will be allocated in one piece, if
230
 * a list larger than this is required then chaining will be utilized.
246
 * a list larger than this is required then chaining will be utilized.
231
 */
247
 */
232
#define SG_MAX_SINGLE_ALLOC     (4*PAGE_SIZE / sizeof(struct scatterlist))
248
#define SG_MAX_SINGLE_ALLOC     (4*PAGE_SIZE / sizeof(struct scatterlist))
Line -... Line 249...
-
 
249
 
-
 
250
/*
-
 
251
 * sg page iterator
-
 
252
 *
-
 
253
 * Iterates over sg entries page-by-page.  On each successful iteration,
-
 
254
 * you can call sg_page_iter_page(@piter) and sg_page_iter_dma_address(@piter)
-
 
255
 * to get the current page and its dma address. @piter->sg will point to the
-
 
256
 * sg holding this page and @piter->sg_pgoffset to the page's page offset
-
 
257
 * within the sg. The iteration will stop either when a maximum number of sg
-
 
258
 * entries was reached or a terminating sg (sg_last(sg) == true) was reached.
-
 
259
 */
-
 
260
struct sg_page_iter {
-
 
261
	struct scatterlist	*sg;		/* sg holding the page */
-
 
262
	unsigned int		sg_pgoffset;	/* page offset within the sg */
-
 
263
 
-
 
264
	/* these are internal states, keep away */
-
 
265
	unsigned int		__nents;	/* remaining sg entries */
-
 
266
	int			__pg_advance;	/* nr pages to advance at the
-
 
267
						 * next step */
-
 
268
};
-
 
269
 
-
 
270
bool __sg_page_iter_next(struct sg_page_iter *piter);
-
 
271
void __sg_page_iter_start(struct sg_page_iter *piter,
-
 
272
			  struct scatterlist *sglist, unsigned int nents,
-
 
273
			  unsigned long pgoffset);
-
 
274
/**
-
 
275
 * sg_page_iter_page - get the current page held by the page iterator
-
 
276
 * @piter:	page iterator holding the page
-
 
277
 */
-
 
278
static inline struct page *sg_page_iter_page(struct sg_page_iter *piter)
-
 
279
{
-
 
280
	return nth_page(sg_page(piter->sg), piter->sg_pgoffset);
-
 
281
}
-
 
282
 
-
 
283
/**
-
 
284
 * sg_page_iter_dma_address - get the dma address of the current page held by
-
 
285
 * the page iterator.
-
 
286
 * @piter:	page iterator holding the page
-
 
287
 */
-
 
288
static inline dma_addr_t sg_page_iter_dma_address(struct sg_page_iter *piter)
-
 
289
{
-
 
290
	return sg_dma_address(piter->sg) + (piter->sg_pgoffset << PAGE_SHIFT);
-
 
291
}
-
 
292
 
-
 
293
/**
-
 
294
 * for_each_sg_page - iterate over the pages of the given sg list
-
 
295
 * @sglist:	sglist to iterate over
-
 
296
 * @piter:	page iterator to hold current page, sg, sg_pgoffset
-
 
297
 * @nents:	maximum number of sg entries to iterate over
-
 
298
 * @pgoffset:	starting page offset
-
 
299
 */
-
 
300
#define for_each_sg_page(sglist, piter, nents, pgoffset)		   \
-
 
301
	for (__sg_page_iter_start((piter), (sglist), (nents), (pgoffset)); \
Line 233... Line 302...
233
 
302
	     __sg_page_iter_next(piter);)
234
 
303
 
235
/*
304
/*
236
 * Mapping sg iterator
305
 * Mapping sg iterator
Line 256... Line 325...
256
	/* the following three fields can be accessed directly */
325
	/* the following three fields can be accessed directly */
257
	struct page		*page;		/* currently mapped page */
326
	struct page		*page;		/* currently mapped page */
258
	void			*addr;		/* pointer to the mapped area */
327
	void			*addr;		/* pointer to the mapped area */
259
	size_t			length;		/* length of the mapped area */
328
	size_t			length;		/* length of the mapped area */
260
	size_t			consumed;	/* number of consumed bytes */
329
	size_t			consumed;	/* number of consumed bytes */
-
 
330
	struct sg_page_iter	piter;		/* page iterator */
Line 261... Line 331...
261
 
331
 
262
	/* these are internal states, keep away */
-
 
263
	struct scatterlist	*__sg;		/* current entry */
332
	/* these are internal states, keep away */
264
	unsigned int		__nents;	/* nr of remaining entries */
333
	unsigned int		__offset;	/* offset within page */
265
	unsigned int		__offset;	/* offset within sg */
334
	unsigned int		__remaining;	/* remaining bytes on page */
266
	unsigned int		__flags;
335
	unsigned int		__flags;
Line 267... Line 336...
267
};
336
};
268
 
337