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


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/ia32
Files:
6 added
18 moved

Legend:

Unmodified
Added
Removed
  • 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        #
Note: See TracChangeset for help on using the changeset viewer.