diff options
author | Michael Brown | 2007-11-28 11:57:26 +0100 |
---|---|---|
committer | Michael Brown | 2007-11-28 11:57:26 +0100 |
commit | 3b1efba8640bbe8dd68a802f6e759879f82c1d95 (patch) | |
tree | a3e16ee94920ac3a6bee366e7026978b6a50f331 /src/include | |
parent | Quick hack to be able to accept transfers from servers that don't (diff) | |
download | ipxe-3b1efba8640bbe8dd68a802f6e759879f82c1d95.tar.gz ipxe-3b1efba8640bbe8dd68a802f6e759879f82c1d95.tar.xz ipxe-3b1efba8640bbe8dd68a802f6e759879f82c1d95.zip |
Add RFC2090 TFTP multicast support.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gpxe/bitmap.h | 83 | ||||
-rw-r--r-- | src/include/gpxe/errfile.h | 1 |
2 files changed, 84 insertions, 0 deletions
diff --git a/src/include/gpxe/bitmap.h b/src/include/gpxe/bitmap.h new file mode 100644 index 00000000..0c2f53c8 --- /dev/null +++ b/src/include/gpxe/bitmap.h @@ -0,0 +1,83 @@ +#ifndef _GPXE_BITMAP_H +#define _GPXE_BITMAP_H + +/** @file + * + * Bitmaps for multicast downloads + * + */ + +#include <stdint.h> +#include <stddef.h> +#include <stdlib.h> + +/** A single block of bits within a bitmap */ +typedef unsigned long bitmap_block_t; + +/** Size of a block of bits (in bits) */ +#define BITMAP_BLKSIZE ( sizeof ( bitmap_block_t ) * 8 ) + +/** + * Block index within bitmap + * + * @v bit Bit index + * @ret index Block index + */ +#define BITMAP_INDEX( bit ) ( (bit) / BITMAP_BLKSIZE ) + +/** + * Block mask within bitmap + * + * @v bit Bit index + * @ret mask Block mask + */ +#define BITMAP_MASK( bit ) ( 1 << ( (bit) % BITMAP_BLKSIZE ) ) + +/** A bitmap */ +struct bitmap { + /** Bitmap data */ + bitmap_block_t *blocks; + /** Length of the bitmap, in bits */ + unsigned int length; + /** Index of first gap in the bitmap */ + unsigned int first_gap; +}; + +extern int bitmap_resize ( struct bitmap *bitmap, unsigned int new_length ); +extern int bitmap_test ( struct bitmap *bitmap, unsigned int bit ); +extern void bitmap_set ( struct bitmap *bitmap, unsigned int bit ); + +/** + * Free bitmap resources + * + * @v bitmap Bitmap + */ +static inline void bitmap_free ( struct bitmap *bitmap ) { + free ( bitmap->blocks ); +} + +/** + * Get first gap within bitmap + * + * @v bitmap Bitmap + * @ret first_gap First gap + * + * The first gap is the first unset bit within the bitmap. + */ +static inline unsigned int bitmap_first_gap ( struct bitmap *bitmap ) { + return bitmap->first_gap; +} + +/** + * Check to see if bitmap is full + * + * @v bitmap Bitmap + * @ret is_full Bitmap is full + * + * The bitmap is full if it has no gaps (i.e. no unset bits). + */ +static inline int bitmap_full ( struct bitmap *bitmap ) { + return ( bitmap->first_gap == bitmap->length ); +} + +#endif /* _GPXE_BITMAP_H */ diff --git a/src/include/gpxe/errfile.h b/src/include/gpxe/errfile.h index 94648e26..c234d13c 100644 --- a/src/include/gpxe/errfile.h +++ b/src/include/gpxe/errfile.h @@ -50,6 +50,7 @@ #define ERRFILE_settings ( ERRFILE_CORE | 0x000c0000 ) #define ERRFILE_vsprintf ( ERRFILE_CORE | 0x000d0000 ) #define ERRFILE_xfer ( ERRFILE_CORE | 0x000e0000 ) +#define ERRFILE_bitmap ( ERRFILE_CORE | 0x000f0000 ) #define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 ) #define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 ) |