Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1863 → Rev 1864

/trunk/uspace/libc/arch/sparc64/src/entry.s
37,5 → 37,21
#
#
__entry:
sethi %hi(_gp), %l7
call __main
or %l7, %lo(_gp), %l7
call __io_init
nop
call main
nop
call __exit
nop
 
__entry_driver:
sethi %hi(_gp), %l7
call __main
or %l7, %lo(_gp), %l7
call main
nop
call __exit
nop
/trunk/uspace/libc/arch/sparc64/src/thread.c
26,10 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libcsparc64
/** @addtogroup libcsparc64 sparc64
* @ingroup lc
* @{
*/
/** @file
*
*/
 
#include <thread.h>
39,20 → 41,23
*
* @param data Start of data section
* @return pointer to tcb_t structure
*
*/
tcb_t * __alloc_tls(void **data, size_t size)
{
tcb_t *result;
tcb_t *tcb;
*data = malloc(sizeof(tcb_t) + size);
 
result = malloc(sizeof(tcb_t) + size);
*data = ((void *)result) + sizeof(tcb_t);
return result;
tcb = (tcb_t *) (*data + size);
tcb->self = tcb;
 
return tcb;
}
 
void __free_tls_arch(tcb_t *tcb, size_t size)
{
free(tcb);
void *start = ((void *)tcb) - size;
free(start);
}
 
/** @}
/trunk/uspace/libc/arch/sparc64/src/thread_entry.s
1,5 → 1,5
#
# Copyright (C) 2006 Martin Decky
# Copyright (C) 2006 Jakub Jermar
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
34,5 → 34,10
#
#
__thread_entry:
 
sethi %hi(_gp), %l7
call __thread_main ! %o0 contains address of uarg
or %l7, %lo(_gp), %l7
! not reached
.end __thread_entry
/trunk/uspace/libc/arch/sparc64/src/psthread.S
1,5 → 1,5
#
# Copyright (C) 2006 Martin Decky
# Copyright (C) 2005 Jakub Jermar
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
26,14 → 26,80
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
.text
#include <libarch/context_offset.h>
 
/**
* Both context_save_arch() and context_restore_arch() are
* leaf-optimized procedures. This kind of optimization
* is very important and prevents any implicit window
* spill/fill/clean traps in these very core kernel
* functions.
*/
.text
 
.global context_save
.global context_restore
 
#include <libarch/context_offset.h>
.macro CONTEXT_STORE r
stx %sp, [\r + OFFSET_SP]
stx %o7, [\r + OFFSET_PC]
stx %i0, [\r + OFFSET_I0]
stx %i1, [\r + OFFSET_I1]
stx %i2, [\r + OFFSET_I2]
stx %i3, [\r + OFFSET_I3]
stx %i4, [\r + OFFSET_I4]
stx %i5, [\r + OFFSET_I5]
stx %fp, [\r + OFFSET_FP]
stx %i7, [\r + OFFSET_I7]
stx %l0, [\r + OFFSET_L0]
stx %l1, [\r + OFFSET_L1]
stx %l2, [\r + OFFSET_L2]
stx %l3, [\r + OFFSET_L3]
stx %l4, [\r + OFFSET_L4]
stx %l5, [\r + OFFSET_L5]
stx %l6, [\r + OFFSET_L6]
stx %l7, [\r + OFFSET_L7]
stx %g7, [\r + OFFSET_TP]
.endm
 
.macro CONTEXT_LOAD r
ldx [\r + OFFSET_SP], %sp
ldx [\r + OFFSET_PC], %o7
ldx [\r + OFFSET_I0], %i0
ldx [\r + OFFSET_I1], %i1
ldx [\r + OFFSET_I2], %i2
ldx [\r + OFFSET_I3], %i3
ldx [\r + OFFSET_I4], %i4
ldx [\r + OFFSET_I5], %i5
ldx [\r + OFFSET_FP], %fp
ldx [\r + OFFSET_I7], %i7
ldx [\r + OFFSET_L0], %l0
ldx [\r + OFFSET_L1], %l1
ldx [\r + OFFSET_L2], %l2
ldx [\r + OFFSET_L3], %l3
ldx [\r + OFFSET_L4], %l4
ldx [\r + OFFSET_L5], %l5
ldx [\r + OFFSET_L6], %l6
ldx [\r + OFFSET_L7], %l7
ldx [\r + OFFSET_TP], %g7
.endm
 
context_save:
CONTEXT_STORE %o0
retl
mov 1, %o0 ! context_save_arch returns 1
 
 
context_restore:
#
# 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
retl
xor %o0, %o0, %o0 ! context_restore_arch returns 0