From bb2024c6d646211226305e8fbd240e603085c93f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 11 Jan 2007 01:47:26 +0000 Subject: Move include/buffer.h to include/gpxe/buffer.h --- src/include/buffer.h | 97 ----------------------------------------------- src/include/dev.h | 2 +- src/include/gpxe/buffer.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++ src/include/load_buffer.h | 2 +- src/include/proto.h | 2 +- src/include/tftp.h | 2 +- 6 files changed, 101 insertions(+), 101 deletions(-) delete mode 100644 src/include/buffer.h create mode 100644 src/include/gpxe/buffer.h (limited to 'src/include') diff --git a/src/include/buffer.h b/src/include/buffer.h deleted file mode 100644 index ac4c31481..000000000 --- a/src/include/buffer.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef BUFFER_H -#define BUFFER_H - -#include "compiler.h" /* for doxygen */ -#include "stdint.h" - -/** @file - * - * Buffers for loading files. - * - * This file provides routines for filling a buffer with data received - * piecemeal, where the size of the data is not necessarily known in - * advance. - * - * Some protocols do not provide a mechanism for us to know the size - * of the file before we happen to receive a particular block - * (e.g. the final block in an MTFTP transfer). In addition, some - * protocols (all the multicast protocols plus any TCP-based protocol) - * can, in theory, provide the data in any order. - * - * Rather than requiring each protocol to implement its own equivalent - * of "dd" to arrange the data into well-sized pieces before handing - * off to the image loader, we provide these generic buffer functions - * which assemble a file into a single contiguous block. The whole - * block is then passed to the image loader. - * - * Example usage: - * - * @code - * - * struct buffer my_buffer; - * void *data; - * off_t offset; - * size_t len; - * - * // We have an area of memory [buf_start,buf_end) into which we want - * // to load a file, where buf_start and buf_end are physical addresses. - * buffer->start = buf_start; - * buffer->end = buf_end; - * init_buffer ( &buffer ); - * ... - * while ( get_file_block ( ... ) ) { - * // Downloaded block is stored in [data,data+len), and represents - * // the portion of the file at offsets [offset,offset+len) - * if ( ! fill_buffer ( &buffer, data, offset, len ) ) { - * // An error occurred - * return 0; - * } - * ... - * } - * ... - * // The whole file is now present at [buf_start,buf_start+filesize), - * // where buf_start is a physical address. The struct buffer can simply - * // be discarded; there is no done_buffer() call. - * - * @endcode - * - * For a description of the internal operation, see buffer.c. - * - */ - -/** - * A buffer - * - * #start and #end denote the real boundaries of the buffer, and are - * physical addresses. #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; /**< Start of buffer in memory */ - physaddr_t end; /**< End of buffer in memory */ - off_t fill; /**< Offset to first gap in buffer */ -}; - -/** - * A free block descriptor. - * - * See buffer.c for a full description of the fields. - * - */ -struct buffer_free_block { - char tail; /**< Tail byte marker */ - char reserved[3]; /**< Padding */ - physaddr_t start; /**< Address of this free block */ - physaddr_t next; /**< Address of next free block */ - physaddr_t end; /**< End of this block */ -} __attribute__ (( packed )); - -/* Functions in buffer.c */ - -extern void init_buffer ( struct buffer *buffer ); -extern int fill_buffer ( struct buffer *buffer, const void *data, - off_t offset, size_t len ); - -#endif /* BUFFER_H */ diff --git a/src/include/dev.h b/src/include/dev.h index 77452ad75..c46a366de 100644 --- a/src/include/dev.h +++ b/src/include/dev.h @@ -3,7 +3,7 @@ #include "stdint.h" #include "string.h" -#include "buffer.h" +#include #include "dhcp.h" /* for dhcp_dev_id */ #include #include diff --git a/src/include/gpxe/buffer.h b/src/include/gpxe/buffer.h new file mode 100644 index 000000000..dba10b889 --- /dev/null +++ b/src/include/gpxe/buffer.h @@ -0,0 +1,97 @@ +#ifndef _GPXE_BUFFER_H +#define _GPXE_BUFFER_H + +#include "compiler.h" /* for doxygen */ +#include "stdint.h" + +/** @file + * + * Buffers for loading files. + * + * This file provides routines for filling a buffer with data received + * piecemeal, where the size of the data is not necessarily known in + * advance. + * + * Some protocols do not provide a mechanism for us to know the size + * of the file before we happen to receive a particular block + * (e.g. the final block in an MTFTP transfer). In addition, some + * protocols (all the multicast protocols plus any TCP-based protocol) + * can, in theory, provide the data in any order. + * + * Rather than requiring each protocol to implement its own equivalent + * of "dd" to arrange the data into well-sized pieces before handing + * off to the image loader, we provide these generic buffer functions + * which assemble a file into a single contiguous block. The whole + * block is then passed to the image loader. + * + * Example usage: + * + * @code + * + * struct buffer my_buffer; + * void *data; + * off_t offset; + * size_t len; + * + * // We have an area of memory [buf_start,buf_end) into which we want + * // to load a file, where buf_start and buf_end are physical addresses. + * buffer->start = buf_start; + * buffer->end = buf_end; + * init_buffer ( &buffer ); + * ... + * while ( get_file_block ( ... ) ) { + * // Downloaded block is stored in [data,data+len), and represents + * // the portion of the file at offsets [offset,offset+len) + * if ( ! fill_buffer ( &buffer, data, offset, len ) ) { + * // An error occurred + * return 0; + * } + * ... + * } + * ... + * // The whole file is now present at [buf_start,buf_start+filesize), + * // where buf_start is a physical address. The struct buffer can simply + * // be discarded; there is no done_buffer() call. + * + * @endcode + * + * For a description of the internal operation, see buffer.c. + * + */ + +/** + * A buffer + * + * #start and #end denote the real boundaries of the buffer, and are + * physical addresses. #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; /**< Start of buffer in memory */ + physaddr_t end; /**< End of buffer in memory */ + off_t fill; /**< Offset to first gap in buffer */ +}; + +/** + * A free block descriptor. + * + * See buffer.c for a full description of the fields. + * + */ +struct buffer_free_block { + char tail; /**< Tail byte marker */ + char reserved[3]; /**< Padding */ + physaddr_t start; /**< Address of this free block */ + physaddr_t next; /**< Address of next free block */ + physaddr_t end; /**< End of this block */ +} __attribute__ (( packed )); + +/* Functions in buffer.c */ + +extern void init_buffer ( struct buffer *buffer ); +extern int fill_buffer ( struct buffer *buffer, const void *data, + off_t offset, size_t len ); + +#endif /* _GPXE_BUFFER_H */ diff --git a/src/include/load_buffer.h b/src/include/load_buffer.h index 5aa37410e..b13c4e2a4 100644 --- a/src/include/load_buffer.h +++ b/src/include/load_buffer.h @@ -1,7 +1,7 @@ #ifndef LOAD_BUFFER_H #define LOAD_BUFFER_H -#include "buffer.h" +#include /* * These functions are architecture-dependent, but the interface must diff --git a/src/include/proto.h b/src/include/proto.h index c16229ef1..a3861f2bd 100644 --- a/src/include/proto.h +++ b/src/include/proto.h @@ -2,7 +2,7 @@ #define PROTO_H #include -#include "buffer.h" +#include #include struct protocol { diff --git a/src/include/tftp.h b/src/include/tftp.h index ed99035ed..bdc63374f 100644 --- a/src/include/tftp.h +++ b/src/include/tftp.h @@ -4,7 +4,7 @@ /** @file */ #include -#include "buffer.h" +#include #include "nic.h" #include "ip.h" #include "udp.h" -- cgit v1.2.3-55-g7522