]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/drivers-frst/include/io_regblock_port.h
Merge branch 'master' of rtime.felk.cvut.cz:l4
[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 <<<<<<< HEAD
55 <<<<<<< HEAD
56     void delay() const
57     { asm volatile ("outb %al,$0x80"); }
58 =======
59     void delay() const //root linux in jailhouse have a problem when cell used port 0x80
60     {   
61          asm volatile ("outb %al,$0x80"); 
62         /*for (int i = 0; i < 1000000; i++);*/
63     }
64 >>>>>>> d8997e7... fiasco: drivers-frst: Get this code back to default state. Port interference problem was solved into the linux kernel configuration.
65 =======
66     void delay() const //root linux in jailhouse have a problem when cell used port 0x80
67     {/* asm volatile ("outb %al,$0x80"); */}
68 >>>>>>> e3e88cd02e4e26d0d588e4c756f63f7aa9447267
69
70   private:
71     unsigned long _base;
72   };
73 }