28 lines
695 B
C
28 lines
695 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef _SG_H_
|
|
#define _SG_H_
|
|
|
|
#include <kernel/types.h>
|
|
|
|
struct sg_entry {
|
|
paddr_t paddr;
|
|
size_t len;
|
|
};
|
|
|
|
struct sg_list {
|
|
struct sg_entry *entries;
|
|
size_t count;
|
|
size_t max_count;
|
|
};
|
|
|
|
#define SG_STATIC(name, n) \
|
|
struct sg_entry name##_buf[n]; \
|
|
struct sg_list name = {.entries = name##_buf, .count = 0, .max_count = (n)}
|
|
|
|
#define sg_for_each(entry, sg) for (struct sg_entry *entry = (sg)->entries; entry < (sg)->entries + (sg)->count; entry++)
|
|
|
|
void sg_init(struct sg_list *sg, struct sg_entry *buf, size_t n);
|
|
int sg_append(struct sg_list *sg, paddr_t paddr, size_t len);
|
|
void sg_reset(struct sg_list *sg);
|
|
|
|
#endif /* _SG_H_ */
|