Skip to content

Commit

Permalink
pmm: map frames_arrays' frames when final VA space is available
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Aug 29, 2021
1 parent 8ae3c54 commit d7b4917
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions mm/pmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <list.h>
#include <setup.h>
#include <spinlock.h>

#include <mm/pmm.h>
#include <mm/regions.h>
#include <mm/vmm.h>

size_t total_phys_memory;

Expand Down Expand Up @@ -71,17 +73,22 @@ static inline void init_frames_array(frames_array_t *array) {
}

static frames_array_t *new_frames_array(void) {
frame_t *frame = get_free_frame();
frames_array_t *array;

if (!frame)
panic("PMM: Unable to allocate new frame for frame array\n");
if (!boot_flags.virt) {
frame_t *frame = get_free_frame();
array = (frames_array_t *) mfn_to_virt_kern(frame->mfn);
}
else
array = get_free_page(GFP_KERNEL);

array = (frames_array_t *) mfn_to_virt_kern(frame->mfn);
init_frames_array(array);
if (!array)
panic("PMM: Unable to allocate new page for frame array\n");

dprintk("%s: allocated new frames array: %p\n", __func__, array);

init_frames_array(array);

total_free_frames += array->meta.free_count;
return array;
}
Expand Down

0 comments on commit d7b4917

Please sign in to comment.