2005-05-09 10:11:11 +00:00
|
|
|
#ifndef BUFFER_H
|
|
|
|
#define BUFFER_H
|
|
|
|
|
2005-05-09 13:24:01 +00:00
|
|
|
#include "stdint.h"
|
|
|
|
|
2005-05-19 11:54:41 +00:00
|
|
|
/* @file */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A buffer
|
|
|
|
*
|
|
|
|
* @c start and @c end denote the real boundaries of the buffer, and
|
|
|
|
* are physical addresses. @c fill denotes the offset to the first
|
|
|
|
* free block in the buffer. (If the buffer is full, @c fill will
|
|
|
|
* equal @c end-start.)
|
2005-05-09 14:26:10 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct buffer {
|
2005-05-19 11:54:41 +00:00
|
|
|
physaddr_t start; /**< Start of buffer in memory */
|
|
|
|
physaddr_t end; /**< End of buffer in memory */
|
|
|
|
off_t fill; /**< Offset to first gap in buffer */
|
2005-05-09 14:26:10 +00:00
|
|
|
};
|
|
|
|
|
2005-05-19 11:54:41 +00:00
|
|
|
/**
|
|
|
|
* A free block descriptor.
|
2005-05-09 13:24:01 +00:00
|
|
|
*
|
2005-05-19 11:54:41 +00:00
|
|
|
* See \ref buffer_int for a full description of the fields.
|
2005-05-09 13:24:01 +00:00
|
|
|
*
|
|
|
|
*/
|
2005-05-09 10:11:11 +00:00
|
|
|
struct buffer_free_block {
|
2005-05-19 11:54:41 +00:00
|
|
|
char tail; /**< Tail byte marker */
|
|
|
|
physaddr_t next_free; /**< Address of next free block */
|
|
|
|
physaddr_t end; /**< End of this block */
|
2005-05-09 13:24:01 +00:00
|
|
|
} __attribute__ (( packed ));
|
2005-05-09 10:11:11 +00:00
|
|
|
|
2005-05-09 13:24:01 +00:00
|
|
|
/* Functions in buffer.c */
|
|
|
|
|
2005-05-09 18:03:44 +00:00
|
|
|
extern void init_buffer ( struct buffer *buffer );
|
2005-05-17 14:34:46 +00:00
|
|
|
extern int fill_buffer ( struct buffer *buffer, const void *data,
|
2005-05-09 14:26:10 +00:00
|
|
|
off_t offset, size_t len );
|
2005-05-09 13:24:01 +00:00
|
|
|
|
2005-05-09 10:11:11 +00:00
|
|
|
#endif /* BUFFER_H */
|