2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _LIBMEINOS_IOPORT_H_
20 #define _LIBMEINOS_IOPORT_H_
26 static inline int ioport_reg(uint16_t port
) {
27 int ret
= syscall_call(SYSCALL_IO_REG
,1,port
);
32 static inline int ioport_unreg(uint16_t port
) {
33 int ret
= syscall_call(SYSCALL_IO_UNREG
,1,port
);
38 static inline uint8_t inb(uint16_t _port
) {
40 __asm__("inb %1, %0":"=a"(_result
):"Nd"(_port
));
44 static inline uint16_t inw(uint16_t _port
) {
46 __asm__("inw %1, %0":"=a"(_result
):"Nd"(_port
));
50 static inline uint32_t inl(uint16_t _port
) {
52 __asm__("inl %1, %0":"=a"(_result
):"Nd"(_port
));
56 static inline void outw(uint16_t _port
,uint16_t _data
) {
57 __asm__("outw %0, %1"::"a"(_data
),"Nd"(_port
));
60 static inline void outb(uint16_t _port
,uint8_t _data
) {
61 __asm__("outb %0, %1"::"a"(_data
),"Nd"(_port
));
64 static inline void outl(uint16_t _port
,uint32_t _data
) {
65 __asm__("outl %0, %1"::"a"(_data
),"Nd" (_port
));