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


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
Files:
59 added
145 moved

Legend:

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

    rb50b5af2 r04803bf  
    11#
    2 # Copyright (c) 2001-2004 Jakub Jermar
     2# Copyright (c) 2010 Martin Decky
    33# All rights reserved.
    44#
     
    2727#
    2828
    29 .text
    30 .global panic_printf
     29ifeq ($(COMPILER),clang)
     30        CLANG_ARCH = i386
     31endif
    3132
    32 panic_printf:
    33         movl $halt, (%esp)      # fake stack to make printf return to halt
    34         jmp printf
     33ENDIANESS = LE
  • uspace/lib/c/arch/abs32le/_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        . = 0x1000 + SIZEOF_HEADERS;
    11 
    12         .init : {
    13                 *(.init);
    14         } : text
     11       
    1512        .text : {
    1613                *(.text);
    17         *(.rodata*);
     14                *(.rodata*);
    1815        } :text
    19 
     16       
    2017        . = . + 0x1000;
    21 
     18       
    2219        .data : {
    23                 *(.opd);
    24                 *(.data .data.*);
    25                 *(.sdata);
     20                *(.data);
     21                *(.data.rel*);
    2622        } :data
     23       
    2724        .tdata : {
    2825                _tdata_start = .;
    2926                *(.tdata);
     27                *(.gnu.linkonce.tb.*);
    3028                _tdata_end = .;
    3129                _tbss_start = .;
     
    3331                _tbss_end = .;
    3432        } :data
     33       
    3534        _tls_alignment = ALIGNOF(.tdata);
     35       
     36        .sbss : {
     37                *(.scommon);
     38                *(.sbss);
     39        }
     40       
    3641        .bss : {
    37                 *(.sbss);
    38                 *(.scommon);
    39         *(COMMON);
    40         *(.bss);
     42                *(COMMON);
     43                *(.bss);
    4144        } :data
    42        
    43         . = ALIGN(0x1000);
    44         _heap = .;
    4545       
    4646        /DISCARD/ : {
    4747                *(*);
    4848        }
    49 
    5049}
  • uspace/lib/c/arch/abs32le/include/faddr.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
     29/** @addtogroup libabs32le
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef BOOT_GENTYPES_H_
    36 #define BOOT_GENTYPES_H_
     35#ifndef LIBC_abs32le_FADDR_H_
     36#define LIBC_abs32le_FADDR_H_
    3737
    38 #define NULL 0
    39 #define false 0
    40 #define true 1
     38#include <libarch/types.h>
    4139
    42 typedef unsigned long size_t;
     40#define FADDR(fptr)  ((uintptr_t) (fptr))
    4341
    4442#endif
  • uspace/lib/c/arch/abs32le/include/types.h

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2006 Martin Decky
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 
    30 /** @addtogroup arm32boot
     29/** @addtogroup libcabs32le
    3130 * @{
    3231 */
    33 /** @file
    34  *  @brief Definitions of basic types like #uintptr_t.
    35  */
     32/** @file
     33 */
    3634
     35#ifndef LIBC_abs32le_TYPES_H_
     36#define LIBC_abs32le_TYPES_H_
    3737
    38 #ifndef BOOT_arm32_TYPES_H
    39 #define BOOT_arm32_TYPES_H
     38#define __32_BITS__
    4039
     40#include <libarch/common.h>
    4141
    42 #include <gentypes.h>
     42#define SIZE_MIN  UINT32_MIN
     43#define SIZE_MAX  UINT32_MAX
    4344
    44 typedef signed char int8_t;
     45#define SSIZE_MIN  INT32_MIN
     46#define SSIZE_MAX  INT32_MAX
    4547
    46 typedef unsigned char uint8_t;
    47 typedef unsigned short uint16_t;
    48 typedef unsigned int uint32_t;
    49 typedef unsigned long long uint64_t;
     48typedef uint32_t sysarg_t;
     49
     50typedef int32_t ssize_t;
     51typedef uint32_t size_t;
    5052
    5153typedef uint32_t uintptr_t;
    52 typedef uint32_t unative_t;
    53 
     54typedef uint32_t atomic_count_t;
     55typedef int32_t atomic_signed_t;
    5456
    5557#endif
    5658
    57 
    5859/** @}
    5960 */
  • uspace/lib/c/arch/abs32le/src/entry.c

    rb50b5af2 r04803bf  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup arm32debug
    30  * @{
    31  */
    3229/** @file
    33  *  @brief Empty.
    3430 */
    3531
    36 #ifndef KERN_arm32_DEBUG_H_
    37 #define KERN_arm32_DEBUG_H_
     32#include <unistd.h>
     33#include <libarch/entry.h>
     34#include "../../../generic/private/libc.h"
    3835
    39 #endif
     36void __entry(void)
     37{
     38        __main(NULL);
     39}
    4040
    4141/** @}
  • uspace/lib/c/arch/amd64/Makefile.inc

    rb50b5af2 r04803bf  
    2727#
    2828
    29 ## Toolchain configuration
    30 #
    31 
    32 TARGET = i686-pc-linux-gnu
    33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/i686/bin
    34 
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
     29ARCH_SOURCES = \
     30        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/thread_entry.s \
     32        arch/$(UARCH)/src/syscall.S \
    3633        arch/$(UARCH)/src/fibril.S \
    3734        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/setjmp.S
     35        arch/$(UARCH)/src/stacktrace.c \
     36        arch/$(UARCH)/src/stacktrace_asm.S
    3937
    40 LFLAGS += -N
    41 
    42 ENDIANESS = LE
    43 
    44 BFD_NAME = elf32-i386
    45 BFD_ARCH = i386
     38.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/amd64/include/atomic.h

    rb50b5af2 r04803bf  
    3838#define LIBC_amd64_ATOMIC_H_
    3939
    40 static inline void atomic_inc(atomic_t *val) {
    41         asm volatile ("lock incq %0\n" : "+m" (val->count));
     40#define LIBC_ARCH_ATOMIC_H_
     41
     42#include <atomicdflt.h>
     43
     44static inline void atomic_inc(atomic_t *val)
     45{
     46        asm volatile (
     47                "lock incq %[count]\n"
     48                : [count] "+m" (val->count)
     49        );
    4250}
    4351
    44 static inline void atomic_dec(atomic_t *val) {
    45         asm volatile ("lock decq %0\n" : "+m" (val->count));
     52static inline void atomic_dec(atomic_t *val)
     53{
     54        asm volatile (
     55                "lock decq %[count]\n"
     56                : [count] "+m" (val->count)
     57        );
    4658}
    4759
    48 static inline long atomic_postinc(atomic_t *val)
     60static inline atomic_count_t atomic_postinc(atomic_t *val)
    4961{
    50         long r;
    51 
    52         asm volatile (
    53                 "movq $1, %0\n"
    54                 "lock xaddq %0, %1\n"
    55                 : "=r" (r), "+m" (val->count)
    56         );
    57 
    58         return r;
    59 }
    60 
    61 static inline long atomic_postdec(atomic_t *val)
    62 {
    63         long r;
     62        atomic_count_t r = 1;
    6463       
    6564        asm volatile (
    66                 "movq $-1, %0\n"
    67                 "lock xaddq %0, %1\n"
    68                 : "=r" (r), "+m" (val->count)
     65                "lock xaddq %[r], %[count]\n"
     66                : [count] "+m" (val->count),
     67                  [r] "+r" (r)
    6968        );
    7069       
     
    7271}
    7372
    74 #define atomic_preinc(val) (atomic_postinc(val) + 1)
    75 #define atomic_predec(val) (atomic_postdec(val) - 1)
     73static inline atomic_count_t atomic_postdec(atomic_t *val)
     74{
     75        atomic_count_t r = -1;
     76       
     77        asm volatile (
     78                "lock xaddq %[r], %[count]\n"
     79                : [count] "+m" (val->count),
     80                  [r] "+r" (r)
     81        );
     82       
     83        return r;
     84}
     85
     86#define atomic_preinc(val)  (atomic_postinc(val) + 1)
     87#define atomic_predec(val)  (atomic_postdec(val) - 1)
    7688
    7789#endif
  • uspace/lib/c/arch/amd64/include/fibril.h

    rb50b5af2 r04803bf  
    4444#define SP_DELTA     16
    4545
     46#define context_set(c, _pc, stack, size, ptls) \
     47        do { \
     48                (c)->pc = (sysarg_t) (_pc); \
     49                (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
     50                (c)->tls = (sysarg_t) (ptls); \
     51                (c)->rbp = 0; \
     52        } while (0)
     53
    4654/* We include only registers that must be preserved
    4755 * during function call
    4856 */
    4957typedef struct {
    50     uint64_t sp;
    51     uint64_t pc;
    52    
    53     uint64_t rbx;
    54     uint64_t rbp;
     58        uint64_t sp;
     59        uint64_t pc;
    5560
    56     uint64_t r12;
    57     uint64_t r13;
    58     uint64_t r14;
    59     uint64_t r15;
     61        uint64_t rbx;
     62        uint64_t rbp;
    6063
    61     uint64_t tls;
     64        uint64_t r12;
     65        uint64_t r13;
     66        uint64_t r14;
     67        uint64_t r15;
     68
     69        uint64_t tls;
    6270} context_t;
     71
     72static inline uintptr_t context_get_fp(context_t *ctx)
     73{
     74        return ctx->rbp;
     75}
    6376
    6477#endif
  • uspace/lib/c/arch/amd64/include/types.h

    rb50b5af2 r04803bf  
    3636#define LIBC_amd64_TYPES_H_
    3737
    38 typedef unsigned long 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 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 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/amd64/src/entry.s

    rb50b5af2 r04803bf  
    3838#
    3939__entry:
     40        #
     41        # Create the first stack frame.
     42        #
     43        pushq $0
     44        movq %rsp, %rbp
     45       
    4046        # %rdi was deliberately chosen as the first argument is also in %rdi
    4147        # Pass PCB pointer to __main (no operation)
    4248        call __main
    43 
    44         call __exit
  • uspace/lib/c/arch/amd64/src/fibril.S

    rb50b5af2 r04803bf  
    4949        movq %rax, OFFSET_TLS(%rdi)
    5050               
    51         xorq %rax,%rax          # context_save returns 1
    52         incq %rax
     51        xorl %eax, %eax         # context_save returns 1
     52        incl %eax
    5353        ret
    5454
     
    6767        # Set thread local storage
    6868        movq OFFSET_TLS(%rdi), %rdi   # Set arg1 to TLS addr
    69         movq $1, %rax           # SYS_TLS_SET
     69        movl $1, %eax           # SYS_TLS_SET
    7070        syscall
    7171
    72         xorq %rax,%rax          # context_restore returns 0
     72        xorl %eax, %eax         # context_restore returns 0
    7373        ret
  • uspace/lib/c/arch/amd64/src/thread_entry.s

    rb50b5af2 r04803bf  
    3636__thread_entry:
    3737        #
     38        # Create the first stack frame.
     39        #
     40        pushq $0
     41        movq %rsp, %rbp
     42
     43        #
    3844        # RAX contains address of uarg
    3945        #
  • uspace/lib/c/arch/arm32/Makefile.inc

    rb50b5af2 r04803bf  
    2828#
    2929
    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 \
     30ARCH_SOURCES = \
     31        arch/$(UARCH)/src/entry.s \
     32        arch/$(UARCH)/src/thread_entry.s \
     33        arch/$(UARCH)/src/syscall.c \
    3734        arch/$(UARCH)/src/fibril.S \
    3835        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
    4039
    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_PREFIX/arch/UARCH/src/entry.o)
     1STARTUP(LIBC_PATH/arch/UARCH/src/entry.o)
    22ENTRY(__entry)
    33
     
    1313                *(.init);
    1414        } :text
     15       
    1516        .text : {
    1617                *(.text);
    1718                *(.rodata*);
    1819        } :text
    19 
     20       
    2021        . = . + 0x1000;
    21 
     22       
    2223        .data : {
    23                 *(.data);
     24                *(.opd);
     25                *(.data .data.*);
     26                *(.sdata);
    2427        } :data
     28       
    2529        .tdata : {
    2630                _tdata_start = .;
     
    3135                _tbss_end = .;
    3236        } :data
     37       
    3338        _tls_alignment = ALIGNOF(.tdata);
     39       
    3440        .bss : {
     41                *(.sbss);
     42                *(.scommon);
    3543                *(COMMON);
    3644                *(.bss);
    3745        } :data
    38 
    39         . = ALIGN(0x1000);
    40         _heap = .;
    4146       
    4247        /DISCARD/ : {
    4348                *(*);
    4449        }
    45 
    4650}
  • uspace/lib/c/arch/arm32/include/atomic.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcarm32       
     29/** @addtogroup libcarm32
    3030 * @{
    3131 */
     
    3737#define LIBC_arm32_ATOMIC_H_
    3838
     39#define LIBC_ARCH_ATOMIC_H_
     40#define CAS
     41
     42#include <atomicdflt.h>
     43#include <bool.h>
     44#include <sys/types.h>
     45
     46extern uintptr_t *ras_page;
     47
     48static 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
    3987/** Atomic addition.
    4088 *
     
    4391 *
    4492 * @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 */
     95static 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       
    65127        return ret;
    66128}
     
    70132 *
    71133 * @param val Variable to be incremented.
     134 *
    72135 */
    73136static inline void atomic_inc(atomic_t *val)
     
    80143 *
    81144 * @param val Variable to be decremented.
     145 *
    82146 */
    83147static inline void atomic_dec(atomic_t *val)
     
    91155 * @param val Variable to be incremented.
    92156 * @return    Value after incrementation.
    93  */
    94 static inline long atomic_preinc(atomic_t *val)
     157 *
     158 */
     159static inline atomic_count_t atomic_preinc(atomic_t *val)
    95160{
    96161        return atomic_add(val, 1);
     
    102167 * @param val Variable to be decremented.
    103168 * @return    Value after decrementation.
    104  */
    105 static inline long atomic_predec(atomic_t *val)
     169 *
     170 */
     171static inline atomic_count_t atomic_predec(atomic_t *val)
    106172{
    107173        return atomic_add(val, -1);
     
    113179 * @param val Variable to be incremented.
    114180 * @return    Value before incrementation.
    115  */
    116 static inline long atomic_postinc(atomic_t *val)
     181 *
     182 */
     183static inline atomic_count_t atomic_postinc(atomic_t *val)
    117184{
    118185        return atomic_add(val, 1) - 1;
     
    124191 * @param val Variable to be decremented.
    125192 * @return    Value before decrementation.
    126  */
    127 static inline long atomic_postdec(atomic_t *val)
     193 *
     194 */
     195static inline atomic_count_t atomic_postdec(atomic_t *val)
    128196{
    129197        return atomic_add(val, -1) + 1;
  • uspace/lib/c/arch/arm32/include/fibril.h

    rb50b5af2 r04803bf  
    5858 *  @param ptls  Pointer to the TCB.
    5959 */
    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)
    6567
    6668/** Fibril context.
     
    7981        uint32_t r7;
    8082        uint32_t r8;
    81         uint32_t tls;
     83        uint32_t tls;   /* r9 */
    8284        uint32_t r10;
    83         uint32_t r11;
     85        uint32_t fp;    /* r11 */
    8486} context_t;
     87
     88static inline uintptr_t context_get_fp(context_t *ctx)
     89{
     90        return ctx->fp;
     91}
    8592
    8693
  • uspace/lib/c/arch/arm32/include/types.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcarm32       
     29/** @addtogroup libcarm32
    3030 * @{
    3131 */
    32 /** @file 
     32/** @file
    3333 *  @brief Definitions of basic types like #uintptr_t.
    3434 */
     
    3737#define LIBC_arm32_TYPES_H_
    3838
    39 typedef unsigned int sysarg_t;
     39#define __32_BITS__
    4040
    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>
    4542
    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
     49typedef uint32_t sysarg_t;
    5050
    5151typedef int32_t ssize_t;
     
    5353
    5454typedef uint32_t uintptr_t;
     55typedef uint32_t atomic_count_t;
     56typedef int32_t atomic_signed_t;
    5557
    5658#endif
  • uspace/lib/c/arch/arm32/src/entry.s

    rb50b5af2 r04803bf  
    3636#
    3737# r1 contains the PCB pointer
     38# r2 contains the RAS page address
    3839#
    3940__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       
    4053        # Pass pcb_ptr to __main as the first argument (in r0)
    4154        mov r0, r1
    4255        bl __main
    4356
    44         bl __exit
     57.data
     58
     59.global ras_page
     60ras_page:
     61        .long 0
  • uspace/lib/c/arch/arm32/src/syscall.c

    rb50b5af2 r04803bf  
    6060        register sysarg_t __arm_reg_r5 asm("r5") = p6;
    6161        register sysarg_t __arm_reg_r6 asm("r6") = id;
    62 
    63         asm volatile ( "swi"
     62       
     63        asm volatile (
     64                "swi 0"
    6465                : "=r" (__arm_reg_r0)
    6566                : "r" (__arm_reg_r0),
     
    7172                  "r" (__arm_reg_r6)
    7273        );
    73 
     74       
    7475        return __arm_reg_r0;
    7576}
  • uspace/lib/c/arch/arm32/src/thread_entry.s

    rb50b5af2 r04803bf  
    3535#
    3636__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
    3745        b __thread_main
  • uspace/lib/c/arch/ia32/Makefile.inc

    rb50b5af2 r04803bf  
    2727#
    2828
    29 ## Toolchain configuration
    30 #
    31 
    32 TARGET = ia64-pc-linux-gnu
    33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia64/bin
    34 
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
     29ARCH_SOURCES = \
     30        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/thread_entry.s \
     32        arch/$(UARCH)/src/syscall.S \
    3633        arch/$(UARCH)/src/fibril.S \
    3734        arch/$(UARCH)/src/tls.c \
    38         arch/$(UARCH)/src/ddi.c
     35        arch/$(UARCH)/src/setjmp.S \
     36        arch/$(UARCH)/src/stacktrace.c \
     37        arch/$(UARCH)/src/stacktrace_asm.S
    3938
    40 CFLAGS += -fno-unwind-tables
    41 LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a
    42 
    43 ENDIANESS = LE
    44 
    45 BFD_NAME = elf64-ia64-little
    46 BFD_ARCH = ia64-elf64
     39.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ia32/include/atomic.h

    rb50b5af2 r04803bf  
    3636#define LIBC_ia32_ATOMIC_H_
    3737
    38 static inline void atomic_inc(atomic_t *val) {
    39         asm volatile ("lock incl %0\n" : "+m" (val->count));
     38#define LIBC_ARCH_ATOMIC_H_
     39
     40#include <atomicdflt.h>
     41
     42static inline void atomic_inc(atomic_t *val)
     43{
     44        asm volatile (
     45                "lock incl %[count]\n"
     46                : [count] "+m" (val->count)
     47        );
    4048}
    4149
    42 static inline void atomic_dec(atomic_t *val) {
    43         asm volatile ("lock decl %0\n" : "+m" (val->count));
     50static inline void atomic_dec(atomic_t *val)
     51{
     52        asm volatile (
     53                "lock decl %[count]\n"
     54                : [count] "+m" (val->count)
     55        );
    4456}
    4557
    46 static inline long atomic_postinc(atomic_t *val)
     58static inline atomic_count_t atomic_postinc(atomic_t *val)
    4759{
    48         long r;
    49 
    50         asm volatile (
    51                 "movl $1, %0\n"
    52                 "lock xaddl %0, %1\n"
    53                 : "=r" (r), "+m" (val->count)
    54         );
    55 
    56         return r;
    57 }
    58 
    59 static inline long atomic_postdec(atomic_t *val)
    60 {
    61         long r;
     60        atomic_count_t r = 1;
    6261       
    6362        asm volatile (
    64                 "movl $-1, %0\n"
    65                 "lock xaddl %0, %1\n"
    66                 : "=r" (r), "+m" (val->count)
     63                "lock xaddl %[r], %[count]\n"
     64                : [count] "+m" (val->count),
     65                  [r] "+r" (r)
    6766        );
    6867       
     
    7069}
    7170
    72 #define atomic_preinc(val) (atomic_postinc(val) + 1)
    73 #define atomic_predec(val) (atomic_postdec(val) - 1)
     71static inline atomic_count_t atomic_postdec(atomic_t *val)
     72{
     73        atomic_count_t r = -1;
     74       
     75        asm volatile (
     76                "lock xaddl %[r], %[count]\n"
     77                : [count] "+m" (val->count),
     78                  [r] "+r" (r)
     79        );
     80       
     81        return r;
     82}
     83
     84#define atomic_preinc(val)  (atomic_postinc(val) + 1)
     85#define atomic_predec(val)  (atomic_postdec(val) - 1)
    7486
    7587#endif
  • uspace/lib/c/arch/ia32/include/fibril.h

    rb50b5af2 r04803bf  
    4444#define SP_DELTA     (12)
    4545
     46#define context_set(c, _pc, stack, size, ptls) \
     47        do { \
     48                (c)->pc = (sysarg_t) (_pc); \
     49                (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
     50                (c)->tls = (sysarg_t) (ptls); \
     51                (c)->ebp = 0; \
     52        } while (0)
     53       
    4654/* We include only registers that must be preserved
    4755 * during function call
     
    5967} context_t;
    6068
     69static inline uintptr_t context_get_fp(context_t *ctx)
     70{
     71        return ctx->ebp;
     72}
     73
    6174#endif
    6275
  • uspace/lib/c/arch/ia32/include/syscall.h

    rb50b5af2 r04803bf  
    4040#include <kernel/syscall/syscall.h>
    4141
    42 #define __syscall0      __syscall_sysenter
    43 #define __syscall1      __syscall_sysenter
    44 #define __syscall2      __syscall_sysenter
    45 #define __syscall3      __syscall_sysenter
    46 #define __syscall4      __syscall_sysenter
    47 #define __syscall5      __syscall_int
    48 #define __syscall6      __syscall_int
     42#define __syscall0  __syscall_fast_func
     43#define __syscall1  __syscall_fast_func
     44#define __syscall2  __syscall_fast_func
     45#define __syscall3  __syscall_fast_func
     46#define __syscall4  __syscall_fast_func
     47#define __syscall5  __syscall_slow
     48#define __syscall6  __syscall_slow
    4949
    50 extern sysarg_t
    51 __syscall_sysenter(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
    52      const sysarg_t, const sysarg_t, const syscall_t);
     50extern sysarg_t (* __syscall_fast_func)(const sysarg_t, const sysarg_t,
     51    const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
     52    const syscall_t);
    5353
    54 extern sysarg_t
    55 __syscall_int(const sysarg_t, const sysarg_t, const sysarg_t, const sysarg_t,
    56      const sysarg_t, const sysarg_t, const syscall_t);
     54extern sysarg_t __syscall_slow(const sysarg_t, const sysarg_t, const sysarg_t,
     55    const sysarg_t, const sysarg_t, const sysarg_t, const syscall_t);
    5756
    5857#endif
  • uspace/lib/c/arch/ia32/include/tls.h

    rb50b5af2 r04803bf  
    5353{
    5454        void *retval;
    55 
    56         asm ("movl %%gs:0, %0" : "=r"(retval));
     55       
     56        asm (
     57                "movl %%gs:0, %0"
     58                : "=r" (retval)
     59        );
     60       
    5761        return retval;
    5862}
  • uspace/lib/c/arch/ia32/include/types.h

    rb50b5af2 r04803bf  
    3636#define LIBC_ia32_TYPES_H_
    3737
    38 typedef unsigned int sysarg_t;
     38#define __32_BITS__
    3939
    40 typedef char int8_t;
    41 typedef short int int16_t;
    42 typedef int int32_t;
    43 typedef long 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 long int uint64_t;
     42#define SIZE_MIN  UINT32_MIN
     43#define SIZE_MAX  UINT32_MAX
     44
     45#define SSIZE_MIN  INT32_MIN
     46#define SSIZE_MAX  INT32_MAX
     47
     48typedef uint32_t sysarg_t;
    4949
    5050typedef int32_t ssize_t;
     
    5252
    5353typedef uint32_t uintptr_t;
     54typedef uint32_t atomic_count_t;
     55typedef int32_t atomic_signed_t;
    5456
    5557#endif
  • uspace/lib/c/arch/ia32/src/entry.s

    rb50b5af2 r04803bf  
    2727#
    2828
     29INTEL_CPUID_STANDARD = 1
     30INTEL_SEP = 11
     31
    2932.section .init, "ax"
    3033
     
    3538## User-space task entry point
    3639#
    37 # %ebx contains the PCB pointer
     40# %edi contains the PCB pointer
    3841#
    3942__entry:
     
    4346        mov %ax, %fs
    4447        # Do not set %gs, it contains descriptor that can see TLS
    45 
     48       
     49        # Detect the mechanism used for making syscalls
     50        movl $(INTEL_CPUID_STANDARD), %eax
     51        cpuid
     52        bt $(INTEL_SEP), %edx
     53        jnc 0f
     54        leal __syscall_fast_func, %eax
     55        movl $__syscall_fast, (%eax)
     560:
     57        #
     58        # Create the first stack frame.
     59        #
     60        pushl $0
     61        movl %esp, %ebp
     62       
    4663        # Pass the PCB pointer to __main as the first argument
    47         pushl %ebx
     64        pushl %edi
    4865        call __main
    49 
    50         call __exit
  • uspace/lib/c/arch/ia32/src/syscall.S

    rb50b5af2 r04803bf  
    2727#
    2828
     29.data
     30
     31.global __syscall_fast_func
     32__syscall_fast_func:
     33        .long __syscall_slow
     34
    2935.text
    3036
     
    3541 * could benefit from this and not save unused registers on the stack.
    3642 */
    37 .global __syscall_int
    38 __syscall_int:
     43.global __syscall_slow
     44__syscall_slow:
    3945        pushl %ebx
    4046        pushl %esi
     
    6470 * segment, otherwise the SYSENTER wouldn't work in the first place).
    6571 */
    66 .global __syscall_sysenter
    67         .type __syscall_sysenter, @function
     72.global __syscall_fast
     73        .type __syscall_fast, @function
    6874
    69 __syscall_sysenter:
     75__syscall_fast:
    7076        pushl %ebx
    7177        pushl %esi
     
    9298        ret
    9399
    94         .size __syscall_sysenter, . - __syscall_sysenter
     100        .size __syscall_fast, . - __syscall_fast
  • uspace/lib/c/arch/ia32/src/thread_entry.s

    rb50b5af2 r04803bf  
    4242
    4343        #
     44        # Create the first stack frame.
     45        #
     46        pushl $0
     47        mov %esp, %ebp
     48
     49        #
    4450        # EAX contains address of uarg.
    4551        #
  • uspace/lib/c/arch/ia64/_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);
    14         } : text
     14        } :text
     15       
    1516        .text : {
    1617                *(.text);
    1718                *(.rodata*);
    1819        } :text
    19 
     20       
    2021        . = . + 0x4000;
    21 
     22       
    2223        .got : {
    2324                _gp = .;
    2425                *(.got*);
    25         } :data
     26        } :data
     27       
    2628        .data : {
    2729                *(.opd);
     
    2931                *(.sdata);
    3032        } :data
     33       
    3134        .tdata : {
    3235                _tdata_start = .;
     
    3740                _tbss_end = .;
    3841        } :data
     42       
    3943        _tls_alignment = ALIGNOF(.tdata);
     44       
    4045        .bss : {
    4146                *(.sbss);
     
    4449                *(.bss);
    4550        } :data
    46 
    47         . = ALIGN(0x4000);
    48         _heap = .;
    49  
     51       
    5052        /DISCARD/ : {
    5153                *(*);
    52         }
     54        }
    5355}
  • uspace/lib/c/arch/ia64/include/ddi.h

    rb50b5af2 r04803bf  
    3939#include <libarch/types.h>
    4040
    41 #define IO_SPACE_BOUNDARY       (64 * 1024)
     41#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
    4242
    4343uint64_t get_ia64_iospace_address(void);
  • uspace/lib/c/arch/ia64/include/faddr.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcia64       
     29/** @addtogroup libcia64
    3030 * @{
    3131 */
     
    3838#include <libarch/types.h>
    3939
    40 /** 
     40/**
    4141 *
    4242 * Calculate absolute address of function
    4343 * referenced by fptr pointer.
    4444 *
    45  * @param f Function pointer.
     45 * @param fptr Function pointer.
    4646 *
    4747 */
    48 #define FADDR(f)         (*((uintptr_t *)(f)));
     48#define FADDR(fptr)  (((fncptr_t *) (fptr))->fnc)
    4949
    5050#endif
  • uspace/lib/c/arch/ia64/include/fibril.h

    rb50b5af2 r04803bf  
    5353#define PSTHREAD_INITIAL_STACK_DIVISION 2 
    5454
    55 #ifdef context_set
    56 #undef context_set
    57 #endif
    58 
    5955#define context_set(c, _pc, stack, size, tls)                                                           \
    6056        do {                                                                                            \
     
    110106        uint64_t pr;
    111107
    112         __r128 f2 __attribute__ ((aligned(16)));
    113         __r128 f3;
    114         __r128 f4;
    115         __r128 f5;
     108        uint128_t f2 __attribute__ ((aligned(16)));
     109        uint128_t f3;
     110        uint128_t f4;
     111        uint128_t f5;
    116112
    117         __r128 f16;
    118         __r128 f17;
    119         __r128 f18;
    120         __r128 f19;
    121         __r128 f20;
    122         __r128 f21;
    123         __r128 f22;
    124         __r128 f23;
    125         __r128 f24;
    126         __r128 f25;
    127         __r128 f26;
    128         __r128 f27;
    129         __r128 f28;
    130         __r128 f29;
    131         __r128 f30;
    132         __r128 f31;
     113        uint128_t f16;
     114        uint128_t f17;
     115        uint128_t f18;
     116        uint128_t f19;
     117        uint128_t f20;
     118        uint128_t f21;
     119        uint128_t f22;
     120        uint128_t f23;
     121        uint128_t f24;
     122        uint128_t f25;
     123        uint128_t f26;
     124        uint128_t f27;
     125        uint128_t f28;
     126        uint128_t f29;
     127        uint128_t f30;
     128        uint128_t f31;
    133129
    134130} context_t;
     131
     132static inline uintptr_t context_get_fp(context_t *ctx)
     133{
     134        return 0;       /* FIXME */
     135}
    135136
    136137#endif
  • uspace/lib/c/arch/ia64/include/types.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcia64       
     29/** @addtogroup libcia64
    3030 * @{
    3131 */
     
    3636#define LIBC_ia64_TYPES_H_
    3737
    38 typedef unsigned long long sysarg_t;
     38#define __64_BITS__
    3939
    40 typedef 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 struct {
     49        uint64_t lo;
     50        int64_t hi;
     51} int128_t;
     52
     53typedef struct {
     54        uint64_t lo;
     55        uint64_t hi;
     56} uint128_t;
     57
     58typedef uint64_t sysarg_t;
    4959
    5060typedef int64_t ssize_t;
     
    5262
    5363typedef uint64_t uintptr_t;
     64typedef uint64_t atomic_count_t;
     65typedef int64_t atomic_signed_t;
    5466
    55 typedef unsigned char __r8;                     /* Reserve byte */
    56 typedef unsigned short __r16;
    57 typedef unsigned int __r32;
    58 typedef unsigned long __r64;
    59 
    60 typedef struct __r128{
    61         __r64 lo;
    62         __r64 hi;
    63 } __r128;
     67typedef struct {
     68        uintptr_t fnc;
     69        uintptr_t gp;
     70} __attribute__((may_alias)) fncptr_t;
    6471
    6572#endif
  • uspace/lib/c/arch/ia64/src/entry.s

    rb50b5af2 r04803bf  
    3939__entry:
    4040        alloc loc0 = ar.pfs, 0, 1, 2, 0
    41         movl r1 = _gp
    42 
     41        movl gp = _gp
     42       
    4343        # Pass PCB pointer as the first argument to __main
    4444        mov out0 = r2
    4545        br.call.sptk.many b0 = __main
    46 0:
    47         br.call.sptk.many b0 = __exit
  • uspace/lib/c/arch/ia64/src/thread_entry.s

    rb50b5af2 r04803bf  
    3737        alloc loc0 = ar.pfs, 0, 1, 1, 0
    3838
    39         movl r1 = _gp
     39        movl gp = _gp
    4040       
    4141        #
  • uspace/lib/c/arch/mips32/Makefile.inc

    rb50b5af2 r04803bf  
    2727#
    2828
    29 ## Toolchain configuration
    30 #
     29ARCH_SOURCES = \
     30        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/thread_entry.s \
     32        arch/$(UARCH)/src/syscall.c \
     33        arch/$(UARCH)/src/fibril.S \
     34        arch/$(UARCH)/src/tls.c \
     35        arch/$(UARCH)/src/stacktrace.c \
     36        arch/$(UARCH)/src/stacktrace_asm.S
    3137
    32 TARGET = amd64-linux-gnu
    33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64/bin
    34 
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.S \
    36         arch/$(UARCH)/src/fibril.S \
    37         arch/$(UARCH)/src/tls.c
    38 
    39 LFLAGS += -N
    40 
    41 ENDIANESS = LE
    42 
    43 BFD_NAME = elf64-x86-64
    44 BFD_ARCH = i386:x86-64
     38.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/mips32/_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
     
    1313                *(.init);
    1414        } :text
     15       
    1516        .text : {
    16                 *(.text);
     17                *(.text);
    1718                *(.rodata*);
    1819        } :text
    19 
     20       
    2021        . = . + 0x4000;
    21 
     22       
    2223        .data : {
    2324                *(.data);
    2425                *(.data.rel*);
    2526        } :data
    26 
     27       
    2728        .got : {
    2829                _gp = .;
    2930                *(.got);
    3031        } :data
    31 
     32       
    3233        .tdata : {
    3334                _tdata_start = .;
    3435                *(.tdata);
    3536                _tdata_end = .;
     37        } :data
     38       
     39        .tbss : {
    3640                _tbss_start = .;
    3741                *(.tbss);
    3842                _tbss_end = .;
    3943        } :data
    40         _tls_alignment = ALIGNOF(.tdata);
    41 
     44       
     45        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
     46       
    4247        .sbss : {
    4348                *(.scommon);
    4449                *(.sbss);
    45         }       
     50        }
     51       
    4652        .bss : {
    4753                *(.bss);
    4854                *(COMMON);
    4955        } :data
    50 
    51         . = ALIGN(0x4000);
    52         _heap = .;
    53 
     56       
    5457        /DISCARD/ : {
    5558                *(*);
  • uspace/lib/c/arch/mips32/include/atomic.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32eb
    3434 */
    3535
     
    3737#define LIBC_mips32_ATOMIC_H_
    3838
    39 #define atomic_inc(x)   ((void) atomic_add(x, 1))
    40 #define atomic_dec(x)   ((void) atomic_add(x, -1))
     39#define LIBC_ARCH_ATOMIC_H_
    4140
    42 #define atomic_postinc(x) (atomic_add(x, 1) - 1)
    43 #define atomic_postdec(x) (atomic_add(x, -1) + 1)
     41#include <atomicdflt.h>
    4442
    45 #define atomic_preinc(x) atomic_add(x, 1)
    46 #define atomic_predec(x) atomic_add(x, -1)
     43#define atomic_inc(x)  ((void) atomic_add(x, 1))
     44#define atomic_dec(x)  ((void) atomic_add(x, -1))
     45
     46#define atomic_postinc(x)  (atomic_add(x, 1) - 1)
     47#define atomic_postdec(x)  (atomic_add(x, -1) + 1)
     48
     49#define atomic_preinc(x)  atomic_add(x, 1)
     50#define atomic_predec(x)  atomic_add(x, -1)
    4751
    4852/* Atomic addition of immediate value.
    4953 *
    5054 * @param val Memory location to which will be the immediate value added.
    51  * @param i Signed immediate that will be added to *val.
     55 * @param i   Signed immediate that will be added to *val.
    5256 *
    5357 * @return Value after addition.
     58 *
    5459 */
    55 static inline long atomic_add(atomic_t *val, int i)
     60static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    5661{
    57         long tmp, v;
    58 
     62        atomic_count_t tmp;
     63        atomic_count_t v;
     64       
    5965        asm volatile (
    6066                "1:\n"
     
    6672                /*      nop     */              /* nop is inserted automatically by compiler */
    6773                "       nop\n"
    68                 : "=&r" (tmp), "+m" (val->count), "=&r" (v)
    69                 : "r" (i), "i" (0)
    70                 );
    71 
     74                : "=&r" (tmp),
     75                  "+m" (val->count),
     76                  "=&r" (v)
     77                : "r" (i),
     78                  "i" (0)
     79        );
     80       
    7281        return v;
    7382}
  • uspace/lib/c/arch/mips32/include/fibril.h

    rb50b5af2 r04803bf  
    8585} context_t;
    8686
     87static inline uintptr_t context_get_fp(context_t *ctx)
     88{
     89        return ctx->sp;
     90}
     91
    8792#endif
    8893
  • uspace/lib/c/arch/mips32/include/types.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
     
    3737#define LIBC_mips32_TYPES_H_
    3838
    39 typedef unsigned int sysarg_t;
     39#define __32_BITS__
    4040
    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>
    4542
    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
     49typedef uint32_t sysarg_t;
    5050
    5151typedef int32_t ssize_t;
     
    5353
    5454typedef uint32_t uintptr_t;
     55typedef uint32_t atomic_count_t;
     56typedef int32_t atomic_signed_t;
    5557
    5658#endif
  • uspace/lib/c/arch/mips32/src/entry.s

    rb50b5af2 r04803bf  
    2929.text
    3030.section .init, "ax"
     31
    3132.global __entry
    32 .global __entry_driver
     33
    3334.set noreorder
    3435.option pic2
     
    5657        jal __main
    5758        nop
    58        
    59         jal __exit
    60         nop
    6159.end
    62 
    63 # Alignment of output section data to 0x4000
    64 .section .data
    65 .align 14
  • uspace/lib/c/arch/mips32eb/Makefile.inc

    rb50b5af2 r04803bf  
    2727#
    2828
    29 ## Toolchain configuration
    30 #
     29ARCH_SOURCES = \
     30        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/thread_entry.s \
     32        arch/$(UARCH)/src/syscall.c \
     33        arch/$(UARCH)/src/fibril.S \
     34        arch/$(UARCH)/src/tls.c \
     35        arch/$(UARCH)/src/stacktrace.c \
     36        arch/$(UARCH)/src/stacktrace_asm.S
    3137
    32 TARGET = mipsel-linux-gnu
    33 TOOLCHAIN_DIR = $(CROSS_PREFIX)/mipsel/bin
    34 
    35 ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
    36         arch/$(UARCH)/src/fibril.S \
    37         arch/$(UARCH)/src/tls.c
    38 
    39 CFLAGS += -mips3
    40 
    41 ENDIANESS = LE
    42 
    43 BFD_ARCH = mips
    44 BFD_NAME = elf32-tradlittlemips
     38.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ppc32/Makefile.common

    rb50b5af2 r04803bf  
    2727#
    2828
    29 #include "regname.h"
     29GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
     30AFLAGS = -a32
    3031
    31 .section BOOTSTRAP, "ax"
     32ENDIANESS = BE
    3233
    33 .global start
    34 
    35 start:
    36         lis r4, ofw_cif@ha
    37         addi r4, r4, ofw_cif@l
    38         stw r5, 0(r4)
    39        
    40         bl ofw_init
    41        
    42         b bootstrap
     34BFD_NAME = elf32-powerpc
     35BFD_ARCH = powerpc:common
  • uspace/lib/c/arch/ppc32/_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        . = 0x1000 + SIZEOF_HEADERS;
    11 
     11       
    1212        .init : {
    1313                *(.init);
    1414        } :text
     15       
    1516        .text : {
    1617                *(.text);
    1718                *(.rodata*);
    1819        } :text
    19 
     20       
    2021        . = . + 0x1000;
    21 
     22       
    2223        .data : {
    2324                *(.data);
    2425                *(.sdata);
    2526        } :data
     27       
    2628        .tdata : {
    2729                _tdata_start = .;
     
    3234                _tbss_end = .;
    3335        } :data
     36       
    3437        _tls_alignment = ALIGNOF(.tdata);
     38       
    3539        .bss : {
    3640                *(.sbss);
     
    3842                *(.bss);
    3943        } :data
    40 
    41         . = ALIGN(0x1000);
    42         _heap = .;
    4344       
    4445        /DISCARD/ : {
    4546                *(*);
    4647        }
    47 
    4848}
  • uspace/lib/c/arch/ppc32/include/atomic.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcppc32       
     29/** @addtogroup libcppc32
    3030 * @{
    3131 */
     
    3636#define LIBC_ppc32_ATOMIC_H_
    3737
     38#define LIBC_ARCH_ATOMIC_H_
     39
     40#include <atomicdflt.h>
     41
    3842static inline void atomic_inc(atomic_t *val)
    3943{
    40         long tmp;
    41 
     44        atomic_count_t tmp;
     45       
    4246        asm volatile (
    4347                "1:\n"
     
    4650                "stwcx. %0, 0, %2\n"
    4751                "bne- 1b"
    48                 : "=&r" (tmp), "=m" (val->count)
    49                 : "r" (&val->count), "m" (val->count)
    50                 : "cc");
     52                : "=&r" (tmp),
     53                  "=m" (val->count)
     54                : "r" (&val->count),
     55                  "m" (val->count)
     56                : "cc"
     57        );
    5158}
    5259
    5360static inline void atomic_dec(atomic_t *val)
    5461{
    55         long tmp;
    56 
     62        atomic_count_t tmp;
     63       
    5764        asm volatile (
    5865                "1:\n"
    5966                "lwarx %0, 0, %2\n"
    6067                "addic %0, %0, -1\n"
    61                 "stwcx. %0, 0, %2\n"
     68                "stwcx. %0, 0, %2\n"
    6269                "bne- 1b"
    63                 : "=&r" (tmp), "=m" (val->count)
    64                 : "r" (&val->count), "m" (val->count)
    65                 : "cc");
     70                : "=&r" (tmp),
     71                  "=m" (val->count)
     72                : "r" (&val->count),
     73                  "m" (val->count)
     74                : "cc"
     75        );
    6676}
    6777
    68 static inline long atomic_postinc(atomic_t *val)
     78static inline atomic_count_t atomic_postinc(atomic_t *val)
    6979{
    7080        atomic_inc(val);
     
    7282}
    7383
    74 static inline long atomic_postdec(atomic_t *val)
     84static inline atomic_count_t atomic_postdec(atomic_t *val)
    7585{
    7686        atomic_dec(val);
     
    7888}
    7989
    80 static inline long atomic_preinc(atomic_t *val)
     90static inline atomic_count_t atomic_preinc(atomic_t *val)
    8191{
    8292        atomic_inc(val);
     
    8494}
    8595
    86 static inline long atomic_predec(atomic_t *val)
     96static inline atomic_count_t atomic_predec(atomic_t *val)
    8797{
    8898        atomic_dec(val);
  • uspace/lib/c/arch/ppc32/include/fibril.h

    rb50b5af2 r04803bf  
    7878} __attribute__ ((packed)) context_t;
    7979
     80static inline uintptr_t context_get_fp(context_t *ctx)
     81{
     82        return ctx->sp;
     83}
     84
    8085#endif
    8186
  • uspace/lib/c/arch/ppc32/include/types.h

    rb50b5af2 r04803bf  
    2727 */
    2828
    29 /** @addtogroup libcppc32       
     29/** @addtogroup libcppc32
    3030 * @{
    3131 */
     
    3636#define LIBC_ppc32_TYPES_H_
    3737
    38 typedef unsigned int sysarg_t;
     38#define __32_BITS__
    3939
    40 typedef char int8_t;
    41 typedef short int int16_t;
    42 typedef int int32_t;
    43 typedef long 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 long int uint64_t;
     42#define SIZE_MIN  UINT32_MIN
     43#define SIZE_MAX  UINT32_MAX
     44
     45#define SSIZE_MIN  INT32_MIN
     46#define SSIZE_MAX  INT32_MAX
     47
     48typedef uint32_t sysarg_t;
    4949
    5050typedef int32_t ssize_t;
     
    5252
    5353typedef uint32_t uintptr_t;
     54typedef uint32_t atomic_count_t;
     55typedef int32_t atomic_signed_t;
    5456
    5557#endif
  • uspace/lib/c/arch/ppc32/src/entry.s

    rb50b5af2 r04803bf  
    3838#
    3939__entry:
     40        #
     41        # Create the first stack frame.
     42        #
     43        li %r3, 0
     44        stw %r3, 0(%r1)
     45        stwu %r1, -16(%r1)
     46       
    4047        # Pass the PCB pointer to __main() as the first argument.
    4148        # The first argument is passed in r3.
    4249        mr %r3, %r6
    4350        bl __main
    44 
    45         bl __exit
  • uspace/lib/c/arch/ppc32/src/thread_entry.s

    rb50b5af2 r04803bf  
    3535#
    3636__thread_entry:
     37        #
     38        # Create the first stack frame.
     39        #
     40        li %r4, 0
     41        stw %r4, 0(%r1)
     42        stwu %r1, -16(%r1)
     43
    3744        b __thread_main
    3845
  • 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.