Ignore:
Timestamp:
2006-09-03T23:37:14Z (18 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.
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.