Changeset 04803bf in mainline for uspace/lib/c/arch/sparc64
- Timestamp:
- 2011-03-21T22:00:17Z (15 years ago)
- 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. - Location:
- uspace/lib/c/arch/sparc64
- Files:
-
- 5 added
- 18 moved
-
Makefile.common (moved) (moved from uspace/lib/libc/arch/sparc64/Makefile.inc ) (2 diffs)
-
Makefile.inc (added)
-
_link.ld.in (moved) (moved from uspace/lib/libc/arch/sparc64/_link.ld.in ) (4 diffs)
-
include/atomic.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/atomic.h ) (2 diffs)
-
include/config.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/config.h ) (1 diff)
-
include/ddi.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/ddi.h ) (1 diff)
-
include/faddr.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/faddr.h )
-
include/fibril.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/fibril.h ) (2 diffs)
-
include/inttypes.h (added)
-
include/istate.h (added)
-
include/limits.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/limits.h )
-
include/stack.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/stack.h )
-
include/stackarg.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/stackarg.h )
-
include/syscall.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/syscall.h )
-
include/thread.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/thread.h )
-
include/tls.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/tls.h )
-
include/types.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/types.h ) (3 diffs)
-
src/entry.s (moved) (moved from uspace/lib/libc/arch/sparc64/src/entry.s ) (1 diff)
-
src/fibril.S (moved) (moved from uspace/lib/libc/arch/sparc64/src/fibril.S ) (2 diffs)
-
src/stacktrace.c (added)
-
src/stacktrace_asm.S (added)
-
src/thread_entry.s (moved) (moved from uspace/lib/libc/arch/sparc64/src/thread_entry.s ) (1 diff)
-
src/tls.c (moved) (moved from uspace/lib/libc/arch/sparc64/src/tls.c )
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/sparc64/Makefile.common
rb50b5af2 r04803bf 27 27 # 28 28 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 29 GCC_CFLAGS += -mcpu=ultrasparc -m64 -mcmodel=medlow 30 LFLAGS = -no-check-sections 40 31 41 32 ENDIANESS = BE … … 43 34 BFD_NAME = elf64-sparc 44 35 BFD_ARCH = sparc 36 37 ifeq ($(PROCESSOR),us) 38 DEFS += -DSUN4U 39 endif 40 41 ifeq ($(PROCESSOR),us3) 42 DEFS += -DSUN4U 43 endif 44 45 ifeq ($(PROCESSOR),sun4v) 46 DEFS += -DSUN4V 47 endif -
uspace/lib/c/arch/sparc64/_link.ld.in
rb50b5af2 r04803bf 1 STARTUP(LIBC_P REFIX/arch/UARCH/src/entry.o)1 STARTUP(LIBC_PATH/arch/UARCH/src/entry.o) 2 2 ENTRY(__entry) 3 3 … … 9 9 SECTIONS { 10 10 . = 0x4000 + SIZEOF_HEADERS; 11 11 12 12 .init : { 13 13 *(.init); 14 14 } :text 15 15 16 .text : { 16 17 *(.text); 17 18 *(.rodata*); 18 19 } :text 19 20 20 21 . = . + 0x4000; 21 22 22 23 .got : { 23 24 _gp = .; 24 25 *(.got*); 25 26 } :data 27 26 28 .data : { 27 29 *(.data); 28 30 *(.sdata); 29 31 } :data 32 30 33 .tdata : { 31 34 _tdata_start = .; … … 36 39 _tbss_end = .; 37 40 } :data 41 38 42 _tls_alignment = ALIGNOF(.tdata); 43 39 44 .bss : { 40 45 *(.sbss); … … 42 47 *(.bss); 43 48 } :data 44 45 . = ALIGN(0x4000);46 _heap = .;47 49 48 50 /DISCARD/ : { 49 51 *(*); 50 52 } 51 52 53 } -
uspace/lib/c/arch/sparc64/include/atomic.h
rb50b5af2 r04803bf 36 36 #define LIBC_sparc64_ATOMIC_H_ 37 37 38 #define LIBC_ARCH_ATOMIC_H_ 39 40 #include <atomicdflt.h> 38 41 #include <sys/types.h> 39 42 … … 43 46 * 44 47 * @param val Atomic variable. 45 * @param i Signed value to be added.48 * @param i Signed value to be added. 46 49 * 47 50 * @return Value of the atomic variable as it existed before addition. 51 * 48 52 */ 49 static inline long atomic_add(atomic_t *val, int i)53 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i) 50 54 { 51 uint64_t a, b; 52 55 atomic_count_t a; 56 atomic_count_t b; 57 53 58 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); 57 62 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 ); 59 70 } while (a != b); 60 71 61 72 return a; 62 73 } 63 74 64 static inline longatomic_preinc(atomic_t *val)75 static inline atomic_count_t atomic_preinc(atomic_t *val) 65 76 { 66 77 return atomic_add(val, 1) + 1; 67 78 } 68 79 69 static inline longatomic_postinc(atomic_t *val)80 static inline atomic_count_t atomic_postinc(atomic_t *val) 70 81 { 71 82 return atomic_add(val, 1); 72 83 } 73 84 74 static inline longatomic_predec(atomic_t *val)85 static inline atomic_count_t atomic_predec(atomic_t *val) 75 86 { 76 87 return atomic_add(val, -1) - 1; 77 88 } 78 89 79 static inline longatomic_postdec(atomic_t *val)90 static inline atomic_count_t atomic_postdec(atomic_t *val) 80 91 { 81 92 return atomic_add(val, -1); -
uspace/lib/c/arch/sparc64/include/config.h
rb50b5af2 r04803bf 36 36 #define LIBC_sparc64_CONFIG_H_ 37 37 38 #if defined (SUN4U) 38 39 #define PAGE_WIDTH 14 40 #elif defined(SUN4V) 41 #define PAGE_WIDTH 13 42 #endif 43 39 44 #define PAGE_SIZE (1 << PAGE_WIDTH) 40 45 -
uspace/lib/c/arch/sparc64/include/ddi.h
rb50b5af2 r04803bf 37 37 #include <libarch/types.h> 38 38 39 static inline memory_barrier(void)39 static inline void memory_barrier(void) 40 40 { 41 asm volatile ("membar #LoadLoad | #StoreStore\n" ::: "memory"); 41 asm volatile ( 42 "membar #LoadLoad | #StoreStore\n" 43 ::: "memory" 44 ); 42 45 } 43 46 -
uspace/lib/c/arch/sparc64/include/fibril.h
rb50b5af2 r04803bf 42 42 #define SP_DELTA (STACK_WINDOW_SAVE_AREA_SIZE + STACK_ARG_SAVE_AREA_SIZE) 43 43 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) 54 52 55 53 /* … … 79 77 } context_t; 80 78 79 static inline uintptr_t context_get_fp(context_t *ctx) 80 { 81 return ctx->sp + STACK_BIAS; 82 } 83 81 84 #endif 82 85 -
uspace/lib/c/arch/sparc64/include/types.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup libcsparc64 29 /** @addtogroup libcsparc64 30 30 * @{ 31 31 */ … … 36 36 #define LIBC_sparc64_TYPES_H_ 37 37 38 typedef unsigned long sysarg_t; 38 #define __64_BITS__ 39 39 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> 44 41 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 48 typedef uint64_t sysarg_t; 49 49 50 50 typedef int64_t ssize_t; … … 52 52 53 53 typedef uint64_t uintptr_t; 54 typedef uint64_t atomic_count_t; 55 typedef int64_t atomic_signed_t; 54 56 55 57 #endif -
uspace/lib/c/arch/sparc64/src/entry.s
rb50b5af2 r04803bf 39 39 # 40 40 __entry: 41 # 42 # Create the first stack frame. 43 # 44 save %sp, -176, %sp 45 flushw 46 add %g0, -0x7ff, %fp 47 41 48 # Pass pcb_ptr as the first argument to __main() 42 mov % o1, %o049 mov %i1, %o0 43 50 sethi %hi(_gp), %l7 44 51 call __main 45 52 or %l7, %lo(_gp), %l7 46 47 call __exit48 nop -
uspace/lib/c/arch/sparc64/src/fibril.S
rb50b5af2 r04803bf 35 35 36 36 context_save: 37 # 38 # We rely on the kernel to flush our active register windows to memory 39 # should a thread switch occur. 40 # 37 41 CONTEXT_SAVE_ARCH_CORE %o0 38 42 retl … … 42 46 # 43 47 # 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 # 49 52 flushw 50 53 -
uspace/lib/c/arch/sparc64/src/thread_entry.s
rb50b5af2 r04803bf 35 35 # 36 36 __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 37 49 sethi %hi(_gp), %l7 38 50 call __thread_main ! %o0 contains address of uarg
Note:
See TracChangeset
for help on using the changeset viewer.
