diff options
Diffstat (limited to 'kern')
-rw-r--r-- | kern/bootstrap.c | 16 | ||||
-rw-r--r-- | kern/cpu_number.h | 2 | ||||
-rw-r--r-- | kern/log2.h | 50 | ||||
-rw-r--r-- | kern/slab.h | 5 | ||||
-rw-r--r-- | kern/startup.c | 2 |
5 files changed, 69 insertions, 6 deletions
diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 249c605c..08362767 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -107,6 +107,20 @@ task_insert_send_right( return name; } +static void +free_bootstrap_pages(phys_addr_t start, phys_addr_t end) +{ + struct vm_page *page; + + while (start < end) + { + page = vm_page_lookup_pa(start); + assert(page != NULL); + vm_page_manage(page); + start += PAGE_SIZE; + } +} + void bootstrap_create(void) { int compat; @@ -265,7 +279,7 @@ void bootstrap_create(void) /* XXX we could free the memory used by the boot loader's descriptors and such. */ for (n = 0; n < boot_info.mods_count; n++) - vm_page_create(bmods[n].mod_start, bmods[n].mod_end); + free_bootstrap_pages(bmods[n].mod_start, bmods[n].mod_end); } static void diff --git a/kern/cpu_number.h b/kern/cpu_number.h index 44bbd641..650f4042 100644 --- a/kern/cpu_number.h +++ b/kern/cpu_number.h @@ -37,5 +37,7 @@ int master_cpu; /* 'master' processor - keeps time */ /* cpu number is always 0 on a single processor system */ #define cpu_number() (0) +#define CPU_L1_SIZE (1 << CPU_L1_SHIFT) + #endif /* NCPUS == 1 */ #endif /* _KERN_CPU_NUMBER_H_ */ diff --git a/kern/log2.h b/kern/log2.h new file mode 100644 index 00000000..0e67701c --- /dev/null +++ b/kern/log2.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Richard Braun. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * + * Integer base 2 logarithm operations. + */ + +#ifndef _KERN_LOG2_H +#define _KERN_LOG2_H + +#include <kern/assert.h> + +#ifdef __LP64__ +#define LONG_BIT 64 +#else /* __LP64__ */ +#define LONG_BIT 32 +#endif /* __LP64__ */ + +static inline unsigned int +ilog2(unsigned long x) +{ + assert(x != 0); + return LONG_BIT - __builtin_clzl(x) - 1; +} + +static inline unsigned int +iorder2(unsigned long size) +{ + assert(size != 0); + + if (size == 1) + return 0; + + return ilog2(size - 1) + 1; +} + +#endif /* _KERN_LOG2_H */ diff --git a/kern/slab.h b/kern/slab.h index 77db7c1b..5ff3960e 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -48,6 +48,7 @@ #define _KERN_SLAB_H #include <cache.h> +#include <kern/cpu_number.h> #include <kern/lock.h> #include <kern/list.h> #include <kern/rbtree.h> @@ -56,10 +57,6 @@ #include <vm/vm_types.h> #if SLAB_USE_CPU_POOLS -/* - * L1 cache line size. - */ -#define CPU_L1_SIZE (1 << CPU_L1_SHIFT) /* * Per-processor cache of pre-constructed objects. diff --git a/kern/startup.c b/kern/startup.c index 30cff5c0..bd296943 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -136,7 +136,7 @@ void setup_main(void) mapable_time_init(); machine_info.max_cpus = NCPUS; - machine_info.memory_size = phys_last_addr - phys_first_addr; /* XXX mem_size */ + machine_info.memory_size = vm_page_mem_size(); /* XXX phys_addr_t -> vm_size_t */ machine_info.avail_cpus = 0; machine_info.major_version = KERNEL_MAJOR_VERSION; machine_info.minor_version = KERNEL_MINOR_VERSION; |