Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia32/include/ddi.h

    rd161715 r667a4f8  
    3737#include <libarch/types.h>
    3838
    39 #define IO_SPACE_BOUNDARY  ((void *) (64 * 1024))
     39#define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
    4040
    4141static inline uint8_t pio_read_8(ioport8_t *port)
    4242{
    43         uint8_t val;
    44        
    45         asm volatile (
    46                 "inb %w[port], %b[val]\n"
    47                 : [val] "=a" (val)
    48                 : [port] "d" (port)
    49         );
    50        
    51         return val;
     43        if (((void *)port) < IO_SPACE_BOUNDARY) {
     44                uint8_t val;
     45                asm volatile (
     46                        "inb %w[port], %b[val]\n"
     47                        : [val] "=a" (val)
     48                        : [port] "d" (port)
     49                );
     50                return val;
     51        } else {
     52                return (uint8_t) *port;
     53        }
    5254}
    5355
    5456static inline uint16_t pio_read_16(ioport16_t *port)
    5557{
    56         uint16_t val;
    57        
    58         asm volatile (
    59                 "inw %w[port], %w[val]\n"
    60                 : [val] "=a" (val)
    61                 : [port] "d" (port)
    62         );
    63        
    64         return val;
     58        if (((void *)port) < IO_SPACE_BOUNDARY) {
     59                uint16_t val;
     60                asm volatile (
     61                        "inw %w[port], %w[val]\n"
     62                        : [val] "=a" (val)
     63                        : [port] "d" (port)
     64                );
     65                return val;
     66        } else {
     67                return (uint16_t) *port;
     68        }
    6569}
    6670
    6771static inline uint32_t pio_read_32(ioport32_t *port)
    6872{
    69         uint32_t val;
    70        
    71         asm volatile (
    72                 "inl %w[port], %[val]\n"
    73                 : [val] "=a" (val)
    74                 : [port] "d" (port)
    75         );
    76        
    77         return val;
     73        if (((void *)port) < IO_SPACE_BOUNDARY) {
     74                uint32_t val;
     75                asm volatile (
     76                        "inl %w[port], %[val]\n"
     77                        : [val] "=a" (val)
     78                        : [port] "d" (port)
     79                );
     80                return val;
     81        } else {
     82                return (uint32_t) *port;
     83        }
    7884}
    7985
    8086static inline void pio_write_8(ioport8_t *port, uint8_t val)
    8187{
    82         asm volatile (
    83                 "outb %b[val], %w[port]\n"
    84                 :: [val] "a" (val), [port] "d" (port)
    85         );
     88        if (((void *)port) < IO_SPACE_BOUNDARY) {
     89                asm volatile (
     90                        "outb %b[val], %w[port]\n"
     91                        :: [val] "a" (val), [port] "d" (port)
     92                );     
     93        } else {
     94                *((uint8_t *) port) = val;
     95        }
    8696}
    8797
    8898static inline void pio_write_16(ioport16_t *port, uint16_t val)
    8999{
    90         asm volatile (
    91                 "outw %w[val], %w[port]\n"
    92                 :: [val] "a" (val), [port] "d" (port)
    93         );
     100        if (((void *)port) < IO_SPACE_BOUNDARY) {
     101                asm volatile (
     102                        "outw %w[val], %w[port]\n"
     103                        :: [val] "a" (val), [port] "d" (port)
     104                );
     105        } else {
     106                *((uint16_t *) port) = val;
     107        }
    94108}
    95109
    96110static inline void pio_write_32(ioport32_t *port, uint32_t val)
    97111{
    98         asm volatile (
    99                 "outl %[val], %w[port]\n"
    100                 :: [val] "a" (val), [port] "d" (port)
    101         );
     112        if (((void *)port) < IO_SPACE_BOUNDARY) {
     113                asm volatile (
     114                        "outl %[val], %w[port]\n"
     115                        :: [val] "a" (val), [port] "d" (port)
     116                );
     117        } else {
     118                *((uint32_t *) port) = val;
     119        }
    102120}
    103121
Note: See TracChangeset for help on using the changeset viewer.