Changeset 1fbbcd6 in mainline


Ignore:
Timestamp:
2005-08-29T20:31:23Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
81887b7
Parents:
4dd0704
Message:

Globalize 'size' and 'delta' and rename them to 'kernel_size' and 'heap_delta'.

Fix heap initialization to take 'heap_delta' into account.

Implement IA-64 get_stack_base().

Adjust SP_DELTA's to consider one extra word on stack.
(So that the stack pointer is within appropriate limits even on IA-64).

More #include cleanup.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/include/asm.h

    r4dd0704 r1fbbcd6  
    162162 * Return the base address of the current stack.
    163163 * The stack is assumed to be STACK_SIZE bytes long.
     164 * The stack must start on page boundary.
    164165 */
    165166static inline __address get_stack_base(void)
  • arch/ia32/include/context.h

    r4dd0704 r1fbbcd6  
    3232#include <arch/types.h>
    3333
     34#define STACK_ITEM_SIZE 4
     35
    3436/*
    3537 * Both context_save() and context_restore() eat two doublewords from the stack.
    3638 * First for pop of the saved register, second during ret instruction.
     39 *
     40 * One item is put onto stack to support get_stack_base().
    3741 */
    38 #define SP_DELTA        8
     42#define SP_DELTA        (8+STACK_ITEM_SIZE)
    3943
    4044struct context {
  • arch/ia32/include/cpu.h

    r4dd0704 r1fbbcd6  
    3030#define __ia32_CPU_H__
    3131
    32 #include <config.h>
    33 #include <proc/thread.h>
    3432#include <typedefs.h>
    3533#include <arch/pm.h>
  • arch/ia64/include/asm.h

    r4dd0704 r1fbbcd6  
    3333#include <config.h>
    3434
    35 /* TODO: implement the real stuff */
     35/** Return base address of current stack
     36 *
     37 * Return the base address of the current stack.
     38 * The stack is assumed to be STACK_SIZE long.
     39 * The stack must start on page boundary.
     40 */
    3641static inline __address get_stack_base(void)
    3742{
    38         return NULL;
     43        __u64 v;
     44
     45        __asm__ volatile ("and %0 = %1, r12" : "=r" (v) : "r" (~(STACK_SIZE-1)));
     46       
     47        return v;
    3948}
    4049
  • arch/ia64/include/context.h

    r4dd0704 r1fbbcd6  
    3232#include <arch/types.h>
    3333
     34#define STACK_ITEM_SIZE 16
     35
    3436/*
    3537 * context_save() and context_restore() are both leaf procedures.
    3638 * No need to allocate scratch area.
     39 *
     40 * One item is put onto the stack to support get_stack_base().
    3741 */
    38 #define SP_DELTA        0
     42#define SP_DELTA        (0+STACK_ITEM_SIZE)
    3943
    4044#ifdef context_set
  • arch/mips/include/asm.h

    r4dd0704 r1fbbcd6  
    3939 * Return the base address of the current stack.
    4040 * The stack is assumed to be STACK_SIZE bytes long.
     41 * The stack must start on page boundary.
    4142 */
    4243static inline __address get_stack_base(void)
  • arch/mips/include/context.h

    r4dd0704 r1fbbcd6  
    3232#include <arch/types.h>
    3333
    34 #define SP_DELTA        0
     34#define STACK_ITEM_SIZE 4
     35
     36/*
     37 * Put one item onto the stack to support get_stack_base().
     38 */
     39#define SP_DELTA        (0+STACK_ITEM_SIZE)
    3540
    3641
  • src/main/main.c

    r4dd0704 r1fbbcd6  
    7474size_t hardcoded_kdata_size = 0;
    7575
     76/*
     77 * Size of memory in bytes taken by kernel and heap.
     78 */
     79static size_t kernel_size;
     80
     81/*
     82 * Extra space on heap to make the stack start on page boundary.
     83 */
     84static size_t heap_delta;
     85
    7686void main_bsp(void);
    7787void main_ap(void);
     
    8696static void main_ap_separated_stack(void);
    8797
    88 
    8998/** Bootstrap CPU main kernel routine
    9099 *
     
    98107        config.cpu_count = 1;
    99108        config.cpu_active = 1;
    100         size_t size, delta;
    101 
    102         /*
    103          * Calculate 'size' that kernel and heap occupies in memory.
    104          */
    105         size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE;   
    106          
    107         /*
    108          * We need the boot stack to start on page boundary.
    109          * That is why 'delta' is calculated.
    110          */
    111         delta = PAGE_SIZE - ((hardcoded_load_address + size) % PAGE_SIZE);
    112         delta = (delta == PAGE_SIZE) ? 0 : delta;
    113        
    114         size += delta;
     109
     110        kernel_size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE;   
     111        heap_delta = PAGE_SIZE - ((hardcoded_load_address + kernel_size) % PAGE_SIZE);
     112        heap_delta = (heap_delta == PAGE_SIZE) ? 0 : heap_delta;
     113        kernel_size += heap_delta;
    115114
    116115        config.base = hardcoded_load_address;
    117116        config.memory_size = get_memory_size();
    118         config.kernel_size = size + CONFIG_STACK_SIZE;
     117        config.kernel_size = kernel_size + CONFIG_STACK_SIZE;
    119118
    120119        context_save(&ctx);
    121         context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + size, CONFIG_STACK_SIZE);
     120        context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + kernel_size, CONFIG_STACK_SIZE);
    122121        context_restore(&ctx);
    123122        /* not reached */
     
    136135        thread_t *t;
    137136
     137        THE->preemption_disabled = 0;
     138        THE->cpu = NULL;
     139        THE->thread = NULL;
     140        THE->task = NULL;
     141
    138142        arch_pre_mm_init();
    139 
    140         heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, CONFIG_HEAP_SIZE);
     143        heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, CONFIG_HEAP_SIZE + heap_delta);
    141144        frame_init();
    142145        page_init();
Note: See TracChangeset for help on using the changeset viewer.