NOVA
Stripped down NOVA kernel for the OSY course
io.h
1 /*
2  * I/O Ports
3  *
4  * Copyright (C) 2009-2011 Udo Steinberg <udo@hypervisor.org>
5  * Economic rights: Technische Universitaet Dresden (Germany)
6  *
7  * This file is part of the NOVA microhypervisor.
8  *
9  * NOVA is free software: you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  * NOVA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License version 2 for more details.
17  */
18 
19 #pragma once
20 
21 #include "compiler.h"
22 
23 class Io
24 {
25  public:
26  template <typename T>
27  ALWAYS_INLINE
28  static inline unsigned in (unsigned port)
29  {
30  T val;
31  asm volatile ("in %w1, %0" : "=a" (val) : "Nd" (port));
32  return val;
33  }
34 
35  template <typename T>
36  ALWAYS_INLINE
37  static inline void out (unsigned port, T val)
38  {
39  asm volatile ("out %0, %w1" : : "a" (val), "Nd" (port));
40  }
41 };
Definition: io.h:24