1 // SPDX-License-Identifier: GPL-2.0
2 #ifndef _MEDIA_FRAME_VECTOR_H
3 #define _MEDIA_FRAME_VECTOR_H
5 /* Container for pinned pfns / pages in frame_vector.c */
7 unsigned int nr_allocated; /* Number of frames we have space for */
8 unsigned int nr_frames; /* Number of frames stored in ptrs array */
9 bool got_ref; /* Did we pin pages by getting page ref? */
10 bool is_pfns; /* Does array contain pages or pfns? */
11 void *ptrs[]; /* Array of pinned pfns / pages. Use
12 * pfns_vector_pages() or pfns_vector_pfns()
16 struct frame_vector *frame_vector_create(unsigned int nr_frames);
17 void frame_vector_destroy(struct frame_vector *vec);
18 int get_vaddr_frames(unsigned long start, unsigned int nr_pfns,
19 bool write, struct frame_vector *vec);
20 void put_vaddr_frames(struct frame_vector *vec);
21 int frame_vector_to_pages(struct frame_vector *vec);
22 void frame_vector_to_pfns(struct frame_vector *vec);
24 static inline unsigned int frame_vector_count(struct frame_vector *vec)
26 return vec->nr_frames;
29 static inline struct page **frame_vector_pages(struct frame_vector *vec)
32 int err = frame_vector_to_pages(vec);
37 return (struct page **)(vec->ptrs);
40 static inline unsigned long *frame_vector_pfns(struct frame_vector *vec)
43 frame_vector_to_pfns(vec);
44 return (unsigned long *)(vec->ptrs);
47 #endif /* _MEDIA_FRAME_VECTOR_H */