/kernel/trunk/generic/include/config.h |
---|
36,7 → 36,6 |
#define STACK_SIZE PAGE_SIZE |
#define CONFIG_MEMORY_SIZE (8*1024*1024) |
#define CONFIG_HEAP_SIZE (300*1024) |
#define CONFIG_STACK_SIZE STACK_SIZE |
struct config { |
49,11 → 48,7 |
__address init_addr; |
size_t init_size; |
__address heap_addr; |
size_t heap_size; |
size_t heap_delta; /**< Extra space between heap and stack (enforced by alignment requirements) */ |
size_t kernel_size; /**< Size of memory in bytes taken by kernel, heap and stack */ |
size_t kernel_size; /**< Size of memory in bytes taken by kernel and stack */ |
}; |
extern config_t config; |
/kernel/trunk/generic/include/mm/frame.h |
---|
74,11 → 74,11 |
return (pfn_t)(addr >> FRAME_WIDTH); |
} |
static inline pfn_t SIZE2PFN(__address size) |
static inline count_t SIZE2FRAMES(size_t size) |
{ |
if (!size) |
return 0; |
return (pfn_t)((size-1) >> FRAME_WIDTH)+1; |
return (count_t)((size-1) >> FRAME_WIDTH)+1; |
} |
#define IS_BUDDY_ORDER_OK(index, order) ((~(((__native) -1) << (order)) & (index)) == 0) |
95,12 → 95,12 |
__address frame_alloc_generic(__u8 order, int flags, int * status, int *pzone); |
extern void frame_free(__address addr); |
extern void zone_create(pfn_t start, pfn_t count, pfn_t confframe, int flags); |
extern void zone_create(pfn_t start, count_t count, pfn_t confframe, int flags); |
void * frame_get_parent(pfn_t frame, int hint); |
void frame_set_parent(pfn_t frame, void *data, int hint); |
void frame_mark_unavailable(pfn_t start, pfn_t count); |
__address zone_conf_size(pfn_t start, pfn_t count); |
void frame_mark_unavailable(pfn_t start, count_t count); |
__address zone_conf_size(pfn_t start, count_t count); |
/* |
* Console functions |
/kernel/trunk/generic/include/typedefs.h |
---|
34,9 → 34,9 |
typedef short bool; |
typedef unsigned int size_t; |
typedef unsigned int count_t; |
typedef unsigned int index_t; |
typedef unsigned long size_t; |
typedef unsigned long count_t; |
typedef unsigned long index_t; |
typedef struct config config_t; |
typedef struct cpu_info cpu_info_t; |
/kernel/trunk/generic/src/main/kinit.c |
---|
72,7 → 72,7 |
as_t *as; |
as_area_t *a; |
__address frame; |
pfn_t frames; |
count_t frames; |
int i; |
task_t *u; |
165,7 → 165,7 |
if (IS_KA(frame)) |
frame = KA2PA(frame); |
frames = SIZE2PFN(config.init_size); |
frames = SIZE2FRAMES(config.init_size); |
a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS); |
if (!a) |
/kernel/trunk/generic/src/mm/frame.c |
---|
61,7 → 61,7 |
typedef struct { |
SPINLOCK_DECLARE(lock); /**< this lock protects everything below */ |
pfn_t base; /**< frame_no of the first frame in the frames array */ |
pfn_t count; /**< Size of zone */ |
count_t count; /**< Size of zone */ |
frame_t *frames; /**< array of frame_t structures in this zone */ |
count_t free_count; /**< number of free frame_t structures */ |
99,7 → 99,7 |
} |
/** Compute pfn_t from frame_t pointer & zone pointer */ |
static pfn_t make_frame_index(zone_t *zone, frame_t *frame) |
static index_t make_frame_index(zone_t *zone, frame_t *frame) |
{ |
return frame - zone->frames; |
} |
423,7 → 423,7 |
* |
* Assume zone is locked |
*/ |
static void zone_frame_free(zone_t *zone, pfn_t frame_idx) |
static void zone_frame_free(zone_t *zone, index_t frame_idx) |
{ |
frame_t *frame; |
__u8 order; |
445,7 → 445,7 |
} |
/** Return frame from zone */ |
static frame_t * zone_get_frame(zone_t *zone, pfn_t frame_idx) |
static frame_t * zone_get_frame(zone_t *zone, index_t frame_idx) |
{ |
ASSERT(frame_idx < zone->count); |
return &zone->frames[frame_idx]; |
452,7 → 452,7 |
} |
/** Mark frame in zone unavailable to allocation */ |
static void zone_mark_unavailable(zone_t *zone, pfn_t frame_idx) |
static void zone_mark_unavailable(zone_t *zone, index_t frame_idx) |
{ |
frame_t *frame; |
link_t *link; |
475,7 → 475,7 |
* |
* @return Initialized zone. |
*/ |
static zone_t * zone_construct(pfn_t start, pfn_t count, |
static zone_t * zone_construct(pfn_t start, count_t count, |
zone_t *z, int flags) |
{ |
int i; |
516,7 → 516,7 |
/** Compute configuration data size for zone */ |
__address zone_conf_size(pfn_t start, pfn_t count) |
__address zone_conf_size(pfn_t start, count_t count) |
{ |
int size = sizeof(zone_t) + count*sizeof(frame_t); |
int max_order; |
530,17 → 530,16 |
/** Create and add zone to system |
* |
* @param confframe Where configuration frame is supposed to be. |
* Always check, that we will not disturb kernel pages |
* the kernel and possibly init. |
* Always check, that we will not disturb the kernel and possibly init. |
* If confframe is given _outside_ this zone, it is expected, |
* that the area is already marked BUSY and big enough |
* to contain zone_conf_size() amount of data |
*/ |
void zone_create(pfn_t start, pfn_t count, pfn_t confframe, int flags) |
void zone_create(pfn_t start, count_t count, pfn_t confframe, int flags) |
{ |
zone_t *z; |
__address addr,endaddr; |
pfn_t confcount; |
count_t confcount; |
int i; |
/* Theoretically we could have here 0, practically make sure |
551,7 → 550,7 |
/* If conframe is supposed to be inside our zone, then make sure |
* it does not span kernel & init |
*/ |
confcount = SIZE2PFN(zone_conf_size(start,count)); |
confcount = SIZE2FRAMES(zone_conf_size(start,count)); |
if (confframe >= start && confframe < start+count) { |
for (;confframe < start+count;confframe++) { |
addr = PFN2ADDR(confframe); |
699,7 → 698,7 |
/** Mark given range unavailable in frame zones */ |
void frame_mark_unavailable(pfn_t start, pfn_t count) |
void frame_mark_unavailable(pfn_t start, count_t count) |
{ |
int i; |
zone_t *zone; |
729,10 → 728,10 |
frame_arch_init(); |
if (config.cpu_active == 1) { |
frame_mark_unavailable(ADDR2PFN(KA2PA(config.base)), |
SIZE2PFN(config.kernel_size)); |
SIZE2FRAMES(config.kernel_size)); |
if (config.init_size > 0) |
frame_mark_unavailable(ADDR2PFN(KA2PA(config.init_addr)), |
SIZE2PFN(config.init_size)); |
SIZE2FRAMES(config.init_size)); |
} |
} |
/kernel/trunk/arch/sparc64/_link.ld.in |
---|
26,9 → 26,9 |
*(.sdata2); |
*(.sbss); |
hardcoded_ktext_size = .; |
LONG(ktext_end - ktext_start); |
QUAD(ktext_end - ktext_start); |
hardcoded_kdata_size = .; |
LONG(kdata_end - kdata_start); |
QUAD(kdata_end - kdata_start); |
hardcoded_load_address = .; |
QUAD(0x4000); |
*(.bss); /* uninitialized static variables */ |
/kernel/trunk/arch/sparc64/src/mm/frame.c |
---|
29,10 → 29,11 |
#include <arch/mm/frame.h> |
#include <mm/frame.h> |
#include <config.h> |
#include <align.h> |
void frame_arch_init(void) |
{ |
zone_create(0, config.memory_size >> FRAME_WIDTH, 1, 0); |
zone_create(0, config.memory_size >> FRAME_WIDTH, ADDR2PFN(ALIGN_UP(config.base + config.kernel_size + CONFIG_STACK_SIZE, FRAME_SIZE)), 0); |
/* |
* Workaround to prevent slab allocator from allocating frame 0. |
/kernel/trunk/arch/amd64/_link.ld.in |
---|
38,9 → 38,9 |
hardcoded_kdata_size = .; |
QUAD(kdata_end - kdata_start + (unmapped_kdata_end - unmapped_kdata_start)); |
hardcoded_unmapped_ktext_size = .; |
LONG(unmapped_ktext_end - unmapped_ktext_start); |
QUAD(unmapped_ktext_end - unmapped_ktext_start); |
hardcoded_unmapped_kdata_size = .; |
LONG(unmapped_kdata_end - unmapped_kdata_start); |
QUAD(unmapped_kdata_end - unmapped_kdata_start); |
*(COMMON); /* global variables */ |
*(.eh_frame); |
/kernel/trunk/arch/amd64/src/asm_utils.S |
---|
218,4 → 218,4 |
.data |
.global interrupt_handler_size |
interrupt_handler_size: .long (h_end-h_start)/IDT_ITEMS |
interrupt_handler_size: .quad (h_end-h_start)/IDT_ITEMS |
/kernel/trunk/arch/amd64/src/boot/boot.S |
---|
164,6 → 164,7 |
je mods_invalid |
xorq %rdx, %rdx |
movq %rdx, %rcx |
movl 24(%ebx), %esi # mbi->mods_addr |
movl 0(%esi), %edx # mods->mod_start |
movl 4(%esi), %ecx # mods->mod_end |
171,7 → 172,7 |
addq $0xffffffff80000000, %rdx |
mods_invalid: |
movl %ecx, init_size |
movq %rcx, init_size |
movq %rdx, init_addr |
bt $6, %eax # mbi->flags[6] (mmap_length, mmap_addr valid) |
/kernel/trunk/arch/mips32/src/drivers/arc.c |
---|
305,7 → 305,7 |
total += basesize; |
zone_create(ADDR2PFN(base), |
SIZE2PFN(ALIGN_DOWN(basesize,FRAME_SIZE)), |
SIZE2FRAMES(ALIGN_DOWN(basesize,FRAME_SIZE)), |
ADDR2PFN(base),0); |
} |
desc = arc_entry->getmemorydescriptor(desc); |
/kernel/trunk/arch/ia32/src/mm/frame.c |
---|
41,7 → 41,6 |
#include <console/cmd.h> |
#include <console/kconsole.h> |
size_t hardcoded_unmapped_ktext_size = 0; |
size_t hardcoded_unmapped_kdata_size = 0; |
50,13 → 49,14 |
static void init_e820_memory(pfn_t minconf) |
{ |
int i; |
pfn_t start, size,conf; |
pfn_t start, conf; |
size_t size; |
for (i = 0; i < e820counter; i++) { |
if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { |
start = ADDR2PFN(ALIGN_UP(e820table[i].base_address, |
FRAME_SIZE)); |
size = SIZE2PFN(ALIGN_DOWN(e820table[i].size, |
size = SIZE2FRAMES(ALIGN_DOWN(e820table[i].size, |
FRAME_SIZE)); |
if (minconf < start || minconf >= start+size) |
conf = start; |