L4Re Operating System Framework
Interface and Usage Documentation
•All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
io_regblock_port.h
1/*
2 * Copyright (C) 2012 Technische Universität Dresden.
3 * Author(s): Adam Lackorzynski <adam@os.inf.tu-dresden.de>
4 *
5 * License: see LICENSE.spdx (in this directory or the directories above)
6 */
7#pragma once
8
9#include "io_regblock.h"
10
11namespace L4
12{
13 class Io_register_block_port : public Io_register_block
14 {
15 public:
16 Io_register_block_port(unsigned long base)
17 : _base(base)
18 {}
19
20 unsigned long addr(unsigned long reg) const override { return _base + reg; }
21
22 unsigned char read8(unsigned long reg) const override
23 {
24 unsigned char val;
25 asm volatile("inb %w1, %b0" : "=a" (val) : "Nd" (_base + reg));
26 return val;
27 }
28
29 unsigned short read16(unsigned long reg) const override
30 {
31 unsigned short val;
32 asm volatile("inw %w1, %w0" : "=a" (val) : "Nd" (_base + reg));
33 return val;
34 }
35
36 unsigned int read32(unsigned long reg) const override
37 {
38 unsigned int val;
39 asm volatile("in %w1, %0" : "=a" (val) : "Nd" (_base + reg));
40 return val;
41 }
42
43 void write8(unsigned long reg, unsigned char val) const override
44 { asm volatile("outb %b0, %w1" : : "a" (val), "Nd" (_base + reg)); }
45
46 void write16(unsigned long reg, unsigned short val) const override
47 { asm volatile("outw %w0, %w1" : : "a" (val), "Nd" (_base + reg)); }
48
49 void write32(unsigned long reg, unsigned int val) const override
50 { asm volatile("out %0, %w1" : : "a" (val), "Nd" (_base + reg)); }
51
52 void delay() const override
53 { asm volatile ("outb %al,$0x80"); }
54
55 private:
56 unsigned long _base;
57 };
58}
L4 low-level kernel interface.