- Implemented execp*.
[planlOS.git] / system / include / ke / ports.h
blob4269ae7c5d6c319fa16b3a99f98eb1274e8ef717
1 /*
2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 /**
22 * \file ports.h
23 * Port IO acess functions.
26 #ifndef PORTS_H_INCLUDED
27 #define PORTS_H_INCLUDED
29 #include <stdint.h>
31 /**
32 * Writes one byte to the port.
34 static inline void outb(uint16_t port, uint8_t data)
36 asm("outb %0, %1"::"a"(data), "Nd"(port));
38 /**
39 * Reads one byte from the port.
41 static inline uint8_t inb(uint16_t port)
43 uint8_t data;
44 asm("inb %1, %0":"=a"(data):"Nd"(port));
45 return data;
47 /**
48 * Writes one byte to the port and waits a bit.
50 static inline void outb_wait(uint16_t port, uint8_t data)
52 asm("outb %0, %1"::"a"(data), "Nd"(port));
53 asm("outb %%al, $0x80"::"a"(0));
55 /**
56 * Writes one word to the port.
58 static inline void outw(uint16_t port, uint16_t data)
60 asm("outw %0, %1"::"a"(data), "Nd"(port));
62 /**
63 * Reads one word from the port.
65 static inline uint16_t inw(uint16_t port)
67 uint16_t data;
68 asm("inw %1, %0":"=a"(data):"Nd"(port));
69 return data;
71 /**
72 * Writes one 32bit integer to the port.
74 static inline void outl(uint16_t port, uint32_t data)
76 asm("outl %0, %1"::"a"(data), "Nd"(port));
78 /**
79 * Reads a 32bit integer from the port.
81 static inline uint32_t inl(uint16_t port)
83 uint32_t data;
84 asm("inl %1, %0":"=a"(data):"Nd"(port));
85 return data;
88 #endif