Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 401 → Rev 402

/SPARTAN/trunk/include/align.h
0,0 → 1,34
/*
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifndef __ALIGN_H__
#define __ALIGN_H__
 
#define ALIGN(s, a) ((s) % (a) ? (((s) / (a)) + 1) * (a) : (s))
 
#endif
/SPARTAN/trunk/src/main/main.c
37,6 → 37,7
#include <proc/task.h>
#include <main/kinit.h>
#include <cpu.h>
#include <align.h>
 
#ifdef __SMP__
#include <arch/smp/apic.h>
85,8 → 86,10
*/
static size_t heap_size;
 
 
/*
* Extra space on heap to make the stack start on page boundary.
* Extra space between heap and stack
* enforced by alignment requirements.
*/
static size_t heap_delta;
 
117,16 → 120,13
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);
heap_delta = kernel_size - (hardcoded_ktext_size + hardcoded_kdata_size + heap_size);
kernel_size = hardcoded_ktext_size + hardcoded_kdata_size + heap_size;
heap_delta = PAGE_SIZE - ((hardcoded_load_address + kernel_size) % PAGE_SIZE);
heap_delta = (heap_delta == PAGE_SIZE) ? 0 : heap_delta;
kernel_size += heap_delta;
config.kernel_size = kernel_size + CONFIG_STACK_SIZE;
context_save(&ctx);
early_mapping(config.base + hardcoded_ktext_size + hardcoded_kdata_size + heap_delta, CONFIG_STACK_SIZE + heap_size);
early_mapping(config.base + hardcoded_ktext_size + hardcoded_kdata_size, CONFIG_STACK_SIZE + heap_size + heap_delta);
context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + kernel_size, CONFIG_STACK_SIZE);
context_restore(&ctx);
/* not reached */
/SPARTAN/trunk/arch/ia64/include/context.h
30,8 → 30,10
#define __ia64_CONTEXT_H__
 
#include <arch/types.h>
#include <align.h>
 
#define STACK_ITEM_SIZE 16
#define STACK_ALIGNMENT 16
 
/*
* context_save() and context_restore() are both leaf procedures.
45,9 → 47,9
#undef context_set
#endif
 
#define context_set(c, _pc, stack, size) \
(c)->pc = (__address) _pc; \
(c)->bsp = ((__address) stack) + (sizeof(the_t)); \
#define context_set(c, _pc, stack, size) \
(c)->pc = (__address) _pc; \
(c)->bsp = ((__address) stack) + (ALIGN(sizeof(the_t), STACK_ALIGNMENT)); \
(c)->sp = ((__address) stack) + (size) - SP_DELTA;
 
/*