Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:40

0001 /**
0002  * @file
0003  * @ingroup i386_io
0004  * @brief I/O
0005  */
0006 
0007 /*
0008  * Copyright (c) 2000 - Rosimildo da Silva.  All Rights Reserved.
0009  *
0010  * MODULE DESCRIPTION:
0011  *
0012  * IO Functions for the PC platform equivalent to DOS/Linux. They make
0013  * eaiser the porting of code from these platforms.
0014  *
0015  *  by: Rosimildo da Silva:  rdasilva@connecttel.com
0016  *
0017  */
0018 
0019 /**
0020  * @defgroup i386_io I/O
0021  * @ingroup i386_comm
0022  * @brief I/O
0023  * @{
0024  */
0025 
0026 #ifndef i386_io_h__
0027 #define i386_io_h__
0028 
0029 #define rtems_inb(port)                         \
0030 ({                                  \
0031         register int _inb_result;                   \
0032                             \
0033         __asm__ volatile ("xorl %%eax,%%eax; inb %%dx,%%al" :       \
0034             "=a" (_inb_result) : "d" (port));               \
0035         _inb_result;                            \
0036 })
0037 
0038 #define rtems_inw(port)                         \
0039 ({                                  \
0040         register int _inbw_result;                  \
0041                                     \
0042         __asm__ volatile ("xorl %%eax,%%eax; inw %%dx,%%ax" :       \
0043             "=a" (_inbw_result) : "d" (port));              \
0044         _inbw_result;                           \
0045 })
0046 
0047 #define rtems_outb(port, data)                      \
0048         __asm__ volatile ("outb %%al,%%dx" : : "a" (data), "d" (port))
0049 
0050 #define rtems_outw(port, data)                      \
0051         __asm__ volatile ("outw %%ax,%%dx" : : "a" (data), "d" (port))
0052 
0053 #define outp(port, val) rtems_outb(port,val)
0054 #define inp(port)         rtems_inb(port)
0055 
0056 #define outb(val, port) rtems_outb(port,val)
0057 #define inb(port)         rtems_inb(port)
0058 
0059 #define outb_p(val, port)   rtems_outb(port,val)
0060 #define inb_p(port)       rtems_inb(port)
0061 
0062 #define outportb(port,val)  rtems_outb(port,val)
0063 #define inportb(port)   rtems_inb(port)
0064 
0065 #define outw(val, port) rtems_outw(port,val)
0066 #define inw(port)         rtems_inw(port)
0067 
0068 #define cli()   __asm__ __volatile__("cli")
0069 #define sti()   __asm__ __volatile__("sti");
0070 
0071 #endif /* i386_io_h__ */
0072 
0073 /** @} */