commented out print holes

This commit is contained in:
Jonathan Turner 2023-11-29 16:33:10 -05:00
parent 2b0ab214a1
commit 51b1572b45

View File

@ -45,7 +45,6 @@
int nDigits = digit_len(base);
if (sstrlen(args1, 15) > nDigits + 1) {
char *args2 = args1 + nDigits + 1;
kprint(args2);
limit = digit_conver(args2);
if (limit < 100) {
kprint("That memory address is to below the min of 0x100.\n");
@ -116,6 +115,8 @@
kprint(" Review the kernel.c source code to see what each command does.\n");
kprint(" These are hard coded and are just examples, modify as you see fit.\n");
kprint(" for example - TEST was just added so that I could test the strlen commands.\n");
} else if (strcmp(input, "HOLES") == 0) {
} else {
kprint("You said: ");
kprint(input);
@ -124,6 +125,39 @@
kprint("> ");
}
void update_memory_holes(node *umen_head) {
// Assume there's a global variable to store the head of the holes list
Node *holes_head = NULL;
u32 last_end_addr = 0;
// Traverse the allocated memory nodes
while (umen_head != NULL) {
if (!umen_head->is_allocated) {
// This is a hole in memory
if (last_end_addr < umen_head->start_addr) {
// Create a new hole node
Node *hole_node = (Node *)malloc(sizeof(Node));
hole_node->start_addr = last_end_addr;
hole_node->size = umen_head->start_addr - last_end_addr;
hole_node->is_allocated = false;
// Insert the hole node at the beginning of the holes list
hole_node->next = holes_head;
holes_head = hole_node;
}
// Update the last end address
last_end_addr = umen_head->start_addr + umen_head->size;
}
umen_head = umen_head->next;
}
// Update the holes list in your global data structure or print it, etc.
// holes_head now represents the list of memory holes
print_holes(holes_head);
}
int digit_len(unsigned digit) {
if (digit >= 1000000000) return 10;