potentially got that fixed?
This commit is contained in:
parent
4e4a739330
commit
7fe78e46c2
@ -57,7 +57,7 @@
|
||||
}
|
||||
}
|
||||
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) {
|
||||
kprint("***** FORWARD ****\n");
|
||||
@ -117,6 +117,9 @@
|
||||
kprint(" for example - TEST was just added so that I could test the strlen commands.\n");
|
||||
} else if (strcmp(input, "HOLES") == 0) {
|
||||
print_holes(umem_head);
|
||||
} else if (strcmp(input, "RESULT") == 0) {
|
||||
node *holes = get_holes( umem_head);
|
||||
print_memory( umem_head, holes);
|
||||
} else {
|
||||
kprint("You said: ");
|
||||
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) {
|
||||
kprint("Holes list is Empty");
|
||||
kprint("Holes list is Empty\n");
|
||||
return NULL;
|
||||
}
|
||||
u32 hole_ids = 0;
|
||||
node *hole = NULL;
|
||||
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) {
|
||||
if (umem_head->next != NULL) {
|
||||
node *next = umem_head->next;
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
print_list(hole, false);
|
||||
return hole;
|
||||
}
|
@ -10,7 +10,8 @@
|
||||
#include "../libc/linked.h"
|
||||
|
||||
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_conver(const char *str);
|
||||
|
||||
|
Reference in New Issue
Block a user