Changeset 04803bf in mainline for uspace/lib/c/arch/sparc64


Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes (needs fixes).

Location:
uspace/lib/c/arch/sparc64
Files:
5 added
18 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/sparc64/Makefile.common

    rb50b5af2 r04803bf  
    2727#
    2828
    29 ## Toolchain configuration
    30 #
    31 
    32 TARGET = sparc64-linux-gnu
    33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/sparc64/bin
    34 
    35 ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \
    36         arch/$(UARCH)/src/tls.c
    37 
    38 CFLAGS += -mcpu=ultrasparc -m64
    39 LFLAGS += -no-check-sections -N
     29GCC_CFLAGS += -mcpu=ultrasparc -m64 -mcmodel=medlow
     30LFLAGS = -no-check-sections
    4031
    4132ENDIANESS = BE
     
    4334BFD_NAME = elf64-sparc
    4435BFD_ARCH = sparc
     36
     37ifeq ($(PROCESSOR),us)
     38        DEFS += -DSUN4U
     39endif
     40
     41ifeq ($(PROCESSOR),us3)
     42        DEFS += -DSUN4U
     43endif
     44
     45ifeq ($(PROCESSOR),sun4v)
     46        DEFS += -DSUN4V
     47endif
  • uspace/lib/c/arch/sparc64/_link.ld.in

    rb50b5af2 r04803bf  
    1 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
     1STARTUP(LIBC_PATH/arch/UARCH/src/entry.o)
    22ENTRY(__entry)
    33
     
    99SECTIONS {
    1010        . = 0x4000 + SIZEOF_HEADERS;
    11 
     11       
    1212        .init : {
    1313                *(.init);
    1414        } :text
     15       
    1516        .text : {
    1617                *(.text);
    1718                *(.rodata*);
    1819        } :text
    19 
     20       
    2021        . = . + 0x4000;
    21 
     22       
    2223        .got : {
    2324                 _gp = .;
    2425                 *(.got*);
    2526        } :data
     27       
    2628        .data : {
    2729                *(.data);
    2830                *(.sdata);
    2931        } :data
     32       
    3033        .tdata : {
    3134                _tdata_start = .;
     
    3639                _tbss_end = .;
    3740        } :data
     41       
    3842        _tls_alignment = ALIGNOF(.tdata);
     43       
    3944        .bss : {
    4045                *(.sbss);
     
    4247                *(.bss);
    4348        } :data
    44 
    45         . = ALIGN(0x4000);
    46         _heap = .;
    4749       
    4850        /DISCARD/ : {
    4951                *(*);
    5052        }
    51 
    5253}
  • uspace/lib/c/arch/sparc64/include/atomic.h

    rb50b5af2 r04803bf  
    3636#define LIBC_sparc64_ATOMIC_H_
    3737
     38#define LIBC_ARCH_ATOMIC_H_
     39
     40#include <atomicdflt.h>
    3841#include <sys/types.h>
    3942
     
    4346 *
    4447 * @param val Atomic variable.
    45  * @param i Signed value to be added.
     48 * @param i   Signed value to be added.
    4649 *
    4750 * @return Value of the atomic variable as it existed before addition.
     51 *
    4852 */
    49 static inline long atomic_add(atomic_t *val, int i)
     53static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    5054{
    51         uint64_t a, b;
    52 
     55        atomic_count_t a;
     56        atomic_count_t b;
     57       
    5358        do {
    54                 volatile uintptr_t x = (uint64_t) &val->count;
    55 
    56                 a = *((uint64_t *) x);
     59                volatile uintptr_t ptr = (uintptr_t) &val->count;
     60               
     61                a = *((atomic_count_t *) ptr);
    5762                b = a + i;
    58                 asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)), "+r" (b) : "r" (a));
     63               
     64                asm volatile (
     65                        "casx %0, %2, %1\n"
     66                        : "+m" (*((atomic_count_t *) ptr)),
     67                          "+r" (b)
     68                        : "r" (a)
     69                );
    5970        } while (a != b);
    60 
     71       
    6172        return a;
    6273}
    6374
    64 static inline long atomic_preinc(atomic_t *val)
     75static inline atomic_count_t atomic_preinc(atomic_t *val)
    6576{
    6677        return atomic_add(val, 1) + 1;
    6778}
    6879
    69 static inline long atomic_postinc(atomic_t *val)
     80static inline atomic_count_t atomic_postinc(atomic_t *val)
    7081{
    7182        return atomic_add(val, 1);
    7283}
    7384
    74 static inline long atomic_predec(atomic_t *val)
     85static inline atomic_count_t atomic_predec(atomic_t *val)
    7586{
    7687        return atomic_add(val, -1) - 1;
    7788}
    7889
    79 static inline long atomic_postdec(atomic_t *val)
     90static inline atomic_count_t atomic_postdec(atomic_t *val)
    8091{
    8192        return atomic_add(val, -1);
  • uspace/lib/c/arch/sparc64/include/config.h

    rb50b5af2 r04803bf  
    3636#define LIBC_sparc64_CONFIG_H_
    3737
     38#if defined (SUN4U)
    3839#define PAGE_WIDTH      14
     40#elif defined(SUN4V)
     41#define PAGE_WIDTH      13
     42#endif
     43
    3944#define PAGE_SIZE       (1 << PAGE_WIDTH)
    4045
  • uspace/lib/c/arch/sparc64/include/ddi.h

    rb50b5af2 r04803bf  
    3737#include <libarch/types.h>
    3838
    39 static inline memory_barrier(void)
     39static inline void memory_barrier(void)
    4040{
    41         asm volatile ("membar #LoadLoad | #StoreStore\n" ::: "memory");
     41        asm volatile (
     42                "membar #LoadLoad | #StoreStore\n"
     43                ::: "memory"
     44        );
    4245}
    4346
  • uspace/lib/c/arch/sparc64/include/fibril.h

    rb50b5af2 r04803bf  
    4242#define SP_DELTA        (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE)
    4343
    44 #ifdef context_set
    45 #undef context_set
    46 #endif
    47 
    48 #define context_set(c, _pc, stack, size, ptls)                  \
    49         (c)->pc = ((uintptr_t) _pc) - 8;                        \
    50         (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size),        \
    51                 STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA);     \
    52         (c)->fp = -STACK_BIAS;                                  \
    53         (c)->tp = ptls
     44#define context_set(c, _pc, stack, size, ptls) \
     45        do { \
     46                (c)->pc = ((uintptr_t) _pc) - 8; \
     47                (c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), \
     48                    STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
     49                (c)->fp = -STACK_BIAS; \
     50                (c)->tp = (uint64_t) ptls; \
     51        } while (0)
    5452       
    5553/*
     
    7977} context_t;
    8078
     79static inline uintptr_t context_get_fp(context_t *ctx)
     80{
     81        return ctx->sp + STACK_BIAS;
     82}
     83
    8184#endif
    8285
  • uspace/lib/c/arch/sparc64/include/types.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    3636#define LIBC_sparc64_TYPES_H_
    3737
    38 typedef unsigned long sysarg_t;
     38#define __64_BITS__
    3939
    40 typedef signed char int8_t;
    41 typedef short int int16_t;
    42 typedef int int32_t;
    43 typedef long int int64_t;
     40#include <libarch/common.h>
    4441
    45 typedef unsigned char uint8_t;
    46 typedef unsigned short int uint16_t;
    47 typedef unsigned int uint32_t;
    48 typedef unsigned long int uint64_t;
     42#define SIZE_MIN  UINT64_MIN
     43#define SIZE_MAX  UINT64_MAX
     44
     45#define SSIZE_MIN  INT64_MIN
     46#define SSIZE_MAX  INT64_MAX
     47
     48typedef uint64_t sysarg_t;
    4949
    5050typedef int64_t ssize_t;
     
    5252
    5353typedef uint64_t uintptr_t;
     54typedef uint64_t atomic_count_t;
     55typedef int64_t atomic_signed_t;
    5456
    5557#endif
  • uspace/lib/c/arch/sparc64/src/entry.s

    rb50b5af2 r04803bf  
    3939#
    4040__entry:
     41        #
     42        # Create the first stack frame.
     43        #
     44        save %sp, -176, %sp
     45        flushw
     46        add %g0, -0x7ff, %fp
     47       
    4148        # Pass pcb_ptr as the first argument to __main()
    42         mov %o1, %o0
     49        mov %i1, %o0
    4350        sethi %hi(_gp), %l7
    4451        call __main
    4552        or %l7, %lo(_gp), %l7
    46 
    47         call __exit
    48         nop
  • uspace/lib/c/arch/sparc64/src/fibril.S

    rb50b5af2 r04803bf  
    3535
    3636context_save:
     37        #
     38        # We rely on the kernel to flush our active register windows to memory
     39        # should a thread switch occur.
     40        #
    3741        CONTEXT_SAVE_ARCH_CORE %o0
    3842        retl
     
    4246        #
    4347        # Flush all active windows.
    44         # This is essential, because CONTEXT_LOAD overwrites
    45         # %sp of CWP - 1 with the value written to %fp of CWP.
    46         # Flushing all active windows mitigates this problem
    47         # as CWP - 1 becomes the overlap window.
    48         #               
     48        # This is essential, because CONTEXT_RESTORE_ARCH_CORE overwrites %sp of
     49        # CWP - 1 with the value written to %fp of CWP.  Flushing all active
     50        # windows mitigates this problem as CWP - 1 becomes the overlap window.
     51        #
    4952        flushw
    5053       
  • uspace/lib/c/arch/sparc64/src/thread_entry.s

    rb50b5af2 r04803bf  
    3535#
    3636__thread_entry:
     37        #
     38        # Create the first stack frame.
     39        #
     40        save %sp, -176, %sp
     41        flushw
     42        add %g0, -0x7ff, %fp
     43
     44        #
     45        # Propagate the input arguments to the new window.
     46        #
     47        mov %i0, %o0
     48
    3749        sethi %hi(_gp), %l7
    3850        call __thread_main              ! %o0 contains address of uarg
Note: See TracChangeset for help on using the changeset viewer.