potentially got that fixed?

This commit is contained in:
Jonathan Turner 2023-11-29 19:15:38 -05:00
parent 4e4a739330
commit 7fe78e46c2
2 changed files with 28 additions and 8 deletions

View File

@ -57,7 +57,7 @@
} }
} }
if (valid) { if (valid) {
umem_head = add_node( umem_head, base, limit, true, global_id++); umem_head = add_node( umem_head, base, limit-1, true, global_id++);
} }
} else if (strcmp(input, "LIST") == 0) { } else if (strcmp(input, "LIST") == 0) {
kprint("***** FORWARD ****\n"); kprint("***** FORWARD ****\n");
@ -117,6 +117,9 @@
kprint(" for example - TEST was just added so that I could test the strlen commands.\n"); kprint(" for example - TEST was just added so that I could test the strlen commands.\n");
} else if (strcmp(input, "HOLES") == 0) { } else if (strcmp(input, "HOLES") == 0) {
print_holes(umem_head); print_holes(umem_head);
} else if (strcmp(input, "RESULT") == 0) {
node *holes = get_holes( umem_head);
print_memory( umem_head, holes);
} else { } else {
kprint("You said: "); kprint("You said: ");
kprint(input); kprint(input);
@ -154,26 +157,42 @@
} }
node* print_holes(node* umem_head) { void print_memory(node *umem_head, node *hole_head) {
u32 total_memory = 0x3FFFF;
// u32 free_memory = total_memory;
// u32 total_allocated = total_memory - free_memory;
//
// int num_of_gaps = 0;
// int num_of_nodes = 0;
// while (umem_head
char c[16];
hex_to_ascii( *total_memory, c, 16);
kprint("Total Physical Memory: ");
kprint(c);
kprint("\n");
}
node* get_holes(node* umem_head) {
if (umem_head == NULL) { if (umem_head == NULL) {
kprint("Holes list is Empty"); kprint("Holes list is Empty\n");
return NULL; return NULL;
} }
u32 hole_ids = 0; u32 hole_ids = 0;
node *hole = NULL; node *hole = NULL;
if (umem_head->base_register-0x10000 != 0) { if (umem_head->base_register-0x10000 != 0) {
hole = add_node( hole, 0x10000, umem_head->base_register-0x10000, true, ++hole_ids); hole = add_node( hole, 0x10000, umem_head->base_register-0x10000-1, true, ++hole_ids);
} }
while(umem_head != NULL) { while(umem_head != NULL) {
if (umem_head->next != NULL) { if (umem_head->next != NULL) {
node *next = umem_head->next; node *next = umem_head->next;
u32 total = umem_head->base_register+umem_head->limit_register; u32 total = umem_head->base_register+umem_head->limit_register;
hole = add_node( hole, total, next->base_register-total, true, ++hole_ids); hole = add_node( hole, total, next->base_register-total-1, true, ++hole_ids);
} else { } else {
hole = add_node( hole, umem_head->base_register+umem_head->limit_register, 0x100000, true, ++hole_ids); hole = add_node( hole, umem_head->base_register+umem_head->limit_register-1, 0x3FFFF, true, ++hole_ids);
} }
umem_head = umem_head->next; umem_head = umem_head->next;
} }
print_list(hole, false);
return hole; return hole;
} }

View File

@ -10,7 +10,8 @@
#include "../libc/linked.h" #include "../libc/linked.h"
void user_input(char *input); void user_input(char *input);
node* print_holes(node *enum_head); node* get_holes(node *enum_head);
void print_memory(node *umem_head, node *hole_head)
int digit_len(unsigned digit); int digit_len(unsigned digit);
int digit_conver(const char *str); int digit_conver(const char *str);