2002-07-09 16:24:59 +04:00
|
|
|
/*
|
|
|
|
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
|
|
|
** Distributed under the terms of the NewOS License.
|
|
|
|
*/
|
|
|
|
#ifndef _KERNEL_CBUF_H
|
|
|
|
#define _KERNEL_CBUF_H
|
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
|
2004-10-12 03:14:49 +04:00
|
|
|
#include <OS.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
typedef struct cbuf cbuf;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
status_t cbuf_init(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
cbuf *cbuf_get_chain(size_t len);
|
|
|
|
cbuf *cbuf_get_chain_noblock(size_t len);
|
|
|
|
void cbuf_free_chain_noblock(cbuf *buf);
|
|
|
|
void cbuf_free_chain(cbuf *buf);
|
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
size_t cbuf_get_length(cbuf *buf);
|
2002-07-09 16:24:59 +04:00
|
|
|
void *cbuf_get_ptr(cbuf *buf, size_t offset);
|
2003-06-27 20:40:53 +04:00
|
|
|
bool cbuf_is_contig_region(cbuf *buf, size_t start, size_t end);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
status_t cbuf_memcpy_to_chain(cbuf *chain, size_t offset, const void *_src, size_t len);
|
|
|
|
status_t cbuf_memcpy_from_chain(void *dest, cbuf *chain, size_t offset, size_t len);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
status_t cbuf_user_memcpy_to_chain(cbuf *chain, size_t offset, const void *_src, size_t len);
|
|
|
|
status_t cbuf_user_memcpy_from_chain(void *dest, cbuf *chain, size_t offset, size_t len);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
uint16 cbuf_ones_cksum16(cbuf *chain, size_t offset, size_t len);
|
|
|
|
|
|
|
|
cbuf *cbuf_merge_chains(cbuf *chain1, cbuf *chain2);
|
|
|
|
cbuf *cbuf_duplicate_chain(cbuf *chain, size_t offset, size_t len);
|
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
status_t cbuf_truncate_head(cbuf *chain, size_t trunc_bytes);
|
|
|
|
status_t cbuf_truncate_tail(cbuf *chain, size_t trunc_bytes);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
void cbuf_test(void);
|
2003-06-27 20:40:53 +04:00
|
|
|
// ToDo: to be removed...
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
|
2003-06-27 20:40:53 +04:00
|
|
|
#endif /* _KERNEL_CBUF_H */
|