From 1c75a688157a0303432c4e8d112682333fa2e41d Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 1 Jan 2013 23:53:18 -0500 Subject: [PATCH] config: add CONFIG_PAGE_SIZE and CONFIG_INIT_PAGE_SIZE --- Makefile | 1 + config_example | 2 ++ drivers/pl110.c | 2 +- drivers/pl111.c | 2 +- include/frames.h | 2 -- kernel/frames.c | 24 ++++++++++++------------ 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index b0af286..4654489 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,7 @@ config.h: config @sed -i 's/#.*$$//g' config.h @sed -i '/^\s*\(CONFIG_[A-Z0-9_]\+\)\s*=\s*[nN]/d' config.h @sed -i 's/^\s*\(CONFIG_[A-Z0-9_]\+\)\s*=\s*[yY]/#define \1/g' config.h + @sed -i 's/^\s*\(CONFIG_[A-Z0-9_]\+\)\s*=\s*\([0-9]\+\)/#define \1 \2/g' config.h clean: @echo ' CLEAN config.h' diff --git a/config_example b/config_example index 18cb5d3..377799f 100644 --- a/config_example +++ b/config_example @@ -1,3 +1,5 @@ CONFIG_RPI = y #CONFIG_VEXPRESS_A9 = y #CONFIG_INTEGRATOR_CP = n +CONFIG_PAGE_SIZE = 0x1000 +CONFIG_INIT_PAGE_SIZE = 0x100000 diff --git a/drivers/pl110.c b/drivers/pl110.c index 68e5bf9..c0380df 100644 --- a/drivers/pl110.c +++ b/drivers/pl110.c @@ -55,7 +55,7 @@ int pl110_init(struct fb *f, unsigned int color_depth) { /* Allocate memory for framebuffer */ fb_size = width * height * (color_depth / 8); - power = log(fb_size) - log(MM_PAGE_SIZE); + power = log(fb_size) - log(CONFIG_PAGE_SIZE); if ((unsigned int)1< -#define MM_PAGE_SIZE 4096 - struct frame { void *address; struct dlist_node list; diff --git a/kernel/frames.c b/kernel/frames.c index a6f50fa..b642f62 100644 --- a/kernel/frames.c +++ b/kernel/frames.c @@ -60,16 +60,16 @@ static void add_physical_memory(void *start, void *end) { //If region starts at 0x0, make it start at next page to not screw up null pointer detection, etc. if (start == 0) - start = (char *)start + MM_PAGE_SIZE; + start = (char *)start + CONFIG_PAGE_SIZE; //make sure both start and end address are aligned to the size of a page - if ((arch_uint_ptr)start % MM_PAGE_SIZE != 0) - start = (char*)start + (MM_PAGE_SIZE - ((arch_uint_ptr)start % MM_PAGE_SIZE)); - if (((arch_uint_ptr)end + 1) % MM_PAGE_SIZE != 0) - end = (char*)end - ((arch_uint_ptr)end + 1) % MM_PAGE_SIZE; + if ((arch_uint_ptr)start % CONFIG_PAGE_SIZE != 0) + start = (char*)start + (CONFIG_PAGE_SIZE - ((arch_uint_ptr)start % CONFIG_PAGE_SIZE)); + if (((arch_uint_ptr)end + 1) % CONFIG_PAGE_SIZE != 0) + end = (char*)end - ((arch_uint_ptr)end + 1) % CONFIG_PAGE_SIZE; - if ((char *)end + 1 - (char *)start < MM_PAGE_SIZE<<1) { - print("Error: Supplied memory area(%x,%x) is smaller than the page size (%d)\n", (arch_uint_ptr)start, (arch_uint_ptr)end, MM_PAGE_SIZE); + if ((char *)end + 1 - (char *)start < CONFIG_PAGE_SIZE<<1) { + print("Error: Supplied memory area(%x,%x) is smaller than the page size (%d)\n", (arch_uint_ptr)start, (arch_uint_ptr)end, CONFIG_PAGE_SIZE); return; } @@ -78,13 +78,13 @@ static void add_physical_memory(void *start, void *end) { //TODO we're potentially losing memory here because we're calculating //the number of page structs we need even for those pages that will contain only page structs - num_pages = ((char *)end + 1 - (char *)start) / MM_PAGE_SIZE; - usable_pages = num_pages - num_pages * sizeof(struct frame) / MM_PAGE_SIZE; - if (num_pages * sizeof(struct frame) % MM_PAGE_SIZE) + num_pages = ((char *)end + 1 - (char *)start) / CONFIG_PAGE_SIZE; + usable_pages = num_pages - num_pages * sizeof(struct frame) / CONFIG_PAGE_SIZE; + if (num_pages * sizeof(struct frame) % CONFIG_PAGE_SIZE) usable_pages--; p = (struct frame *)start; - for (page = ((char *)start) + (num_pages - usable_pages)*MM_PAGE_SIZE; page < end; page = (void *)(((char *)page) + MM_PAGE_SIZE)) { + for (page = ((char *)start) + (num_pages - usable_pages)*CONFIG_PAGE_SIZE; page < end; page = (void *)(((char *)page) + CONFIG_PAGE_SIZE)) { p->address = page; insert_page_frame(p); p++; @@ -115,7 +115,7 @@ struct frame* get_free_frames(unsigned int power) { for (it2 = container(it->list.next, struct frame, list); it2->list.next != &free_frames_list && curr_pages < num_pages; it2 = container(it2->list.next, struct frame, list)) { - if ((char*)it2->address != (char*)container(it2->list.prev, struct frame, list)->address + MM_PAGE_SIZE) { + if ((char*)it2->address != (char*)container(it2->list.prev, struct frame, list)->address + CONFIG_PAGE_SIZE) { it = it2; //fast-forward 'it' to start of next contiguous section of pages break; } else {