From b75b1902f224a8fb219a33a55d8e5bf22469eefa Mon Sep 17 00:00:00 2001 From: Reto Buerki Date: Fri, 6 Mar 2015 10:56:46 +0100 Subject: [PATCH] hw_x86_64: Provide inb and outb functions for port I/O The port_io.h file provides the inb and outb functions to perform port I/O operations. --- .../src/core/include/spec/x86/port_io.h | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 repos/base-hw/src/core/include/spec/x86/port_io.h diff --git a/repos/base-hw/src/core/include/spec/x86/port_io.h b/repos/base-hw/src/core/include/spec/x86/port_io.h new file mode 100644 index 000000000..24453337d --- /dev/null +++ b/repos/base-hw/src/core/include/spec/x86/port_io.h @@ -0,0 +1,27 @@ +#ifndef _PORT_IO_H_ +#define _PORT_IO_H_ + +#include + +namespace Genode +{ + /** + * Read byte from I/O port + */ + inline uint8_t inb(uint16_t port) + { + uint8_t res; + asm volatile ("inb %w1, %0" : "=a"(res) : "Nd"(port)); + return res; + } + + /** + * Write byte to I/O port + */ + inline void outb(uint16_t port, uint8_t val) + { + asm volatile ("outb %0, %w1" : : "a"(val), "Nd"(port)); + } +} + +#endif /* _PORT_IO_H_ */