Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 527 → Rev 528

/kernel/trunk/tools/sparc64/gencontext.c
34,6 → 34,7
fprintf(f,"#define OFFSET_O5 0x%x\n",((int)&pctx->o5) - (int )pctx);
fprintf(f,"#define OFFSET_SP 0x%x\n",((int)&pctx->sp) - (int )pctx);
fprintf(f,"#define OFFSET_PC 0x%x\n",((int)&pctx->pc) - (int )pctx);
fprintf(f,"#define OFFSET_FP 0x%x\n",((int)&pctx->fp) - (int )pctx);
 
fclose(f);
 
/kernel/trunk/arch/sparc64/include/context_offset.h
7,3 → 7,4
#define OFFSET_O5 0x20
#define OFFSET_SP 0x28
#define OFFSET_PC 0x30
#define OFFSET_FP 0x38
/kernel/trunk/arch/sparc64/include/context.h
47,9 → 47,11
#undef context_set
#endif
 
#define context_set(c, _pc, stack, size) \
(c)->pc = ((__address) _pc) - 8; \
(c)->sp = ((__address) stack) + ALIGN((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA)
#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)->fp = -STACK_BIAS
 
/*
* Only save registers that must be preserved across
64,6 → 66,7
__u64 o5;
__address sp; /* %o6 */
__address pc; /* %o7 */
__address fp;
ipl_t ipl;
};
 
/kernel/trunk/arch/sparc64/src/context.S
28,6 → 28,16
 
#include <arch/context_offset.h>
#include <arch/stack.h>
 
/**
* Both context_save_arch() and context_restore_arch() are
* leaf-optimized procedures. Both of them touch %sp and
* %fp and thus break SCD 2.4 compliance. However, these
* functions are special enough to be allowed this
* kind of behavior. Moreover, this kind of optimization
* is very important and prevents any window spill/
* fill/clean traps in these very core kernel functions.
*/
.text
 
35,36 → 45,42
.global context_restore_arch
 
.macro CONTEXT_STORE r
stx %o1, [\r + OFFSET_I1]
stx %o2, [\r + OFFSET_I2]
stx %o3, [\r + OFFSET_I3]
stx %o4, [\r + OFFSET_I4]
stx %o5, [\r + OFFSET_I5]
stx %o1, [\r + OFFSET_O1]
stx %o2, [\r + OFFSET_O2]
stx %o3, [\r + OFFSET_O3]
stx %o4, [\r + OFFSET_O4]
stx %o5, [\r + OFFSET_O5]
stx %o7, [\r + OFFSET_PC]
stx %sp, [\r + OFFSET_SP]
stx %fp, [\r + OFFSET_FP]
.endm
 
.macro CONTEXT_LOAD r
ldx [\r + OFFSET_I1], %o1
ldx [\r + OFFSET_I2], %o2
ldx [\r + OFFSET_I3], %o3
ldx [\r + OFFSET_I4], %o4
ldx [\r + OFFSET_I5], %o5
ldx [\r + OFFSET_O1], %o1
ldx [\r + OFFSET_O2], %o2
ldx [\r + OFFSET_O3], %o3
ldx [\r + OFFSET_O4], %o4
ldx [\r + OFFSET_O5], %o5
ldx [\r + OFFSET_PC], %o7
ldx [\r + OFFSET_SP], %sp
ldx [\r + OFFSET_FP], %fp
.endm
 
context_save_arch:
CONTEXT_STORE %o0
 
# context_save returns 1
retl
mov 1, %o0
mov 1, %o0 ! context_save_arch returns 1
 
context_restore_arch:
#
# Flush all active windows.
# This is essential, because CONTEXT_LOAD overwrites
# %sp of CWP - 1 with the value written to %fp of CWP.
# Flushing all active windows mitigates this problem
# as CWP - 1 becomes the overlap window.
#
flushw
CONTEXT_LOAD %o0
 
# context_restore returns 0
retl
xor %o0, %o0, %o0
xor %o0, %o0, %o0 ! context_restore_arch returns 0