Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 1863 → Rev 1864

/trunk/uspace/libc/arch/sparc64/include/context_offset.h
1,4 → 1,22
/* This file is automatically generated by gencontext.c. */
/* struct context */
#define OFFSET_SP 0x0
#define OFFSET_PC 0x8
#define OFFSET_I0 0x10
#define OFFSET_I1 0x18
#define OFFSET_I2 0x20
#define OFFSET_I3 0x28
#define OFFSET_I4 0x30
#define OFFSET_I5 0x38
#define OFFSET_FP 0x40
#define OFFSET_I7 0x48
#define OFFSET_L0 0x50
#define OFFSET_L1 0x58
#define OFFSET_L2 0x60
#define OFFSET_L3 0x68
#define OFFSET_L4 0x70
#define OFFSET_L5 0x78
#define OFFSET_L6 0x80
#define OFFSET_L7 0x88
#define OFFSET_TP 0x90
 
/** @}
*/
/trunk/uspace/libc/arch/sparc64/include/psthread.h
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,35 → 26,56
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libcsparc64
/** @addtogroup libcsparc64
* @{
*/
/** @file
*/
 
#ifndef __LIBC__sparc64__PSTHREAD_H__
#define __LIBC__sparc64__PSTHREAD_H__
#ifndef LIBC_sparc64_PSTHREAD_H_
#define LIBC_sparc64_PSTHREAD_H_
 
#include <libarch/stack.h>
#include <types.h>
#include <align.h>
 
/* We define our own context_set, because we need to set
* the TLS pointer to the tcb+0x7000
*
* See tls_set in thread.h
*/
#define context_set(c, _pc, stack, size, ptls) \
(c)->pc = (sysarg_t) (_pc); \
(c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
(c)->tls = ((sysarg_t) (ptls)) + 0x7000 + sizeof(tcb_t);
#define SP_DELTA STACK_WINDOW_SAVE_AREA_SIZE
 
#define SP_DELTA 16
#ifdef context_set
#undef context_set
#endif
 
#define context_set(c, _pc, stack, size, ptls) \
(c)->pc = ((uintptr_t) _pc) - 8; \
(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
(c)->fp = -STACK_BIAS; \
(c)->tp = ptls
/*
* Only save registers that must be preserved across
* function calls.
*/
typedef struct {
uint64_t sp;
uint64_t pc;
uint64_t tls;
} __attribute__ ((packed)) context_t;
uintptr_t sp; /* %o6 */
uintptr_t pc; /* %o7 */
uint64_t i0;
uint64_t i1;
uint64_t i2;
uint64_t i3;
uint64_t i4;
uint64_t i5;
uintptr_t fp; /* %i6 */
uintptr_t i7;
uint64_t l0;
uint64_t l1;
uint64_t l2;
uint64_t l3;
uint64_t l4;
uint64_t l5;
uint64_t l6;
uint64_t l7;
uint64_t tp; /* %g7 */
} context_t;
 
#endif
 
/trunk/uspace/libc/arch/sparc64/include/syscall.h
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
/** @addtogroup libcsparc64
* @{
*/
/** @file
/trunk/uspace/libc/arch/sparc64/include/atomic.h
1,5 → 1,5
/*
* Copyright (C) 2005 Martin Decky
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,45 → 26,74
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libcsparc64
/** @addtogroup libcsparc64
* @{
*/
/** @file
*/
 
#ifndef __sparc64_ATOMIC_H__
#define __sparc64_ATOMIC_H__
#ifndef LIBC_sparc64_ATOMIC_H_
#define LIBC_sparc64_ATOMIC_H_
 
static inline void atomic_inc(atomic_t *val)
#include <types.h>
 
/** Atomic add operation.
*
* Use atomic compare and swap operation to atomically add signed value.
*
* @param val Atomic variable.
* @param i Signed value to be added.
*
* @return Value of the atomic variable as it existed before addition.
*/
static inline long atomic_add(atomic_t *val, int i)
{
uint64_t a, b;
volatile uint64_t x = (uint64_t) &val->count;
 
__asm__ volatile (
"0:\n"
"ldx %0, %1\n"
"add %1, %3, %2\n"
"casx %0, %1, %2\n"
"cmp %1, %2\n"
"bne 0b\n" /* The operation failed and must be attempted again if a != b. */
"nop\n"
: "=m" (*((uint64_t *)x)), "=r" (a), "=r" (b)
: "r" (i)
);
 
return a;
}
 
static inline void atomic_dec(atomic_t *val)
static inline long atomic_preinc(atomic_t *val)
{
return atomic_add(val, 1) + 1;
}
 
static inline long atomic_postinc(atomic_t *val)
{
atomic_inc(val);
return val->count - 1;
return atomic_add(val, 1);
}
 
static inline long atomic_predec(atomic_t *val)
{
return atomic_add(val, -1) - 1;
}
 
static inline long atomic_postdec(atomic_t *val)
{
atomic_dec(val);
return val->count + 1;
return atomic_add(val, -1);
}
 
static inline long atomic_preinc(atomic_t *val)
static inline void atomic_inc(atomic_t *val)
{
atomic_inc(val);
return val->count;
(void) atomic_add(val, 1);
}
 
static inline long atomic_predec(atomic_t *val)
static inline void atomic_dec(atomic_t *val)
{
atomic_dec(val);
return val->count;
(void) atomic_add(val, -1);
}
 
#endif
/trunk/uspace/libc/arch/sparc64/include/endian.h
26,14 → 26,14
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libcsparc64
/** @addtogroup libcsparc64
* @{
*/
/** @file
*/
 
#ifndef __sparc64_ENDIAN_H__
#define __sparc64_ENDIAN_H__
#ifndef LIBC_sparc64_ENDIAN_H_
#define LIBC_sparc64_ENDIAN_H_
 
#ifndef __LIBC__ENDIAN_H__
# error "Never use <libarch/endian.h> directly - use <endian.h> instead."
43,6 → 43,5
 
#endif
 
/** @}
/** @}
*/
 
/trunk/uspace/libc/arch/sparc64/include/stackarg.h
32,11 → 32,10
/** @file
*/
 
#ifndef __LIBC__STACKARG_H__
#define __LIBC__STACKARG_H__
#ifndef LIBC_sparc64_STACKARG_H_
#define LIBC_sparc64_STACKARG_H_
 
#endif
 
 
/** @}
*/
/trunk/uspace/libc/arch/sparc64/include/limits.h
32,8 → 32,8
/** @file
*/
 
#ifndef __sparc64__LIMITS_H__
#define __sparc64__LIMITS_H__
#ifndef LIBC_sparc64__LIMITS_H_
#define LIBC_sparc64__LIMITS_H_
 
#define LONG_MIN MIN_INT64
#define LONG_MAX MAX_INT64
/trunk/uspace/libc/arch/sparc64/include/types.h
35,12 → 35,12
#ifndef LIBC_sparc64_TYPES_H_
#define LIBC_sparc64_TYPES_H_
 
typedef unsigned int sysarg_t;
typedef unsigned int size_t;
typedef signed int ssize_t;
typedef unsigned long sysarg_t;
typedef unsigned long size_t;
typedef signed long ssize_t;
typedef ssize_t off_t;
 
typedef char int8_t;
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
typedef long int int64_t;
/trunk/uspace/libc/arch/sparc64/include/config.h
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libsparc64
/** @addtogroup libcsparc64
* @{
*/
/** @file
35,7 → 35,7
#ifndef LIBC_sparc64_CONFIG_H_
#define LIBC_sparc64_CONFIG_H_
 
#define PAGE_WIDTH 12
#define PAGE_WIDTH 13
#define PAGE_SIZE (1<<PAGE_WIDTH)
 
#endif
/trunk/uspace/libc/arch/sparc64/include/stack.h
0,0 → 1,56
/*
* 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.
*/
 
/** @addtogroup libcsparc64
* @{
*/
/** @file
*/
 
#ifndef LIBC_sparc64_STACK_H_
#define LIBC_sparc64_STACK_H_
 
#define STACK_ITEM_SIZE 8
 
/** According to SPARC Compliance Definition, every stack frame is 16-byte aligned. */
#define STACK_ALIGNMENT 16
 
/**
* 16-extended-word save area for %i[0-7] and %l[0-7] registers.
*/
#define STACK_WINDOW_SAVE_AREA_SIZE (16*STACK_ITEM_SIZE)
 
/**
* By convention, the actual top of the stack is %sp + STACK_BIAS.
*/
#define STACK_BIAS 2047
 
#endif
 
/** @}
*/
/trunk/uspace/libc/arch/sparc64/include/thread.h
1,5 → 1,6
/*
* Copyright (C) 2006 Martin Decky
* Copyright (C) 2006 Ondrej Palkovsky
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,30 → 27,38
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libcsparc64
/** @addtogroup libcsparc64
* @{
*/
/** @file
/**
* @file
* @brief sparc64 TLS functions.
*
* The implementation is based on the IA-32 implementation which was also
* designed by Sun and is virtually the same, except the TCB is stored in
* %g7 (of the normal set).
*/
 
#ifndef __LIBC__sparc64__THREAD_H__
#define __LIBC__sparc64__THREAD_H__
#ifndef LIBC_sparc64_THREAD_H_
#define LIBC_sparc64_THREAD_H_
 
#define PPC_TP_OFFSET 0x7000
 
typedef struct {
void *self;
void *pst_data;
} tcb_t;
 
static inline void __tcb_set(tcb_t *tcb)
{
void *tp = tcb;
tp += PPC_TP_OFFSET + sizeof(tcb_t);
__asm__ volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7");
}
 
static inline tcb_t *__tcb_get(void)
static inline tcb_t * __tcb_get(void)
{
return (tcb_t *)(PPC_TP_OFFSET - sizeof(tcb_t));
void *retval;
 
__asm__ volatile ("mov %%g7, %0\n" : "=r" (retval));
 
return retval;
}
 
#endif