summaryrefslogtreecommitdiffstats
path: root/src/core/buffer.c
diff options
context:
space:
mode:
authorMichael Brown2005-05-09 15:47:04 +0200
committerMichael Brown2005-05-09 15:47:04 +0200
commita89651f3bbabf203b6e7fe6767e403f162371e3d (patch)
tree9e9d99ff3ab34f6cec233fc349b989cfa54ee651 /src/core/buffer.c
parentAdded explanatory comment. (diff)
downloadipxe-a89651f3bbabf203b6e7fe6767e403f162371e3d.tar.gz
ipxe-a89651f3bbabf203b6e7fe6767e403f162371e3d.tar.xz
ipxe-a89651f3bbabf203b6e7fe6767e403f162371e3d.zip
Added debugging
Diffstat (limited to 'src/core/buffer.c')
-rw-r--r--src/core/buffer.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/buffer.c b/src/core/buffer.c
index 5254c64e..2a0cc493 100644
--- a/src/core/buffer.c
+++ b/src/core/buffer.c
@@ -41,6 +41,8 @@ void init_buffer ( struct buffer *buffer, physaddr_t start, size_t len ) {
char tail = 1;
copy_to_phys ( start, &tail, sizeof ( tail ) );
}
+
+ DBG ( "BUFFER [%x,%x) initialised\n", buffer->start, buffer->end );
}
/*
@@ -57,6 +59,9 @@ static void split_free_block ( struct buffer_free_block *desc,
if ( split >= desc->end )
return;
+ DBG ( "BUFFER splitting [%x,%x) into [%x,%x) and [%x,%x)\n",
+ block, desc->end, block, split, split, desc->end );
+
/* Create descriptor for new free block */
copy_to_phys ( split, &desc->tail, sizeof ( desc->tail ) );
if ( ! desc->tail )
@@ -80,6 +85,8 @@ static inline void unfree_block ( struct buffer *buffer,
/* If this is the first block, just update first_free */
if ( ! prev_block ) {
+ DBG ( "BUFFER marking [%x,%x) as used\n",
+ buffer->first_free, desc->end );
buffer->first_free = desc->next_free;
return;
}
@@ -87,6 +94,9 @@ static inline void unfree_block ( struct buffer *buffer,
/* Get descriptor for previous block (which cannot be a tail block) */
copy_from_phys ( &prev_desc, prev_block, sizeof ( prev_desc ) );
+ DBG ( "BUFFER marking [%x,%x) as used\n",
+ prev_desc.next_free, desc->end );
+
/* Modify descriptor for previous block and write it back */
prev_desc.next_free = desc->next_free;
copy_to_phys ( prev_block, &prev_desc, sizeof ( prev_desc ) );
@@ -114,6 +124,8 @@ off_t fill_buffer ( struct buffer *buffer, void *data,
/* Calculate start and end addresses of data */
data_start = buffer->start + offset;
data_end = data_start + len;
+ DBG ( "BUFFER [%x,%x) writing portion [%x,%x)\n",
+ buffer->start, buffer->end, data_start, data_end );
/* Iterate through the buffer's free blocks */
prev_block = 0;
@@ -133,7 +145,7 @@ off_t fill_buffer ( struct buffer *buffer, void *data,
/* Block is now either completely contained by or
* completely outside the data area
*/
- if ( ( block >= data_start ) && ( block <= data_end ) ) {
+ if ( ( block >= data_start ) && ( block < data_end ) ) {
/* Block is within the data area */
unfree_block ( buffer, &desc, prev_block );
copy_to_phys ( block, data + ( block - data_start ),
@@ -147,5 +159,8 @@ off_t fill_buffer ( struct buffer *buffer, void *data,
block = desc.next_free;
}
+ DBG ( "BUFFER [%x,%x) full up to %x\n",
+ buffer->start, buffer->end, buffer->first_free );
+
return ( buffer->first_free - buffer->start );
}