dreamos82 / Dreamos64

My experiments with osdev... again
160 stars 8 forks source link

_mmap_setup: is not mapping all the available memory #209

Closed dreamos82 closed 4 months ago

dreamos82 commented 6 months ago

The current version of _mmap_setup:

void _mmap_setup(){
    count_physical_reserved=0;
    if(used_frames > 0){
        uint32_t counter = 0;
        uint64_t mem_limit = (tagmem->mem_upper + 1024) * 1024;
        while(counter < mmap_number_of_entries){
            if(mmap_entries[counter].addr < mem_limit &&
                    mmap_entries[counter].type > 1){
                pretty_logf(Verbose, "\tFound unusable entry at addr: %x", mmap_entries[counter].addr);
                pmm_reserve_area(mmap_entries[counter].addr, mmap_entries[counter].len);
                count_physical_reserved++;
            }
            counter++;
        }
    }
}

is marking as used only the part of the memory that is below the mem_limit variable.

The prblem is that mem_upper , as defined in multiboot2 specs:

The maximum possible value for lower memory is 640 kilobytes. The value returned for upper memory is maximally the address of the first upper memory hole minus 1 megabyte.

is considering only the first hole.

The problem, is that there can be more than one available entry after the first, as well as multiple reserved/unusable areas, this means that we should mark as used other areas in the pmm.