Changeset d5d2a3f in mainline


Ignore:
Timestamp:
2005-05-25T12:29:18Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2998046
Parents:
c23fd6b1
Message:

Add context_set() macro to support extended behaviour for architectures with more than one stack (e.g. IA-64).
Now there is one generic context_set() defined in include/context.h and one IA-64 specific defined in arch/ia64/include/context.h.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • arch/ia64/include/context.h

    rc23fd6b1 rd5d2a3f  
    3838#define SP_DELTA        0
    3939
     40#ifdef context_set
     41#undef context_set
     42#endif
     43
     44#define context_set(c, _pc, stack, size)        \
     45        (c)->pc = (__address) _pc;              \
     46        (c)->bsp = (__address) stack;           \
     47        (c)->sp = ((__address) stack) + (size) - SP_DELTA;
     48
    4049struct context {
    4150
     
    4756        __u64 ar_unat_callee;
    4857        __u64 ar_rsc;
    49         __u64 ar_bsp;
     58        __u64 bsp;      /* ar_bsp */
    5059        __u64 ar_rnat;
    5160        __u64 ar_lc;
  • include/context.h

    rc23fd6b1 rd5d2a3f  
    3030#define __CONTEXT_H__
    3131
     32#include <arch/types.h>
    3233#include <typedefs.h>
    33 #include "fpu_context.h"
    3434
     35#ifndef context_set
     36#define context_set(c, _pc, stack, size)        \
     37        (c)->pc = (__address) (_pc);            \
     38        (c)->sp = ((__address) (stack)) + (size) - SP_DELTA;
     39#endif /* context_set */
    3540
    3641extern int context_save(context_t *c);
  • src/main/main.c

    rc23fd6b1 rd5d2a3f  
    2828
    2929#include <arch/asm.h>
    30 #include <arch/context.h>
     30#include <context.h>
    3131#include <print.h>
    3232#include <panic.h>
     
    9595
    9696        context_save(&ctx);
    97         ctx.sp = config.base + config.kernel_size - SP_DELTA;
    98         ctx.pc = FADDR(main_bsp_separated_stack);
     97        context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE, CONFIG_STACK_SIZE);
    9998        context_restore(&ctx);
    10099        /* not reached */
     
    193192         * switch to this cpu's private stack prior to waking kmp up.
    194193         */
    195         CPU->saved_context.sp = (__address) &CPU->stack[CPU_STACK_SIZE-SP_DELTA];
    196         CPU->saved_context.pc = FADDR(main_ap_separated_stack);
     194        context_set(&CPU->saved_context, FADDR(main_ap_separated_stack), CPU->stack, CPU_STACK_SIZE);
    197195        context_restore(&CPU->saved_context);
    198196        /* not reached */
  • src/proc/scheduler.c

    rc23fd6b1 rd5d2a3f  
    233233         */
    234234        context_save(&CPU->saved_context);
    235         CPU->saved_context.sp = (__address) &CPU->stack[CPU_STACK_SIZE-SP_DELTA];
    236         CPU->saved_context.pc = FADDR(scheduler_separated_stack);
     235        context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), CPU->stack, CPU_STACK_SIZE);
    237236        context_restore(&CPU->saved_context);
    238237        /* not reached */
  • src/proc/thread.c

    rc23fd6b1 rd5d2a3f  
    166166               
    167167                context_save(&t->saved_context);
    168                 t->saved_context.pc = FADDR(cushion);
    169                 t->saved_context.sp = (__address) &t->kstack[THREAD_STACK_SIZE-SP_DELTA];
     168                context_set(&t->saved_context, FADDR(cushion), t->kstack, THREAD_STACK_SIZE);
    170169
    171170                pri = cpu_priority_high();
Note: See TracChangeset for help on using the changeset viewer.