Changeset ff3b7da7 in mainline


Ignore:
Timestamp:
2008-11-11T22:11:18Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aa8d0f7
Parents:
f3c4a26
Message:

Accesses to memory mapped registers should use volatile pointers so that
the compiler doesn't even think of trying to be clever. Add memory barriers
and fixed cstyle.

Location:
kernel/arch/sparc64/include
Files:
2 edited

Legend:

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

    rf3c4a26 rff3b7da7  
    4343#include <config.h>
    4444#include <arch/stack.h>
    45 
    46 typedef uint64_t ioport_t;
    47 
    48 
    49 static inline void  outb(ioport_t port,uint8_t v)
    50 {
    51         *((uint8_t *)(port)) = v;
    52 }
    53 
    54 static inline void  outw(ioport_t port,uint16_t v)
    55 {
    56         *((uint16_t *)(port)) = v;
    57 }
    58 
    59 static inline void  outl(ioport_t port,uint32_t v)
    60 {
    61         *((uint32_t *)(port)) = v;
    62 }
    63 
    64 
     45#include <arch/barrier.h>
     46
     47static inline void outb(ioport_t port, uint8_t v)
     48{
     49        *((volatile uint8_t *)(port)) = v;
     50        memory_barrier();
     51}
     52
     53static inline void outw(ioport_t port, uint16_t v)
     54{
     55        *((volatile uint16_t *)(port)) = v;
     56        memory_barrier();
     57}
     58
     59static inline void outl(ioport_t port, uint32_t v)
     60{
     61        *((volatile uint32_t *)(port)) = v;
     62        memory_barrier();
     63}
    6564
    6665static inline uint8_t inb(ioport_t port)
    6766{
    68         return *((uint8_t *)(port));
     67        uint8_t rv;
     68
     69        rv = *((volatile uint8_t *)(port));
     70        memory_barrier();
     71
     72        return rv;
    6973}
    7074
    7175static inline uint16_t inw(ioport_t port)
    7276{
    73         return *((uint16_t *)(port));
     77        uint16_t rv;
     78
     79        rv = *((volatile uint16_t *)(port));
     80        memory_barrier();
     81
     82        return rv;
    7483}
    7584
    7685static inline uint32_t inl(ioport_t port)
    7786{
    78         return *((uint32_t *)(port));
    79 }
    80 
    81 
    82 
    83 
     87        uint32_t rv;
     88
     89        rv = *((volatile uint32_t *)(port));
     90        memory_barrier();
     91
     92        return rv;
     93}
    8494
    8595/** Read Processor State register.
  • kernel/arch/sparc64/include/types.h

    rf3c4a26 rff3b7da7  
    5555typedef uint64_t ipl_t;
    5656
     57typedef uint64_t ioport_t;
     58
    5759typedef uint64_t unative_t;
    5860typedef int64_t native_t;
Note: See TracChangeset for help on using the changeset viewer.