Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 563 → Rev 564

/kernel/trunk/generic/include/align.h
29,6 → 29,18
#ifndef __ALIGN_H__
#define __ALIGN_H__
 
#define ALIGN(s, a) ((s) % (a) ? (((s) / (a)) + 1) * (a) : (s))
/** Align to the nearest higher address.
*
* @param s Address or size to be aligned.
* @param a Size of alignment.
*/
#define ALIGN_UP(s, a) ((s) % (a) ? (((s) / (a)) + 1) * (a) : (s))
 
/** Align to the nearest lower address.
*
* @param s Address or size to be aligned.
* @param a Size of alignment.
*/
#define ALIGN_DOWN(s, a) ((s) & ~((a)-1))
 
#endif
/kernel/trunk/generic/include/mm/frame.h
45,7 → 45,9
#define ADDR2FRAME(zone, addr) (&((zone)->frames[((addr) - (zone)->base) / FRAME_SIZE]))
#define FRAME_INDEX(zone, frame) ((index_t)((frame) - (zone)->frames))
#define FRAME_INDEX_VALID(zone, index) (((index) >= 0) && ((index) < ((zone)->free_count + (zone)->busy_count)))
#define IS_BUDDY_LEFT_BLOCK(zone, frame) ((FRAME_INDEX((zone), (frame)) & ~(((__native) -1)<<((frame)->buddy_order + 1))) == 0)
#define IS_BUDDY_ORDER_OK(index, order) ((~(((__native) -1) << (order)) & (index)) == 0)
#define IS_BUDDY_LEFT_BLOCK(zone, frame) (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
#define IS_BUDDY_RIGHT_BLOCK(zone, frame) (((FRAME_INDEX((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
 
#define ZONE_BLACKLIST_SIZE 3
 
/kernel/trunk/generic/src/main/main.c
141,7 → 141,7
config.memory_size = get_memory_size();
 
heap_size = CONFIG_HEAP_SIZE + (config.memory_size/FRAME_SIZE)*sizeof(frame_t);
kernel_size = ALIGN(hardcoded_ktext_size + hardcoded_kdata_size + heap_size, PAGE_SIZE);
kernel_size = ALIGN_UP(hardcoded_ktext_size + hardcoded_kdata_size + heap_size, PAGE_SIZE);
heap_delta = kernel_size - (hardcoded_ktext_size + hardcoded_kdata_size + heap_size);
config.kernel_size = kernel_size + CONFIG_STACK_SIZE;
/kernel/trunk/generic/src/mm/frame.c
1,5 → 1,6
/*
* Copyright (C) 2001-2004 Jakub Jermar
* Copyright (C) 2001-2005 Jakub Jermar
* Copyright (C) 2005 Sergey Bondari
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
225,11 → 226,11
index = zone_blacklist_count++;
 
/* Force base to the nearest lower address frame boundary. */
base &= ~(FRAME_SIZE - 1);
base = ALIGN_DOWN(base, FRAME_SIZE);
/* Align size to frame boundary. */
size = ALIGN(size, FRAME_SIZE);
size = ALIGN_UP(size, FRAME_SIZE);
 
ASSERT(zone_blacklist_count <= ZONE_BLACKLIST_SIZE);
ASSERT(index < ZONE_BLACKLIST_SIZE);
zone_blacklist[index].base = base;
zone_blacklist[index].size = size;
}
284,7 → 285,7
z = zone_create(base, size, 0);
 
if (!z) {
panic("Cannot allocate zone (%dB).\n", size);
panic("Cannot allocate zone (base=%P, size=%d).\n", base, size);
}
zone_attach(z);
393,18 → 394,19
link_t * zone_buddy_find_buddy(buddy_system_t *b, link_t * block) {
frame_t * frame;
zone_t * zone;
count_t index;
index_t index;
bool is_left, is_right;
 
frame = list_get_instance(block, frame_t, buddy_link);
zone = (zone_t *) b->data;
ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX(zone, frame), frame->buddy_order));
is_left = IS_BUDDY_LEFT_BLOCK(zone, frame);
is_right = !is_left;
is_right = IS_BUDDY_RIGHT_BLOCK(zone, frame);
/*
* test left buddy
*/
ASSERT(is_left ^ is_right);
if (is_left) {
index = (FRAME_INDEX(zone, frame)) + (1 << frame->buddy_order);
} else if (is_right) {
430,8 → 432,10
*/
link_t * zone_buddy_bisect(buddy_system_t *b, link_t * block) {
frame_t * frame_l, * frame_r;
 
frame_l = list_get_instance(block, frame_t, buddy_link);
frame_r = (frame_l + (1 << (frame_l->buddy_order - 1)));
return &frame_r->buddy_link;
}
 
445,8 → 449,10
*/
link_t * zone_buddy_coalesce(buddy_system_t *b, link_t * block_1, link_t * block_2) {
frame_t * frame1, * frame2;
frame1 = list_get_instance(block_1, frame_t, buddy_link);
frame2 = list_get_instance(block_2, frame_t, buddy_link);
return frame1 < frame2 ? block_1 : block_2;
}
 
/kernel/trunk/arch/sparc64/include/context.h
30,7 → 30,7
#define __sparc64_CONTEXT_H__
 
#ifndef __sparc64_STACK_H__
#include <arch/stack.h>
# include <arch/stack.h>
#endif
 
#ifndef __sparc64_TYPES_H__
49,7 → 49,7
 
#define context_set(c, _pc, stack, size) \
(c)->pc = ((__address) _pc) - 8; \
(c)->sp = ((__address) stack) + ALIGN((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
(c)->sp = ((__address) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
(c)->fp = -STACK_BIAS
 
/kernel/trunk/arch/ia64/include/context.h
40,7 → 40,7
*
* One item is put onto the stack to support get_stack_base().
*/
#define SP_DELTA (0+ALIGN(STACK_ITEM_SIZE, STACK_ALIGNMENT))
#define SP_DELTA (0+ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
 
#define PFM_MASK (~0x3fffffffff)
 
50,9 → 50,9
 
#define context_set(c, _pc, stack, size) \
(c)->pc = (__address) _pc; \
(c)->bsp = ((__address) stack) + ALIGN(sizeof(the_t), REGISTER_STACK_ALIGNMENT); \
(c)->bsp = ((__address) stack) + ALIGN_UP(sizeof(the_t), REGISTER_STACK_ALIGNMENT); \
(c)->ar_pfs &= PFM_MASK; \
(c)->sp = ((__address) stack) + ALIGN((size), STACK_ALIGNMENT) - SP_DELTA;
(c)->sp = ((__address) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - SP_DELTA;
 
/*
* Only save registers that must be preserved across
/kernel/trunk/arch/ia32/src/mm/frame.c
57,8 → 57,8
for (i = 0; i < e820counter; i++) {
if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
zone_create_in_region(e820table[i].base_address, e820table[i].size & ~(FRAME_SIZE-1));
if (last_frame < ALIGN(e820table[i].base_address + e820table[i].size, FRAME_SIZE))
last_frame = ALIGN(e820table[i].base_address + e820table[i].size, FRAME_SIZE);
if (last_frame < ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE))
last_frame = ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE);
}
}
}