mirror of
https://github.com/drasko/codezero.git
synced 2026-08-05 22:10:07 +02:00
Fixed a bug with page_map size by dynamically allocating it.
This commit is contained in:
@@ -404,6 +404,10 @@ void init_finalize(struct kernel_container *kcont)
|
|||||||
*/
|
*/
|
||||||
free_bootmem();
|
free_bootmem();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up KIP UTCB ref
|
||||||
|
*/
|
||||||
|
kip.utcb = (u32)current->utcb_address;
|
||||||
/*
|
/*
|
||||||
* Start the scheduler, jumping to task
|
* Start the scheduler, jumping to task
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,18 +17,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <physmem.h>
|
#include <physmem.h>
|
||||||
|
#include <bootm.h>
|
||||||
|
|
||||||
struct page_bitmap page_map; /* Bitmap of used/unused pages at bootup */
|
|
||||||
struct memdesc physmem; /* Initial, primitive memory descriptor */
|
struct memdesc physmem; /* Initial, primitive memory descriptor */
|
||||||
struct membank membank[1]; /* The memory bank */
|
struct membank membank[1]; /* The memory bank */
|
||||||
struct page *page_array; /* The physical page array based on mem bank */
|
struct page *page_array; /* The physical page array based on mem bank */
|
||||||
|
|
||||||
|
|
||||||
static void init_page_map(unsigned long pfn_start, unsigned long pfn_end)
|
static void init_page_map(struct page_bitmap *pmap, unsigned long pfn_start, unsigned long pfn_end)
|
||||||
{
|
{
|
||||||
page_map.pfn_start = pfn_start;
|
pmap->pfn_start = pfn_start;
|
||||||
page_map.pfn_end = pfn_end;
|
pmap->pfn_end = pfn_end;
|
||||||
set_page_map(&page_map, pfn_start, pfn_end - pfn_start, 0);
|
set_page_map(pmap, pfn_start, pfn_end - pfn_start, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -143,20 +143,26 @@ void init_physmem_primary(struct initdata *initdata)
|
|||||||
unsigned long pfn_start, pfn_end, pfn_images_end = 0;
|
unsigned long pfn_start, pfn_end, pfn_images_end = 0;
|
||||||
struct bootdesc *bootdesc = initdata->bootdesc;
|
struct bootdesc *bootdesc = initdata->bootdesc;
|
||||||
|
|
||||||
/* Initialise page map from physmem capability */
|
/* Allocate page map structure */
|
||||||
init_page_map(initdata->physmem->start,
|
initdata->page_map = alloc_bootmem(sizeof(struct page_bitmap) +
|
||||||
initdata->physmem->end);
|
((initdata->physmem->end -
|
||||||
|
initdata->physmem->start)
|
||||||
|
>> 5) + 1, 0);
|
||||||
|
|
||||||
/* Set initdata pointer to initialized page map */
|
/* Initialise page map from physmem capability */
|
||||||
initdata->page_map = &page_map;
|
init_page_map(initdata->page_map,
|
||||||
|
initdata->physmem->start,
|
||||||
|
initdata->physmem->end);
|
||||||
|
|
||||||
/* Mark pager and other boot task areas as used */
|
/* Mark pager and other boot task areas as used */
|
||||||
for (int i = 0; i < bootdesc->total_images; i++) {
|
for (int i = 0; i < bootdesc->total_images; i++) {
|
||||||
pfn_start = __pfn(page_align_up(bootdesc->images[i].phys_start));
|
pfn_start =
|
||||||
|
__pfn(page_align_up(bootdesc->images[i].phys_start));
|
||||||
pfn_end = __pfn(page_align_up(bootdesc->images[i].phys_end));
|
pfn_end = __pfn(page_align_up(bootdesc->images[i].phys_end));
|
||||||
if (pfn_end > pfn_images_end)
|
if (pfn_end > pfn_images_end)
|
||||||
pfn_images_end = pfn_end;
|
pfn_images_end = pfn_end;
|
||||||
set_page_map(&page_map, pfn_start, pfn_end - pfn_start, 1);
|
set_page_map(initdata->page_map, pfn_start,
|
||||||
|
pfn_end - pfn_start, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
physmem.start = initdata->physmem->start;
|
physmem.start = initdata->physmem->start;
|
||||||
|
|||||||
Reference in New Issue
Block a user