Changeset cfa70add in mainline for uspace/libc/arch/sparc64/include


Ignore:
Timestamp:
2006-09-03T23:37:14Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd85ae5
Parents:
002e613
Message:

sparc64 update.

  • Prototype userspace layer implementation that at least relates to sparc64 and compiles cleanly.
  • Fixes for kernel's preemptible_handler and code related to running userspace.
  • Enable userspace. Several dozen instructions are now run in userspace! We are pretty near the userspace milestone for sparc64.
Location:
uspace/libc/arch/sparc64/include
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/libc/arch/sparc64/include/atomic.h

    r002e613 rcfa70add  
    11/*
    2  * Copyright (C) 2005 Martin Decky
     2 * Copyright (C) 2005 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_ATOMIC_H__
    36 #define __sparc64_ATOMIC_H__
     35#ifndef LIBC_sparc64_ATOMIC_H_
     36#define LIBC_sparc64_ATOMIC_H_
     37
     38#include <types.h>
     39
     40/** Atomic add operation.
     41 *
     42 * Use atomic compare and swap operation to atomically add signed value.
     43 *
     44 * @param val Atomic variable.
     45 * @param i Signed value to be added.
     46 *
     47 * @return Value of the atomic variable as it existed before addition.
     48 */
     49static inline long atomic_add(atomic_t *val, int i)
     50{
     51        uint64_t a, b;
     52        volatile uint64_t x = (uint64_t) &val->count;
     53
     54        __asm__ volatile (
     55                "0:\n"
     56                "ldx %0, %1\n"
     57                "add %1, %3, %2\n"
     58                "casx %0, %1, %2\n"
     59                "cmp %1, %2\n"
     60                "bne 0b\n"              /* The operation failed and must be attempted again if a != b. */
     61                "nop\n"
     62                : "=m" (*((uint64_t *)x)), "=r" (a), "=r" (b)
     63                : "r" (i)
     64        );
     65
     66        return a;
     67}
     68
     69static inline long atomic_preinc(atomic_t *val)
     70{
     71        return atomic_add(val, 1) + 1;
     72}
     73
     74static inline long atomic_postinc(atomic_t *val)
     75{
     76        return atomic_add(val, 1);
     77}
     78
     79static inline long atomic_predec(atomic_t *val)
     80{
     81        return atomic_add(val, -1) - 1;
     82}
     83
     84static inline long atomic_postdec(atomic_t *val)
     85{
     86        return atomic_add(val, -1);
     87}
    3788
    3889static inline void atomic_inc(atomic_t *val)
    3990{
     91        (void) atomic_add(val, 1);
    4092}
    4193
    4294static inline void atomic_dec(atomic_t *val)
    4395{
    44 }
    45 
    46 static inline long atomic_postinc(atomic_t *val)
    47 {
    48         atomic_inc(val);
    49         return val->count - 1;
    50 }
    51 
    52 static inline long atomic_postdec(atomic_t *val)
    53 {
    54         atomic_dec(val);
    55         return val->count + 1;
    56 }
    57 
    58 static inline long atomic_preinc(atomic_t *val)
    59 {
    60         atomic_inc(val);
    61         return val->count;
    62 }
    63 
    64 static inline long atomic_predec(atomic_t *val)
    65 {
    66         atomic_dec(val);
    67         return val->count;
     96        (void) atomic_add(val, -1);
    6897}
    6998
  • uspace/libc/arch/sparc64/include/config.h

    r002e613 rcfa70add  
    2727 */
    2828
    29 /** @addtogroup libsparc64
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    3636#define LIBC_sparc64_CONFIG_H_
    3737
    38 #define PAGE_WIDTH      12
     38#define PAGE_WIDTH      13
    3939#define PAGE_SIZE       (1<<PAGE_WIDTH)
    4040
  • uspace/libc/arch/sparc64/include/context_offset.h

    r002e613 rcfa70add  
     1/* This file is automatically generated by gencontext.c. */
    12/* struct context */
     3#define OFFSET_SP       0x0
     4#define OFFSET_PC       0x8
     5#define OFFSET_I0       0x10
     6#define OFFSET_I1       0x18
     7#define OFFSET_I2       0x20
     8#define OFFSET_I3       0x28
     9#define OFFSET_I4       0x30
     10#define OFFSET_I5       0x38
     11#define OFFSET_FP       0x40
     12#define OFFSET_I7       0x48
     13#define OFFSET_L0       0x50
     14#define OFFSET_L1       0x58
     15#define OFFSET_L2       0x60
     16#define OFFSET_L3       0x68
     17#define OFFSET_L4       0x70
     18#define OFFSET_L5       0x78
     19#define OFFSET_L6       0x80
     20#define OFFSET_L7       0x88
     21#define OFFSET_TP       0x90
    222
    3 /** @}
    4  */
  • uspace/libc/arch/sparc64/include/endian.h

    r002e613 rcfa70add  
    2727 */
    2828
    29  /** @addtogroup libcsparc64   
     29/** @addtogroup libcsparc64     
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __sparc64_ENDIAN_H__
    36 #define __sparc64_ENDIAN_H__
     35#ifndef LIBC_sparc64_ENDIAN_H_
     36#define LIBC_sparc64_ENDIAN_H_
    3737
    3838#ifndef __LIBC__ENDIAN_H__
     
    4444#endif
    4545
    46  /** @}
     46/** @}
    4747 */
    48 
  • uspace/libc/arch/sparc64/include/limits.h

    r002e613 rcfa70add  
    3333 */
    3434
    35 #ifndef __sparc64__LIMITS_H__
    36 #define __sparc64__LIMITS_H__
     35#ifndef LIBC_sparc64__LIMITS_H_
     36#define LIBC_sparc64__LIMITS_H_
    3737
    3838#define LONG_MIN MIN_INT64
  • uspace/libc/arch/sparc64/include/psthread.h

    r002e613 rcfa70add  
    11/*
    2  * Copyright (C) 2006 Martin Decky
     2 * Copyright (C) 2005 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libcsparc64     
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef __LIBC__sparc64__PSTHREAD_H__
    36 #define __LIBC__sparc64__PSTHREAD_H__
     35#ifndef LIBC_sparc64_PSTHREAD_H_
     36#define LIBC_sparc64_PSTHREAD_H_
    3737
     38#include <libarch/stack.h>
    3839#include <types.h>
     40#include <align.h>
    3941
    40 /* We define our own context_set, because we need to set
    41  * the TLS pointer to the tcb+0x7000
    42  *
    43  * See tls_set in thread.h
     42#define SP_DELTA        STACK_WINDOW_SAVE_AREA_SIZE
     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), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA);    \
     51        (c)->fp = -STACK_BIAS;                                                                          \
     52        (c)->tp = ptls
     53       
     54/*
     55 * Only save registers that must be preserved across
     56 * function calls.
    4457 */
    45 #define context_set(c, _pc, stack, size, ptls)                  \
    46         (c)->pc = (sysarg_t) (_pc);                             \
    47         (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA;     \
    48         (c)->tls = ((sysarg_t) (ptls)) + 0x7000 + sizeof(tcb_t);
    49 
    50 #define SP_DELTA        16
    51 
    5258typedef struct {
    53         uint64_t sp;
    54         uint64_t pc;
    55        
    56         uint64_t tls;
    57 } __attribute__ ((packed)) context_t;
     59        uintptr_t sp;           /* %o6 */
     60        uintptr_t pc;           /* %o7 */
     61        uint64_t i0;
     62        uint64_t i1;
     63        uint64_t i2;
     64        uint64_t i3;
     65        uint64_t i4;
     66        uint64_t i5;
     67        uintptr_t fp;           /* %i6 */
     68        uintptr_t i7;
     69        uint64_t l0;
     70        uint64_t l1;
     71        uint64_t l2;
     72        uint64_t l3;
     73        uint64_t l4;
     74        uint64_t l5;
     75        uint64_t l6;
     76        uint64_t l7;
     77        uint64_t tp;            /* %g7 */
     78} context_t;
    5879
    5980#endif
  • uspace/libc/arch/sparc64/include/stackarg.h

    r002e613 rcfa70add  
    3333 */
    3434
    35 #ifndef __LIBC__STACKARG_H__
    36 #define __LIBC__STACKARG_H__
     35#ifndef LIBC_sparc64_STACKARG_H_
     36#define LIBC_sparc64_STACKARG_H_
    3737
    3838#endif
    3939
    40 
    4140/** @}
    4241 */
  • uspace/libc/arch/sparc64/include/syscall.h

    r002e613 rcfa70add  
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup libcsparc64
    3030 * @{
    3131 */
  • uspace/libc/arch/sparc64/include/thread.h

    r002e613 rcfa70add  
    11/*
    2  * Copyright (C) 2006 Martin Decky
     2 * Copyright (C) 2006 Ondrej Palkovsky
     3 * Copyright (C) 2006 Jakub Jermar
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup libcsparc64     
     30/** @addtogroup libcsparc64
    3031 * @{
    3132 */
    32 /** @file
     33/**
     34 * @file
     35 * @brief       sparc64 TLS functions.
     36 *
     37 * The implementation is based on the IA-32 implementation which was also
     38 * designed by Sun and is virtually the same, except the TCB is stored in
     39 * %g7 (of the normal set).
    3340 */
    3441
    35 #ifndef __LIBC__sparc64__THREAD_H__
    36 #define __LIBC__sparc64__THREAD_H__
    37 
    38 #define PPC_TP_OFFSET 0x7000
     42#ifndef LIBC_sparc64_THREAD_H_
     43#define LIBC_sparc64_THREAD_H_
    3944
    4045typedef struct {
     46        void *self;
    4147        void *pst_data;
    4248} tcb_t;
     
    4450static inline void __tcb_set(tcb_t *tcb)
    4551{
    46         void *tp = tcb;
    47         tp += PPC_TP_OFFSET + sizeof(tcb_t);
     52        __asm__ volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7");
    4853}
    4954
    50 static inline tcb_t *__tcb_get(void)
     55static inline tcb_t * __tcb_get(void)
    5156{
    52         return (tcb_t *)(PPC_TP_OFFSET - sizeof(tcb_t));
     57        void *retval;
     58
     59        __asm__ volatile ("mov %%g7, %0\n" : "=r" (retval));
     60
     61        return retval;
    5362}
    5463
  • uspace/libc/arch/sparc64/include/types.h

    r002e613 rcfa70add  
    3636#define LIBC_sparc64_TYPES_H_
    3737
    38 typedef unsigned int sysarg_t;
    39 typedef unsigned int size_t;
    40 typedef signed int ssize_t;
     38typedef unsigned long sysarg_t;
     39typedef unsigned long size_t;
     40typedef signed long ssize_t;
    4141typedef ssize_t off_t;
    4242
    43 typedef char int8_t;
     43typedef signed char int8_t;
    4444typedef short int int16_t;
    4545typedef int int32_t;
Note: See TracChangeset for help on using the changeset viewer.