Changeset abf04a54 in mainline for kernel/arch


Ignore:
Timestamp:
2011-08-20T13:39:25Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e6577c
Parents:
a0fc4be (diff), 667a4f8 (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 PIO improvement from Zdenek Bouska.

Location:
kernel/arch
Files:
2 edited

Legend:

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

    ra0fc4be rabf04a54  
    7777}
    7878
     79#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
     80
    7981/** Byte from port
    8082 *
     
    8789NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
    8890{
    89         uint8_t val;
    90        
    91         asm volatile (
    92                 "inb %w[port], %b[val]\n"
    93                 : [val] "=a" (val)
    94                 : [port] "d" (port)
    95         );
    96        
    97         return val;
     91        if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
     92                uint8_t val;
     93                asm volatile (
     94                        "inb %w[port], %b[val]\n"
     95                        : [val] "=a" (val)
     96                        : [port] "d" (port)
     97                );
     98                return val;
     99        } else {
     100                return (uint8_t) *port;
     101        }
    98102}
    99103
     
    108112NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
    109113{
    110         uint16_t val;
    111        
    112         asm volatile (
    113                 "inw %w[port], %w[val]\n"
    114                 : [val] "=a" (val)
    115                 : [port] "d" (port)
    116         );
    117        
    118         return val;
     114        if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
     115                uint16_t val;
     116                asm volatile (
     117                        "inw %w[port], %w[val]\n"
     118                        : [val] "=a" (val)
     119                        : [port] "d" (port)
     120                );
     121                return val;
     122        } else {
     123                return (uint16_t) *port;
     124        }
    119125}
    120126
     
    129135NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
    130136{
    131         uint32_t val;
    132        
    133         asm volatile (
    134                 "inl %w[port], %[val]\n"
    135                 : [val] "=a" (val)
    136                 : [port] "d" (port)
    137         );
    138        
    139         return val;
     137        if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
     138                uint32_t val;
     139                asm volatile (
     140                        "inl %w[port], %[val]\n"
     141                        : [val] "=a" (val)
     142                        : [port] "d" (port)
     143                );
     144                return val;
     145        } else {
     146                return (uint32_t) *port;
     147        }
    140148}
    141149
     
    150158NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t val)
    151159{
    152         asm volatile (
    153                 "outb %b[val], %w[port]\n"
    154                 :: [val] "a" (val),
    155                    [port] "d" (port)
    156         );
     160        if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
     161                asm volatile (
     162                        "outb %b[val], %w[port]\n"
     163                        :: [val] "a" (val), [port] "d" (port)
     164                );     
     165        } else {
     166                *port = val;
     167        }
    157168}
    158169
     
    167178NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t val)
    168179{
    169         asm volatile (
    170                 "outw %w[val], %w[port]\n"
    171                 :: [val] "a" (val),
    172                    [port] "d" (port)
    173         );
     180        if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
     181                asm volatile (
     182                        "outw %w[val], %w[port]\n"
     183                        :: [val] "a" (val), [port] "d" (port)
     184                );
     185        } else {
     186                *port = val;
     187        }
    174188}
    175189
     
    184198NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t val)
    185199{
    186         asm volatile (
    187                 "outl %[val], %w[port]\n"
    188                 :: [val] "a" (val),
    189                    [port] "d" (port)
    190         );
     200        if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
     201                asm volatile (
     202                        "outl %[val], %w[port]\n"
     203                        :: [val] "a" (val), [port] "d" (port)
     204                );
     205        } else {
     206                *port = val;
     207        }
    191208}
    192209
  • kernel/arch/ia32/include/asm.h

    ra0fc4be rabf04a54  
    101101GEN_WRITE_REG(dr7)
    102102
     103#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
     104
    103105/** Byte to port
    104106 *
     
    111113NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t val)
    112114{
    113         asm volatile (
    114                 "outb %b[val], %w[port]\n"
    115                 :: [val] "a" (val),
    116                    [port] "d" (port)
    117         );
     115        if (port < (ioport8_t *) IO_SPACE_BOUNDARY) {
     116                asm volatile (
     117                        "outb %b[val], %w[port]\n"
     118                        :: [val] "a" (val), [port] "d" (port)
     119                );     
     120        } else {
     121                *port = val;
     122        }
    118123}
    119124
     
    128133NO_TRACE static inline void pio_write_16(ioport16_t *port, uint16_t val)
    129134{
    130         asm volatile (
    131                 "outw %w[val], %w[port]\n"
    132                 :: [val] "a" (val),
    133                    [port] "d" (port)
    134         );
     135        if (port < (ioport16_t *) IO_SPACE_BOUNDARY) {
     136                asm volatile (
     137                        "outw %w[val], %w[port]\n"
     138                        :: [val] "a" (val), [port] "d" (port)
     139                );
     140        } else {
     141                *port = val;
     142        }
    135143}
    136144
     
    145153NO_TRACE static inline void pio_write_32(ioport32_t *port, uint32_t val)
    146154{
    147         asm volatile (
    148                 "outl %[val], %w[port]\n"
    149                 :: [val] "a" (val),
    150                    [port] "d" (port)
    151         );
     155        if (port < (ioport32_t *) IO_SPACE_BOUNDARY) {
     156                asm volatile (
     157                        "outl %[val], %w[port]\n"
     158                        :: [val] "a" (val), [port] "d" (port)
     159                );
     160        } else {
     161                *port = val;
     162        }
    152163}
    153164
     
    162173NO_TRACE static inline uint8_t pio_read_8(ioport8_t *port)
    163174{
    164         uint8_t val;
    165        
    166         asm volatile (
    167                 "inb %w[port], %b[val]\n"
    168                 : [val] "=a" (val)
    169                 : [port] "d" (port)
    170         );
    171        
    172         return val;
     175        if (((void *)port) < IO_SPACE_BOUNDARY) {
     176                uint8_t val;
     177                asm volatile (
     178                        "inb %w[port], %b[val]\n"
     179                        : [val] "=a" (val)
     180                        : [port] "d" (port)
     181                );
     182                return val;
     183        } else {
     184                return (uint8_t) *port;
     185        }
    173186}
    174187
     
    183196NO_TRACE static inline uint16_t pio_read_16(ioport16_t *port)
    184197{
    185         uint16_t val;
    186        
    187         asm volatile (
    188                 "inw %w[port], %w[val]\n"
    189                 : [val] "=a" (val)
    190                 : [port] "d" (port)
    191         );
    192        
    193         return val;
     198        if (((void *)port) < IO_SPACE_BOUNDARY) {
     199                uint16_t val;
     200                asm volatile (
     201                        "inw %w[port], %w[val]\n"
     202                        : [val] "=a" (val)
     203                        : [port] "d" (port)
     204                );
     205                return val;
     206        } else {
     207                return (uint16_t) *port;
     208        }
    194209}
    195210
     
    204219NO_TRACE static inline uint32_t pio_read_32(ioport32_t *port)
    205220{
    206         uint32_t val;
    207        
    208         asm volatile (
    209                 "inl %w[port], %[val]\n"
    210                 : [val] "=a" (val)
    211                 : [port] "d" (port)
    212         );
    213        
    214         return val;
     221        if (((void *)port) < IO_SPACE_BOUNDARY) {
     222                uint32_t val;
     223                asm volatile (
     224                        "inl %w[port], %[val]\n"
     225                        : [val] "=a" (val)
     226                        : [port] "d" (port)
     227                );
     228                return val;
     229        } else {
     230                return (uint32_t) *port;
     231        }
    215232}
    216233
Note: See TracChangeset for help on using the changeset viewer.