Browse Source

Added debugging

tags/v0.9.3
Michael Brown 20 years ago
parent
commit
a89651f3bb
1 changed files with 16 additions and 1 deletions
  1. 16
    1
      src/core/buffer.c

+ 16
- 1
src/core/buffer.c View File

41
 		char tail = 1;
41
 		char tail = 1;
42
 		copy_to_phys ( start, &tail, sizeof ( tail ) );
42
 		copy_to_phys ( start, &tail, sizeof ( tail ) );
43
 	}
43
 	}
44
+
45
+	DBG ( "BUFFER [%x,%x) initialised\n", buffer->start, buffer->end );
44
 }
46
 }
45
 
47
 
46
 /*
48
 /*
57
 	if ( split >= desc->end )
59
 	if ( split >= desc->end )
58
 		return;
60
 		return;
59
 
61
 
62
+	DBG ( "BUFFER splitting [%x,%x) into [%x,%x) and [%x,%x)\n",
63
+	      block, desc->end, block, split, split, desc->end );
64
+
60
 	/* Create descriptor for new free block */
65
 	/* Create descriptor for new free block */
61
 	copy_to_phys ( split, &desc->tail, sizeof ( desc->tail ) );
66
 	copy_to_phys ( split, &desc->tail, sizeof ( desc->tail ) );
62
 	if ( ! desc->tail )
67
 	if ( ! desc->tail )
80
 	
85
 	
81
 	/* If this is the first block, just update first_free */
86
 	/* If this is the first block, just update first_free */
82
 	if ( ! prev_block ) {
87
 	if ( ! prev_block ) {
88
+		DBG ( "BUFFER marking [%x,%x) as used\n",
89
+		      buffer->first_free, desc->end );
83
 		buffer->first_free = desc->next_free;
90
 		buffer->first_free = desc->next_free;
84
 		return;
91
 		return;
85
 	}
92
 	}
87
 	/* Get descriptor for previous block (which cannot be a tail block) */
94
 	/* Get descriptor for previous block (which cannot be a tail block) */
88
 	copy_from_phys ( &prev_desc, prev_block, sizeof ( prev_desc ) );
95
 	copy_from_phys ( &prev_desc, prev_block, sizeof ( prev_desc ) );
89
 
96
 
97
+	DBG ( "BUFFER marking [%x,%x) as used\n",
98
+	      prev_desc.next_free, desc->end );
99
+
90
 	/* Modify descriptor for previous block and write it back */
100
 	/* Modify descriptor for previous block and write it back */
91
 	prev_desc.next_free = desc->next_free;
101
 	prev_desc.next_free = desc->next_free;
92
 	copy_to_phys ( prev_block, &prev_desc, sizeof ( prev_desc ) );
102
 	copy_to_phys ( prev_block, &prev_desc, sizeof ( prev_desc ) );
114
 	/* Calculate start and end addresses of data */
124
 	/* Calculate start and end addresses of data */
115
 	data_start = buffer->start + offset;
125
 	data_start = buffer->start + offset;
116
 	data_end = data_start + len;
126
 	data_end = data_start + len;
127
+	DBG ( "BUFFER [%x,%x) writing portion [%x,%x)\n",
128
+	      buffer->start, buffer->end, data_start, data_end );
117
 
129
 
118
 	/* Iterate through the buffer's free blocks */
130
 	/* Iterate through the buffer's free blocks */
119
 	prev_block = 0;
131
 	prev_block = 0;
133
 		/* Block is now either completely contained by or
145
 		/* Block is now either completely contained by or
134
 		 * completely outside the data area
146
 		 * completely outside the data area
135
 		 */
147
 		 */
136
-		if ( ( block >= data_start ) && ( block <= data_end ) ) {
148
+		if ( ( block >= data_start ) && ( block < data_end ) ) {
137
 			/* Block is within the data area */
149
 			/* Block is within the data area */
138
 			unfree_block ( buffer, &desc, prev_block );
150
 			unfree_block ( buffer, &desc, prev_block );
139
 			copy_to_phys ( block, data + ( block - data_start ),
151
 			copy_to_phys ( block, data + ( block - data_start ),
147
 		block = desc.next_free;
159
 		block = desc.next_free;
148
 	}
160
 	}
149
 
161
 
162
+	DBG ( "BUFFER [%x,%x) full up to %x\n",
163
+	      buffer->start, buffer->end, buffer->first_free );
164
+
150
 	return ( buffer->first_free - buffer->start );
165
 	return ( buffer->first_free - buffer->start );
151
 }
166
 }

Loading…
Cancel
Save