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-09 14:26:10 +00:00
|
|
|
/*
|
|
|
|
* "start" and "end" denote the real boundaries of the buffer. "fill"
|
|
|
|
* denotes the offset to the first free block in the buffer. (If the
|
|
|
|
* buffer is full, "fill" will equal ( end - start ) ).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct buffer {
|
|
|
|
physaddr_t start;
|
|
|
|
physaddr_t end;
|
|
|
|
off_t fill;
|
|
|
|
};
|
|
|
|
|
2005-05-09 13:24:01 +00:00
|
|
|
/*
|
|
|
|
* Free blocks in the buffer start with a "tail byte". If non-zero,
|
|
|
|
* this byte indicates that the free block is the tail of the buffer,
|
|
|
|
* i.e. occupies all the remaining space up to the end of the buffer.
|
|
|
|
* When the tail byte is non-zero, it indicates that the remainder of
|
|
|
|
* the descriptor (the struct buffer_free_block) follows the tail
|
|
|
|
* byte.
|
|
|
|
*
|
|
|
|
* This scheme is necessary because we may end up with a tail that is
|
|
|
|
* smaller than a struct buffer_free_block.
|
|
|
|
*
|
|
|
|
*/
|
2005-05-09 10:11:11 +00:00
|
|
|
struct buffer_free_block {
|
2005-05-09 13:24:01 +00:00
|
|
|
char tail;
|
|
|
|
physaddr_t next_free;
|
|
|
|
physaddr_t end;
|
|
|
|
} __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 */
|