2 * (c) 2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
11 #include "io_regblock.h"
15 class Io_register_block_port : public Io_register_block
18 Io_register_block_port(unsigned long base)
22 unsigned long addr(unsigned long reg) const { return _base + reg; }
24 unsigned char read8(unsigned long reg) const
27 asm volatile("inb %w1, %b0" : "=a" (val) : "Nd" (_base + reg));
31 unsigned short read16(unsigned long reg) const
34 asm volatile("inw %w1, %w0" : "=a" (val) : "Nd" (_base + reg));
38 unsigned int read32(unsigned long reg) const
41 asm volatile("in %w1, %0" : "=a" (val) : "Nd" (_base + reg));
45 void write8(unsigned long reg, unsigned char val) const
46 { asm volatile("outb %b0, %w1" : : "a" (val), "Nd" (_base + reg)); }
48 void write16(unsigned long reg, unsigned short val) const
49 { asm volatile("outw %w0, %w1" : : "a" (val), "Nd" (_base + reg)); }
51 void write32(unsigned long reg, unsigned int val) const
52 { asm volatile("out %0, %w1" : : "a" (val), "Nd" (_base + reg)); }
55 { asm volatile ("outb %al,$0x80"); }