-
Notifications
You must be signed in to change notification settings - Fork 246
/
io_port_session.h
116 lines (94 loc) · 3.14 KB
/
io_port_session.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* \brief I/O-port session interface
* \author Christian Helmuth
* \date 2007-04-17
*
* An I/O port session permits access to a range of ports. Inside this range
* variable-sized accesses (i.e., 8, 16, 32 bit) at arbitrary addresses are
* allowed - currently, alignment is not enforced. Core enforces that access is
* limited to the session-defined range while the user provides physical I/O port
* addresses as arguments.
*
* The design is founded on experiences while programming PCI configuration
* space which needs two 32-bit port registers. Each byte, word and dword in
* the data register must be explicitly accessible for read and write. The old
* design needs six capabilities only for the data register.
*/
/*
* Copyright (C) 2007-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__IO_PORT_SESSION__IO_PORT_SESSION_H_
#define _INCLUDE__IO_PORT_SESSION__IO_PORT_SESSION_H_
#include <base/capability.h>
#include <session/session.h>
namespace Genode { struct Io_port_session; }
struct Genode::Io_port_session : Session
{
static const char *service_name() { return "IO_PORT"; }
virtual ~Io_port_session() { }
/******************************
** Read value from I/O port **
******************************/
/**
* Read byte (8 bit)
*
* \param address physical I/O port address
*
* \return value read from port
*/
virtual unsigned char inb(unsigned short address) = 0;
/**
* Read word (16 bit)
*
* \param address physical I/O port address
*
* \return value read from port
*/
virtual unsigned short inw(unsigned short address) = 0;
/**
* Read double word (32 bit)
*
* \param address physical I/O port address
*
* \return value read from port
*/
virtual unsigned inl(unsigned short address) = 0;
/*****************************
** Write value to I/O port **
*****************************/
/**
* Write byte (8 bit)
*
* \param address physical I/O port address
* \param value value to write to port
*/
virtual void outb(unsigned short address, unsigned char value) = 0;
/**
* Write word (16 bit)
*
* \param address physical I/O port address
* \param value value to write to port
*/
virtual void outw(unsigned short address, unsigned short value) = 0;
/**
* Write double word (32 bit)
*
* \param address physical I/O port address
* \param value value to write to port
*/
virtual void outl(unsigned short address, unsigned value) = 0;
/*********************
** RPC declaration **
*********************/
GENODE_RPC(Rpc_inb, unsigned char, inb, unsigned short);
GENODE_RPC(Rpc_inw, unsigned short, inw, unsigned short);
GENODE_RPC(Rpc_inl, unsigned, inl, unsigned short);
GENODE_RPC(Rpc_outb, void, outb, unsigned short, unsigned char);
GENODE_RPC(Rpc_outw, void, outw, unsigned short, unsigned short);
GENODE_RPC(Rpc_outl, void, outl, unsigned short, unsigned);
GENODE_RPC_INTERFACE(Rpc_inb, Rpc_inw, Rpc_inl, Rpc_outb, Rpc_outw, Rpc_outl);
};
#endif /* _INCLUDE__IO_PORT_SESSION__IO_PORT_SESSION_H_ */