Changeset 04803bf in mainline for uspace/lib/c/arch/arm32
- 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/arm32
- Files:
-
- 5 added
- 19 moved
-
Makefile.common (added)
-
Makefile.inc (moved) (moved from uspace/lib/libc/arch/arm32/Makefile.inc ) (1 diff)
-
_link.ld.in (moved) (moved from uspace/lib/libc/arch/amd64/_link.ld.in ) (3 diffs)
-
include/atomic.h (moved) (moved from uspace/lib/libc/arch/arm32/include/atomic.h ) (9 diffs)
-
include/config.h (moved) (moved from uspace/lib/libc/arch/arm32/include/config.h )
-
include/ddi.h (moved) (moved from uspace/lib/libc/arch/arm32/include/ddi.h )
-
include/faddr.h (moved) (moved from uspace/lib/libc/arch/arm32/include/faddr.h )
-
include/fibril.h (moved) (moved from uspace/lib/libc/arch/arm32/include/fibril.h ) (2 diffs)
-
include/inttypes.h (added)
-
include/istate.h (added)
-
include/limits.h (moved) (moved from uspace/lib/libc/arch/arm32/include/limits.h )
-
include/stackarg.h (moved) (moved from uspace/lib/libc/arch/arm32/include/stackarg.h )
-
include/syscall.h (moved) (moved from uspace/lib/libc/arch/arm32/include/syscall.h )
-
include/thread.h (moved) (moved from uspace/lib/libc/arch/arm32/include/thread.h )
-
include/tls.h (moved) (moved from uspace/lib/libc/arch/arm32/include/tls.h )
-
include/types.h (moved) (moved from uspace/lib/libc/arch/arm32/include/types.h ) (3 diffs)
-
src/eabi.S (moved) (moved from uspace/lib/libc/arch/arm32/src/eabi.S )
-
src/entry.s (moved) (moved from uspace/lib/libc/arch/arm32/src/entry.s ) (1 diff)
-
src/fibril.S (moved) (moved from uspace/lib/libc/arch/arm32/src/fibril.S )
-
src/stacktrace.c (added)
-
src/stacktrace_asm.S (added)
-
src/syscall.c (moved) (moved from uspace/lib/libc/arch/arm32/src/syscall.c ) (2 diffs)
-
src/thread_entry.s (moved) (moved from uspace/lib/libc/arch/arm32/src/thread_entry.s ) (1 diff)
-
src/tls.c (moved) (moved from uspace/lib/libc/arch/arm32/src/tls.c )
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/arm32/Makefile.inc
rb50b5af2 r04803bf 28 28 # 29 29 30 ## Toolchain configuration 31 # 32 33 TARGET = arm-linux-gnu 34 TOOLCHAIN_DIR = $(CROSS_PREFIX)/arm/bin 35 36 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \ 30 ARCH_SOURCES = \ 31 arch/$(UARCH)/src/entry.s \ 32 arch/$(UARCH)/src/thread_entry.s \ 33 arch/$(UARCH)/src/syscall.c \ 37 34 arch/$(UARCH)/src/fibril.S \ 38 35 arch/$(UARCH)/src/tls.c \ 39 arch/$(UARCH)/src/eabi.S 36 arch/$(UARCH)/src/eabi.S \ 37 arch/$(UARCH)/src/stacktrace.c \ 38 arch/$(UARCH)/src/stacktrace_asm.S 40 39 41 CFLAGS += -ffixed-r9 -mtp=soft 42 LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a 43 44 ENDIANESS = LE 45 46 BFD_NAME = elf32-littlearm 47 BFD_ARCH = arm 40 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/arm32/_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 … … 13 13 *(.init); 14 14 } :text 15 15 16 .text : { 16 17 *(.text); 17 18 *(.rodata*); 18 19 } :text 19 20 20 21 . = . + 0x1000; 21 22 22 23 .data : { 23 *(.data); 24 *(.opd); 25 *(.data .data.*); 26 *(.sdata); 24 27 } :data 28 25 29 .tdata : { 26 30 _tdata_start = .; … … 31 35 _tbss_end = .; 32 36 } :data 37 33 38 _tls_alignment = ALIGNOF(.tdata); 39 34 40 .bss : { 41 *(.sbss); 42 *(.scommon); 35 43 *(COMMON); 36 44 *(.bss); 37 45 } :data 38 39 . = ALIGN(0x1000);40 _heap = .;41 46 42 47 /DISCARD/ : { 43 48 *(*); 44 49 } 45 46 50 } -
uspace/lib/c/arch/arm32/include/atomic.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup libcarm32 29 /** @addtogroup libcarm32 30 30 * @{ 31 31 */ … … 37 37 #define LIBC_arm32_ATOMIC_H_ 38 38 39 #define LIBC_ARCH_ATOMIC_H_ 40 #define CAS 41 42 #include <atomicdflt.h> 43 #include <bool.h> 44 #include <sys/types.h> 45 46 extern uintptr_t *ras_page; 47 48 static inline bool cas(atomic_t *val, atomic_count_t ov, atomic_count_t nv) 49 { 50 atomic_count_t ret = 0; 51 52 /* 53 * The following instructions between labels 1 and 2 constitute a 54 * Restartable Atomic Seqeunce. Should the sequence be non-atomic, 55 * the kernel will restart it. 56 */ 57 asm volatile ( 58 "1:\n" 59 " adr %[ret], 1b\n" 60 " str %[ret], %[rp0]\n" 61 " adr %[ret], 2f\n" 62 " str %[ret], %[rp1]\n" 63 " ldr %[ret], %[addr]\n" 64 " cmp %[ret], %[ov]\n" 65 " streq %[nv], %[addr]\n" 66 "2:\n" 67 " moveq %[ret], #1\n" 68 " movne %[ret], #0\n" 69 : [ret] "+&r" (ret), 70 [rp0] "=m" (ras_page[0]), 71 [rp1] "=m" (ras_page[1]), 72 [addr] "+m" (val->count) 73 : [ov] "r" (ov), 74 [nv] "r" (nv) 75 : "memory" 76 ); 77 78 ras_page[0] = 0; 79 asm volatile ( 80 "" ::: "memory" 81 ); 82 ras_page[1] = 0xffffffff; 83 84 return (bool) ret; 85 } 86 39 87 /** Atomic addition. 40 88 * … … 43 91 * 44 92 * @return Value after addition. 45 */ 46 static inline long atomic_add(atomic_t *val, int i) 47 { 48 int ret; 49 volatile long * mem = &(val->count); 50 51 asm volatile ( 52 "1:\n" 53 "ldr r2, [%1]\n" 54 "add r3, r2, %2\n" 55 "str r3, %0\n" 56 "swp r3, r3, [%1]\n" 57 "cmp r3, r2\n" 58 "bne 1b\n" 59 60 : "=m" (ret) 61 : "r" (mem), "r" (i) 62 : "r3", "r2" 63 ); 64 93 * 94 */ 95 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i) 96 { 97 atomic_count_t ret = 0; 98 99 /* 100 * The following instructions between labels 1 and 2 constitute a 101 * Restartable Atomic Seqeunce. Should the sequence be non-atomic, 102 * the kernel will restart it. 103 */ 104 asm volatile ( 105 "1:\n" 106 " adr %[ret], 1b\n" 107 " str %[ret], %[rp0]\n" 108 " adr %[ret], 2f\n" 109 " str %[ret], %[rp1]\n" 110 " ldr %[ret], %[addr]\n" 111 " add %[ret], %[ret], %[imm]\n" 112 " str %[ret], %[addr]\n" 113 "2:\n" 114 : [ret] "+&r" (ret), 115 [rp0] "=m" (ras_page[0]), 116 [rp1] "=m" (ras_page[1]), 117 [addr] "+m" (val->count) 118 : [imm] "r" (i) 119 ); 120 121 ras_page[0] = 0; 122 asm volatile ( 123 "" ::: "memory" 124 ); 125 ras_page[1] = 0xffffffff; 126 65 127 return ret; 66 128 } … … 70 132 * 71 133 * @param val Variable to be incremented. 134 * 72 135 */ 73 136 static inline void atomic_inc(atomic_t *val) … … 80 143 * 81 144 * @param val Variable to be decremented. 145 * 82 146 */ 83 147 static inline void atomic_dec(atomic_t *val) … … 91 155 * @param val Variable to be incremented. 92 156 * @return Value after incrementation. 93 */ 94 static inline long atomic_preinc(atomic_t *val) 157 * 158 */ 159 static inline atomic_count_t atomic_preinc(atomic_t *val) 95 160 { 96 161 return atomic_add(val, 1); … … 102 167 * @param val Variable to be decremented. 103 168 * @return Value after decrementation. 104 */ 105 static inline long atomic_predec(atomic_t *val) 169 * 170 */ 171 static inline atomic_count_t atomic_predec(atomic_t *val) 106 172 { 107 173 return atomic_add(val, -1); … … 113 179 * @param val Variable to be incremented. 114 180 * @return Value before incrementation. 115 */ 116 static inline long atomic_postinc(atomic_t *val) 181 * 182 */ 183 static inline atomic_count_t atomic_postinc(atomic_t *val) 117 184 { 118 185 return atomic_add(val, 1) - 1; … … 124 191 * @param val Variable to be decremented. 125 192 * @return Value before decrementation. 126 */ 127 static inline long atomic_postdec(atomic_t *val) 193 * 194 */ 195 static inline atomic_count_t atomic_postdec(atomic_t *val) 128 196 { 129 197 return atomic_add(val, -1) + 1; -
uspace/lib/c/arch/arm32/include/fibril.h
rb50b5af2 r04803bf 58 58 * @param ptls Pointer to the TCB. 59 59 */ 60 #define context_set(c, _pc, stack, size, ptls) \ 61 (c)->pc = (sysarg_t) (_pc); \ 62 (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \ 63 (c)->tls = ((sysarg_t)(ptls)) + sizeof(tcb_t) + ARM_TP_OFFSET; 64 60 #define context_set(c, _pc, stack, size, ptls) \ 61 do { \ 62 (c)->pc = (sysarg_t) (_pc); \ 63 (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \ 64 (c)->tls = ((sysarg_t)(ptls)) + sizeof(tcb_t) + ARM_TP_OFFSET; \ 65 (c)->fp = 0; \ 66 } while (0) 65 67 66 68 /** Fibril context. … … 79 81 uint32_t r7; 80 82 uint32_t r8; 81 uint32_t tls; 83 uint32_t tls; /* r9 */ 82 84 uint32_t r10; 83 uint32_t r11;85 uint32_t fp; /* r11 */ 84 86 } context_t; 87 88 static inline uintptr_t context_get_fp(context_t *ctx) 89 { 90 return ctx->fp; 91 } 85 92 86 93 -
uspace/lib/c/arch/arm32/include/types.h
rb50b5af2 r04803bf 27 27 */ 28 28 29 /** @addtogroup libcarm32 29 /** @addtogroup libcarm32 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file 33 33 * @brief Definitions of basic types like #uintptr_t. 34 34 */ … … 37 37 #define LIBC_arm32_TYPES_H_ 38 38 39 typedef unsigned int sysarg_t; 39 #define __32_BITS__ 40 40 41 typedef char int8_t; 42 typedef short int int16_t; 43 typedef long int int32_t; 44 typedef long long int int64_t; 41 #include <libarch/common.h> 45 42 46 typedef unsigned char uint8_t; 47 typedef unsigned short int uint16_t; 48 typedef unsigned long int uint32_t; 49 typedef unsigned long long int uint64_t; 43 #define SIZE_MIN UINT32_MIN 44 #define SIZE_MAX UINT32_MAX 45 46 #define SSIZE_MIN INT32_MIN 47 #define SSIZE_MAX INT32_MAX 48 49 typedef uint32_t sysarg_t; 50 50 51 51 typedef int32_t ssize_t; … … 53 53 54 54 typedef uint32_t uintptr_t; 55 typedef uint32_t atomic_count_t; 56 typedef int32_t atomic_signed_t; 55 57 56 58 #endif -
uspace/lib/c/arch/arm32/src/entry.s
rb50b5af2 r04803bf 36 36 # 37 37 # r1 contains the PCB pointer 38 # r2 contains the RAS page address 38 39 # 39 40 __entry: 41 # Store the RAS page address into the ras_page variable 42 ldr r0, =ras_page 43 str r2, [r0] 44 45 # 46 # Create the first stack frame. 47 # 48 mov fp, #0 49 mov ip, sp 50 push {fp, ip, lr, pc} 51 sub fp, ip, #4 52 40 53 # Pass pcb_ptr to __main as the first argument (in r0) 41 54 mov r0, r1 42 55 bl __main 43 56 44 bl __exit 57 .data 58 59 .global ras_page 60 ras_page: 61 .long 0 -
uspace/lib/c/arch/arm32/src/syscall.c
rb50b5af2 r04803bf 60 60 register sysarg_t __arm_reg_r5 asm("r5") = p6; 61 61 register sysarg_t __arm_reg_r6 asm("r6") = id; 62 63 asm volatile ( "swi" 62 63 asm volatile ( 64 "swi 0" 64 65 : "=r" (__arm_reg_r0) 65 66 : "r" (__arm_reg_r0), … … 71 72 "r" (__arm_reg_r6) 72 73 ); 73 74 74 75 return __arm_reg_r0; 75 76 } -
uspace/lib/c/arch/arm32/src/thread_entry.s
rb50b5af2 r04803bf 35 35 # 36 36 __thread_entry: 37 # 38 # Create the first stack frame. 39 # 40 mov fp, #0 41 mov ip, sp 42 push {fp, ip, lr, pc} 43 sub fp, ip, #4 44 37 45 b __thread_main
Note:
See TracChangeset
for help on using the changeset viewer.
