mirror of
https://github.com/ipxe/ipxe
synced 2025-12-16 09:32:33 +03:00
Return -1 to indicate buffer overflow. Allow buffer fill level to be read
easily from struct buffer.
This commit is contained in:
@@ -3,6 +3,18 @@
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/*
|
||||
* "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;
|
||||
};
|
||||
|
||||
/*
|
||||
* 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,
|
||||
@@ -15,24 +27,17 @@
|
||||
* smaller than a struct buffer_free_block.
|
||||
*
|
||||
*/
|
||||
|
||||
struct buffer_free_block {
|
||||
char tail;
|
||||
physaddr_t next_free;
|
||||
physaddr_t end;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
struct buffer {
|
||||
physaddr_t start;
|
||||
physaddr_t end;
|
||||
physaddr_t first_free;
|
||||
};
|
||||
|
||||
/* Functions in buffer.c */
|
||||
|
||||
extern void init_buffer ( struct buffer *buffer, physaddr_t start,
|
||||
size_t len );
|
||||
extern off_t fill_buffer ( struct buffer *buffer, void *data,
|
||||
off_t offset, size_t len );
|
||||
extern int fill_buffer ( struct buffer *buffer, void *data,
|
||||
off_t offset, size_t len );
|
||||
|
||||
#endif /* BUFFER_H */
|
||||
|
||||
Reference in New Issue
Block a user