]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/drivers-frst/include/io_regblock_port.h
fiasco: drivers-frst: Force bootstrap not to use delay() with port 0x80.
[l4.git] / l4 / pkg / drivers-frst / include / io_regblock_port.h
1 /*
2  * (c) 2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
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.
8  */
9 #pragma once
10
11 #include "io_regblock.h"
12
13 namespace L4
14 {
15   class Io_register_block_port : public Io_register_block
16   {
17   public:
18     Io_register_block_port(unsigned long base)
19     : _base(base)
20     {}
21
22     unsigned long addr(unsigned long reg) const { return _base + reg; }
23
24     unsigned char  read8(unsigned long reg) const
25     {
26       unsigned char val;
27       asm volatile("inb %w1, %b0" : "=a" (val) : "Nd" (_base + reg));
28       return val;
29     }
30
31     unsigned short read16(unsigned long reg) const
32     {
33       unsigned short val;
34       asm volatile("inw %w1, %w0" : "=a" (val) : "Nd" (_base + reg));
35       return val;
36     }
37
38     unsigned int   read32(unsigned long reg) const
39     {
40       unsigned int val;
41       asm volatile("in %w1, %0" : "=a" (val) : "Nd" (_base + reg));
42       return val;
43     }
44
45     void write8(unsigned long reg, unsigned char val) const
46     { asm volatile("outb %b0, %w1" : : "a" (val), "Nd" (_base + reg)); }
47
48     void write16(unsigned long reg, unsigned short val) const
49     { asm volatile("outw %w0, %w1" : : "a" (val), "Nd" (_base + reg)); }
50
51     void write32(unsigned long reg, unsigned int val) const
52     { asm volatile("out %0, %w1" : : "a" (val), "Nd" (_base + reg)); }
53
54     void delay() const //root linux in jailhouse have a problem when cell used port 0x80
55     {/* asm volatile ("outb %al,$0x80"); */}
56
57   private:
58     unsigned long _base;
59   };
60 }