Changeset 208b5f5 in mainline for kernel/arch/sparc32/include


Ignore:
Timestamp:
2013-12-29T14:32:55Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4c14b88, 6fa9a99d, 9be30cdf, aacdb8e
Parents:
2a13328
Message:

cherrypick important fixes and updates from lp:~jceel/helenos/leon3

Location:
kernel/arch/sparc32/include/arch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc32/include/arch/asm.h

    r2a13328 r208b5f5  
    161161        pil = psr.pil;
    162162       
     163        psr.pil = 0x00;
     164        psr_write(psr.value);
     165       
     166        return pil;
     167}
     168
     169NO_TRACE static inline ipl_t interrupts_disable(void)
     170{
     171        psr_reg_t psr;
     172        psr.value = psr_read();
     173       
     174        ipl_t pil;
     175        pil = psr.pil;
     176       
    163177        psr.pil = 0x0f;
    164178        psr_write(psr.value);
     
    167181}
    168182
    169 NO_TRACE static inline ipl_t interrupts_disable(void)
    170 {
    171         psr_reg_t psr;
    172         psr.value = psr_read();
    173        
    174         ipl_t pil;
    175         pil = psr.pil;
    176        
    177         psr.pil = 0;
    178         psr_write(psr.value);
    179        
    180         return pil;
    181 }
    182 
    183183NO_TRACE static inline void interrupts_restore(ipl_t ipl)
    184184{
     
    200200        psr_reg_t psr;
    201201        psr.value = psr_read();
    202         return psr.pil == 0;
     202        return (psr.pil == 0x0f);
    203203}
    204204
  • kernel/arch/sparc32/include/arch/atomic.h

    r2a13328 r208b5f5  
    3737
    3838#include <typedefs.h>
     39#include <arch/asm.h>
    3940#include <arch/barrier.h>
    4041#include <preemption.h>
     
    4748    REQUIRES(val->count < ATOMIC_COUNT_MAX)
    4849{
    49         // FIXME TODO
     50        // FIXME: Isn't there any intrinsic atomic operation?
     51        ipl_t ipl = interrupts_disable();
    5052        val->count++;
     53        interrupts_restore(ipl);
    5154}
    5255
     
    5659    REQUIRES(val->count > ATOMIC_COUNT_MIN)
    5760{
    58         // FIXME TODO
     61        // FIXME: Isn't there any intrinsic atomic operation?
     62        ipl_t ipl = interrupts_disable();
    5963        val->count--;
     64        interrupts_restore(ipl);
    6065}
    6166
     
    6570    REQUIRES(val->count < ATOMIC_COUNT_MAX)
    6671{
    67         // FIXME TODO
     72        // FIXME: Isn't there any intrinsic atomic operation?
    6873       
     74        ipl_t ipl = interrupts_disable();
    6975        atomic_count_t prev = val->count;
    7076       
    7177        val->count++;
     78        interrupts_restore(ipl);
    7279        return prev;
    7380}
     
    7885    REQUIRES(val->count > ATOMIC_COUNT_MIN)
    7986{
    80         // FIXME TODO
     87        // FIXME: Isn't there any intrinsic atomic operation?
    8188       
     89        ipl_t ipl = interrupts_disable();
    8290        atomic_count_t prev = val->count;
    8391       
    8492        val->count--;
     93        interrupts_restore(ipl);
    8594        return prev;
    8695}
     
    93102    REQUIRES_EXTENT_MUTABLE(val)
    94103{
    95         // FIXME TODO
     104        atomic_count_t prev;
     105        volatile uintptr_t ptr = (uintptr_t) &val->count;
    96106       
    97         atomic_count_t prev = val->count;
    98         val->count = 1;
     107        asm volatile (
     108                "ldstub [%[ptr]] %[prev]\n"
     109                : [prev] "=r" (prev)
     110                : [ptr] "r" (ptr)
     111                : "memory"
     112        );
     113       
    99114        return prev;
    100115}
     
    104119    REQUIRES_EXTENT_MUTABLE(val)
    105120{
    106         // FIXME TODO
     121        atomic_count_t tmp1 = 0;
    107122       
    108         do {
    109                 while (val->count);
    110         } while (test_and_set(val));
     123        volatile uintptr_t ptr = (uintptr_t) &val->count;
     124       
     125        preemption_disable();
     126       
     127        asm volatile (
     128                "0:\n"
     129                        "ldstub %0, %1\n"
     130                        "tst %1\n"
     131                        "be 2f\n"
     132                        "nop\n"
     133                "1:\n"
     134                        "ldub %0, %1\n"
     135                        "tst %1\n"
     136                        "bne 1b\n"
     137                        "nop\n"
     138                        "ba,a 0b\n"
     139                "2:\n"
     140                : "+m" (*((atomic_count_t *) ptr)),
     141                  "+r" (tmp1)
     142                : "r" (0)
     143        );
     144       
     145        /*
     146         * Prevent critical section code from bleeding out this way up.
     147         */
     148        CS_ENTER_BARRIER();
    111149}
    112150
  • kernel/arch/sparc32/include/arch/barrier.h

    r2a13328 r208b5f5  
    3636#define KERN_sparc32_BARRIER_H_
    3737
    38 // FIXME TODO
     38/*
     39 * Provisions are made to prevent compiler from reordering instructions itself.
     40 */
    3941
    40 #define CS_ENTER_BARRIER()
    41 #define CS_LEAVE_BARRIER()
     42#define CS_ENTER_BARRIER() \
     43        asm volatile ( \
     44                "stbar\n" \
     45                ::: "memory" \
     46        )
    4247
    43 #define memory_barrier()
    44 #define read_barrier()
    45 #define write_barrier()
     48#define CS_LEAVE_BARRIER() \
     49        asm volatile ( \
     50                "stbar\n" \
     51                ::: "memory" \
     52        )
     53
     54#define memory_barrier() \
     55        asm volatile ( \
     56                "stbar\n" \
     57                ::: "memory" \
     58        )
     59
     60#define read_barrier() \
     61        asm volatile ( \
     62                "stbar\n" \
     63                ::: "memory" \
     64        )
     65
     66#define write_barrier() \
     67        asm volatile ( \
     68                "stbar\n" \
     69                ::: "memory" \
     70        )
    4671
    4772#define smc_coherence(addr)
  • kernel/arch/sparc32/include/arch/mm/page.h

    r2a13328 r208b5f5  
    7171/* Page table sizes for each level. */
    7272#define PTL0_FRAMES_ARCH  1
    73 #define PTL1_FRAMES_ARCH  0
     73#define PTL1_FRAMES_ARCH  1
    7474#define PTL2_FRAMES_ARCH  1
    7575#define PTL3_FRAMES_ARCH  1
Note: See TracChangeset for help on using the changeset viewer.