mirror of
https://git.stationery.faith/corn/corn.git
synced 2024-11-22 00:22:17 +00:00
better print and mem
This commit is contained in:
parent
179ddf64c1
commit
95f52a55ad
6 changed files with 33 additions and 11 deletions
|
@ -8,7 +8,6 @@
|
|||
struct memory_segment {
|
||||
uint64_t addr;
|
||||
uint64_t len;
|
||||
uint32_t type;
|
||||
};
|
||||
|
||||
struct memory_map {
|
||||
|
|
|
@ -300,7 +300,7 @@ static int debugger_prompt(struct isr_regs *state) {
|
|||
case 's': // step (n)
|
||||
rflags->tf = 1;
|
||||
dbg_steps = atol(buf + 1) - 1;
|
||||
if (dbg_steps < 0) dbg_steps = 0;
|
||||
//if (dbg_steps < 0) dbg_steps = 0;
|
||||
return 0;
|
||||
case 'b': // breakpoints
|
||||
{
|
||||
|
|
|
@ -133,19 +133,43 @@ static void read_cmdline(
|
|||
shim_info->cmdline[size] = '\0';
|
||||
}
|
||||
|
||||
static const char *segment_type[] = {
|
||||
"Reserved",
|
||||
"Free",
|
||||
"Reserved",
|
||||
"ACPI Reserved",
|
||||
"Hibernation",
|
||||
"Defective",
|
||||
"Unknown"
|
||||
};
|
||||
|
||||
static void read_memory_map(
|
||||
struct boot_info *shim_info,
|
||||
struct mboot_tag_mmap *map
|
||||
) {
|
||||
int idx = 0;
|
||||
uintptr_t i = (uintptr_t)map->entries;
|
||||
kprintf("MEMORY MAP\n");
|
||||
char buf[20];
|
||||
for ( ;
|
||||
i < (uintptr_t)map->entries + map->size;
|
||||
i += map->entry_size, idx++
|
||||
) {
|
||||
struct mboot_mmap_entry *seg = (struct mboot_mmap_entry *) i;
|
||||
const char *type = NULL;
|
||||
if (seg->type > 4)
|
||||
type = segment_type[6];
|
||||
else
|
||||
type = segment_type[seg->type];
|
||||
kprintf("ADDR: 0x%16p LEN: %4s TYPE: %s (%d)\n",
|
||||
(void *)seg->addr,
|
||||
btoa(seg->len, buf),
|
||||
type,
|
||||
seg->type
|
||||
);
|
||||
if (seg->type != 1 || seg->len < 1)
|
||||
continue;
|
||||
shim_info->map.entries[idx].addr = seg->addr;
|
||||
shim_info->map.entries[idx].type = seg->type;
|
||||
shim_info->map.entries[idx].len = seg->len;
|
||||
}
|
||||
shim_info->map.entry_count = idx;
|
||||
|
|
|
@ -109,7 +109,6 @@ void free_phys_pages(void *ptr, int pages) {
|
|||
}
|
||||
|
||||
static bool segment_invalid(const struct memory_segment *segment) {
|
||||
if (segment->type != 1) return true;
|
||||
if (segment->addr < kaddr(kernel_start)) return true;
|
||||
if (segment->addr + segment->len < memory_start) return true;
|
||||
if (segment->addr + segment->len < kaddr(kernel_start)) return true;
|
||||
|
@ -188,14 +187,12 @@ void memory_init(struct memory_map *map) {
|
|||
|
||||
struct memory_area *area = page_start;
|
||||
|
||||
kprintf("MEMORY MAP\n");
|
||||
for (uint32_t i = 0; i < map->entry_count; i++) {
|
||||
struct memory_segment *segment = &map->entries[i];
|
||||
|
||||
if (segment_invalid(segment))
|
||||
continue;
|
||||
|
||||
kprintf("addr: 0x%16p\tlen: %ld\n", (void *)segment->addr, segment->len);
|
||||
|
||||
struct memory_area temp = segment_to_area(segment);
|
||||
*area = temp;
|
||||
|
|
|
@ -129,13 +129,9 @@ static void merge_back(struct addr_node *node) {
|
|||
}
|
||||
|
||||
static void merge_forward(struct addr_node *node) {
|
||||
<<<<<<< HEAD
|
||||
while (node->next && !node->is_alloc) {
|
||||
=======
|
||||
while(node->next) {
|
||||
if (node->is_alloc != node->next->is_alloc)
|
||||
break;
|
||||
>>>>>>> ea2de5a (looping kalloc can allocate all of memory (sometimes) :3)
|
||||
struct addr_node *temp = node->next;
|
||||
node->end = temp->end;
|
||||
node->next = temp->next;
|
||||
|
|
|
@ -344,7 +344,7 @@ static void print_unum(
|
|||
|
||||
bool space_pre = (flag & FLG_LEFT_ALIGN) || !(flag & FLG_ZERO);
|
||||
|
||||
if (space_pre && radix == 16 && flag & FLG_ALTERNATE) {
|
||||
if (!space_pre && radix == 16 && flag & FLG_ALTERNATE) {
|
||||
char x = base + ('x' - 'a');
|
||||
serial_out('0');
|
||||
serial_out(x);
|
||||
|
@ -372,6 +372,12 @@ static void print_unum(
|
|||
zero_padded = true;
|
||||
}
|
||||
|
||||
if (space_pre && radix == 16 && flag & FLG_ALTERNATE) {
|
||||
char x = base + ('x' - 'a');
|
||||
serial_out('0');
|
||||
serial_out(x);
|
||||
}
|
||||
|
||||
kputs(str);
|
||||
|
||||
if (!zero_padded && (flag & FLG_ALTERNATE) && radix == 8)
|
||||
|
|
Loading…
Reference in a new issue